From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/cbs: allow fine tunning selection of features Date: Fri, 21 Mar 2025 16:42:36 -0300 Message-ID: <20250321194237.20559-1-jamrial@gmail.com> (raw) In-Reply-To: <DU0P250MB07476C3EDEC5F4849B1102798FDB2@DU0P250MB0747.EURP250.PROD.OUTLOOK.COM> This will be useful in an upcoming commit, where CBS will be utilized by a module outside libavcodec. Signed-off-by: James Almer <jamrial@gmail.com> --- libavcodec/cbs.c | 100 ++++++++++++++++++++++----- libavcodec/cbs_av1.c | 64 ++++++++++++++++- libavcodec/cbs_av1.h | 15 ++++ libavcodec/cbs_av1_syntax_template.c | 6 ++ libavcodec/cbs_internal.h | 48 +++++++++++++ 5 files changed, 212 insertions(+), 21 deletions(-) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index 01dd916d81..94bf174700 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -18,8 +18,6 @@ #include <string.h> -#include "config.h" - #include "libavutil/avassert.h" #include "libavutil/buffer.h" #include "libavutil/common.h" @@ -33,55 +31,55 @@ static const CodedBitstreamType *const cbs_type_table[] = { -#if CONFIG_CBS_AV1 +#if CBS_AV1 &ff_cbs_type_av1, #endif -#if CONFIG_CBS_H264 +#if CBS_H264 &ff_cbs_type_h264, #endif -#if CONFIG_CBS_H265 +#if CBS_H265 &ff_cbs_type_h265, #endif -#if CONFIG_CBS_H266 +#if CBS_H266 &ff_cbs_type_h266, #endif -#if CONFIG_CBS_JPEG +#if CBS_JPEG &ff_cbs_type_jpeg, #endif -#if CONFIG_CBS_MPEG2 +#if CBS_MPEG2 &ff_cbs_type_mpeg2, #endif -#if CONFIG_CBS_VP8 +#if CBS_VP8 &ff_cbs_type_vp8, #endif -#if CONFIG_CBS_VP9 +#if CBS_VP9 &ff_cbs_type_vp9, #endif }; const enum AVCodecID ff_cbs_all_codec_ids[] = { -#if CONFIG_CBS_AV1 +#if CBS_AV1 AV_CODEC_ID_AV1, #endif -#if CONFIG_CBS_H264 +#if CBS_H264 AV_CODEC_ID_H264, #endif -#if CONFIG_CBS_H265 +#if CBS_H265 AV_CODEC_ID_H265, #endif -#if CONFIG_CBS_H266 +#if CBS_H266 AV_CODEC_ID_H266, #endif -#if CONFIG_CBS_JPEG +#if CBS_JPEG AV_CODEC_ID_MJPEG, #endif -#if CONFIG_CBS_MPEG2 +#if CBS_MPEG2 AV_CODEC_ID_MPEG2VIDEO, #endif -#if CONFIG_CBS_VP8 +#if CBS_VP8 AV_CODEC_ID_VP8, #endif -#if CONFIG_CBS_VP9 +#if CBS_VP9 AV_CODEC_ID_VP9, #endif AV_CODEC_ID_NONE @@ -234,6 +232,7 @@ static int cbs_read_fragment_content(CodedBitstreamContext *ctx, return 0; } +#if CBS_READ static int cbs_fill_fragment_data(CodedBitstreamFragment *frag, const uint8_t *data, size_t size) { @@ -282,37 +281,51 @@ static int cbs_read_data(CodedBitstreamContext *ctx, return cbs_read_fragment_content(ctx, frag); } +#endif int ff_cbs_read_extradata(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVCodecParameters *par) { +#if CBS_READ return cbs_read_data(ctx, frag, NULL, par->extradata, par->extradata_size, 1); +#else + return AVERROR(ENOSYS); +#endif } int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVCodecContext *avctx) { +#if CBS_READ return cbs_read_data(ctx, frag, NULL, avctx->extradata, avctx->extradata_size, 1); +#else + return AVERROR(ENOSYS); +#endif } int ff_cbs_read_packet(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVPacket *pkt) { +#if CBS_READ return cbs_read_data(ctx, frag, pkt->buf, pkt->data, pkt->size, 0); +#else + return AVERROR(ENOSYS); +#endif } int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVPacket *pkt) { +#if CBS_READ size_t side_data_size; const uint8_t *side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, @@ -320,16 +333,24 @@ int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx, return cbs_read_data(ctx, frag, NULL, side_data, side_data_size, 1); +#else + return AVERROR(ENOSYS); +#endif } int ff_cbs_read(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const uint8_t *data, size_t size) { +#if CBS_READ return cbs_read_data(ctx, frag, NULL, data, size, 0); +#else + return AVERROR(ENOSYS); +#endif } +#if CBS_WRITE /** * Allocate a new internal data buffer of the given size in the unit. * @@ -405,10 +426,12 @@ static int cbs_write_unit_data(CodedBitstreamContext *ctx, return 0; } +#endif int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag) { +#if CBS_WRITE int err, i; for (i = 0; i < frag->nb_units; i++) { @@ -440,12 +463,16 @@ int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx, av_assert0(frag->data && frag->data_ref); return 0; +#else + return AVERROR(ENOSYS); +#endif } int ff_cbs_write_extradata(CodedBitstreamContext *ctx, AVCodecParameters *par, CodedBitstreamFragment *frag) { +#if CBS_WRITE int err; err = ff_cbs_write_fragment_data(ctx, frag); @@ -469,12 +496,16 @@ int ff_cbs_write_extradata(CodedBitstreamContext *ctx, par->extradata_size = frag->data_size; return 0; +#else + return AVERROR(ENOSYS); +#endif } int ff_cbs_write_packet(CodedBitstreamContext *ctx, AVPacket *pkt, CodedBitstreamFragment *frag) { +#if CBS_WRITE AVBufferRef *buf; int err; @@ -493,16 +524,21 @@ int ff_cbs_write_packet(CodedBitstreamContext *ctx, pkt->size = frag->data_size; return 0; +#else + return AVERROR(ENOSYS); +#endif } void ff_cbs_trace_header(CodedBitstreamContext *ctx, const char *name) { +#if CBS_TRACE if (!ctx->trace_enable) return; av_log(ctx->log_ctx, ctx->trace_level, "%s\n", name); +#endif } void ff_cbs_trace_read_log(void *trace_context, @@ -510,6 +546,7 @@ void ff_cbs_trace_read_log(void *trace_context, const char *str, const int *subscripts, int64_t value) { +#if CBS_TRACE CodedBitstreamContext *ctx = trace_context; char name[256]; char bits[256]; @@ -561,6 +598,7 @@ void ff_cbs_trace_read_log(void *trace_context, av_log(ctx->log_ctx, ctx->trace_level, "%-10d %s%*s = %"PRId64"\n", position, name, pad, bits, value); +#endif } void ff_cbs_trace_write_log(void *trace_context, @@ -568,6 +606,7 @@ void ff_cbs_trace_write_log(void *trace_context, const char *str, const int *subscripts, int64_t value) { +#if CBS_TRACE CodedBitstreamContext *ctx = trace_context; // Ensure that the syntax element is written to the output buffer, @@ -591,6 +630,7 @@ void ff_cbs_trace_write_log(void *trace_context, skip_bits_long(&gbc, position - length); ff_cbs_trace_read_log(ctx, &gbc, length, str, subscripts, value); +#endif } static av_always_inline int cbs_read_unsigned(CodedBitstreamContext *ctx, @@ -633,15 +673,23 @@ int ff_cbs_read_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, const int *subscripts, uint32_t *write_to, uint32_t range_min, uint32_t range_max) { +#if CBS_READ return cbs_read_unsigned(ctx, gbc, width, name, subscripts, write_to, range_min, range_max); +#else + return AVERROR(ENOSYS); +#endif } int ff_cbs_read_simple_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, uint32_t *write_to) { +#if CBS_READ return cbs_read_unsigned(ctx, gbc, width, name, NULL, write_to, 0, UINT32_MAX); +#else + return AVERROR(ENOSYS); +#endif } int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, @@ -649,6 +697,7 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, const int *subscripts, uint32_t value, uint32_t range_min, uint32_t range_max) { +#if CBS_WRITE CBS_TRACE_WRITE_START(); av_assert0(width > 0 && width <= 32); @@ -671,13 +720,20 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, CBS_TRACE_WRITE_END(); return 0; +#else + return AVERROR(ENOSYS); +#endif } int ff_cbs_write_simple_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, uint32_t value) { +#if CBS_WRITE return ff_cbs_write_unsigned(ctx, pbc, width, name, NULL, value, 0, MAX_UINT_BITS(width)); +#else + return AVERROR(ENOSYS); +#endif } int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc, @@ -685,6 +741,7 @@ int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc, const int *subscripts, int32_t *write_to, int32_t range_min, int32_t range_max) { +#if CBS_READ int32_t value; CBS_TRACE_READ_START(); @@ -710,6 +767,9 @@ int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc, *write_to = value; return 0; +#else + return AVERROR(ENOSYS); +#endif } int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, @@ -717,6 +777,7 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, const int *subscripts, int32_t value, int32_t range_min, int32_t range_max) { +#if CBS_WRITE CBS_TRACE_WRITE_START(); av_assert0(width > 0 && width <= 32); @@ -739,6 +800,9 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, CBS_TRACE_WRITE_END(); return 0; +#else + return AVERROR(ENOSYS); +#endif } diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c index d7862a2e48..e0a4eba20f 100644 --- a/libavcodec/cbs_av1.c +++ b/libavcodec/cbs_av1.c @@ -27,6 +27,7 @@ #include "libavutil/refstruct.h" +#if CBS_READ static int cbs_av1_read_uvlc(CodedBitstreamContext *ctx, GetBitContext *gbc, const char *name, uint32_t *write_to, uint32_t range_min, uint32_t range_max) @@ -84,7 +85,9 @@ static int cbs_av1_read_uvlc(CodedBitstreamContext *ctx, GetBitContext *gbc, *write_to = value; return 0; } +#endif +#if CBS_WRITE static int cbs_av1_write_uvlc(CodedBitstreamContext *ctx, PutBitContext *pbc, const char *name, uint32_t value, uint32_t range_min, uint32_t range_max) @@ -115,7 +118,9 @@ static int cbs_av1_write_uvlc(CodedBitstreamContext *ctx, PutBitContext *pbc, return 0; } +#endif +#if CBS_READ static int cbs_av1_read_leb128(CodedBitstreamContext *ctx, GetBitContext *gbc, const char *name, uint64_t *write_to) { @@ -146,7 +151,9 @@ static int cbs_av1_read_leb128(CodedBitstreamContext *ctx, GetBitContext *gbc, *write_to = value; return 0; } +#endif +#if CBS_WRITE static int cbs_av1_write_leb128(CodedBitstreamContext *ctx, PutBitContext *pbc, const char *name, uint64_t value, int fixed_length) { @@ -182,7 +189,9 @@ static int cbs_av1_write_leb128(CodedBitstreamContext *ctx, PutBitContext *pbc, return 0; } +#endif +#if CBS_READ static int cbs_av1_read_ns(CodedBitstreamContext *ctx, GetBitContext *gbc, uint32_t n, const char *name, const int *subscripts, uint32_t *write_to) @@ -220,7 +229,9 @@ static int cbs_av1_read_ns(CodedBitstreamContext *ctx, GetBitContext *gbc, *write_to = value; return 0; } +#endif +#if CBS_WRITE static int cbs_av1_write_ns(CodedBitstreamContext *ctx, PutBitContext *pbc, uint32_t n, const char *name, const int *subscripts, uint32_t value) @@ -256,7 +267,9 @@ static int cbs_av1_write_ns(CodedBitstreamContext *ctx, PutBitContext *pbc, return 0; } +#endif +#if CBS_READ static int cbs_av1_read_increment(CodedBitstreamContext *ctx, GetBitContext *gbc, uint32_t range_min, uint32_t range_max, const char *name, uint32_t *write_to) @@ -284,7 +297,9 @@ static int cbs_av1_read_increment(CodedBitstreamContext *ctx, GetBitContext *gbc *write_to = value; return 0; } +#endif +#if CBS_WRITE static int cbs_av1_write_increment(CodedBitstreamContext *ctx, PutBitContext *pbc, uint32_t range_min, uint32_t range_max, const char *name, uint32_t value) @@ -315,7 +330,9 @@ static int cbs_av1_write_increment(CodedBitstreamContext *ctx, PutBitContext *pb return 0; } +#endif +#if CBS_READ static int cbs_av1_read_subexp(CodedBitstreamContext *ctx, GetBitContext *gbc, uint32_t range_max, const char *name, const int *subscripts, uint32_t *write_to) @@ -360,7 +377,9 @@ static int cbs_av1_read_subexp(CodedBitstreamContext *ctx, GetBitContext *gbc, *write_to = value; return err; } +#endif +#if CBS_WRITE static int cbs_av1_write_subexp(CodedBitstreamContext *ctx, PutBitContext *pbc, uint32_t range_max, const char *name, const int *subscripts, uint32_t value) @@ -420,6 +439,7 @@ static int cbs_av1_write_subexp(CodedBitstreamContext *ctx, PutBitContext *pbc, return err; } +#endif static int cbs_av1_tile_log2(int blksize, int target) @@ -441,7 +461,7 @@ static int cbs_av1_get_relative_dist(const AV1RawSequenceHeader *seq, return diff; } -static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) +static av_unused size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) { GetBitContext tmp = *gbc; size_t size = 0; @@ -469,6 +489,7 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL) +#if CBS_READ #define fc(width, name, range_min, range_max) \ xf(width, name, current->name, range_min, range_max, 0, ) #define flag(name) fb(1, name) @@ -584,8 +605,9 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) #undef leb128 #undef infer #undef byte_alignment +#endif // CBS_READ - +#if CBS_WRITE #define WRITE #define READWRITE write #define RWContext PutBitContext @@ -668,12 +690,13 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) #undef leb128 #undef infer #undef byte_alignment - +#endif // CBS_WRITE static int cbs_av1_split_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header) { +#if CBS_READ GetBitContext gbc; uint8_t *data; size_t size; @@ -777,6 +800,9 @@ success: fail: ctx->trace_enable = trace; return err; +#else + return AVERROR(ENOSYS); +#endif } static int cbs_av1_ref_tile_data(CodedBitstreamContext *ctx, @@ -809,6 +835,7 @@ static int cbs_av1_ref_tile_data(CodedBitstreamContext *ctx, static int cbs_av1_read_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit) { +#if CBS_READ CodedBitstreamAV1Context *priv = ctx->priv_data; AV1RawOBU *obu; GetBitContext gbc; @@ -931,6 +958,7 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, return err; } break; +#if CBS_OBU_TILE_LIST case AV1_OBU_TILE_LIST: { err = cbs_av1_read_tile_list_obu(ctx, &gbc, @@ -946,6 +974,8 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, return err; } break; +#endif +#if CBS_OBU_METADATA case AV1_OBU_METADATA: { err = cbs_av1_read_metadata_obu(ctx, &gbc, &obu->obu.metadata); @@ -953,6 +983,8 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, return err; } break; +#endif +#if CBS_OBU_PADDING case AV1_OBU_PADDING: { err = cbs_av1_read_padding_obu(ctx, &gbc, &obu->obu.padding); @@ -960,6 +992,7 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, return err; } break; +#endif default: return AVERROR(ENOSYS); } @@ -982,12 +1015,16 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, } return 0; +#else + return AVERROR(ENOSYS); +#endif } static int cbs_av1_write_obu(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc) { +#if CBS_WRITE CodedBitstreamAV1Context *priv = ctx->priv_data; AV1RawOBU *obu = unit->content; PutBitContext pbc_tmp; @@ -1087,6 +1124,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, td = &tile_group->tile_data; } break; +#if CBS_OBU_TILE_LIST case AV1_OBU_TILE_LIST: { err = cbs_av1_write_tile_list_obu(ctx, pbc, &obu->obu.tile_list); @@ -1096,6 +1134,8 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, td = &obu->obu.tile_list.tile_data; } break; +#endif +#if CBS_OBU_METADATA case AV1_OBU_METADATA: { err = cbs_av1_write_metadata_obu(ctx, pbc, &obu->obu.metadata); @@ -1103,6 +1143,8 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, goto error; } break; +#endif +#if CBS_OBU_PADDING case AV1_OBU_PADDING: { err = cbs_av1_write_padding_obu(ctx, pbc, &obu->obu.padding); @@ -1110,6 +1152,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, goto error; } break; +#endif default: err = AVERROR(ENOSYS); goto error; @@ -1182,11 +1225,15 @@ error: av_buffer_unref(&av1ctx.frame_header_ref); return err; +#else + return AVERROR(ENOSYS); +#endif } static int cbs_av1_assemble_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag) { +#if CBS_WRITE size_t size, pos; int i; @@ -1210,6 +1257,9 @@ static int cbs_av1_assemble_fragment(CodedBitstreamContext *ctx, frag->data_size = size; return 0; +#else + return AVERROR(ENOSYS); +#endif } static void cbs_av1_flush(CodedBitstreamContext *ctx) @@ -1234,6 +1284,7 @@ static void cbs_av1_close(CodedBitstreamContext *ctx) av_buffer_unref(&priv->frame_header_ref); } +#if CBS_OBU_METADATA static void cbs_av1_free_metadata(AVRefStructOpaque unused, void *content) { AV1RawOBU *obu = content; @@ -1255,6 +1306,7 @@ static void cbs_av1_free_metadata(AVRefStructOpaque unused, void *content) av_buffer_unref(&md->metadata.unknown.payload_ref); } } +#endif static const CodedBitstreamUnitTypeDescriptor cbs_av1_unit_types[] = { CBS_UNIT_TYPE_POD(AV1_OBU_SEQUENCE_HEADER, AV1RawOBU), @@ -1284,13 +1336,19 @@ static const CodedBitstreamUnitTypeDescriptor cbs_av1_unit_types[] = { offsetof(AV1RawOBU, obu.frame.tile_group.tile_data.data) } }, }, +#if CBS_OBU_TILE_LIST CBS_UNIT_TYPE_INTERNAL_REF(AV1_OBU_TILE_LIST, AV1RawOBU, obu.tile_list.tile_data.data), +#endif +#if CBS_OBU_PADDING CBS_UNIT_TYPE_INTERNAL_REF(AV1_OBU_PADDING, AV1RawOBU, obu.padding.payload), +#endif +#if CBS_OBU_METADATA CBS_UNIT_TYPE_COMPLEX(AV1_OBU_METADATA, AV1RawOBU, &cbs_av1_free_metadata), +#endif CBS_UNIT_TYPE_END_OF_LIST }; diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h index 62c7720142..0c73e12c84 100644 --- a/libavcodec/cbs_av1.h +++ b/libavcodec/cbs_av1.h @@ -25,6 +25,15 @@ #include "av1.h" #include "cbs.h" +#ifndef CBS_OBU_METADATA +#define CBS_OBU_METADATA 1 +#endif +#ifndef CBS_OBU_TILE_LIST +#define CBS_OBU_TILE_LIST 1 +#endif +#ifndef CBS_OBU_PADDING +#define CBS_OBU_PADDING 1 +#endif typedef struct AV1RawOBUHeader { uint8_t obu_forbidden_bit; @@ -411,9 +420,15 @@ typedef struct AV1RawOBU { AV1RawFrameHeader frame_header; AV1RawFrame frame; AV1RawTileGroup tile_group; +#if CBS_OBU_TILE_LIST AV1RawTileList tile_list; +#endif +#if CBS_OBU_METADATA AV1RawMetadata metadata; +#endif +#if CBS_OBU_PADDING AV1RawPadding padding; +#endif } obu; } AV1RawOBU; diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index 62a83945ec..b594bfd22b 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -1868,6 +1868,7 @@ static int FUNC(frame_obu)(CodedBitstreamContext *ctx, RWContext *rw, return 0; } +#if CBS_OBU_TILE_LIST static int FUNC(tile_list_obu)(CodedBitstreamContext *ctx, RWContext *rw, AV1RawTileList *current) { @@ -1882,7 +1883,9 @@ static int FUNC(tile_list_obu)(CodedBitstreamContext *ctx, RWContext *rw, return 0; } +#endif +#if CBS_OBU_METADATA static int FUNC(metadata_hdr_cll)(CodedBitstreamContext *ctx, RWContext *rw, AV1RawMetadataHDRCLL *current) { @@ -2101,7 +2104,9 @@ static int FUNC(metadata_obu)(CodedBitstreamContext *ctx, RWContext *rw, return 0; } +#endif +#if CBS_OBU_PADDING static int FUNC(padding_obu)(CodedBitstreamContext *ctx, RWContext *rw, AV1RawPadding *current) { @@ -2125,3 +2130,4 @@ static int FUNC(padding_obu)(CodedBitstreamContext *ctx, RWContext *rw, return 0; } +#endif diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h index 80cad2b162..f15ba1ab90 100644 --- a/libavcodec/cbs_internal.h +++ b/libavcodec/cbs_internal.h @@ -22,6 +22,8 @@ #include <stddef.h> #include <stdint.h> +#include "config.h" + #include "libavutil/log.h" #include "cbs.h" @@ -30,6 +32,40 @@ #include "put_bits.h" #include "libavutil/refstruct.h" +#ifndef CBS_READ +#define CBS_READ 1 +#endif +#ifndef CBS_WRITE +#define CBS_WRITE 1 +#endif +#ifndef CBS_TRACE +#define CBS_TRACE 1 +#endif + +#ifndef CBS_AV1 +#define CBS_AV1 CONFIG_CBS_AV1 +#endif +#ifndef CBS_H264 +#define CBS_H264 CONFIG_CBS_H264 +#endif +#ifndef CBS_H265 +#define CBS_H265 CONFIG_CBS_H265 +#endif +#ifndef CBS_H266 +#define CBS_H266 CONFIG_CBS_H266 +#endif +#ifndef CBS_JPEG +#define CBS_JPEG CONFIG_CBS_JPEG +#endif +#ifndef CBS_MPEG2 +#define CBS_MPEG2 CONFIG_CBS_MPEG2 +#endif +#ifndef CBS_VP8 +#define CBS_VP8 CONFIG_CBS_VP8 +#endif +#ifndef CBS_VP9 +#define CBS_VP9 CONFIG_CBS_VP9 +#endif enum CBSContentType { // Unit content may contain some references to other structures, but all @@ -204,6 +240,7 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, #define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1))) +#if CBS_TRACE // Start of a syntax element during read tracing. #define CBS_TRACE_READ_START() \ GetBitContext trace_start; \ @@ -284,6 +321,17 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, } \ } while (0) +#else // CBS_TRACE +#define CBS_TRACE_READ_START() do { } while (0) +#define CBS_TRACE_READ_END() do { } while (0) +#define CBS_TRACE_READ_END_NO_SUBSCRIPTS() do { } while (0) +#define CBS_TRACE_READ_END_VALUE_ONLY() do { } while (0) +#define CBS_TRACE_WRITE_START() do { } while (0) +#define CBS_TRACE_WRITE_END() do { } while (0) +#define CBS_TRACE_WRITE_END_NO_SUBSCRIPTS() do { } while (0) +#define CBS_TRACE_WRITE_END_VALUE_ONLY() do { } while (0) +#endif // CBS_TRACE + #define TYPE_LIST(...) { __VA_ARGS__ } #define CBS_UNIT_TYPE_POD(type_, structure) { \ .nb_unit_types = 1, \ -- 2.48.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2025-03-21 19:44 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-03-20 17:01 [FFmpeg-devel] [PATCH 1/2] avcodec/cbs_av1: also store a pointer to the start of the tile group data James Almer 2025-03-20 17:01 ` [FFmpeg-devel] [PATCH 2/2] avformat/movenccenc: add support for CENC AV1 encryption James Almer 2025-03-21 2:55 ` Andreas Rheinhardt 2025-03-21 3:30 ` James Almer 2025-03-21 3:52 ` Andreas Rheinhardt 2025-03-21 12:50 ` James Almer 2025-03-21 19:42 ` James Almer [this message] 2025-03-21 19:42 ` [FFmpeg-devel] [PATCH v2 3/3] " James Almer 2025-03-22 14:25 ` [FFmpeg-devel] [PATCH 2/3] avcodec/cbs: allow fine tunning selection of features Andreas Rheinhardt 2025-03-22 22:56 ` James Almer 2025-03-23 13:42 ` [FFmpeg-devel] [PATCH v2 1/2] " James Almer 2025-03-23 13:42 ` [FFmpeg-devel] [PATCH v3 2/2] avformat/movenccenc: add support for CENC AV1 encryption James Almer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250321194237.20559-1-jamrial@gmail.com \ --to=jamrial@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git