Go to the documentation of this file.
19 #ifndef AVCODEC_CBS_INTERNAL_H
20 #define AVCODEC_CBS_INTERNAL_H
46 #define CBS_APV CONFIG_CBS_APV
49 #define CBS_AV1 CONFIG_CBS_AV1
52 #define CBS_H264 CONFIG_CBS_H264
55 #define CBS_H265 CONFIG_CBS_H265
58 #define CBS_H266 CONFIG_CBS_H266
61 #define CBS_LCEVC CONFIG_CBS_LCEVC
64 #define CBS_JPEG CONFIG_CBS_JPEG
67 #define CBS_MPEG2 CONFIG_CBS_MPEG2
70 #define CBS_VP8 CONFIG_CBS_VP8
73 #define CBS_VP9 CONFIG_CBS_VP9
212 const int *subscripts, uint32_t *write_to,
213 uint32_t range_min, uint32_t range_max);
216 int width,
const char *
name, uint32_t *write_to);
220 const int *subscripts, uint32_t
value,
221 uint32_t range_min, uint32_t range_max);
228 const int *subscripts,
int32_t *write_to,
238 #define MAX_UINT_BITS(length) ((UINT64_C(1) << (length)) - 1)
242 #define MAX_INT_BITS(length) ((INT64_C(1) << ((length) - 1)) - 1)
246 #define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1)))
251 #define CBS_TRACE_READ_START() \
252 GetBitContext trace_start; \
254 if (ctx->trace_enable) \
255 trace_start = *gbc; \
259 #define CBS_TRACE_READ_END() \
261 if (ctx->trace_enable) { \
262 int start_position = get_bits_count(&trace_start); \
263 int end_position = get_bits_count(gbc); \
264 av_assert0(start_position <= end_position); \
265 ctx->trace_read_callback(ctx->trace_context, &trace_start, \
266 end_position - start_position, \
267 name, subscripts, value); \
272 #define CBS_TRACE_READ_END_NO_SUBSCRIPTS() \
274 const int *subscripts = NULL; \
275 CBS_TRACE_READ_END(); \
280 #define CBS_TRACE_READ_END_VALUE_ONLY() \
282 if (ctx->trace_enable) { \
283 ctx->trace_read_callback(ctx->trace_context, &trace_start, 0, \
284 name, subscripts, value); \
289 #define CBS_TRACE_WRITE_START() \
290 int start_position; \
292 if (ctx->trace_enable) \
293 start_position = put_bits_count(pbc);; \
297 #define CBS_TRACE_WRITE_END() \
299 if (ctx->trace_enable) { \
300 int end_position = put_bits_count(pbc); \
301 av_assert0(start_position <= end_position); \
302 ctx->trace_write_callback(ctx->trace_context, pbc, \
303 end_position - start_position, \
304 name, subscripts, value); \
309 #define CBS_TRACE_WRITE_END_NO_SUBSCRIPTS() \
311 const int *subscripts = NULL; \
312 CBS_TRACE_WRITE_END(); \
319 #define CBS_TRACE_WRITE_END_VALUE_ONLY() \
321 if (ctx->trace_enable) { \
323 init_put_bits(&tmp, pbc->buf, start_position); \
324 skip_put_bits(&tmp, start_position); \
325 ctx->trace_write_callback(ctx->trace_context, &tmp, 0, \
326 name, subscripts, value); \
331 #define CBS_TRACE_READ_START() do { } while (0)
332 #define CBS_TRACE_READ_END() do { } while (0)
333 #define CBS_TRACE_READ_END_NO_SUBSCRIPTS() do { } while (0)
334 #define CBS_TRACE_READ_END_VALUE_ONLY() do { } while (0)
335 #define CBS_TRACE_WRITE_START() do { } while (0)
336 #define CBS_TRACE_WRITE_END() do { } while (0)
337 #define CBS_TRACE_WRITE_END_NO_SUBSCRIPTS() do { } while (0)
338 #define CBS_TRACE_WRITE_END_VALUE_ONLY() do { } while (0)
341 #define TYPE_LIST(...) { __VA_ARGS__ }
342 #define CBS_UNIT_TYPE_POD(type_, structure) { \
343 .nb_unit_types = 1, \
344 .unit_type.list = { type_ }, \
345 .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
346 .content_size = sizeof(structure), \
347 .type.ref = { .nb_offsets = 0 }, \
349 #define CBS_UNIT_RANGE_POD(range_start, range_end, structure) { \
350 .nb_unit_types = CBS_UNIT_TYPE_RANGE, \
351 .unit_type.range.start = range_start, \
352 .unit_type.range.end = range_end, \
353 .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
354 .content_size = sizeof(structure), \
355 .type.ref = { .nb_offsets = 0 }, \
358 #define CBS_UNIT_TYPES_INTERNAL_REF(types, structure, ref_field) { \
359 .nb_unit_types = FF_ARRAY_ELEMS((CodedBitstreamUnitType[])TYPE_LIST types), \
360 .unit_type.list = TYPE_LIST types, \
361 .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
362 .content_size = sizeof(structure), \
363 .type.ref = { .nb_offsets = 1, \
364 .offsets = { offsetof(structure, ref_field) } }, \
366 #define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field) \
367 CBS_UNIT_TYPES_INTERNAL_REF((type), structure, ref_field)
369 #define CBS_UNIT_RANGE_INTERNAL_REF(range_start, range_end, structure, ref_field) { \
370 .nb_unit_types = CBS_UNIT_TYPE_RANGE, \
371 .unit_type.range.start = range_start, \
372 .unit_type.range.end = range_end, \
373 .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
374 .content_size = sizeof(structure), \
375 .type.ref = { .nb_offsets = 1, \
376 .offsets = { offsetof(structure, ref_field) } }, \
379 #define CBS_UNIT_TYPES_COMPLEX(types, structure, free_func) { \
380 .nb_unit_types = FF_ARRAY_ELEMS((CodedBitstreamUnitType[])TYPE_LIST types), \
381 .unit_type.list = TYPE_LIST types, \
382 .content_type = CBS_CONTENT_TYPE_COMPLEX, \
383 .content_size = sizeof(structure), \
384 .type.complex = { .content_free = free_func }, \
386 #define CBS_UNIT_TYPE_COMPLEX(type, structure, free_func) \
387 CBS_UNIT_TYPES_COMPLEX((type), structure, free_func)
389 #define CBS_UNIT_TYPE_END_OF_LIST { .nb_unit_types = 0 }
CodedBitstreamUnitType start
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
void(* close)(CodedBitstreamContext *ctx)
RefStruct is an API for creating reference-counted objects with minimal overhead.
const AVClass * priv_class
enum CBSContentType content_type
Context structure for coded bitstream operations.
void(* content_free)(AVRefStructOpaque opaque, void *content)
int CBS_FUNC() read_simple_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, uint32_t *write_to)
struct CodedBitstreamUnitTypeDescriptor::@87::@89 range
struct CodedBitstreamUnitTypeDescriptor::@88::@90 ref
int CBS_FUNC() write_simple_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, uint32_t value)
CodedBitstreamUnitTypeDescriptor * unit_types
CodedBitstreamUnitType end
Coded bitstream unit structure.
union CodedBitstreamUnitTypeDescriptor::@88 type
int(* discarded_unit)(CodedBitstreamContext *ctx, const CodedBitstreamUnit *unit, enum AVDiscard skip)
@ CBS_CONTENT_TYPE_INTERNAL_REFS
CodedBitstreamUnitType list[CBS_MAX_LIST_UNIT_TYPES]
Coded bitstream fragment structure, combining one or more units.
int(* content_clone)(void **new_content, CodedBitstreamUnit *unit)
void CBS_FUNC() trace_header(CodedBitstreamContext *ctx, const char *name)
uint32_t CodedBitstreamUnitType
The codec-specific type of a bitstream unit.
static AVFormatContext * ctx
int(* read_unit)(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Describe the class of an AVClass context structure.
int CBS_FUNC() read_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, const int *subscripts, uint32_t *write_to, uint32_t range_min, uint32_t range_max)
size_t offsets[CBS_MAX_REF_OFFSETS]
int CBS_FUNC() write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, const int *subscripts, uint32_t value, uint32_t range_min, uint32_t range_max)
AVCodecID
Identify the syntax and semantics of the bitstream.
int CBS_FUNC() read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, const int *subscripts, int32_t *write_to, int32_t range_min, int32_t range_max)
@ CBS_CONTENT_TYPE_COMPLEX
static const uint8_t header[24]
@ CBS_MAX_LIST_UNIT_TYPES
union CodedBitstreamUnitTypeDescriptor::@87 unit_type
int(* write_unit)(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
const CodedBitstreamType CBS_FUNC(type_apv)
void(* flush)(CodedBitstreamContext *ctx)
struct CodedBitstreamUnitTypeDescriptor::@88::@91 complex
int CBS_FUNC() write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, const int *subscripts, int32_t value, int32_t range_min, int32_t range_max)
int(* assemble_fragment)(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
int(* split_fragment)(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.