FFmpeg
Loading...
Searching...
No Matches
api-hevc-mp4toannexb-test.c
Go to the documentation of this file.
1/*
2 * Test for HEVC mp4toannexb bitstream filter parameter set deduplication
3 *
4 * Copyright (c) 2026 FFmpeg developers
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include <stdio.h>
24#include <string.h>
25
26#include "libavutil/error.h"
28#include "libavutil/macros.h"
29#include "libavutil/mem.h"
30#include "libavcodec/avcodec.h"
31#include "libavcodec/bsf.h"
32#include "libavcodec/packet.h"
33
34/* Valid 64x64 HEVC parameter sets and slice from x265 */
35static const uint8_t vps_bytes[] = {
36 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x03, 0x70,
37 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03,
38 0x00, 0x00, 0x03, 0x00, 0x1e, 0x95, 0x94, 0x09
39};
40
41static const uint8_t sps_bytes[] = {
42 0x42, 0x01, 0x01, 0x03, 0x70, 0x00, 0x00, 0x03,
43 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03,
44 0x00, 0x1e, 0xa0, 0x20, 0x81, 0x05, 0x96, 0x56,
45 0x54, 0xa4, 0xc2, 0xe0, 0x10, 0x00, 0x00, 0x3e,
46 0x80, 0x00, 0x00, 0x3e, 0x80, 0x80
47};
48
49/* SPS 1 differs only in sps_seq_parameter_set_id: ue(v) 1 becomes 010.
50 * Repacked trailing bits and reinserted emulation-prevention bytes. */
51static const uint8_t sps1_bytes[] = {
52 0x42, 0x01, 0x01, 0x03, 0x70, 0x00, 0x00, 0x03,
53 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03,
54 0x00, 0x1e, 0x48, 0x08, 0x20, 0x41, 0x65, 0x95,
55 0x95, 0x29, 0x30, 0xb8, 0x04, 0x00, 0x00, 0x0f,
56 0xa0, 0x00, 0x00, 0x0f, 0xa0, 0x20
57};
58
59/* PPS with pps_pic_parameter_set_id = 0 */
60static const uint8_t pps0_bytes[] = {
61 0x44, 0x01, 0xc0, 0x73, 0xc0, 0x89
62};
63
64/* PPS with pps_pic_parameter_set_id = 1 */
65static const uint8_t pps1_bytes[] = {
66 0x44, 0x01, 0x50, 0x1c, 0xf0, 0x22, 0x40
67};
68
69/* Prefix SEI (filler payload type 3 to verify SEI NAL retention and ordering) */
70static const uint8_t prefix_sei_bytes[] = {
71 0x4e, 0x01, 0x03, 0x01, 0xff, 0x80
72};
73
74/* Valid 2-byte Prefix SEI header for cap-testing */
75static const uint8_t dummy_sei_bytes[] = {
76 0x4e, 0x01
77};
78
79/* Valid IDR slice referencing PPS 0 */
80static const uint8_t idr_slice_bytes[] = {
81 0x28, 0x01, 0xac, 0x4e, 0xd7, 0x1f, 0xff, 0xf5,
82 0xde, 0x9c, 0xaf, 0xea, 0xf8
83};
84
85static const uint8_t hvcc_header[22] = {
86 1, /* configurationVersion = 1 */
87 0x01, /* general_profile_space / tier / profile_idc */
88 0x60, 0, 0, 0, /* general_profile_compatibility_flags */
89 0x90, 0, 0, 0, 0, 0, /* general_constraint_indicator_flags */
90 0x5d, /* general_level_idc */
91 0xf0, 0x00, /* min_spatial_segmentation_idc (1111 0000) */
92 0xfc, /* parallelismType */
93 0xfd, /* chroma_format_idc (3 = 4:2:0) */
94 0xf8, /* bit_depth_luma_minus8 */
95 0xf8, /* bit_depth_chroma_minus8 */
96 0x00, 0x00, /* avgFrameRate */
97 0x03 /* lengthSizeMinusOne = 3 (4-byte length prefix) */
98};
99
100typedef struct HVCCNALDesc {
101 int type;
102 const uint8_t *data;
103 size_t size;
104 int count;
106
107static void print_packet_hex(const char *label, const AVPacket *pkt)
108{
109 printf("%s: size %d, hex: ", label, pkt->size);
110 for (int i = 0; i < pkt->size; i++)
111 printf("%02x", pkt->data[i]);
112 printf("\n");
113}
114
115/* Helper to build a HEVCDecoderConfigurationRecord (hvcC) from array descriptors */
116static uint8_t *build_hvcc(size_t *hvcc_size, const HVCCNALDesc *arrays, int nb_arrays)
117{
118 size_t total = sizeof(hvcc_header) + 1;
119 uint8_t *buf, *p;
120
121 for (int i = 0; i < nb_arrays; i++)
122 total += 3 + (size_t)arrays[i].count * (2 + arrays[i].size);
123
125 if (!buf)
126 return NULL;
127
128 p = buf;
129 memcpy(p, hvcc_header, sizeof(hvcc_header));
130 p += sizeof(hvcc_header);
131 *p++ = nb_arrays;
132
133 for (int i = 0; i < nb_arrays; i++) {
134 int cnt = arrays[i].count;
135 size_t len = arrays[i].size;
136
137 *p++ = arrays[i].type & 0x3f;
138 *p++ = (cnt >> 8) & 0xff;
139 *p++ = cnt & 0xff;
140 for (int j = 0; j < cnt; j++) {
141 *p++ = (len >> 8) & 0xff;
142 *p++ = len & 0xff;
143 if (arrays[i].data)
144 memcpy(p, arrays[i].data, len);
145 else
146 memset(p, 0x80, len);
147 p += len;
148 }
149 }
150
151 *hvcc_size = p - buf;
152 return buf;
153}
154
155/* Helper to build a packet with 4-byte length-prefixed NALUs */
157 const uint8_t *nalus[], const size_t lens[], int count)
158{
159 size_t total = 0;
160 uint8_t *p;
161 int ret;
162
163 for (int i = 0; i < count; i++)
164 total += 4 + lens[i];
165
166 ret = av_new_packet(pkt, total);
167 if (ret < 0)
168 return ret;
169
170 p = pkt->data;
171 for (int i = 0; i < count; i++) {
172 AV_WB32(p, lens[i]);
173 memcpy(p + 4, nalus[i], lens[i]);
174 p += 4 + lens[i];
175 }
176
177 return 0;
178}
179
180static int decode_packet(const AVPacket *pkt)
181{
184 AVFrame *frame = NULL;
185 AVPacket *dec_pkt = NULL;
186 int ret = 0, got_frame = 0;
187
188 if (!codec) {
189 fprintf(stderr, "HEVC decoder not found\n");
191 }
192
195 dec_pkt = av_packet_alloc();
196 if (!dec_ctx || !frame || !dec_pkt) {
197 ret = AVERROR(ENOMEM);
198 goto end;
199 }
200
201 ret = avcodec_open2(dec_ctx, codec, NULL);
202 if (ret < 0)
203 goto end;
204
205 ret = av_packet_ref(dec_pkt, pkt);
206 if (ret < 0)
207 goto end;
208
209 ret = avcodec_send_packet(dec_ctx, dec_pkt);
210 if (ret < 0)
211 goto end;
212
213 while (1) {
215 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
216 break;
217 if (ret < 0)
218 goto end;
219 got_frame++;
220 }
221
223 if (ret < 0 && ret != AVERROR_EOF)
224 goto end;
225
226 while (1) {
228 if (ret == AVERROR_EOF)
229 break;
230 if (ret < 0)
231 goto end;
232 got_frame++;
233 }
234
235 printf("Decoded frames: %d\n", got_frame);
236 ret = 0;
237
238end:
239 av_packet_free(&dec_pkt);
242 return ret;
243}
244
245static int run_test_case(const char *case_name,
246 const uint8_t *hvcc, size_t hvcc_size,
247 AVPacket *in_pkt, int init_only,
248 int check_decode)
249{
250 const AVBitStreamFilter *bsf;
252 AVPacket *out_pkt = NULL;
253 int ret = 0;
254
255 printf("=== Test: %s ===\n", case_name);
256
257 bsf = av_bsf_get_by_name("hevc_mp4toannexb");
258 if (!bsf) {
259 fprintf(stderr, "Bitstream filter hevc_mp4toannexb not found\n");
260 return -1;
261 }
262
263 ret = av_bsf_alloc(bsf, &ctx);
264 if (ret < 0)
265 return ret;
266
267 ctx->par_in->codec_type = AVMEDIA_TYPE_VIDEO;
268 ctx->par_in->codec_id = AV_CODEC_ID_HEVC;
269 ctx->par_in->extradata = av_memdup(hvcc, hvcc_size + AV_INPUT_BUFFER_PADDING_SIZE);
270 if (!ctx->par_in->extradata) {
271 ret = AVERROR(ENOMEM);
272 goto end;
273 }
274 ctx->par_in->extradata_size = hvcc_size;
275
276 ret = av_bsf_init(ctx);
277 if (init_only) {
278 printf("av_bsf_init: %d\n", ret);
279 ret = 0;
280 goto end;
281 } else if (ret < 0) {
282 char errbuf[AV_ERROR_MAX_STRING_SIZE];
283 av_strerror(ret, errbuf, sizeof(errbuf));
284 fprintf(stderr, "av_bsf_init failed: %s\n", errbuf);
285 goto end;
286 }
287
288 out_pkt = av_packet_alloc();
289 if (!out_pkt) {
290 ret = AVERROR(ENOMEM);
291 goto end;
292 }
293
294 ret = av_bsf_send_packet(ctx, in_pkt);
295 if (ret < 0) {
296 fprintf(stderr, "av_bsf_send_packet failed: %d\n", ret);
297 goto end;
298 }
299
300 ret = av_bsf_receive_packet(ctx, out_pkt);
301 if (ret < 0) {
302 fprintf(stderr, "av_bsf_receive_packet failed: %d\n", ret);
303 goto end;
304 }
305
306 print_packet_hex("Output", out_pkt);
307
308 if (check_decode) {
309 ret = decode_packet(out_pkt);
310 if (ret < 0) {
311 fprintf(stderr, "%s: decoding output packet failed\n", case_name);
312 goto end;
313 }
314 /* The decoder prints the actual frame count for FATE. */
315 }
316
317 ret = 0;
318
319end:
320 av_packet_free(&out_pkt);
322 return ret;
323}
324
325int main(void)
326{
327 uint8_t *hvcc_std = NULL, *hvcc_sei = NULL, *hvcc_dup = NULL, *hvcc_limit = NULL;
328 size_t sz_std = 0, sz_sei = 0, sz_dup = 0, sz_limit = 0;
330 int ret = 0, err;
331
332 const HVCCNALDesc std_arrays[] = {
333 { 32, vps_bytes, sizeof(vps_bytes), 1 },
334 { 33, sps_bytes, sizeof(sps_bytes), 1 },
335 { 34, pps0_bytes, sizeof(pps0_bytes), 1 },
336 };
337 const HVCCNALDesc sei_arrays[] = {
338 { 39, prefix_sei_bytes, sizeof(prefix_sei_bytes), 1 },
339 { 32, vps_bytes, sizeof(vps_bytes), 1 },
340 { 33, sps_bytes, sizeof(sps_bytes), 1 },
341 { 34, pps0_bytes, sizeof(pps0_bytes), 1 },
342 };
343 const HVCCNALDesc dup_arrays[] = {
344 { 32, vps_bytes, sizeof(vps_bytes), 1 },
345 { 33, sps_bytes, sizeof(sps_bytes), 2 },
346 { 34, pps0_bytes, sizeof(pps0_bytes), 1 },
347 };
348 const HVCCNALDesc limit_arrays[] = {
349 { 39, dummy_sei_bytes, sizeof(dummy_sei_bytes), 2049 },
350 };
351
352 if (!pkt)
353 return 1;
354
355 hvcc_std = build_hvcc(&sz_std, std_arrays, FF_ARRAY_ELEMS(std_arrays));
356 hvcc_sei = build_hvcc(&sz_sei, sei_arrays, FF_ARRAY_ELEMS(sei_arrays));
357 hvcc_dup = build_hvcc(&sz_dup, dup_arrays, FF_ARRAY_ELEMS(dup_arrays));
358 hvcc_limit = build_hvcc(&sz_limit, limit_arrays, FF_ARRAY_ELEMS(limit_arrays));
359
360 if (!hvcc_std || !hvcc_sei || !hvcc_dup || !hvcc_limit) {
361 ret = 1;
362 goto cleanup;
363 }
364
365 /* Case 1: Standard insertion (extradata has VPS, SPS, PPS 0; packet only has IDR slice) */
366 {
367 const uint8_t *nalus[] = { idr_slice_bytes };
368 const size_t lens[] = { sizeof(idr_slice_bytes) };
369 if (build_packet(pkt, nalus, lens, FF_ARRAY_ELEMS(nalus)) < 0) {
370 ret = 1;
371 goto cleanup;
372 }
373 err = run_test_case("Case 1 (Standard Insertion)", hvcc_std, sz_std, pkt, 0, 1);
374 if (err < 0)
375 ret = 1;
377 }
378
379 /* Case 2: Exact payload deduplication (extradata has VPS, SPS, PPS 0; packet has identical in-band VPS, SPS, PPS 0 + IDR slice) */
380 {
381 const uint8_t *nalus[] = { vps_bytes, sps_bytes, pps0_bytes, idr_slice_bytes };
382 const size_t lens[] = { sizeof(vps_bytes), sizeof(sps_bytes), sizeof(pps0_bytes), sizeof(idr_slice_bytes) };
383 if (build_packet(pkt, nalus, lens, FF_ARRAY_ELEMS(nalus)) < 0) {
384 ret = 1;
385 goto cleanup;
386 }
387 err = run_test_case("Case 2 (Exact Payload Deduplication)", hvcc_std, sz_std, pkt, 0, 1);
388 if (err < 0)
389 ret = 1;
391 }
392
393 /* Case 3: Reviewer Fairy counterexample (extradata has VPS, SPS, PPS 0; packet has in-band VPS, SPS, PPS 1 + IDR slice) */
394 {
395 const uint8_t *nalus[] = { vps_bytes, sps_bytes, pps1_bytes, idr_slice_bytes };
396 const size_t lens[] = { sizeof(vps_bytes), sizeof(sps_bytes), sizeof(pps1_bytes), sizeof(idr_slice_bytes) };
397 if (build_packet(pkt, nalus, lens, FF_ARRAY_ELEMS(nalus)) < 0) {
398 ret = 1;
399 goto cleanup;
400 }
401 err = run_test_case("Case 3 (Fairy Counterexample - Retain PPS 0)", hvcc_std, sz_std, pkt, 0, 1);
402 if (err < 0)
403 ret = 1;
405 }
406
407 /* Case 4: Filler SEI preservation (extradata has Prefix SEI, VPS, SPS, PPS 0; packet has identical VPS, SPS, PPS 0 + IDR slice) */
408 {
409 const uint8_t *nalus[] = { vps_bytes, sps_bytes, pps0_bytes, idr_slice_bytes };
410 const size_t lens[] = { sizeof(vps_bytes), sizeof(sps_bytes), sizeof(pps0_bytes), sizeof(idr_slice_bytes) };
411 if (build_packet(pkt, nalus, lens, FF_ARRAY_ELEMS(nalus)) < 0) {
412 ret = 1;
413 goto cleanup;
414 }
415 err = run_test_case("Case 4 (Filler SEI Preservation)", hvcc_sei, sz_sei, pkt, 0, 1);
416 if (err < 0)
417 ret = 1;
419 }
420
421 /* Case 5: Many nonmatching in-band PPS copies before a matching PPS */
422 {
423 const uint8_t *nalus[36];
424 size_t lens[36];
425 int count = 0;
426
427 nalus[count] = vps_bytes;
428 lens[count++] = sizeof(vps_bytes);
429
430 nalus[count] = sps_bytes;
431 lens[count++] = sizeof(sps_bytes);
432
433 for (int k = 0; k < 32; k++) {
434 nalus[count] = pps1_bytes;
435 lens[count++] = sizeof(pps1_bytes);
436 }
437
438 nalus[count] = pps0_bytes;
439 lens[count++] = sizeof(pps0_bytes);
440
441 nalus[count] = idr_slice_bytes;
442 lens[count++] = sizeof(idr_slice_bytes);
443
444 if (build_packet(pkt, nalus, lens, count) < 0) {
445 ret = 1;
446 goto cleanup;
447 }
448 err = run_test_case("Case 5 (Many Nonmatching In-band PPS Copies)", hvcc_std, sz_std, pkt, 0, 1);
449 if (err < 0)
450 ret = 1;
452 }
453
454 /* Case 6: In-band parameter set suppresses duplicate extradata entries
455 * (extradata has 1xVPS, 2xSPS, 1xPPS 0; packet has 1xVPS, 1xSPS, 1xPPS 0 + IDR slice).
456 * Verifies that matching in-band parameter sets suppress all identical
457 * extradata copies, leaving only the in-band entry.
458 */
459 {
460 const uint8_t *nalus[] = { vps_bytes, sps_bytes, pps0_bytes, idr_slice_bytes };
461 const size_t lens[] = { sizeof(vps_bytes), sizeof(sps_bytes), sizeof(pps0_bytes), sizeof(idr_slice_bytes) };
462 if (build_packet(pkt, nalus, lens, FF_ARRAY_ELEMS(nalus)) < 0) {
463 ret = 1;
464 goto cleanup;
465 }
466 err = run_test_case("Case 6 (Duplicate Extradata PS Suppressed By In-Band Match)",
467 hvcc_dup, sz_dup, pkt, 0, 1);
468 if (err < 0)
469 ret = 1;
471 }
472
473 /* Case 7: Exceeds MAX_EXTRADATA_NALS limit rejection (hvcC carries >2048 NALUs) */
474 err = run_test_case("Case 7 (Exceeds MAX_EXTRADATA_NALS Limit Rejection)",
475 hvcc_limit, sz_limit, NULL, 1, 0);
476 if (err < 0)
477 ret = 1;
478
479 /* Case 8: Leading Prefix SEI before matching in-band VPS and SPS
480 * (extradata has VPS, SPS, PPS 0; packet has Prefix SEI, matching VPS, matching SPS + IDR slice).
481 * Verifies that extradata PPS 0 is not prematurely emitted before matching VPS/SPS.
482 */
483 {
484 const uint8_t *nalus[] = { prefix_sei_bytes, vps_bytes, sps_bytes, idr_slice_bytes };
485 const size_t lens[] = { sizeof(prefix_sei_bytes), sizeof(vps_bytes), sizeof(sps_bytes), sizeof(idr_slice_bytes) };
486 if (build_packet(pkt, nalus, lens, FF_ARRAY_ELEMS(nalus)) < 0) {
487 ret = 1;
488 goto cleanup;
489 }
490 err = run_test_case("Case 8 (Leading Prefix SEI Before Matching VPS/SPS)",
491 hvcc_std, sz_std, pkt, 0, 1);
492 if (err < 0)
493 ret = 1;
495 }
496
497 /* Case 9: In-band PPS before SPS reordering
498 * (extradata has VPS, SPS, PPS 0; packet has in-band PPS 0, matching SPS + IDR slice).
499 * Verifies that out-of-order in-band SPS does not suppress extradata SPS needed by earlier PPS.
500 */
501 {
502 const uint8_t *nalus[] = { pps0_bytes, sps_bytes, idr_slice_bytes };
503 const size_t lens[] = { sizeof(pps0_bytes), sizeof(sps_bytes), sizeof(idr_slice_bytes) };
504 if (build_packet(pkt, nalus, lens, FF_ARRAY_ELEMS(nalus)) < 0) {
505 ret = 1;
506 goto cleanup;
507 }
508 err = run_test_case("Case 9 (In-band PPS Before SPS Reordering)",
509 hvcc_std, sz_std, pkt, 0, 1);
510 if (err < 0)
511 ret = 1;
513 }
514
515 /* Case 10: Leading Prefix SEI with only VPS matched
516 * (extradata has VPS 0, SPS 0, PPS 0; packet has Prefix SEI, matching VPS 0 + IDR slice).
517 * Verifies that extradata SPS 0 and PPS 0 are not prematurely emitted before
518 * in-band VPS 0 due to the Prefix SEI barrier, ensuring valid decoding topology.
519 */
520 {
521 const uint8_t *nalus[] = { prefix_sei_bytes, vps_bytes, idr_slice_bytes };
522 const size_t lens[] = { sizeof(prefix_sei_bytes), sizeof(vps_bytes), sizeof(idr_slice_bytes) };
523 if (build_packet(pkt, nalus, lens, FF_ARRAY_ELEMS(nalus)) < 0) {
524 ret = 1;
525 goto cleanup;
526 }
527 err = run_test_case("Case 10 (Leading Prefix SEI With Matching VPS Only)",
528 hvcc_std, sz_std, pkt, 0, 1);
529 if (err < 0)
530 ret = 1;
532 }
533
534 /* Case 11: Multiple SPS IDs across Prefix SEI
535 * (extradata has VPS 0, SPS 0, PPS 0; packet has matching VPS 0, in-band SPS 1,
536 * Prefix SEI, matching SPS 0 + IDR slice).
537 * Verifies that seeing SPS 1 before Prefix SEI does not prematurely emit extradata PPS 0
538 * which depends on SPS 0 that appears after the SEI.
539 */
540 {
541 const uint8_t *nalus[] = { vps_bytes, sps1_bytes, prefix_sei_bytes, sps_bytes, idr_slice_bytes };
542 const size_t lens[] = { sizeof(vps_bytes), sizeof(sps1_bytes), sizeof(prefix_sei_bytes),
543 sizeof(sps_bytes), sizeof(idr_slice_bytes) };
544 if (build_packet(pkt, nalus, lens, FF_ARRAY_ELEMS(nalus)) < 0) {
545 ret = 1;
546 goto cleanup;
547 }
548 err = run_test_case("Case 11 (Multiple SPS IDs Across Prefix SEI)",
549 hvcc_std, sz_std, pkt, 0, 1);
550 if (err < 0)
551 ret = 1;
553 }
554
555cleanup:
556 av_freep(&hvcc_std);
557 av_freep(&hvcc_sei);
558 av_freep(&hvcc_dup);
559 av_freep(&hvcc_limit);
561 return ret;
562}
static int build_packet(AVPacket *pkt, const uint8_t *nalus[], const size_t lens[], int count)
static const uint8_t prefix_sei_bytes[]
static const uint8_t sps1_bytes[]
static int decode_packet(const AVPacket *pkt)
static const uint8_t idr_slice_bytes[]
static uint8_t * build_hvcc(size_t *hvcc_size, const HVCCNALDesc *arrays, int nb_arrays)
static const uint8_t vps_bytes[]
int main(void)
static const uint8_t dummy_sei_bytes[]
static int run_test_case(const char *case_name, const uint8_t *hvcc, size_t hvcc_size, AVPacket *in_pkt, int init_only, int check_decode)
static void print_packet_hex(const char *label, const AVPacket *pkt)
static const uint8_t pps1_bytes[]
static const uint8_t sps_bytes[]
static const uint8_t pps0_bytes[]
static const uint8_t hvcc_header[22]
static AVFormatContext * ctx
Libavcodec external API header.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define NULL
Definition coverity.c:32
__device__ int printf(const char *,...)
static AVCodecContext * dec_ctx
static AVPacket * pkt
static AVFrame * frame
error code definitions
const char * label
Definition ffplay.c:1187
static av_cold void cleanup(FlashSV2Context *s)
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
Definition bsf.c:47
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
Definition bsf.c:147
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
Allocate a context for a given bitstream filter.
Definition bsf.c:99
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
Definition bsf.c:228
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
Definition bsf.c:200
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
Definition avcodec.c:144
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
Definition options.c:149
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition allcodecs.c:995
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
Definition options.c:164
@ AV_CODEC_ID_HEVC
Definition codec_id.h:223
int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Alias for avcodec_receive_frame_flags(avctx, frame, 0).
Definition avcodec.c:720
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
Definition decode.c:734
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
Definition defs.h:40
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition packet.c:74
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition packet.c:434
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition packet.c:63
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
Definition packet.c:442
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition packet.c:98
#define AVERROR_DECODER_NOT_FOUND
Decoder not found.
Definition error.h:54
#define AV_ERROR_MAX_STRING_SIZE
Definition error.h:86
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
Definition error.c:134
#define AVERROR_EOF
End of file.
Definition error.h:57
#define AVERROR(e)
Definition error.h:45
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition frame.c:52
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
Definition mem.c:408
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
#define AV_WB32(p, v)
Utility Preprocessor macros.
Memory handling functions.
const char data[16]
Definition mxf.c:149
#define FF_ARRAY_ELEMS(a)
The bitstream filter state.
Definition bsf.h:68
main external API structure.
Definition avcodec.h:443
AVCodec.
Definition codec.h:175
This structure describes decoded (raw) audio or video data.
Definition frame.h:479
This structure stores compressed data.
Definition packet.h:580
#define av_mallocz(s)
#define av_freep(p)
int len