FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
cbs_internal.h File Reference
#include <stddef.h>
#include <stdint.h>
#include "libavutil/log.h"
#include "cbs.h"
#include "codec_id.h"
#include "get_bits.h"
#include "put_bits.h"
#include "refstruct.h"

Go to the source code of this file.

Data Structures

struct  CodedBitstreamUnitTypeDescriptor
 
struct  CodedBitstreamType
 

Macros

#define MAX_UINT_BITS(length)   ((UINT64_C(1) << (length)) - 1)
 
#define MAX_INT_BITS(length)   ((INT64_C(1) << ((length) - 1)) - 1)
 
#define MIN_INT_BITS(length)   (-(INT64_C(1) << ((length) - 1)))
 
#define CBS_TRACE_READ_START()
 
#define CBS_TRACE_READ_END()
 
#define CBS_TRACE_READ_END_NO_SUBSCRIPTS()
 
#define CBS_TRACE_READ_END_VALUE_ONLY()
 
#define CBS_TRACE_WRITE_START()
 
#define CBS_TRACE_WRITE_END()
 
#define CBS_TRACE_WRITE_END_NO_SUBSCRIPTS()
 
#define CBS_TRACE_WRITE_END_VALUE_ONLY()
 
#define TYPE_LIST(...)   { __VA_ARGS__ }
 
#define CBS_UNIT_TYPE_POD(type_, structure)
 
#define CBS_UNIT_RANGE_POD(range_start, range_end, structure)
 
#define CBS_UNIT_TYPES_INTERNAL_REF(types, structure, ref_field)
 
#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field)   CBS_UNIT_TYPES_INTERNAL_REF((type), structure, ref_field)
 
#define CBS_UNIT_RANGE_INTERNAL_REF(range_start, range_end, structure, ref_field)
 
#define CBS_UNIT_TYPES_COMPLEX(types, structure, free_func)
 
#define CBS_UNIT_TYPE_COMPLEX(type, structure, free_func)   CBS_UNIT_TYPES_COMPLEX((type), structure, free_func)
 
#define CBS_UNIT_TYPE_END_OF_LIST   { .nb_unit_types = 0 }
 

Enumerations

enum  CBSContentType { CBS_CONTENT_TYPE_INTERNAL_REFS, CBS_CONTENT_TYPE_COMPLEX }
 
enum  { CBS_MAX_LIST_UNIT_TYPES = 3, CBS_MAX_REF_OFFSETS = 2, CBS_UNIT_TYPE_RANGE = -1 }
 

Functions

void ff_cbs_trace_header (CodedBitstreamContext *ctx, const char *name)
 
int ff_cbs_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)
 
int ff_cbs_read_simple_unsigned (CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, uint32_t *write_to)
 
int ff_cbs_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)
 
int ff_cbs_write_simple_unsigned (CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, uint32_t value)
 
int ff_cbs_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)
 
int ff_cbs_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)
 

Variables

const CodedBitstreamType ff_cbs_type_av1
 
const CodedBitstreamType ff_cbs_type_h264
 
const CodedBitstreamType ff_cbs_type_h265
 
const CodedBitstreamType ff_cbs_type_h266
 
const CodedBitstreamType ff_cbs_type_jpeg
 
const CodedBitstreamType ff_cbs_type_mpeg2
 
const CodedBitstreamType ff_cbs_type_vp8
 
const CodedBitstreamType ff_cbs_type_vp9
 

Macro Definition Documentation

◆ MAX_UINT_BITS

#define MAX_UINT_BITS (   length)    ((UINT64_C(1) << (length)) - 1)

Definition at line 196 of file cbs_internal.h.

◆ MAX_INT_BITS

#define MAX_INT_BITS (   length)    ((INT64_C(1) << ((length) - 1)) - 1)

Definition at line 200 of file cbs_internal.h.

◆ MIN_INT_BITS

#define MIN_INT_BITS (   length)    (-(INT64_C(1) << ((length) - 1)))

Definition at line 204 of file cbs_internal.h.

◆ CBS_TRACE_READ_START

#define CBS_TRACE_READ_START ( )
Value:
GetBitContext trace_start; \
do { \
if (ctx->trace_enable) \
trace_start = *gbc; \
} while (0)

Definition at line 208 of file cbs_internal.h.

◆ CBS_TRACE_READ_END

#define CBS_TRACE_READ_END ( )
Value:
do { \
if (ctx->trace_enable) { \
int start_position = get_bits_count(&trace_start); \
int end_position = get_bits_count(gbc); \
av_assert0(start_position <= end_position); \
ctx->trace_read_callback(ctx->trace_context, &trace_start, \
end_position - start_position, \
name, subscripts, value); \
} \
} while (0)

Definition at line 216 of file cbs_internal.h.

◆ CBS_TRACE_READ_END_NO_SUBSCRIPTS

#define CBS_TRACE_READ_END_NO_SUBSCRIPTS ( )
Value:
do { \
const int *subscripts = NULL; \
CBS_TRACE_READ_END(); \
} while (0)

