FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/bsf/extract_extradata.c
Date: 2024-02-29 09:57:37
Exec Total Coverage
Lines: 169 215 78.6%
Functions: 11 11 100.0%
Branches: 116 156 74.4%

Line Branch Exec Source
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
19 #include <stdint.h>
20
21 #include "libavutil/log.h"
22 #include "libavutil/opt.h"
23
24 #include "av1.h"
25 #include "av1_parse.h"
26 #include "bsf.h"
27 #include "bsf_internal.h"
28 #include "bytestream.h"
29 #include "h2645_parse.h"
30 #include "h264.h"
31 #include "hevc.h"
32 #include "startcode.h"
33 #include "vc1_common.h"
34 #include "vvc.h"
35
36 typedef struct ExtractExtradataContext {
37 const AVClass *class;
38
39 int (*extract)(AVBSFContext *ctx, AVPacket *pkt,
40 uint8_t **data, int *size);
41
42 /* AV1 specific fields */
43 AV1Packet av1_pkt;
44
45 /* H264/HEVC specific fields */
46 H2645Packet h2645_pkt;
47
48 /* AVOptions */
49 int remove;
50 } ExtractExtradataContext;
51
52 5958 static int val_in_array(const int *arr, size_t len, int val)
53 {
54
2/2
✓ Branch 0 taken 13675 times.
✓ Branch 1 taken 3376 times.
17051 for (size_t i = 0; i < len; i++)
55
2/2
✓ Branch 0 taken 2582 times.
✓ Branch 1 taken 11093 times.
13675 if (arr[i] == val)
56 2582 return 1;
57 3376 return 0;
58 }
59
60 8 static int metadata_is_global(const AV1OBU *obu)
61 {
62 static const int metadata_obu_types[] = {
63 AV1_METADATA_TYPE_HDR_CLL, AV1_METADATA_TYPE_HDR_MDCV,
64 };
65 GetBitContext gb;
66 int metadata_type;
67
68
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
8 if (init_get_bits(&gb, obu->data, obu->size_bits) < 0)
69 return 0;
70
71 8 metadata_type = get_leb(&gb);
72
73 8 return val_in_array(metadata_obu_types, FF_ARRAY_ELEMS(metadata_obu_types),
74 metadata_type);
75 }
76
77 219 static int obu_is_global(const AV1OBU *obu)
78 {
79 static const int extradata_obu_types[] = {
80 AV1_OBU_SEQUENCE_HEADER, AV1_OBU_METADATA,
81 };
82
83
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 50 times.
219 if (!val_in_array(extradata_obu_types, FF_ARRAY_ELEMS(extradata_obu_types),
84 219 obu->type))
85 169 return 0;
86
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 8 times.
50 if (obu->type != AV1_OBU_METADATA)
87 42 return 1;
88
89 8 return metadata_is_global(obu);
90 }
91
92 44 static int extract_extradata_av1(AVBSFContext *ctx, AVPacket *pkt,
93 uint8_t **data, int *size)
94 {
95
96 44 ExtractExtradataContext *s = ctx->priv_data;
97
98 44 int extradata_size = 0, filtered_size = 0;
99 44 int i, has_seq = 0, ret = 0;
100
101 44 ret = ff_av1_packet_split(&s->av1_pkt, pkt->data, pkt->size, ctx);
102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if (ret < 0)
103 return ret;
104
105
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 44 times.
181 for (i = 0; i < s->av1_pkt.nb_obus; i++) {
106 137 AV1OBU *obu = &s->av1_pkt.obus[i];
107
2/2
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 112 times.
137 if (obu_is_global(obu)) {
108 25 extradata_size += obu->raw_size;
109
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 4 times.
25 if (obu->type == AV1_OBU_SEQUENCE_HEADER)
110 21 has_seq = 1;
111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 } else if (s->remove) {
112 filtered_size += obu->raw_size;
113 }
114 }
115
116
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
44 if (extradata_size && has_seq) {
117 21 AVBufferRef *filtered_buf = NULL;
118 PutByteContext pb_filtered_data, pb_extradata;
119 uint8_t *extradata;
120
121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if (s->remove) {
122 filtered_buf = av_buffer_alloc(filtered_size + AV_INPUT_BUFFER_PADDING_SIZE);
123 if (!filtered_buf) {
124 return AVERROR(ENOMEM);
125 }
126 memset(filtered_buf->data + filtered_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
127 }
128
129 21 extradata = av_malloc(extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if (!extradata) {
131 av_buffer_unref(&filtered_buf);
132 return AVERROR(ENOMEM);
133 }
134
135 21 *data = extradata;
136 21 *size = extradata_size;
137
138 21 bytestream2_init_writer(&pb_extradata, extradata, extradata_size);
139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if (s->remove)
140 bytestream2_init_writer(&pb_filtered_data, filtered_buf->data, filtered_size);
141
142
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 21 times.
103 for (i = 0; i < s->av1_pkt.nb_obus; i++) {
143 82 AV1OBU *obu = &s->av1_pkt.obus[i];
144
2/2
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 57 times.
82 if (obu_is_global(obu)) {
145 25 bytestream2_put_bufferu(&pb_extradata, obu->raw_data, obu->raw_size);
146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 } else if (s->remove) {
147 bytestream2_put_bufferu(&pb_filtered_data, obu->raw_data, obu->raw_size);
148 }
149 }
150
151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if (s->remove) {
152 av_buffer_unref(&pkt->buf);
153 pkt->buf = filtered_buf;
154 pkt->data = filtered_buf->data;
155 pkt->size = filtered_size;
156 }
157 }
158
159 44 return 0;
160 }
161
162 547 static int extract_extradata_h2645(AVBSFContext *ctx, AVPacket *pkt,
163 uint8_t **data, int *size)
164 {
165 static const int extradata_nal_types_vvc[] = {
166 VVC_VPS_NUT, VVC_SPS_NUT, VVC_PPS_NUT,
167 };
168 static const int extradata_nal_types_hevc[] = {
169 HEVC_NAL_VPS, HEVC_NAL_SPS, HEVC_NAL_PPS,
170 };
171 static const int extradata_nal_types_h264[] = {
172 H264_NAL_SPS, H264_NAL_PPS,
173 };
174
175 547 ExtractExtradataContext *s = ctx->priv_data;
176
177 547 int extradata_size = 0, filtered_size = 0;
178 const int *extradata_nal_types;
179 size_t nb_extradata_nal_types;
180 547 int i, has_sps = 0, has_vps = 0, ret = 0;
181
182
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 496 times.
547 if (ctx->par_in->codec_id == AV_CODEC_ID_VVC) {
183 51 extradata_nal_types = extradata_nal_types_vvc;
184 51 nb_extradata_nal_types = FF_ARRAY_ELEMS(extradata_nal_types_vvc);
185
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 265 times.
496 } else if (ctx->par_in->codec_id == AV_CODEC_ID_HEVC) {
186 231 extradata_nal_types = extradata_nal_types_hevc;
187 231 nb_extradata_nal_types = FF_ARRAY_ELEMS(extradata_nal_types_hevc);
188 } else {
189 265 extradata_nal_types = extradata_nal_types_h264;
190 265 nb_extradata_nal_types = FF_ARRAY_ELEMS(extradata_nal_types_h264);
191 }
192
193 547 ret = ff_h2645_packet_split(&s->h2645_pkt, pkt->data, pkt->size,
194 547 ctx, 0, 0, ctx->par_in->codec_id, 1, 0);
195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 547 times.
547 if (ret < 0)
196 return ret;
197
198
2/2
✓ Branch 0 taken 3029 times.
✓ Branch 1 taken 547 times.
3576 for (i = 0; i < s->h2645_pkt.nb_nals; i++) {
199 3029 H2645NAL *nal = &s->h2645_pkt.nals[i];
200
2/2
✓ Branch 1 taken 1262 times.
✓ Branch 2 taken 1767 times.
3029 if (val_in_array(extradata_nal_types, nb_extradata_nal_types, nal->type)) {
201 1262 extradata_size += nal->raw_size + 3;
202
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 1152 times.
1262 if (ctx->par_in->codec_id == AV_CODEC_ID_VVC) {
203
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 55 times.
110 if (nal->type == VVC_SPS_NUT) has_sps = 1;
204
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 106 times.
110 if (nal->type == VVC_VPS_NUT) has_vps = 1;
205
2/2
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 466 times.
1152 } else if (ctx->par_in->codec_id == AV_CODEC_ID_HEVC) {
206
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 479 times.
686 if (nal->type == HEVC_NAL_SPS) has_sps = 1;
207
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 478 times.
686 if (nal->type == HEVC_NAL_VPS) has_vps = 1;
208 } else {
209
2/2
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 237 times.
466 if (nal->type == H264_NAL_SPS) has_sps = 1;
210 }
211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1767 times.
1767 } else if (s->remove) {
212 filtered_size += nal->raw_size + 3;
213 }
214 }
215
216
2/2
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 69 times.
547 if (extradata_size &&
217
3/4
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 427 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 51 times.
478 ((ctx->par_in->codec_id == AV_CODEC_ID_VVC && has_sps) ||
218
4/6
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 229 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 198 times.
427 (ctx->par_in->codec_id == AV_CODEC_ID_HEVC && has_sps && has_vps) ||
219
2/4
✓ Branch 0 taken 229 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229 times.
✗ Branch 3 not taken.
229 (ctx->par_in->codec_id == AV_CODEC_ID_H264 && has_sps))) {
220 478 AVBufferRef *filtered_buf = NULL;
221 PutByteContext pb_filtered_data, pb_extradata;
222 uint8_t *extradata;
223
224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 478 times.
478 if (s->remove) {
225 filtered_buf = av_buffer_alloc(filtered_size + AV_INPUT_BUFFER_PADDING_SIZE);
226 if (!filtered_buf) {
227 return AVERROR(ENOMEM);
228 }
229 memset(filtered_buf->data + filtered_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
230 }
231
232 478 extradata = av_malloc(extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 478 times.
478 if (!extradata) {
234 av_buffer_unref(&filtered_buf);
235 return AVERROR(ENOMEM);
236 }
237
238 478 *data = extradata;
239 478 *size = extradata_size;
240
241 478 bytestream2_init_writer(&pb_extradata, extradata, extradata_size);
242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 478 times.
478 if (s->remove)
243 bytestream2_init_writer(&pb_filtered_data, filtered_buf->data, filtered_size);
244
245
2/2
✓ Branch 0 taken 2702 times.
✓ Branch 1 taken 478 times.
3180 for (i = 0; i < s->h2645_pkt.nb_nals; i++) {
246 2702 H2645NAL *nal = &s->h2645_pkt.nals[i];
247
2/2
✓ Branch 1 taken 1262 times.
✓ Branch 2 taken 1440 times.
2702 if (val_in_array(extradata_nal_types, nb_extradata_nal_types,
248 nal->type)) {
249 1262 bytestream2_put_be24u(&pb_extradata, 1); //startcode
250 1262 bytestream2_put_bufferu(&pb_extradata, nal->raw_data, nal->raw_size);
251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1440 times.
1440 } else if (s->remove) {
252 bytestream2_put_be24u(&pb_filtered_data, 1); // startcode
253 bytestream2_put_bufferu(&pb_filtered_data, nal->raw_data, nal->raw_size);
254 }
255 }
256
257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 478 times.
478 if (s->remove) {
258 av_buffer_unref(&pkt->buf);
259 pkt->buf = filtered_buf;
260 pkt->data = filtered_buf->data;
261 pkt->size = filtered_size;
262 }
263 }
264
265 547 return 0;
266 }
267
268 6 static int extract_extradata_vc1(AVBSFContext *ctx, AVPacket *pkt,
269 uint8_t **data, int *size)
270 {
271 6 ExtractExtradataContext *s = ctx->priv_data;
272 6 const uint8_t *ptr = pkt->data, *end = pkt->data + pkt->size;
273 6 uint32_t state = UINT32_MAX;
274 6 int has_extradata = 0, extradata_size = 0;
275
276
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 while (ptr < end) {
277 23 ptr = avpriv_find_start_code(ptr, end, &state);
278
4/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 6 times.
23 if (state == VC1_CODE_SEQHDR || state == VC1_CODE_ENTRYPOINT) {
279 17 has_extradata = 1;
280
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 } else if (has_extradata && IS_MARKER(state)) {
281 6 extradata_size = ptr - 4 - pkt->data;
282 6 break;
283 }
284 }
285
286
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (extradata_size) {
287 6 *data = av_malloc(extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (!*data)
289 return AVERROR(ENOMEM);
290
291 6 memcpy(*data, pkt->data, extradata_size);
292 6 *size = extradata_size;
293
294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (s->remove) {
295 pkt->data += extradata_size;
296 pkt->size -= extradata_size;
297 }
298 }
299
300 6 return 0;
301 }
302
303 433 static int extract_extradata_mpeg12(AVBSFContext *ctx, AVPacket *pkt,
304 uint8_t **data, int *size)
305 {
306 433 ExtractExtradataContext *s = ctx->priv_data;
307 433 uint32_t state = UINT32_MAX;
308 433 int i, found = 0;
309
310
2/2
✓ Branch 0 taken 3770471 times.
✓ Branch 1 taken 253 times.
3770724 for (i = 0; i < pkt->size; i++) {
311 3770471 state = (state << 8) | pkt->data[i];
312
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 3770291 times.
3770471 if (state == 0x1B3)
313 180 found = 1;
314
8/8
✓ Branch 0 taken 5289 times.
✓ Branch 1 taken 3765002 times.
✓ Branch 2 taken 5106 times.
✓ Branch 3 taken 183 times.
✓ Branch 4 taken 424 times.
✓ Branch 5 taken 4682 times.
✓ Branch 6 taken 180 times.
✓ Branch 7 taken 244 times.
3770291 else if (found && state != 0x1B5 && state < 0x200 && state >= 0x100) {
315 180 *size = i - 3;
316 180 *data = av_malloc(*size + AV_INPUT_BUFFER_PADDING_SIZE);
317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if (!*data)
318 return AVERROR(ENOMEM);
319
320 180 memcpy(*data, pkt->data, *size);
321
322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if (s->remove) {
323 pkt->data += *size;
324 pkt->size -= *size;
325 }
326 180 break;
327 }
328 }
329 433 return 0;
330 }
331
332 120 static int extract_extradata_mpeg4(AVBSFContext *ctx, AVPacket *pkt,
333 uint8_t **data, int *size)
334 {
335 120 ExtractExtradataContext *s = ctx->priv_data;
336 120 const uint8_t *ptr = pkt->data, *end = pkt->data + pkt->size;
337 120 uint32_t state = UINT32_MAX;
338
339
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 while (ptr < end) {
340 394 ptr = avpriv_find_start_code(ptr, end, &state);
341
4/4
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 274 times.
394 if (state == 0x1B3 || state == 0x1B6) {
342
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 50 times.
120 if (ptr - pkt->data > 4) {
343 70 *size = ptr - 4 - pkt->data;
344 70 *data = av_malloc(*size + AV_INPUT_BUFFER_PADDING_SIZE);
345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!*data)
346 return AVERROR(ENOMEM);
347
348 70 memcpy(*data, pkt->data, *size);
349
350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (s->remove) {
351 pkt->data += *size;
352 pkt->size -= *size;
353 }
354 }
355 120 break;
356 }
357 }
358 120 return 0;
359 }
360
361 static const struct {
362 enum AVCodecID id;
363 int (*extract)(AVBSFContext *ctx, AVPacket *pkt,
364 uint8_t **data, int *size);
365 } extract_tab[] = {
366 { AV_CODEC_ID_AV1, extract_extradata_av1 },
367 { AV_CODEC_ID_AVS2, extract_extradata_mpeg4 },
368 { AV_CODEC_ID_AVS3, extract_extradata_mpeg4 },
369 { AV_CODEC_ID_CAVS, extract_extradata_mpeg4 },
370 { AV_CODEC_ID_H264, extract_extradata_h2645 },
371 { AV_CODEC_ID_HEVC, extract_extradata_h2645 },
372 { AV_CODEC_ID_MPEG1VIDEO, extract_extradata_mpeg12 },
373 { AV_CODEC_ID_MPEG2VIDEO, extract_extradata_mpeg12 },
374 { AV_CODEC_ID_MPEG4, extract_extradata_mpeg4 },
375 { AV_CODEC_ID_VC1, extract_extradata_vc1 },
376 { AV_CODEC_ID_VVC, extract_extradata_h2645 },
377 };
378
379 763 static int extract_extradata_init(AVBSFContext *ctx)
380 {
381 763 ExtractExtradataContext *s = ctx->priv_data;
382 int i;
383
384
1/2
✓ Branch 0 taken 5081 times.
✗ Branch 1 not taken.
5081 for (i = 0; i < FF_ARRAY_ELEMS(extract_tab); i++) {
385
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 4318 times.
5081 if (extract_tab[i].id == ctx->par_in->codec_id) {
386 763 s->extract = extract_tab[i].extract;
387 763 break;
388 }
389 }
390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 if (!s->extract)
391 return AVERROR_BUG;
392
393 763 return 0;
394 }
395
396 1547 static int extract_extradata_filter(AVBSFContext *ctx, AVPacket *pkt)
397 {
398 1547 ExtractExtradataContext *s = ctx->priv_data;
399 1547 uint8_t *extradata = NULL;
400 int extradata_size;
401 1547 int ret = 0;
402
403 1547 ret = ff_bsf_get_packet_ref(ctx, pkt);
404
2/2
✓ Branch 0 taken 397 times.
✓ Branch 1 taken 1150 times.
1547 if (ret < 0)
405 397 return ret;
406
407 1150 ret = s->extract(ctx, pkt, &extradata, &extradata_size);
408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1150 times.
1150 if (ret < 0)
409 goto fail;
410
411
2/2
✓ Branch 0 taken 755 times.
✓ Branch 1 taken 395 times.
1150 if (extradata) {
412 755 memset(extradata + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
413 755 ret = av_packet_add_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
414 extradata, extradata_size);
415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 755 times.
755 if (ret < 0) {
416 av_freep(&extradata);
417 goto fail;
418 }
419 }
420
421 1150 return 0;
422
423 fail:
424 av_packet_unref(pkt);
425 return ret;
426 }
427
428 763 static void extract_extradata_close(AVBSFContext *ctx)
429 {
430 763 ExtractExtradataContext *s = ctx->priv_data;
431 763 ff_av1_packet_uninit(&s->av1_pkt);
432 763 ff_h2645_packet_uninit(&s->h2645_pkt);
433 763 }
434
435 static const enum AVCodecID codec_ids[] = {
436 AV_CODEC_ID_AV1,
437 AV_CODEC_ID_AVS2,
438 AV_CODEC_ID_AVS3,
439 AV_CODEC_ID_CAVS,
440 AV_CODEC_ID_H264,
441 AV_CODEC_ID_HEVC,
442 AV_CODEC_ID_MPEG1VIDEO,
443 AV_CODEC_ID_MPEG2VIDEO,
444 AV_CODEC_ID_MPEG4,
445 AV_CODEC_ID_VC1,
446 AV_CODEC_ID_VVC,
447 AV_CODEC_ID_NONE,
448 };
449
450 #define OFFSET(x) offsetof(ExtractExtradataContext, x)
451 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
452 static const AVOption options[] = {
453 { "remove", "remove the extradata from the bitstream", OFFSET(remove), AV_OPT_TYPE_INT,
454 { .i64 = 0 }, 0, 1, FLAGS },
455 { NULL },
456 };
457
458 static const AVClass extract_extradata_class = {
459 .class_name = "extract_extradata",
460 .item_name = av_default_item_name,
461 .option = options,
462 .version = LIBAVUTIL_VERSION_INT,
463 };
464
465 const FFBitStreamFilter ff_extract_extradata_bsf = {
466 .p.name = "extract_extradata",
467 .p.codec_ids = codec_ids,
468 .p.priv_class = &extract_extradata_class,
469 .priv_data_size = sizeof(ExtractExtradataContext),
470 .init = extract_extradata_init,
471 .filter = extract_extradata_filter,
472 .close = extract_extradata_close,
473 };
474