1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
22
24
26 {
29 uint8_t *side_data;
30 int err;
31
33 return 0;
34
35 err = ff_cbs_read_packet_side_data(
ctx->input, frag,
pkt);
36 if (err < 0) {
38 "Failed to read extradata from packet side data.\n");
39 return err;
40 }
41
42 err =
ctx->type->update_fragment(bsf,
NULL, frag);
43 if (err < 0)
44 return err;
45
46 err = ff_cbs_write_fragment_data(
ctx->output, frag);
47 if (err < 0) {
49 "Failed to write extradata into packet side data.\n");
50 return err;
51 }
52
55 if (!side_data)
58
59 ff_cbs_fragment_reset(frag);
60 return 0;
61 }
62
64 {
67 int err;
68
70 if (err < 0)
71 return err;
72
74 if (err < 0)
76
77 err = ff_cbs_read_packet(
ctx->input, frag,
pkt);
78 if (err < 0) {
80 ctx->type->fragment_name);
82 }
83
86 ctx->type->unit_name);
89 }
90
91 err =
ctx->type->update_fragment(bsf,
pkt, frag);
92 if (err < 0)
94
95 err = ff_cbs_write_packet(
ctx->output,
pkt, frag);
96 if (err < 0) {
98 ctx->type->fragment_name);
100 }
101
102 err = 0;
104 ff_cbs_fragment_reset(frag);
105
106 if (err < 0)
108
109 return err;
110 }
111
113 {
116 int err;
117
119
120 err = ff_cbs_init(&
ctx->input,
type->codec_id, bsf);
121 if (err < 0)
122 return err;
123
124 err = ff_cbs_init(&
ctx->output,
type->codec_id, bsf);
125 if (err < 0)
126 return err;
127
128 ctx->output->trace_enable = 1;
130 ctx->output->trace_context =
ctx->output;
131 ctx->output->trace_write_callback = ff_cbs_trace_write_log;
132
134 err = ff_cbs_read_extradata(
ctx->input, frag, bsf->
par_in);
135 if (err < 0) {
138 }
139
140 err =
type->update_fragment(bsf,
NULL, frag);
141 if (err < 0)
143
144 err = ff_cbs_write_extradata(
ctx->output, bsf->
par_out, frag);
145 if (err < 0) {
148 }
149 }
150
151 err = 0;
153 ff_cbs_fragment_reset(frag);
154 return err;
155 }
156
158 {
160
161 ff_cbs_fragment_free(&
ctx->fragment);
162 ff_cbs_close(&
ctx->input);
163 ff_cbs_close(&
ctx->output);
164 }