Definition at line 229 of file cbs_internal.h.

◆ CBS_TRACE_READ_END_VALUE_ONLY

#define CBS_TRACE_READ_END_VALUE_ONLY ( )
Value:
do { \
if (ctx->trace_enable) { \
ctx->trace_read_callback(ctx->trace_context, &trace_start, 0, \
name, subscripts, value); \
} \
} while (0)

Definition at line 237 of file cbs_internal.h.

◆ CBS_TRACE_WRITE_START

#define CBS_TRACE_WRITE_START ( )
Value:
int start_position; \
do { \
if (ctx->trace_enable) \
start_position = put_bits_count(pbc);; \
} while (0)

Definition at line 246 of file cbs_internal.h.

◆ CBS_TRACE_WRITE_END

#define CBS_TRACE_WRITE_END ( )
Value:
do { \
if (ctx->trace_enable) { \
int end_position = put_bits_count(pbc); \
av_assert0(start_position <= end_position); \
ctx->trace_write_callback(ctx->trace_context, pbc, \
end_position - start_position, \
name, subscripts, value); \
} \
} while (0)

Definition at line 254 of file cbs_internal.h.

◆ CBS_TRACE_WRITE_END_NO_SUBSCRIPTS

#define CBS_TRACE_WRITE_END_NO_SUBSCRIPTS ( )
Value:
do { \
const int *subscripts = NULL; \
CBS_TRACE_WRITE_END(); \
} while (0)

Definition at line 266 of file cbs_internal.h.

◆ CBS_TRACE_WRITE_END_VALUE_ONLY

#define CBS_TRACE_WRITE_END_VALUE_ONLY ( )
Value:
do { \
if (ctx->trace_enable) { \
PutBitContext tmp; \
init_put_bits(&tmp, pbc->buf, start_position); \
skip_put_bits(&tmp, start_position); \
ctx->trace_write_callback(ctx->trace_context, &tmp, 0, \
name, subscripts, value); \
} \
} while (0)

Definition at line 276 of file cbs_internal.h.

◆ TYPE_LIST

#define TYPE_LIST (   ...)    { __VA_ARGS__ }

Definition at line 287 of file cbs_internal.h.

◆ CBS_UNIT_TYPE_POD

#define CBS_UNIT_TYPE_POD (   type_,
  structure 
)
Value:
{ \
.nb_unit_types = 1, \
.unit_type.list = { type_ }, \
.content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
.content_size = sizeof(structure), \
.type.ref = { .nb_offsets = 0 }, \
}

Definition at line 288 of file cbs_internal.h.

◆ CBS_UNIT_RANGE_POD

#define CBS_UNIT_RANGE_POD (   range_start,
  range_end,
  structure 
)
Value:
{ \
.nb_unit_types = CBS_UNIT_TYPE_RANGE, \
.unit_type.range.start = range_start, \
.unit_type.range.end = range_end, \
.content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
.content_size = sizeof(structure), \
.type.ref = { .nb_offsets = 0 }, \
}

Definition at line 295 of file cbs_internal.h.

◆ CBS_UNIT_TYPES_INTERNAL_REF

#define CBS_UNIT_TYPES_INTERNAL_REF (   types,
  structure,
  ref_field 
)
Value:
{ \
.nb_unit_types = FF_ARRAY_ELEMS((CodedBitstreamUnitType[])TYPE_LIST types), \
.unit_type.list = TYPE_LIST types, \
.content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
.content_size = sizeof(structure), \
.type.ref = { .nb_offsets = 1, \
.offsets = { offsetof(structure, ref_field) } }, \
}

Definition at line 304 of file cbs_internal.h.

◆ CBS_UNIT_TYPE_INTERNAL_REF

#define CBS_UNIT_TYPE_INTERNAL_REF (   type,
  structure,
  ref_field 
)    CBS_UNIT_TYPES_INTERNAL_REF((type), structure, ref_field)

Definition at line 312 of file cbs_internal.h.

◆ CBS_UNIT_RANGE_INTERNAL_REF

#define CBS_UNIT_RANGE_INTERNAL_REF (   range_start,
  range_end,
  structure,
  ref_field 
)
Value:
{ \
.nb_unit_types = CBS_UNIT_TYPE_RANGE, \
.unit_type.range.start = range_start, \
.unit_type.range.end = range_end, \
.content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
.content_size = sizeof(structure), \
.type.ref = { .nb_offsets = 1, \
.offsets = { offsetof(structure, ref_field) } }, \
}

Definition at line 315 of file cbs_internal.h.

◆ CBS_UNIT_TYPES_COMPLEX

#define CBS_UNIT_TYPES_COMPLEX (   types,
  structure,
  free_func 
)
Value:
{ \
.nb_unit_types = FF_ARRAY_ELEMS((CodedBitstreamUnitType[])TYPE_LIST types), \
.unit_type.list = TYPE_LIST types, \
.content_type = CBS_CONTENT_TYPE_COMPLEX, \
.content_size = sizeof(structure), \
.type.complex = { .content_free = free_func }, \
}

