Go to the documentation of this file.
19 #ifndef AVCODEC_CBS_INTERNAL_H
20 #define AVCODEC_CBS_INTERNAL_H
46 #define CBS_AV1 CONFIG_CBS_AV1
49 #define CBS_H264 CONFIG_CBS_H264
52 #define CBS_H265 CONFIG_CBS_H265
55 #define CBS_H266 CONFIG_CBS_H266
58 #define CBS_JPEG CONFIG_CBS_JPEG
61 #define CBS_MPEG2 CONFIG_CBS_MPEG2
64 #define CBS_VP8 CONFIG_CBS_VP8
67 #define CBS_VP9 CONFIG_CBS_VP9
206 const int *subscripts, uint32_t *write_to,
207 uint32_t range_min, uint32_t range_max);
210 int width,
const char *
name, uint32_t *write_to);
214 const int *subscripts, uint32_t
value,
215 uint32_t range_min, uint32_t range_max);
222 const int *subscripts,
int32_t *write_to,
232 #define MAX_UINT_BITS(length) ((UINT64_C(1) << (length)) - 1)
236 #define MAX_INT_BITS(length) ((INT64_C(1) << ((length) - 1)) - 1)
240 #define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1)))
245 #define CBS_TRACE_READ_START() \
246 GetBitContext trace_start; \
248 if (ctx->trace_enable) \
249 trace_start = *gbc; \
253 #define CBS_TRACE_READ_END() \
255 if (ctx->trace_enable) { \
256 int start_position = get_bits_count(&trace_start); \
257 int end_position = get_bits_count(gbc); \
258 av_assert0(start_position <= end_position); \
259 ctx->trace_read_callback(ctx->trace_context, &trace_start, \
260 end_position - start_position, \
261 name, subscripts, value); \
266 #define CBS_TRACE_READ_END_NO_SUBSCRIPTS() \
268 const int *subscripts = NULL; \
269 CBS_TRACE_READ_END(); \
274 #define CBS_TRACE_READ_END_VALUE_ONLY() \
276 if (ctx->trace_enable) { \
277 ctx->trace_read_callback(ctx->trace_context, &trace_start, 0, \
278 name, subscripts, value); \
283 #define CBS_TRACE_WRITE_START() \
284 int start_position; \
286 if (ctx->trace_enable) \
287 start_position = put_bits_count(pbc);; \
291 #define CBS_TRACE_WRITE_END() \
293 if (ctx->trace_enable) { \
294 int end_position = put_bits_count(pbc); \
295 av_assert0(start_position <= end_position); \
296 ctx->trace_write_callback(ctx->trace_context, pbc, \
297 end_position - start_position, \
298 name, subscripts, value); \
303 #define CBS_TRACE_WRITE_END_NO_SUBSCRIPTS() \
305 const int *subscripts = NULL; \
306 CBS_TRACE_WRITE_END(); \
313 #define CBS_TRACE_WRITE_END_VALUE_ONLY() \
315 if (ctx->trace_enable) { \
317 init_put_bits(&tmp, pbc->buf, start_position); \
318 skip_put_bits(&tmp, start_position); \
319 ctx->trace_write_callback(ctx->trace_context, &tmp, 0, \
320 name, subscripts, value); \
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)
335 #define TYPE_LIST(...) { __VA_ARGS__ }
336 #define CBS_UNIT_TYPE_POD(type_, structure) { \
337 .nb_unit_types = 1, \
338 .unit_type.list = { type_ }, \
339 .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
340 .content_size = sizeof(structure), \
341 .type.ref = { .nb_offsets = 0 }, \
343 #define CBS_UNIT_RANGE_POD(range_start, range_end, structure) { \
344 .nb_unit_types = CBS_UNIT_TYPE_RANGE, \
345 .unit_type.range.start = range_start, \
346 .unit_type.range.end = range_end, \
347 .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
348 .content_size = sizeof(structure), \
349 .type.ref = { .nb_offsets = 0 }, \
352 #define CBS_UNIT_TYPES_INTERNAL_REF(types, structure, ref_field) { \
353 .nb_unit_types = FF_ARRAY_ELEMS((CodedBitstreamUnitType[])TYPE_LIST types), \
354 .unit_type.list = TYPE_LIST types, \
355 .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
356 .content_size = sizeof(structure), \
357 .type.ref = { .nb_offsets = 1, \
358 .offsets = { offsetof(structure, ref_field) } }, \
360 #define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field) \
361 CBS_UNIT_TYPES_INTERNAL_REF((type), structure, ref_field)
363 #define CBS_UNIT_RANGE_INTERNAL_REF(range_start, range_end, structure, ref_field) { \
364 .nb_unit_types = CBS_UNIT_TYPE_RANGE, \
365 .unit_type.range.start = range_start, \
366 .unit_type.range.end = range_end, \
367 .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
368 .content_size = sizeof(structure), \
369 .type.ref = { .nb_offsets = 1, \
370 .offsets = { offsetof(structure, ref_field) } }, \
373 #define CBS_UNIT_TYPES_COMPLEX(types, structure, free_func) { \
374 .nb_unit_types = FF_ARRAY_ELEMS((CodedBitstreamUnitType[])TYPE_LIST types), \
375 .unit_type.list = TYPE_LIST types, \
376 .content_type = CBS_CONTENT_TYPE_COMPLEX, \
377 .content_size = sizeof(structure), \
378 .type.complex = { .content_free = free_func }, \
380 #define CBS_UNIT_TYPE_COMPLEX(type, structure, free_func) \
381 CBS_UNIT_TYPES_COMPLEX((type), structure, free_func)
383 #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)
int CBS_FUNC() write_simple_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, uint32_t value)
union CodedBitstreamUnitTypeDescriptor::@75 type
CodedBitstreamUnitType end
Coded bitstream unit structure.
int(* discarded_unit)(CodedBitstreamContext *ctx, const CodedBitstreamUnit *unit, enum AVDiscard skip)
@ CBS_CONTENT_TYPE_INTERNAL_REFS
union CodedBitstreamUnitTypeDescriptor::@74 unit_type
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.
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)
struct CodedBitstreamUnitTypeDescriptor::@74::@76 range
size_t offsets[CBS_MAX_REF_OFFSETS]
struct CodedBitstreamUnitTypeDescriptor::@75::@78 complex
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.
struct CodedBitstreamUnitTypeDescriptor::@75::@77 ref
const CodedBitstreamUnitTypeDescriptor * unit_types
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]
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_av1)
void(* flush)(CodedBitstreamContext *ctx)
@ CBS_MAX_LIST_UNIT_TYPES
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.