History

avcodec/cbs: allow fine tunning selection of features

Core framework and AV1 only for now. This will be useful in an upcoming commit, where CBS will be utilized by a module outside libavcodec.

James Almer committed 1 year ago

Commit 56317041 parent 3e0b38e6 files · +269 −116Browse files

Unified · Split

6 files
  1. libavcodec/cbs.c +79 −63
  2. libavcodec/cbs.h +30 −23
  3. libavcodec/cbs_av1.c +76 −15
  4. libavcodec/cbs_av1.h +15 −0
  5. libavcodec/cbs_av1_syntax_template.c +6 −0
  6. libavcodec/cbs_internal.h +63 −15
libavcodec/cbs.c+79−63
@@ -18,8 +18,6 @@ · 17 unmodified lines
18 18
19#include <string.h>19#include <string.h>
20 20
21#include "config.h"
22
23#include "libavutil/avassert.h"21#include "libavutil/avassert.h"
24#include "libavutil/buffer.h"22#include "libavutil/buffer.h"
25#include "libavutil/common.h"23#include "libavutil/common.h"
@@ -33,61 +31,61 @@ · 7 unmodified lines
33 31
34 32
35static const CodedBitstreamType *const cbs_type_table[] = {33static const CodedBitstreamType *const cbs_type_table[] = {
36#if CONFIG_CBS_AV134#if CBS_AV1
37 &ff_cbs_type_av1,35 &CBS_FUNC(type_av1),
38#endif36#endif
39#if CONFIG_CBS_H26437#if CBS_H264
40 &ff_cbs_type_h264,38 &CBS_FUNC(type_h264),
41#endif39#endif
42#if CONFIG_CBS_H26540#if CBS_H265
43 &ff_cbs_type_h265,41 &CBS_FUNC(type_h265),
44#endif42#endif
45#if CONFIG_CBS_H26643#if CBS_H266
46 &ff_cbs_type_h266,44 &CBS_FUNC(type_h266),
47#endif45#endif
48#if CONFIG_CBS_JPEG46#if CBS_JPEG
49 &ff_cbs_type_jpeg,47 &CBS_FUNC(type_jpeg),
50#endif48#endif
51#if CONFIG_CBS_MPEG249#if CBS_MPEG2
52 &ff_cbs_type_mpeg2,50 &CBS_FUNC(type_mpeg2),
53#endif51#endif
54#if CONFIG_CBS_VP852#if CBS_VP8
55 &ff_cbs_type_vp8,53 &CBS_FUNC(type_vp8),
56#endif54#endif
57#if CONFIG_CBS_VP955#if CBS_VP9
58 &ff_cbs_type_vp9,56 &CBS_FUNC(type_vp9),
59#endif57#endif
60};58};
61 59
62const enum AVCodecID ff_cbs_all_codec_ids[] = {60const enum AVCodecID CBS_FUNC(all_codec_ids)[] = {
63#if CONFIG_CBS_AV161#if CBS_AV1
64 AV_CODEC_ID_AV1,62 AV_CODEC_ID_AV1,
65#endif63#endif
66#if CONFIG_CBS_H26464#if CBS_H264
67 AV_CODEC_ID_H264,65 AV_CODEC_ID_H264,
68#endif66#endif
69#if CONFIG_CBS_H26567#if CBS_H265
70 AV_CODEC_ID_H265,68 AV_CODEC_ID_H265,
71#endif69#endif
72#if CONFIG_CBS_H26670#if CBS_H266
73 AV_CODEC_ID_H266,71 AV_CODEC_ID_H266,
74#endif72#endif
75#if CONFIG_CBS_JPEG73#if CBS_JPEG
76 AV_CODEC_ID_MJPEG,74 AV_CODEC_ID_MJPEG,
77#endif75#endif
78#if CONFIG_CBS_MPEG276#if CBS_MPEG2
79 AV_CODEC_ID_MPEG2VIDEO,77 AV_CODEC_ID_MPEG2VIDEO,
80#endif78#endif
81#if CONFIG_CBS_VP879#if CBS_VP8
82 AV_CODEC_ID_VP8,80 AV_CODEC_ID_VP8,
83#endif81#endif
84#if CONFIG_CBS_VP982#if CBS_VP9
85 AV_CODEC_ID_VP9,83 AV_CODEC_ID_VP9,
86#endif84#endif
87 AV_CODEC_ID_NONE85 AV_CODEC_ID_NONE
88};86};
89 87
90av_cold int ff_cbs_init(CodedBitstreamContext **ctx_ptr,88av_cold int CBS_FUNC(init)(CodedBitstreamContext **ctx_ptr,
91 enum AVCodecID codec_id, void *log_ctx)89 enum AVCodecID codec_id, void *log_ctx)
92{90{
93 CodedBitstreamContext *ctx;91 CodedBitstreamContext *ctx;
@@ -133,13 +131,13 @@ av_cold int ff_cbs_init(CodedBitstreamContext **ctx_ptr, · 39 unmodified lines
133 return 0;131 return 0;
134}132}
135 133
136av_cold void ff_cbs_flush(CodedBitstreamContext *ctx)134av_cold void CBS_FUNC(flush)(CodedBitstreamContext *ctx)
137{135{
138 if (ctx->codec->flush)136 if (ctx->codec->flush)
139 ctx->codec->flush(ctx);137 ctx->codec->flush(ctx);
140}138}
141 139
142av_cold void ff_cbs_close(CodedBitstreamContext **ctx_ptr)140av_cold void CBS_FUNC(close)(CodedBitstreamContext **ctx_ptr)
143{141{
144 CodedBitstreamContext *ctx = *ctx_ptr;142 CodedBitstreamContext *ctx = *ctx_ptr;
145 143
@@ -169,7 +167,7 @@ static void cbs_unit_uninit(CodedBitstreamUnit *unit) · 23 unmodified lines
169 unit->data_bit_padding = 0;167 unit->data_bit_padding = 0;
170}168}
171 169
172void ff_cbs_fragment_reset(CodedBitstreamFragment *frag)170void CBS_FUNC(fragment_reset)(CodedBitstreamFragment *frag)
173{171{
174 int i;172 int i;
175 173
@@ -183,14 +181,15 @@ void ff_cbs_fragment_reset(CodedBitstreamFragment *frag) · 7 unmodified lines
183 frag->data_bit_padding = 0;181 frag->data_bit_padding = 0;
184}182}
185 183
186av_cold void ff_cbs_fragment_free(CodedBitstreamFragment *frag)184av_cold void CBS_FUNC(fragment_free)(CodedBitstreamFragment *frag)
187{185{
188 ff_cbs_fragment_reset(frag);186 CBS_FUNC(fragment_reset)(frag);
189 187
190 av_freep(&frag->units);188 av_freep(&frag->units);
191 frag->nb_units_allocated = 0;189 frag->nb_units_allocated = 0;
192}190}
193 191
192#if CBS_READ
194static int cbs_read_fragment_content(CodedBitstreamContext *ctx,193static int cbs_read_fragment_content(CodedBitstreamContext *ctx,
195 CodedBitstreamFragment *frag)194 CodedBitstreamFragment *frag)
196{195{
@@ -283,7 +282,7 @@ static int cbs_read_data(CodedBitstreamContext *ctx, · 86 unmodified lines
283 return cbs_read_fragment_content(ctx, frag);282 return cbs_read_fragment_content(ctx, frag);
284}283}
285 284
286int ff_cbs_read_extradata(CodedBitstreamContext *ctx,285int CBS_FUNC(read_extradata)(CodedBitstreamContext *ctx,
287 CodedBitstreamFragment *frag,286 CodedBitstreamFragment *frag,
288 const AVCodecParameters *par)287 const AVCodecParameters *par)
289{288{
@@ -292,7 +291,7 @@ int ff_cbs_read_extradata(CodedBitstreamContext *ctx, · 2 unmodified lines
292 par->extradata_size, 1);291 par->extradata_size, 1);
293}292}
294 293
295int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx,294int CBS_FUNC(read_extradata_from_codec)(CodedBitstreamContext *ctx,
296 CodedBitstreamFragment *frag,295 CodedBitstreamFragment *frag,
297 const AVCodecContext *avctx)296 const AVCodecContext *avctx)
298{297{
@@ -301,7 +300,7 @@ int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx, · 2 unmodified lines
301 avctx->extradata_size, 1);300 avctx->extradata_size, 1);
302}301}
303 302
304int ff_cbs_read_packet(CodedBitstreamContext *ctx,303int CBS_FUNC(read_packet)(CodedBitstreamContext *ctx,
305 CodedBitstreamFragment *frag,304 CodedBitstreamFragment *frag,
306 const AVPacket *pkt)305 const AVPacket *pkt)
307{306{
@@ -309,7 +308,7 @@ int ff_cbs_read_packet(CodedBitstreamContext *ctx, · 1 unmodified line
309 pkt->data, pkt->size, 0);308 pkt->data, pkt->size, 0);
310}309}
311 310
312int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx,311int CBS_FUNC(read_packet_side_data)(CodedBitstreamContext *ctx,
313 CodedBitstreamFragment *frag,312 CodedBitstreamFragment *frag,
314 const AVPacket *pkt)313 const AVPacket *pkt)
315{314{
@@ -322,14 +321,16 @@ int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx, · 6 unmodified lines
322 side_data, side_data_size, 1);321 side_data, side_data_size, 1);
323}322}
324 323
325int ff_cbs_read(CodedBitstreamContext *ctx,324int CBS_FUNC(read)(CodedBitstreamContext *ctx,
326 CodedBitstreamFragment *frag,325 CodedBitstreamFragment *frag,
327 const uint8_t *data, size_t size)326 const uint8_t *data, size_t size)
328{327{
329 return cbs_read_data(ctx, frag, NULL,328 return cbs_read_data(ctx, frag, NULL,
330 data, size, 0);329 data, size, 0);
331}330}
331#endif
332 332
333#if CBS_WRITE
333/**334/**
334 * Allocate a new internal data buffer of the given size in the unit.335 * Allocate a new internal data buffer of the given size in the unit.
335 *336 *
@@ -406,7 +407,7 @@ static int cbs_write_unit_data(CodedBitstreamContext *ctx, · 70 unmodified lines
406 return 0;407 return 0;
407}408}
408 409
409int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx,410int CBS_FUNC(write_fragment_data)(CodedBitstreamContext *ctx,
410 CodedBitstreamFragment *frag)411 CodedBitstreamFragment *frag)
411{412{
412 int err, i;413 int err, i;
@@ -442,13 +443,13 @@ int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx, · 29 unmodified lines
442 return 0;443 return 0;
443}444}
444 445
445int ff_cbs_write_extradata(CodedBitstreamContext *ctx,446int CBS_FUNC(write_extradata)(CodedBitstreamContext *ctx,
446 AVCodecParameters *par,447 AVCodecParameters *par,
447 CodedBitstreamFragment *frag)448 CodedBitstreamFragment *frag)
448{449{
449 int err;450 int err;
450 451
451 err = ff_cbs_write_fragment_data(ctx, frag);452 err = CBS_FUNC(write_fragment_data)(ctx, frag);
452 if (err < 0)453 if (err < 0)
453 return err;454 return err;
454 455
@@ -471,14 +472,14 @@ int ff_cbs_write_extradata(CodedBitstreamContext *ctx, · 16 unmodified lines
471 return 0;472 return 0;
472}473}
473 474
474int ff_cbs_write_packet(CodedBitstreamContext *ctx,475int CBS_FUNC(write_packet)(CodedBitstreamContext *ctx,
475 AVPacket *pkt,476 AVPacket *pkt,
476 CodedBitstreamFragment *frag)477 CodedBitstreamFragment *frag)
477{478{
478 AVBufferRef *buf;479 AVBufferRef *buf;
479 int err;480 int err;
480 481
481 err = ff_cbs_write_fragment_data(ctx, frag);482 err = CBS_FUNC(write_fragment_data)(ctx, frag);
482 if (err < 0)483 if (err < 0)
483 return err;484 return err;
484 485
@@ -494,22 +495,26 @@ int ff_cbs_write_packet(CodedBitstreamContext *ctx, · 9 unmodified lines
494 495
495 return 0;496 return 0;
496}497}
498#endif
497 499
498 500
499void ff_cbs_trace_header(CodedBitstreamContext *ctx,501void CBS_FUNC(trace_header)(CodedBitstreamContext *ctx,
500 const char *name)502 const char *name)
501{503{
504#if CBS_TRACE
502 if (!ctx->trace_enable)505 if (!ctx->trace_enable)
503 return;506 return;
504 507
505 av_log(ctx->log_ctx, ctx->trace_level, "%s\n", name);508 av_log(ctx->log_ctx, ctx->trace_level, "%s\n", name);
509#endif
506}510}
507 511
508void ff_cbs_trace_read_log(void *trace_context,512void CBS_FUNC(trace_read_log)(void *trace_context,
509 GetBitContext *gbc, int length,513 GetBitContext *gbc, int length,
510 const char *str, const int *subscripts,514 const char *str, const int *subscripts,
511 int64_t value)515 int64_t value)
512{516{
517#if CBS_TRACE
513 CodedBitstreamContext *ctx = trace_context;518 CodedBitstreamContext *ctx = trace_context;
514 char name[256];519 char name[256];
515 char bits[256];520 char bits[256];
@@ -561,13 +566,15 @@ void ff_cbs_trace_read_log(void *trace_context, · 45 unmodified lines
561 566
562 av_log(ctx->log_ctx, ctx->trace_level, "%-10d %s%*s = %"PRId64"\n",567 av_log(ctx->log_ctx, ctx->trace_level, "%-10d %s%*s = %"PRId64"\n",
563 position, name, pad, bits, value);568 position, name, pad, bits, value);
569#endif
564}570}
565 571
566void ff_cbs_trace_write_log(void *trace_context,572void CBS_FUNC(trace_write_log)(void *trace_context,
567 PutBitContext *pbc, int length,573 PutBitContext *pbc, int length,
568 const char *str, const int *subscripts,574 const char *str, const int *subscripts,
569 int64_t value)575 int64_t value)
570{576{
577#if CBS_TRACE
571 CodedBitstreamContext *ctx = trace_context;578 CodedBitstreamContext *ctx = trace_context;
572 579
573 // Ensure that the syntax element is written to the output buffer,580 // Ensure that the syntax element is written to the output buffer,
@@ -590,9 +597,11 @@ void ff_cbs_trace_write_log(void *trace_context, · 16 unmodified lines
590 597
591 skip_bits_long(&gbc, position - length);598 skip_bits_long(&gbc, position - length);
592 599
593 ff_cbs_trace_read_log(ctx, &gbc, length, str, subscripts, value);600 CBS_FUNC(trace_read_log)(ctx, &gbc, length, str, subscripts, value);
601#endif
594}602}
595 603
604#if CBS_READ
596static av_always_inline int cbs_read_unsigned(CodedBitstreamContext *ctx,605static av_always_inline int cbs_read_unsigned(CodedBitstreamContext *ctx,
597 GetBitContext *gbc,606 GetBitContext *gbc,
598 int width, const char *name,607 int width, const char *name,
@@ -628,7 +637,7 @@ static av_always_inline int cbs_read_unsigned(CodedBitstreamContext *ctx, · 29 unmodified lines
628 return 0;637 return 0;
629}638}
630 639
631int ff_cbs_read_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc,640int CBS_FUNC(read_unsigned)(CodedBitstreamContext *ctx, GetBitContext *gbc,
632 int width, const char *name,641 int width, const char *name,
633 const int *subscripts, uint32_t *write_to,642 const int *subscripts, uint32_t *write_to,
634 uint32_t range_min, uint32_t range_max)643 uint32_t range_min, uint32_t range_max)
@@ -637,14 +646,16 @@ int ff_cbs_read_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, · 2 unmodified lines
637 write_to, range_min, range_max);646 write_to, range_min, range_max);
638}647}
639 648
640int ff_cbs_read_simple_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc,649int CBS_FUNC(read_simple_unsigned)(CodedBitstreamContext *ctx, GetBitContext *gbc,
641 int width, const char *name, uint32_t *write_to)650 int width, const char *name, uint32_t *write_to)
642{651{
643 return cbs_read_unsigned(ctx, gbc, width, name, NULL,652 return cbs_read_unsigned(ctx, gbc, width, name, NULL,
644 write_to, 0, UINT32_MAX);653 write_to, 0, UINT32_MAX);
645}654}
655#endif
646 656
647int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc,657#if CBS_WRITE
658int CBS_FUNC(write_unsigned)(CodedBitstreamContext *ctx, PutBitContext *pbc,
648 int width, const char *name,659 int width, const char *name,
649 const int *subscripts, uint32_t value,660 const int *subscripts, uint32_t value,
650 uint32_t range_min, uint32_t range_max)661 uint32_t range_min, uint32_t range_max)
@@ -673,14 +684,16 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, · 22 unmodified lines
673 return 0;684 return 0;
674}685}
675 686
676int ff_cbs_write_simple_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc,687int CBS_FUNC(write_simple_unsigned)(CodedBitstreamContext *ctx, PutBitContext *pbc,
677 int width, const char *name, uint32_t value)688 int width, const char *name, uint32_t value)
678{689{
679 return ff_cbs_write_unsigned(ctx, pbc, width, name, NULL,690 return CBS_FUNC(write_unsigned)(ctx, pbc, width, name, NULL,
680 value, 0, MAX_UINT_BITS(width));691 value, 0, MAX_UINT_BITS(width));
681}692}
693#endif
682 694
683int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc,695#if CBS_READ
696int CBS_FUNC(read_signed)(CodedBitstreamContext *ctx, GetBitContext *gbc,
684 int width, const char *name,697 int width, const char *name,
685 const int *subscripts, int32_t *write_to,698 const int *subscripts, int32_t *write_to,
686 int32_t range_min, int32_t range_max)699 int32_t range_min, int32_t range_max)
@@ -711,8 +724,10 @@ int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc, · 24 unmodified lines
711 *write_to = value;724 *write_to = value;
712 return 0;725 return 0;
713}726}
727#endif
714 728
715int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc,729#if CBS_WRITE
730int CBS_FUNC(write_signed)(CodedBitstreamContext *ctx, PutBitContext *pbc,
716 int width, const char *name,731 int width, const char *name,
717 const int *subscripts, int32_t value,732 const int *subscripts, int32_t value,
718 int32_t range_min, int32_t range_max)733 int32_t range_min, int32_t range_max)
@@ -740,6 +755,7 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, · 21 unmodified lines
740 755
741 return 0;756 return 0;
742}757}
758#endif
743 759
744 760
745static int cbs_insert_unit(CodedBitstreamFragment *frag,761static int cbs_insert_unit(CodedBitstreamFragment *frag,
@@ -780,7 +796,7 @@ static int cbs_insert_unit(CodedBitstreamFragment *frag, · 34 unmodified lines
780 return 0;796 return 0;
781}797}
782 798
783int ff_cbs_insert_unit_content(CodedBitstreamFragment *frag,799int CBS_FUNC(insert_unit_content)(CodedBitstreamFragment *frag,
784 int position,800 int position,
785 CodedBitstreamUnitType type,801 CodedBitstreamUnitType type,
786 void *content,802 void *content,
@@ -847,7 +863,7 @@ static int cbs_insert_unit_data(CodedBitstreamFragment *frag, · 60 unmodified lines
847 return 0;863 return 0;
848}864}
849 865
850int ff_cbs_append_unit_data(CodedBitstreamFragment *frag,866int CBS_FUNC(append_unit_data)(CodedBitstreamFragment *frag,
851 CodedBitstreamUnitType type,867 CodedBitstreamUnitType type,
852 uint8_t *data, size_t data_size,868 uint8_t *data, size_t data_size,
853 AVBufferRef *data_buf)869 AVBufferRef *data_buf)
@@ -857,7 +873,7 @@ int ff_cbs_append_unit_data(CodedBitstreamFragment *frag, · 3 unmodified lines
857 frag->nb_units);873 frag->nb_units);
858}874}
859 875
860void ff_cbs_delete_unit(CodedBitstreamFragment *frag,876void CBS_FUNC(delete_unit)(CodedBitstreamFragment *frag,
861 int position)877 int position)
862{878{
863 av_assert0(0 <= position && position < frag->nb_units879 av_assert0(0 <= position && position < frag->nb_units
@@ -920,7 +936,7 @@ static void *cbs_alloc_content(const CodedBitstreamUnitTypeDescriptor *desc) · 56 unmodified lines
920 : cbs_default_free_unit_content);936 : cbs_default_free_unit_content);
921}937}
922 938
923int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx,939int CBS_FUNC(alloc_unit_content)(CodedBitstreamContext *ctx,
924 CodedBitstreamUnit *unit)940 CodedBitstreamUnit *unit)
925{941{
926 const CodedBitstreamUnitTypeDescriptor *desc;942 const CodedBitstreamUnitTypeDescriptor *desc;
@@ -1032,7 +1048,7 @@ static int cbs_clone_unit_content(CodedBitstreamContext *ctx, · 105 unmodified lines
1032 return 0;1048 return 0;
1033}1049}
1034 1050
1035int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx,1051int CBS_FUNC(make_unit_refcounted)(CodedBitstreamContext *ctx,
1036 CodedBitstreamUnit *unit)1052 CodedBitstreamUnit *unit)
1037{1053{
1038 av_assert0(unit->content);1054 av_assert0(unit->content);
@@ -1041,7 +1057,7 @@ int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx, · 2 unmodified lines
1041 return cbs_clone_unit_content(ctx, unit);1057 return cbs_clone_unit_content(ctx, unit);
1042}1058}
1043 1059
1044int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx,1060int CBS_FUNC(make_unit_writable)(CodedBitstreamContext *ctx,
1045 CodedBitstreamUnit *unit)1061 CodedBitstreamUnit *unit)
1046{1062{
1047 void *ref = unit->content_ref;1063 void *ref = unit->content_ref;
@@ -1058,7 +1074,7 @@ int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx, · 10 unmodified lines
1058 return 0;1074 return 0;
1059}1075}
1060 1076
1061void ff_cbs_discard_units(CodedBitstreamContext *ctx,1077void CBS_FUNC(discard_units)(CodedBitstreamContext *ctx,
1062 CodedBitstreamFragment *frag,1078 CodedBitstreamFragment *frag,
1063 enum AVDiscard skip,1079 enum AVDiscard skip,
1064 int flags)1080 int flags)
@@ -1070,11 +1086,11 @@ void ff_cbs_discard_units(CodedBitstreamContext *ctx, · 5 unmodified lines
1070 if (ctx->codec->discarded_unit(ctx, &frag->units[i], skip)) {1086 if (ctx->codec->discarded_unit(ctx, &frag->units[i], skip)) {
1071 // discard all units1087 // discard all units
1072 if (!(flags & DISCARD_FLAG_KEEP_NON_VCL)) {1088 if (!(flags & DISCARD_FLAG_KEEP_NON_VCL)) {
1073 ff_cbs_fragment_free(frag);1089 CBS_FUNC(fragment_free)(frag);
1074 return;1090 return;
1075 }1091 }
1076 1092
1077 ff_cbs_delete_unit(frag, i);1093 CBS_FUNC(delete_unit)(frag, i);
1078 }1094 }
1079 }1095 }
1080}1096}
libavcodec/cbs.h+30−23
@@ -29,6 +29,13 @@ · 28 unmodified lines
29#include "defs.h"29#include "defs.h"
30#include "packet.h"30#include "packet.h"
31 31
32#ifndef CBS_PREFIX
33#define CBS_PREFIX cbs
34#endif
35
36#define CBS_FUNC_PREFIX_NAME(prefix, name) ff_ ## prefix ## _ ## name
37#define CBS_FUNC_NAME(prefix, name) CBS_FUNC_PREFIX_NAME(prefix, name)
38#define CBS_FUNC(name) CBS_FUNC_NAME(CBS_PREFIX, name)
32 39
33/*40/*
34 * This defines a framework for converting between a coded bitstream41 * This defines a framework for converting between a coded bitstream
@@ -294,24 +301,24 @@ typedef struct CodedBitstreamContext { · 259 unmodified lines
294 *301 *
295 * Terminated by AV_CODEC_ID_NONE.302 * Terminated by AV_CODEC_ID_NONE.
296 */303 */
297extern const enum AVCodecID ff_cbs_all_codec_ids[];304extern const enum AVCodecID CBS_FUNC(all_codec_ids)[];
298 305
299 306
300/**307/**
301 * Create and initialise a new context for the given codec.308 * Create and initialise a new context for the given codec.
302 */309 */
303int ff_cbs_init(CodedBitstreamContext **ctx,310int CBS_FUNC(init)(CodedBitstreamContext **ctx,
304 enum AVCodecID codec_id, void *log_ctx);311 enum AVCodecID codec_id, void *log_ctx);
305 312
306/**313/**
307 * Reset all internal state in a context.314 * Reset all internal state in a context.
308 */315 */
309void ff_cbs_flush(CodedBitstreamContext *ctx);316void CBS_FUNC(flush)(CodedBitstreamContext *ctx);
310 317
311/**318/**
312 * Close a context and free all internal state.319 * Close a context and free all internal state.
313 */320 */
314void ff_cbs_close(CodedBitstreamContext **ctx);321void CBS_FUNC(close)(CodedBitstreamContext **ctx);
315 322
316 323
317/**324/**
@@ -325,7 +332,7 @@ void ff_cbs_close(CodedBitstreamContext **ctx); · 7 unmodified lines
325 * The fragment must have been zeroed or reset via ff_cbs_fragment_reset332 * The fragment must have been zeroed or reset via ff_cbs_fragment_reset
326 * before use.333 * before use.
327 */334 */
328int ff_cbs_read_extradata(CodedBitstreamContext *ctx,335int CBS_FUNC(read_extradata)(CodedBitstreamContext *ctx,
329 CodedBitstreamFragment *frag,336 CodedBitstreamFragment *frag,
330 const AVCodecParameters *par);337 const AVCodecParameters *par);
331 338
@@ -336,11 +343,11 @@ int ff_cbs_read_extradata(CodedBitstreamContext *ctx, · 4 unmodified lines
336 * This acts identical to ff_cbs_read_extradata() for the case where343 * This acts identical to ff_cbs_read_extradata() for the case where
337 * you already have a codec context.344 * you already have a codec context.
338 */345 */
339int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx,346int CBS_FUNC(read_extradata_from_codec)(CodedBitstreamContext *ctx,
340 CodedBitstreamFragment *frag,347 CodedBitstreamFragment *frag,
341 const struct AVCodecContext *avctx);348 const struct AVCodecContext *avctx);
342 349
343int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx,350int CBS_FUNC(read_packet_side_data)(CodedBitstreamContext *ctx,
344 CodedBitstreamFragment *frag,351 CodedBitstreamFragment *frag,
345 const AVPacket *pkt);352 const AVPacket *pkt);
346 353
@@ -355,7 +362,7 @@ int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx, · 8 unmodified lines
355 * The fragment must have been zeroed or reset via ff_cbs_fragment_reset362 * The fragment must have been zeroed or reset via ff_cbs_fragment_reset
356 * before use.363 * before use.
357 */364 */
358int ff_cbs_read_packet(CodedBitstreamContext *ctx,365int CBS_FUNC(read_packet)(CodedBitstreamContext *ctx,
359 CodedBitstreamFragment *frag,366 CodedBitstreamFragment *frag,
360 const AVPacket *pkt);367 const AVPacket *pkt);
361 368
@@ -370,7 +377,7 @@ int ff_cbs_read_packet(CodedBitstreamContext *ctx, · 8 unmodified lines
370 * The fragment must have been zeroed or reset via ff_cbs_fragment_reset377 * The fragment must have been zeroed or reset via ff_cbs_fragment_reset
371 * before use.378 * before use.
372 */379 */
373int ff_cbs_read(CodedBitstreamContext *ctx,380int CBS_FUNC(read)(CodedBitstreamContext *ctx,
374 CodedBitstreamFragment *frag,381 CodedBitstreamFragment *frag,
375 const uint8_t *data, size_t size);382 const uint8_t *data, size_t size);
376 383
@@ -387,7 +394,7 @@ int ff_cbs_read(CodedBitstreamContext *ctx, · 10 unmodified lines
387 * with any persistent data from the fragment which may be required to394 * with any persistent data from the fragment which may be required to
388 * write following fragments (e.g. parameter sets).395 * write following fragments (e.g. parameter sets).
389 */396 */
390int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx,397int CBS_FUNC(write_fragment_data)(CodedBitstreamContext *ctx,
391 CodedBitstreamFragment *frag);398 CodedBitstreamFragment *frag);
392 399
393/**400/**
@@ -396,7 +403,7 @@ int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx, · 2 unmodified lines
396 * Modifies context and fragment as ff_cbs_write_fragment_data does and403 * Modifies context and fragment as ff_cbs_write_fragment_data does and
397 * replaces any existing extradata in the structure.404 * replaces any existing extradata in the structure.
398 */405 */
399int ff_cbs_write_extradata(CodedBitstreamContext *ctx,406int CBS_FUNC(write_extradata)(CodedBitstreamContext *ctx,
400 AVCodecParameters *par,407 AVCodecParameters *par,
401 CodedBitstreamFragment *frag);408 CodedBitstreamFragment *frag);
402 409
@@ -410,7 +417,7 @@ int ff_cbs_write_extradata(CodedBitstreamContext *ctx, · 7 unmodified lines
410 * fragment; other fields are not touched. On failure, the packet is not417 * fragment; other fields are not touched. On failure, the packet is not
411 * touched at all.418 * touched at all.
412 */419 */
413int ff_cbs_write_packet(CodedBitstreamContext *ctx,420int CBS_FUNC(write_packet)(CodedBitstreamContext *ctx,
414 AVPacket *pkt,421 AVPacket *pkt,
415 CodedBitstreamFragment *frag);422 CodedBitstreamFragment *frag);
416 423
@@ -419,20 +426,20 @@ int ff_cbs_write_packet(CodedBitstreamContext *ctx, · 2 unmodified lines
419 * Free the units contained in a fragment as well as the fragment's426 * Free the units contained in a fragment as well as the fragment's
420 * own data buffer, but not the units array itself.427 * own data buffer, but not the units array itself.
421 */428 */
422void ff_cbs_fragment_reset(CodedBitstreamFragment *frag);429void CBS_FUNC(fragment_reset)(CodedBitstreamFragment *frag);
423 430
424/**431/**
425 * Free the units array of a fragment in addition to what432 * Free the units array of a fragment in addition to what
426 * ff_cbs_fragment_reset does.433 * ff_cbs_fragment_reset does.
427 */434 */
428void ff_cbs_fragment_free(CodedBitstreamFragment *frag);435void CBS_FUNC(fragment_free)(CodedBitstreamFragment *frag);
429 436
430/**437/**
431 * Allocate a new internal content buffer matching the type of the unit.438 * Allocate a new internal content buffer matching the type of the unit.
432 *439 *
433 * The content will be zeroed.440 * The content will be zeroed.
434 */441 */
435int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx,442int CBS_FUNC(alloc_unit_content)(CodedBitstreamContext *ctx,
436 CodedBitstreamUnit *unit);443 CodedBitstreamUnit *unit);
437 444
438/**445/**
@@ -443,7 +450,7 @@ int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx, · 4 unmodified lines
443 * The content structure continues to be owned by the caller if450 * The content structure continues to be owned by the caller if
444 * content_ref is not supplied.451 * content_ref is not supplied.
445 */452 */
446int ff_cbs_insert_unit_content(CodedBitstreamFragment *frag,453int CBS_FUNC(insert_unit_content)(CodedBitstreamFragment *frag,
447 int position,454 int position,
448 CodedBitstreamUnitType type,455 CodedBitstreamUnitType type,
449 void *content,456 void *content,
@@ -456,7 +463,7 @@ int ff_cbs_insert_unit_content(CodedBitstreamFragment *frag, · 6 unmodified lines
456 * av_malloc() and will on success become owned by the unit after this463 * av_malloc() and will on success become owned by the unit after this
457 * call or freed on error.464 * call or freed on error.
458 */465 */
459int ff_cbs_append_unit_data(CodedBitstreamFragment *frag,466int CBS_FUNC(append_unit_data)(CodedBitstreamFragment *frag,
460 CodedBitstreamUnitType type,467 CodedBitstreamUnitType type,
461 uint8_t *data, size_t data_size,468 uint8_t *data, size_t data_size,
462 AVBufferRef *data_buf);469 AVBufferRef *data_buf);
@@ -466,7 +473,7 @@ int ff_cbs_append_unit_data(CodedBitstreamFragment *frag, · 3 unmodified lines
466 *473 *
467 * Requires position to be >= 0 and < frag->nb_units.474 * Requires position to be >= 0 and < frag->nb_units.
468 */475 */
469void ff_cbs_delete_unit(CodedBitstreamFragment *frag,476void CBS_FUNC(delete_unit)(CodedBitstreamFragment *frag,
470 int position);477 int position);
471 478
472 479
@@ -479,7 +486,7 @@ void ff_cbs_delete_unit(CodedBitstreamFragment *frag, · 6 unmodified lines
479 * It is not valid to call this function on a unit which does not have486 * It is not valid to call this function on a unit which does not have
480 * decomposed content.487 * decomposed content.
481 */488 */
482int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx,489int CBS_FUNC(make_unit_refcounted)(CodedBitstreamContext *ctx,
483 CodedBitstreamUnit *unit);490 CodedBitstreamUnit *unit);
484 491
485/**492/**
@@ -495,7 +502,7 @@ int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx, · 9 unmodified lines
495 * It is not valid to call this function on a unit which does not have502 * It is not valid to call this function on a unit which does not have
496 * decomposed content.503 * decomposed content.
497 */504 */
498int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx,505int CBS_FUNC(make_unit_writable)(CodedBitstreamContext *ctx,
499 CodedBitstreamUnit *unit);506 CodedBitstreamUnit *unit);
500 507
501enum CbsDiscardFlags {508enum CbsDiscardFlags {
@@ -510,7 +517,7 @@ enum CbsDiscardFlags { · 8 unmodified lines
510/**517/**
511 * Discard units accroding to 'skip'.518 * Discard units accroding to 'skip'.
512 */519 */
513void ff_cbs_discard_units(CodedBitstreamContext *ctx,520void CBS_FUNC(discard_units)(CodedBitstreamContext *ctx,
514 CodedBitstreamFragment *frag,521 CodedBitstreamFragment *frag,
515 enum AVDiscard skip,522 enum AVDiscard skip,
516 int flags);523 int flags);
@@ -522,7 +529,7 @@ void ff_cbs_discard_units(CodedBitstreamContext *ctx, · 5 unmodified lines
522 *529 *
523 * Trace context should be set to the CodedBitstreamContext.530 * Trace context should be set to the CodedBitstreamContext.
524 */531 */
525void ff_cbs_trace_read_log(void *trace_context,532void CBS_FUNC(trace_read_log)(void *trace_context,
526 struct GetBitContext *gbc, int length,533 struct GetBitContext *gbc, int length,
527 const char *str, const int *subscripts,534 const char *str, const int *subscripts,
528 int64_t value);535 int64_t value);
@@ -533,7 +540,7 @@ void ff_cbs_trace_read_log(void *trace_context, · 4 unmodified lines
533 *540 *
534 * Trace context should be set to the CodedBitstreamContext.541 * Trace context should be set to the CodedBitstreamContext.
535 */542 */
536void ff_cbs_trace_write_log(void *trace_context,543void CBS_FUNC(trace_write_log)(void *trace_context,
537 struct PutBitContext *pbc, int length,544 struct PutBitContext *pbc, int length,
538 const char *str, const int *subscripts,545 const char *str, const int *subscripts,
539 int64_t value);546 int64_t value);
libavcodec/cbs_av1.c+76−15
@@ -27,6 +27,7 @@ · 26 unmodified lines
27#include "libavutil/refstruct.h"27#include "libavutil/refstruct.h"
28 28
29 29
30#if CBS_READ
30static int cbs_av1_read_uvlc(CodedBitstreamContext *ctx, GetBitContext *gbc,31static int cbs_av1_read_uvlc(CodedBitstreamContext *ctx, GetBitContext *gbc,
31 const char *name, uint32_t *write_to,32 const char *name, uint32_t *write_to,
32 uint32_t range_min, uint32_t range_max)33 uint32_t range_min, uint32_t range_max)
@@ -84,7 +85,9 @@ static int cbs_av1_read_uvlc(CodedBitstreamContext *ctx, GetBitContext *gbc, · 51 unmodified lines
84 *write_to = value;85 *write_to = value;
85 return 0;86 return 0;
86}87}
88#endif
87 89
90#if CBS_WRITE
88static int cbs_av1_write_uvlc(CodedBitstreamContext *ctx, PutBitContext *pbc,91static int cbs_av1_write_uvlc(CodedBitstreamContext *ctx, PutBitContext *pbc,
89 const char *name, uint32_t value,92 const char *name, uint32_t value,
90 uint32_t range_min, uint32_t range_max)93 uint32_t range_min, uint32_t range_max)
@@ -115,7 +118,9 @@ static int cbs_av1_write_uvlc(CodedBitstreamContext *ctx, PutBitContext *pbc, · 24 unmodified lines
115 118
116 return 0;119 return 0;
117}120}
121#endif
118 122
123#if CBS_READ
119static int cbs_av1_read_leb128(CodedBitstreamContext *ctx, GetBitContext *gbc,124static int cbs_av1_read_leb128(CodedBitstreamContext *ctx, GetBitContext *gbc,
120 const char *name, uint64_t *write_to)125 const char *name, uint64_t *write_to)
121{126{
@@ -146,7 +151,9 @@ static int cbs_av1_read_leb128(CodedBitstreamContext *ctx, GetBitContext *gbc, · 24 unmodified lines
146 *write_to = value;151 *write_to = value;
147 return 0;152 return 0;
148}153}
154#endif
149 155
156#if CBS_WRITE
150static int cbs_av1_write_leb128(CodedBitstreamContext *ctx, PutBitContext *pbc,157static int cbs_av1_write_leb128(CodedBitstreamContext *ctx, PutBitContext *pbc,
151 const char *name, uint64_t value, int fixed_length)158 const char *name, uint64_t value, int fixed_length)
152{159{
@@ -182,7 +189,9 @@ static int cbs_av1_write_leb128(CodedBitstreamContext *ctx, PutBitContext *pbc, · 29 unmodified lines
182 189
183 return 0;190 return 0;
184}191}
192#endif
185 193
194#if CBS_READ
186static int cbs_av1_read_ns(CodedBitstreamContext *ctx, GetBitContext *gbc,195static int cbs_av1_read_ns(CodedBitstreamContext *ctx, GetBitContext *gbc,
187 uint32_t n, const char *name,196 uint32_t n, const char *name,
188 const int *subscripts, uint32_t *write_to)197 const int *subscripts, uint32_t *write_to)
@@ -220,7 +229,9 @@ static int cbs_av1_read_ns(CodedBitstreamContext *ctx, GetBitContext *gbc, · 31 unmodified lines
220 *write_to = value;229 *write_to = value;
221 return 0;230 return 0;
222}231}
232#endif
223 233
234#if CBS_WRITE
224static int cbs_av1_write_ns(CodedBitstreamContext *ctx, PutBitContext *pbc,235static int cbs_av1_write_ns(CodedBitstreamContext *ctx, PutBitContext *pbc,
225 uint32_t n, const char *name,236 uint32_t n, const char *name,
226 const int *subscripts, uint32_t value)237 const int *subscripts, uint32_t value)
@@ -256,7 +267,9 @@ static int cbs_av1_write_ns(CodedBitstreamContext *ctx, PutBitContext *pbc, · 29 unmodified lines
256 267
257 return 0;268 return 0;
258}269}
270#endif
259 271
272#if CBS_READ
260static int cbs_av1_read_increment(CodedBitstreamContext *ctx, GetBitContext *gbc,273static int cbs_av1_read_increment(CodedBitstreamContext *ctx, GetBitContext *gbc,
261 uint32_t range_min, uint32_t range_max,274 uint32_t range_min, uint32_t range_max,
262 const char *name, uint32_t *write_to)275 const char *name, uint32_t *write_to)
@@ -284,7 +297,9 @@ static int cbs_av1_read_increment(CodedBitstreamContext *ctx, GetBitContext *gbc · 21 unmodified lines
284 *write_to = value;297 *write_to = value;
285 return 0;298 return 0;
286}299}
300#endif
287 301
302#if CBS_WRITE
288static int cbs_av1_write_increment(CodedBitstreamContext *ctx, PutBitContext *pbc,303static int cbs_av1_write_increment(CodedBitstreamContext *ctx, PutBitContext *pbc,
289 uint32_t range_min, uint32_t range_max,304 uint32_t range_min, uint32_t range_max,
290 const char *name, uint32_t value)305 const char *name, uint32_t value)
@@ -315,7 +330,9 @@ static int cbs_av1_write_increment(CodedBitstreamContext *ctx, PutBitContext *pb · 24 unmodified lines
315 330
316 return 0;331 return 0;
317}332}
333#endif
318 334
335#if CBS_READ
319static int cbs_av1_read_subexp(CodedBitstreamContext *ctx, GetBitContext *gbc,336static int cbs_av1_read_subexp(CodedBitstreamContext *ctx, GetBitContext *gbc,
320 uint32_t range_max, const char *name,337 uint32_t range_max, const char *name,
321 const int *subscripts, uint32_t *write_to)338 const int *subscripts, uint32_t *write_to)
@@ -342,7 +359,7 @@ static int cbs_av1_read_subexp(CodedBitstreamContext *ctx, GetBitContext *gbc, · 20 unmodified lines
342 }359 }
343 360
344 if (len < max_len) {361 if (len < max_len) {
345 err = ff_cbs_read_simple_unsigned(ctx, gbc, range_bits,362 err = CBS_FUNC(read_simple_unsigned)(ctx, gbc, range_bits,
346 "subexp_bits", &value);363 "subexp_bits", &value);
347 if (err < 0)364 if (err < 0)
348 return err;365 return err;
@@ -360,7 +377,9 @@ static int cbs_av1_read_subexp(CodedBitstreamContext *ctx, GetBitContext *gbc, · 11 unmodified lines
360 *write_to = value;377 *write_to = value;
361 return err;378 return err;
362}379}
380#endif
363 381
382#if CBS_WRITE
364static int cbs_av1_write_subexp(CodedBitstreamContext *ctx, PutBitContext *pbc,383static int cbs_av1_write_subexp(CodedBitstreamContext *ctx, PutBitContext *pbc,
365 uint32_t range_max, const char *name,384 uint32_t range_max, const char *name,
366 const int *subscripts, uint32_t value)385 const int *subscripts, uint32_t value)
@@ -402,7 +421,7 @@ static int cbs_av1_write_subexp(CodedBitstreamContext *ctx, PutBitContext *pbc, · 35 unmodified lines
402 return err;421 return err;
403 422
404 if (len < max_len) {423 if (len < max_len) {
405 err = ff_cbs_write_simple_unsigned(ctx, pbc, range_bits,424 err = CBS_FUNC(write_simple_unsigned)(ctx, pbc, range_bits,
406 "subexp_bits",425 "subexp_bits",
407 value - range_offset);426 value - range_offset);
408 if (err < 0)427 if (err < 0)
@@ -420,6 +439,7 @@ static int cbs_av1_write_subexp(CodedBitstreamContext *ctx, PutBitContext *pbc, · 11 unmodified lines
420 439
421 return err;440 return err;
422}441}
442#endif
423 443
424 444
425static int cbs_av1_tile_log2(int blksize, int target)445static int cbs_av1_tile_log2(int blksize, int target)
@@ -441,7 +461,7 @@ static int cbs_av1_get_relative_dist(const AV1RawSequenceHeader *seq, · 15 unmodified lines
441 return diff;461 return diff;
442}462}
443 463
444static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc)464static av_unused size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc)
445{465{
446 GetBitContext tmp = *gbc;466 GetBitContext tmp = *gbc;
447 size_t size = 0;467 size_t size = 0;
@@ -454,7 +474,7 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) · 6 unmodified lines
454 474
455 475
456#define HEADER(name) do { \476#define HEADER(name) do { \
457 ff_cbs_trace_header(ctx, name); \477 CBS_FUNC(trace_header)(ctx, name); \
458 } while (0)478 } while (0)
459 479
460#define CHECK(call) do { \480#define CHECK(call) do { \
@@ -469,6 +489,7 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) · 8 unmodified lines
469 489
470#define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)490#define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
471 491
492#if CBS_READ
472#define fc(width, name, range_min, range_max) \493#define fc(width, name, range_min, range_max) \
473 xf(width, name, current->name, range_min, range_max, 0, )494 xf(width, name, current->name, range_min, range_max, 0, )
474#define flag(name) fb(1, name)495#define flag(name) fb(1, name)
@@ -496,14 +517,14 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) · 21 unmodified lines
496 517
497#define fb(width, name) do { \518#define fb(width, name) do { \
498 uint32_t value; \519 uint32_t value; \
499 CHECK(ff_cbs_read_simple_unsigned(ctx, rw, width, \520 CHECK(CBS_FUNC(read_simple_unsigned)(ctx, rw, width, \
500 #name, &value)); \521 #name, &value)); \
501 current->name = value; \522 current->name = value; \
502 } while (0)523 } while (0)
503 524
504#define xf(width, name, var, range_min, range_max, subs, ...) do { \525#define xf(width, name, var, range_min, range_max, subs, ...) do { \
505 uint32_t value; \526 uint32_t value; \
506 CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \527 CHECK(CBS_FUNC(read_unsigned)(ctx, rw, width, #name, \
507 SUBSCRIPTS(subs, __VA_ARGS__), \528 SUBSCRIPTS(subs, __VA_ARGS__), \
508 &value, range_min, range_max)); \529 &value, range_min, range_max)); \
509 var = value; \530 var = value; \
@@ -511,7 +532,7 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) · 1 unmodified line
511 532
512#define xsu(width, name, var, subs, ...) do { \533#define xsu(width, name, var, subs, ...) do { \
513 int32_t value; \534 int32_t value; \
514 CHECK(ff_cbs_read_signed(ctx, rw, width, #name, \535 CHECK(CBS_FUNC(read_signed)(ctx, rw, width, #name, \
515 SUBSCRIPTS(subs, __VA_ARGS__), &value, \536 SUBSCRIPTS(subs, __VA_ARGS__), &value, \
516 MIN_INT_BITS(width), \537 MIN_INT_BITS(width), \
517 MAX_INT_BITS(width))); \538 MAX_INT_BITS(width))); \
@@ -584,25 +605,27 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) · 66 unmodified lines
584#undef leb128605#undef leb128
585#undef infer606#undef infer
586#undef byte_alignment607#undef byte_alignment
608#endif // CBS_READ
587 609
588 610
611#if CBS_WRITE
589#define WRITE612#define WRITE
590#define READWRITE write613#define READWRITE write
591#define RWContext PutBitContext614#define RWContext PutBitContext
592 615
593#define fb(width, name) do { \616#define fb(width, name) do { \
594 CHECK(ff_cbs_write_simple_unsigned(ctx, rw, width, #name, \617 CHECK(CBS_FUNC(write_simple_unsigned)(ctx, rw, width, #name, \
595 current->name)); \618 current->name)); \
596 } while (0)619 } while (0)
597 620
598#define xf(width, name, var, range_min, range_max, subs, ...) do { \621#define xf(width, name, var, range_min, range_max, subs, ...) do { \
599 CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \622 CHECK(CBS_FUNC(write_unsigned)(ctx, rw, width, #name, \
600 SUBSCRIPTS(subs, __VA_ARGS__), \623 SUBSCRIPTS(subs, __VA_ARGS__), \
601 var, range_min, range_max)); \624 var, range_min, range_max)); \
602 } while (0)625 } while (0)
603 626
604#define xsu(width, name, var, subs, ...) do { \627#define xsu(width, name, var, subs, ...) do { \
605 CHECK(ff_cbs_write_signed(ctx, rw, width, #name, \628 CHECK(CBS_FUNC(write_signed)(ctx, rw, width, #name, \
606 SUBSCRIPTS(subs, __VA_ARGS__), var, \629 SUBSCRIPTS(subs, __VA_ARGS__), var, \
607 MIN_INT_BITS(width), \630 MIN_INT_BITS(width), \
608 MAX_INT_BITS(width))); \631 MAX_INT_BITS(width))); \
@@ -668,12 +691,13 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) · 59 unmodified lines
668#undef leb128691#undef leb128
669#undef infer692#undef infer
670#undef byte_alignment693#undef byte_alignment
671 694#endif // CBS_WRITE
672 695
673static int cbs_av1_split_fragment(CodedBitstreamContext *ctx,696static int cbs_av1_split_fragment(CodedBitstreamContext *ctx,
674 CodedBitstreamFragment *frag,697 CodedBitstreamFragment *frag,
675 int header)698 int header)
676{699{
700#if CBS_READ
677 GetBitContext gbc;701 GetBitContext gbc;
678 uint8_t *data;702 uint8_t *data;
679 size_t size;703 size_t size;
@@ -763,7 +787,7 @@ static int cbs_av1_split_fragment(CodedBitstreamContext *ctx, · 83 unmodified lines
763 goto fail;787 goto fail;
764 }788 }
765 789
766 err = ff_cbs_append_unit_data(frag, obu_header.obu_type,790 err = CBS_FUNC(append_unit_data)(frag, obu_header.obu_type,
767 data, obu_length, frag->data_ref);791 data, obu_length, frag->data_ref);
768 if (err < 0)792 if (err < 0)
769 goto fail;793 goto fail;
@@ -777,8 +801,12 @@ success: · 7 unmodified lines
777fail:801fail:
778 ctx->trace_enable = trace;802 ctx->trace_enable = trace;
779 return err;803 return err;
804#else
805 return AVERROR(ENOSYS);
806#endif
780}807}
781 808
809#if CBS_READ
782static int cbs_av1_ref_tile_data(CodedBitstreamContext *ctx,810static int cbs_av1_ref_tile_data(CodedBitstreamContext *ctx,
783 CodedBitstreamUnit *unit,811 CodedBitstreamUnit *unit,
784 GetBitContext *gbc,812 GetBitContext *gbc,
@@ -805,16 +833,18 @@ static int cbs_av1_ref_tile_data(CodedBitstreamContext *ctx, · 20 unmodified lines
805 833
806 return 0;834 return 0;
807}835}
836#endif
808 837
809static int cbs_av1_read_unit(CodedBitstreamContext *ctx,838static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
810 CodedBitstreamUnit *unit)839 CodedBitstreamUnit *unit)
811{840{
841#if CBS_READ
812 CodedBitstreamAV1Context *priv = ctx->priv_data;842 CodedBitstreamAV1Context *priv = ctx->priv_data;
813 AV1RawOBU *obu;843 AV1RawOBU *obu;
814 GetBitContext gbc;844 GetBitContext gbc;
815 int err, start_pos, end_pos;845 int err, start_pos, end_pos;
816 846
817 err = ff_cbs_alloc_unit_content(ctx, unit);847 err = CBS_FUNC(alloc_unit_content)(ctx, unit);
818 if (err < 0)848 if (err < 0)
819 return err;849 return err;
820 obu = unit->content;850 obu = unit->content;
@@ -931,6 +961,7 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, · 110 unmodified lines
931 return err;961 return err;
932 }962 }
933 break;963 break;
964#if CBS_AV1_OBU_TILE_LIST
934 case AV1_OBU_TILE_LIST:965 case AV1_OBU_TILE_LIST:
935 {966 {
936 err = cbs_av1_read_tile_list_obu(ctx, &gbc,967 err = cbs_av1_read_tile_list_obu(ctx, &gbc,
@@ -946,6 +977,8 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, · 9 unmodified lines
946 return err;977 return err;
947 }978 }
948 break;979 break;
980#endif
981#if CBS_AV1_OBU_METADATA
949 case AV1_OBU_METADATA:982 case AV1_OBU_METADATA:
950 {983 {
951 err = cbs_av1_read_metadata_obu(ctx, &gbc, &obu->obu.metadata);984 err = cbs_av1_read_metadata_obu(ctx, &gbc, &obu->obu.metadata);
@@ -953,6 +986,8 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, · 1 unmodified line
953 return err;986 return err;
954 }987 }
955 break;988 break;
989#endif
990#if CBS_AV1_OBU_PADDING
956 case AV1_OBU_PADDING:991 case AV1_OBU_PADDING:
957 {992 {
958 err = cbs_av1_read_padding_obu(ctx, &gbc, &obu->obu.padding);993 err = cbs_av1_read_padding_obu(ctx, &gbc, &obu->obu.padding);
@@ -960,6 +995,7 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, · 1 unmodified line
960 return err;995 return err;
961 }996 }
962 break;997 break;
998#endif
963 default:999 default:
964 return AVERROR(ENOSYS);1000 return AVERROR(ENOSYS);
965 }1001 }
@@ -982,12 +1018,16 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, · 16 unmodified lines
982 }1018 }
983 1019
984 return 0;1020 return 0;
1021#else
1022 return AVERROR(ENOSYS);
1023#endif
985}1024}
986 1025
987static int cbs_av1_write_obu(CodedBitstreamContext *ctx,1026static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
988 CodedBitstreamUnit *unit,1027 CodedBitstreamUnit *unit,
989 PutBitContext *pbc)1028 PutBitContext *pbc)
990{1029{
1030#if CBS_WRITE
991 CodedBitstreamAV1Context *priv = ctx->priv_data;1031 CodedBitstreamAV1Context *priv = ctx->priv_data;
992 AV1RawOBU *obu = unit->content;1032 AV1RawOBU *obu = unit->content;
993 PutBitContext pbc_tmp;1033 PutBitContext pbc_tmp;
@@ -1044,7 +1084,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, · 50 unmodified lines
1044 av_refstruct_unref(&priv->sequence_header_ref);1084 av_refstruct_unref(&priv->sequence_header_ref);
1045 priv->sequence_header = NULL;1085 priv->sequence_header = NULL;
1046 1086
1047 err = ff_cbs_make_unit_refcounted(ctx, unit);1087 err = CBS_FUNC(make_unit_refcounted)(ctx, unit);
1048 if (err < 0)1088 if (err < 0)
1049 goto error;1089 goto error;
1050 1090
@@ -1087,6 +1127,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, · 36 unmodified lines
1087 td = &tile_group->tile_data;1127 td = &tile_group->tile_data;
1088 }1128 }
1089 break;1129 break;
1130#if CBS_AV1_OBU_TILE_LIST
1090 case AV1_OBU_TILE_LIST:1131 case AV1_OBU_TILE_LIST:
1091 {1132 {
1092 err = cbs_av1_write_tile_list_obu(ctx, pbc, &obu->obu.tile_list);1133 err = cbs_av1_write_tile_list_obu(ctx, pbc, &obu->obu.tile_list);
@@ -1096,6 +1137,8 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, · 3 unmodified lines
1096 td = &obu->obu.tile_list.tile_data;1137 td = &obu->obu.tile_list.tile_data;
1097 }1138 }
1098 break;1139 break;
1140#endif
1141#if CBS_AV1_OBU_METADATA
1099 case AV1_OBU_METADATA:1142 case AV1_OBU_METADATA:
1100 {1143 {
1101 err = cbs_av1_write_metadata_obu(ctx, pbc, &obu->obu.metadata);1144 err = cbs_av1_write_metadata_obu(ctx, pbc, &obu->obu.metadata);
@@ -1103,6 +1146,8 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, · 1 unmodified line
1103 goto error;1146 goto error;
1104 }1147 }
1105 break;1148 break;
1149#endif
1150#if CBS_AV1_OBU_PADDING
1106 case AV1_OBU_PADDING:1151 case AV1_OBU_PADDING:
1107 {1152 {
1108 err = cbs_av1_write_padding_obu(ctx, pbc, &obu->obu.padding);1153 err = cbs_av1_write_padding_obu(ctx, pbc, &obu->obu.padding);
@@ -1110,6 +1155,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, · 1 unmodified line
1110 goto error;1155 goto error;
1111 }1156 }
1112 break;1157 break;
1158#endif
1113 default:1159 default:
1114 err = AVERROR(ENOSYS);1160 err = AVERROR(ENOSYS);
1115 goto error;1161 goto error;
@@ -1182,11 +1228,15 @@ error: · 66 unmodified lines
1182 av_buffer_unref(&av1ctx.frame_header_ref);1228 av_buffer_unref(&av1ctx.frame_header_ref);
1183 1229
1184 return err;1230 return err;
1231#else
1232 return AVERROR(ENOSYS);
1233#endif
1185}1234}
1186 1235
1187static int cbs_av1_assemble_fragment(CodedBitstreamContext *ctx,1236static int cbs_av1_assemble_fragment(CodedBitstreamContext *ctx,
1188 CodedBitstreamFragment *frag)1237 CodedBitstreamFragment *frag)
1189{1238{
1239#if CBS_WRITE
1190 size_t size, pos;1240 size_t size, pos;
1191 int i;1241 int i;
1192 1242
@@ -1210,6 +1260,9 @@ static int cbs_av1_assemble_fragment(CodedBitstreamContext *ctx, · 17 unmodified lines
1210 frag->data_size = size;1260 frag->data_size = size;
1211 1261
1212 return 0;1262 return 0;
1263#else
1264 return AVERROR(ENOSYS);
1265#endif
1213}1266}
1214 1267
1215static void cbs_av1_flush(CodedBitstreamContext *ctx)1268static void cbs_av1_flush(CodedBitstreamContext *ctx)
@@ -1234,6 +1287,7 @@ static void cbs_av1_close(CodedBitstreamContext *ctx) · 18 unmodified lines
1234 av_buffer_unref(&priv->frame_header_ref);1287 av_buffer_unref(&priv->frame_header_ref);
1235}1288}
1236 1289
1290#if CBS_AV1_OBU_METADATA
1237static void cbs_av1_free_metadata(AVRefStructOpaque unused, void *content)1291static void cbs_av1_free_metadata(AVRefStructOpaque unused, void *content)
1238{1292{
1239 AV1RawOBU *obu = content;1293 AV1RawOBU *obu = content;
@@ -1255,6 +1309,7 @@ static void cbs_av1_free_metadata(AVRefStructOpaque unused, void *content) · 15 unmodified lines
1255 av_buffer_unref(&md->metadata.unknown.payload_ref);1309 av_buffer_unref(&md->metadata.unknown.payload_ref);
1256 }1310 }
1257}1311}
1312#endif
1258 1313
1259static const CodedBitstreamUnitTypeDescriptor cbs_av1_unit_types[] = {1314static const CodedBitstreamUnitTypeDescriptor cbs_av1_unit_types[] = {
1260 CBS_UNIT_TYPE_POD(AV1_OBU_SEQUENCE_HEADER, AV1RawOBU),1315 CBS_UNIT_TYPE_POD(AV1_OBU_SEQUENCE_HEADER, AV1RawOBU),
@@ -1284,13 +1339,19 @@ static const CodedBitstreamUnitTypeDescriptor cbs_av1_unit_types[] = { · 23 unmodified lines
1284 offsetof(AV1RawOBU, obu.frame.tile_group.tile_data.data) }1339 offsetof(AV1RawOBU, obu.frame.tile_group.tile_data.data) }
1285 },1340 },
1286 },1341 },
1342#if CBS_AV1_OBU_TILE_LIST
1287 CBS_UNIT_TYPE_INTERNAL_REF(AV1_OBU_TILE_LIST, AV1RawOBU,1343 CBS_UNIT_TYPE_INTERNAL_REF(AV1_OBU_TILE_LIST, AV1RawOBU,
1288 obu.tile_list.tile_data.data),1344 obu.tile_list.tile_data.data),
1345#endif
1346#if CBS_AV1_OBU_PADDING
1289 CBS_UNIT_TYPE_INTERNAL_REF(AV1_OBU_PADDING, AV1RawOBU,1347 CBS_UNIT_TYPE_INTERNAL_REF(AV1_OBU_PADDING, AV1RawOBU,
1290 obu.padding.payload),1348 obu.padding.payload),
1349#endif
1291 1350
1351#if CBS_AV1_OBU_METADATA
1292 CBS_UNIT_TYPE_COMPLEX(AV1_OBU_METADATA, AV1RawOBU,1352 CBS_UNIT_TYPE_COMPLEX(AV1_OBU_METADATA, AV1RawOBU,
1293 &cbs_av1_free_metadata),1353 &cbs_av1_free_metadata),
1354#endif
1294 1355
1295 CBS_UNIT_TYPE_END_OF_LIST1356 CBS_UNIT_TYPE_END_OF_LIST
1296};1357};
@@ -1311,7 +1372,7 @@ static const AVClass cbs_av1_class = { · 14 unmodified lines
1311 .version = LIBAVUTIL_VERSION_INT,1372 .version = LIBAVUTIL_VERSION_INT,
1312};1373};
1313 1374
1314const CodedBitstreamType ff_cbs_type_av1 = {1375const CodedBitstreamType CBS_FUNC(type_av1) = {
1315 .codec_id = AV_CODEC_ID_AV1,1376 .codec_id = AV_CODEC_ID_AV1,
1316 1377
1317 .priv_class = &cbs_av1_class,1378 .priv_class = &cbs_av1_class,
libavcodec/cbs_av1.h+15−0
@@ -25,6 +25,15 @@ · 24 unmodified lines
25#include "av1.h"25#include "av1.h"
26#include "cbs.h"26#include "cbs.h"
27 27
28#ifndef CBS_AV1_OBU_METADATA
29#define CBS_AV1_OBU_METADATA 1
30#endif
31#ifndef CBS_AV1_OBU_TILE_LIST
32#define CBS_AV1_OBU_TILE_LIST 1
33#endif
34#ifndef CBS_AV1_OBU_PADDING
35#define CBS_AV1_OBU_PADDING 1
36#endif
28 37
29typedef struct AV1RawOBUHeader {38typedef struct AV1RawOBUHeader {
30 uint8_t obu_forbidden_bit;39 uint8_t obu_forbidden_bit;
@@ -411,9 +420,15 @@ typedef struct AV1RawOBU { · 380 unmodified lines
411 AV1RawFrameHeader frame_header;420 AV1RawFrameHeader frame_header;
412 AV1RawFrame frame;421 AV1RawFrame frame;
413 AV1RawTileGroup tile_group;422 AV1RawTileGroup tile_group;
423#if CBS_AV1_OBU_TILE_LIST
414 AV1RawTileList tile_list;424 AV1RawTileList tile_list;
425#endif
426#if CBS_AV1_OBU_METADATA
415 AV1RawMetadata metadata;427 AV1RawMetadata metadata;
428#endif
429#if CBS_AV1_OBU_PADDING
416 AV1RawPadding padding;430 AV1RawPadding padding;
431#endif
417 } obu;432 } obu;
418} AV1RawOBU;433} AV1RawOBU;
419 434
libavcodec/cbs_av1_syntax_template.c+6−0
@@ -1868,6 +1868,7 @@ static int FUNC(frame_obu)(CodedBitstreamContext *ctx, RWContext *rw, · 1867 unmodified lines
1868 return 0;1868 return 0;
1869}1869}
1870 1870
1871#if CBS_AV1_OBU_TILE_LIST
1871static int FUNC(tile_list_obu)(CodedBitstreamContext *ctx, RWContext *rw,1872static int FUNC(tile_list_obu)(CodedBitstreamContext *ctx, RWContext *rw,
1872 AV1RawTileList *current)1873 AV1RawTileList *current)
1873{1874{
@@ -1882,7 +1883,9 @@ static int FUNC(tile_list_obu)(CodedBitstreamContext *ctx, RWContext *rw, · 8 unmodified lines
1882 1883
1883 return 0;1884 return 0;
1884}1885}
1886#endif
1885 1887
1888#if CBS_AV1_OBU_METADATA
1886static int FUNC(metadata_hdr_cll)(CodedBitstreamContext *ctx, RWContext *rw,1889static int FUNC(metadata_hdr_cll)(CodedBitstreamContext *ctx, RWContext *rw,
1887 AV1RawMetadataHDRCLL *current)1890 AV1RawMetadataHDRCLL *current)
1888{1891{
@@ -2101,7 +2104,9 @@ static int FUNC(metadata_obu)(CodedBitstreamContext *ctx, RWContext *rw, · 212 unmodified lines
2101 2104
2102 return 0;2105 return 0;
2103}2106}
2107#endif
2104 2108
2109#if CBS_AV1_OBU_PADDING
2105static int FUNC(padding_obu)(CodedBitstreamContext *ctx, RWContext *rw,2110static int FUNC(padding_obu)(CodedBitstreamContext *ctx, RWContext *rw,
2106 AV1RawPadding *current)2111 AV1RawPadding *current)
2107{2112{
@@ -2125,3 +2130,4 @@ static int FUNC(padding_obu)(CodedBitstreamContext *ctx, RWContext *rw, · 17 unmodified lines
2125 2130
2126 return 0;2131 return 0;
2127}2132}
2133#endif
libavcodec/cbs_internal.h+63−15
@@ -22,6 +22,8 @@ · 21 unmodified lines
22#include <stddef.h>22#include <stddef.h>
23#include <stdint.h>23#include <stdint.h>
24 24
25#include "config.h"
26
25#include "libavutil/log.h"27#include "libavutil/log.h"
26 28
27#include "cbs.h"29#include "cbs.h"
@@ -30,6 +32,40 @@ · 2 unmodified lines
30#include "put_bits.h"32#include "put_bits.h"
31#include "libavutil/refstruct.h"33#include "libavutil/refstruct.h"
32 34
35#ifndef CBS_READ
36#define CBS_READ 1
37#endif
38#ifndef CBS_WRITE
39#define CBS_WRITE 1
40#endif
41#ifndef CBS_TRACE
42#define CBS_TRACE 1
43#endif
44
45#ifndef CBS_AV1
46#define CBS_AV1 CONFIG_CBS_AV1
47#endif
48#ifndef CBS_H264
49#define CBS_H264 CONFIG_CBS_H264
50#endif
51#ifndef CBS_H265
52#define CBS_H265 CONFIG_CBS_H265
53#endif
54#ifndef CBS_H266
55#define CBS_H266 CONFIG_CBS_H266
56#endif
57#ifndef CBS_JPEG
58#define CBS_JPEG CONFIG_CBS_JPEG
59#endif
60#ifndef CBS_MPEG2
61#define CBS_MPEG2 CONFIG_CBS_MPEG2
62#endif
63#ifndef CBS_VP8
64#define CBS_VP8 CONFIG_CBS_VP8
65#endif
66#ifndef CBS_VP9
67#define CBS_VP9 CONFIG_CBS_VP9
68#endif
33 69
34enum CBSContentType {70enum CBSContentType {
35 // Unit content may contain some references to other structures, but all71 // Unit content may contain some references to other structures, but all
@@ -155,7 +191,7 @@ typedef struct CodedBitstreamType { · 119 unmodified lines
155 191
156// Helper functions for trace output.192// Helper functions for trace output.
157 193
158void ff_cbs_trace_header(CodedBitstreamContext *ctx,194void CBS_FUNC(trace_header)(CodedBitstreamContext *ctx,
159 const char *name);195 const char *name);
160 196
161 197
@@ -165,28 +201,28 @@ void ff_cbs_trace_header(CodedBitstreamContext *ctx, · 3 unmodified lines
165// (i.e. only limited by the amount of bits used) and they lack201// (i.e. only limited by the amount of bits used) and they lack
166// the ability to use subscripts.202// the ability to use subscripts.
167 203
168int ff_cbs_read_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc,204int CBS_FUNC(read_unsigned)(CodedBitstreamContext *ctx, GetBitContext *gbc,
169 int width, const char *name,205 int width, const char *name,
170 const int *subscripts, uint32_t *write_to,206 const int *subscripts, uint32_t *write_to,
171 uint32_t range_min, uint32_t range_max);207 uint32_t range_min, uint32_t range_max);
172 208
173int ff_cbs_read_simple_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc,209int CBS_FUNC(read_simple_unsigned)(CodedBitstreamContext *ctx, GetBitContext *gbc,
174 int width, const char *name, uint32_t *write_to);210 int width, const char *name, uint32_t *write_to);
175 211
176int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc,212int CBS_FUNC(write_unsigned)(CodedBitstreamContext *ctx, PutBitContext *pbc,
177 int width, const char *name,213 int width, const char *name,
178 const int *subscripts, uint32_t value,214 const int *subscripts, uint32_t value,
179 uint32_t range_min, uint32_t range_max);215 uint32_t range_min, uint32_t range_max);
180 216
181int ff_cbs_write_simple_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc,217int CBS_FUNC(write_simple_unsigned)(CodedBitstreamContext *ctx, PutBitContext *pbc,
182 int width, const char *name, uint32_t value);218 int width, const char *name, uint32_t value);
183 219
184int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc,220int CBS_FUNC(read_signed)(CodedBitstreamContext *ctx, GetBitContext *gbc,
185 int width, const char *name,221 int width, const char *name,
186 const int *subscripts, int32_t *write_to,222 const int *subscripts, int32_t *write_to,
187 int32_t range_min, int32_t range_max);223 int32_t range_min, int32_t range_max);
188 224
189int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc,225int CBS_FUNC(write_signed)(CodedBitstreamContext *ctx, PutBitContext *pbc,
190 int width, const char *name,226 int width, const char *name,
191 const int *subscripts, int32_t value,227 const int *subscripts, int32_t value,
192 int32_t range_min, int32_t range_max);228 int32_t range_min, int32_t range_max);
@@ -204,6 +240,7 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, · 11 unmodified lines
204#define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1)))240#define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1)))
205 241
206 242
243#if CBS_TRACE
207// Start of a syntax element during read tracing.244// Start of a syntax element during read tracing.
208#define CBS_TRACE_READ_START() \245#define CBS_TRACE_READ_START() \
209 GetBitContext trace_start; \246 GetBitContext trace_start; \
@@ -284,6 +321,17 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, · 74 unmodified lines
284 } \321 } \
285 } while (0)322 } while (0)
286 323
324#else // CBS_TRACE
325#define CBS_TRACE_READ_START() do { } while (0)
326#define CBS_TRACE_READ_END() do { } while (0)
327#define CBS_TRACE_READ_END_NO_SUBSCRIPTS() do { } while (0)
328#define CBS_TRACE_READ_END_VALUE_ONLY() do { } while (0)
329#define CBS_TRACE_WRITE_START() do { } while (0)
330#define CBS_TRACE_WRITE_END() do { } while (0)
331#define CBS_TRACE_WRITE_END_NO_SUBSCRIPTS() do { } while (0)
332#define CBS_TRACE_WRITE_END_VALUE_ONLY() do { } while (0)
333#endif // CBS_TRACE
334
287#define TYPE_LIST(...) { __VA_ARGS__ }335#define TYPE_LIST(...) { __VA_ARGS__ }
288#define CBS_UNIT_TYPE_POD(type_, structure) { \336#define CBS_UNIT_TYPE_POD(type_, structure) { \
289 .nb_unit_types = 1, \337 .nb_unit_types = 1, \
@@ -335,14 +383,14 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, · 45 unmodified lines
335#define CBS_UNIT_TYPE_END_OF_LIST { .nb_unit_types = 0 }383#define CBS_UNIT_TYPE_END_OF_LIST { .nb_unit_types = 0 }
336 384
337 385
338extern const CodedBitstreamType ff_cbs_type_av1;386extern const CodedBitstreamType CBS_FUNC(type_av1);
339extern const CodedBitstreamType ff_cbs_type_h264;387extern const CodedBitstreamType CBS_FUNC(type_h264);
340extern const CodedBitstreamType ff_cbs_type_h265;388extern const CodedBitstreamType CBS_FUNC(type_h265);
341extern const CodedBitstreamType ff_cbs_type_h266;389extern const CodedBitstreamType CBS_FUNC(type_h266);
342extern const CodedBitstreamType ff_cbs_type_jpeg;390extern const CodedBitstreamType CBS_FUNC(type_jpeg);
343extern const CodedBitstreamType ff_cbs_type_mpeg2;391extern const CodedBitstreamType CBS_FUNC(type_mpeg2);
344extern const CodedBitstreamType ff_cbs_type_vp8;392extern const CodedBitstreamType CBS_FUNC(type_vp8);
345extern const CodedBitstreamType ff_cbs_type_vp9;393extern const CodedBitstreamType CBS_FUNC(type_vp9);
346 394
347 395
348#endif /* AVCODEC_CBS_INTERNAL_H */396#endif /* AVCODEC_CBS_INTERNAL_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t