Definition at line 325 of file cbs_internal.h.

◆ CBS_UNIT_TYPE_COMPLEX

#define CBS_UNIT_TYPE_COMPLEX (   type,
  structure,
  free_func 
)    CBS_UNIT_TYPES_COMPLEX((type), structure, free_func)

Definition at line 332 of file cbs_internal.h.

◆ CBS_UNIT_TYPE_END_OF_LIST

#define CBS_UNIT_TYPE_END_OF_LIST   { .nb_unit_types = 0 }

Definition at line 335 of file cbs_internal.h.

Enumeration Type Documentation

◆ CBSContentType

Enumerator
CBS_CONTENT_TYPE_INTERNAL_REFS 
CBS_CONTENT_TYPE_COMPLEX 

Definition at line 34 of file cbs_internal.h.

◆ anonymous enum

anonymous enum
Enumerator
CBS_MAX_LIST_UNIT_TYPES 
CBS_MAX_REF_OFFSETS 
CBS_UNIT_TYPE_RANGE 

Definition at line 44 of file cbs_internal.h.

Function Documentation

◆ ff_cbs_trace_header()

void ff_cbs_trace_header ( CodedBitstreamContext ctx,
const char *  name 
)

Definition at line 498 of file cbs.c.

◆ ff_cbs_read_unsigned()

int ff_cbs_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 
)

Definition at line 630 of file cbs.c.

◆ ff_cbs_read_simple_unsigned()

int ff_cbs_read_simple_unsigned ( CodedBitstreamContext ctx,
GetBitContext gbc,
int  width,
const char *  name,
uint32_t *  write_to 
)

Definition at line 639 of file cbs.c.

Referenced by cbs_av1_read_subexp().

◆ ff_cbs_write_unsigned()

int ff_cbs_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 
)

Definition at line 646 of file cbs.c.

Referenced by ff_cbs_write_simple_unsigned().

◆ ff_cbs_write_simple_unsigned()

int ff_cbs_write_simple_unsigned ( CodedBitstreamContext ctx,
PutBitContext pbc,
int  width,
const char *  name,
uint32_t  value 
)

Definition at line 675 of file cbs.c.

Referenced by cbs_av1_write_subexp().

◆ ff_cbs_read_signed()

int ff_cbs_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 
)

Definition at line 682 of file cbs.c.

◆ ff_cbs_write_signed()

int ff_cbs_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 
)

Definition at line 714 of file cbs.c.

Variable Documentation

◆ ff_cbs_type_av1

const CodedBitstreamType ff_cbs_type_av1

Definition at line 1285 of file cbs_av1.c.

◆ ff_cbs_type_h264

const CodedBitstreamType ff_cbs_type_h264

Definition at line 2033 of file cbs_h2645.c.

◆ ff_cbs_type_h265

const CodedBitstreamType ff_cbs_type_h265

Definition at line 2050 of file cbs_h2645.c.

◆ ff_cbs_type_h266

const CodedBitstreamType ff_cbs_type_h266

Definition at line 2067 of file cbs_h2645.c.

◆ ff_cbs_type_jpeg

const CodedBitstreamType ff_cbs_type_jpeg

Definition at line 435 of file cbs_jpeg.c.

◆ ff_cbs_type_mpeg2

const CodedBitstreamType ff_cbs_type_mpeg2

Definition at line 427 of file cbs_mpeg2.c.

◆ ff_cbs_type_vp8

const CodedBitstreamType ff_cbs_type_vp8

Definition at line 374 of file cbs_vp8.c.

◆ ff_cbs_type_vp9

const CodedBitstreamType ff_cbs_type_vp9

Definition at line 602 of file cbs_vp9.c.

name
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
Definition: writing_filters.txt:88
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:266
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
GetBitContext
Definition: get_bits.h:108
CBS_CONTENT_TYPE_INTERNAL_REFS
@ CBS_CONTENT_TYPE_INTERNAL_REFS
Definition: cbs_internal.h:38
type
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 type
Definition: writing_filters.txt:86
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
ctx
AVFormatContext * ctx
Definition: movenc.c:48
CBS_UNIT_TYPE_RANGE
@ CBS_UNIT_TYPE_RANGE
Definition: cbs_internal.h:53
NULL
#define NULL
Definition: coverity.c:32
CBS_CONTENT_TYPE_COMPLEX
@ CBS_CONTENT_TYPE_COMPLEX
Definition: cbs_internal.h:41
TYPE_LIST
#define TYPE_LIST(...)
Definition: cbs_internal.h:287
put_bits_count
static int put_bits_count(PutBitContext *s)
Definition: put_bits.h:80
value
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
Definition: writing_filters.txt:86
CodedBitstreamUnitType
uint32_t CodedBitstreamUnitType
The codec-specific type of a bitstream unit.
Definition: cbs.h:47