FFmpeg
Macros | Functions | Variables
cbs_vp9.c File Reference
#include "libavutil/avassert.h"
#include "cbs.h"
#include "cbs_internal.h"
#include "cbs_vp9.h"
#include "cbs_vp9_syntax_template.c"

Go to the source code of this file.

Macros

#define HEADER(name)
 
#define CHECK(call)
 
#define FUNC_NAME(rw, codec, name)   cbs_ ## codec ## _ ## rw ## _ ## name
 
#define FUNC_VP9(rw, name)   FUNC_NAME(rw, vp9, name)
 
#define FUNC(name)   FUNC_VP9(READWRITE, name)
 
#define SUBSCRIPTS(subs, ...)   (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
 
#define s(width, name)   xs(width, name, current->name, 0, )
 
#define fs(width, name, subs, ...)   xf(width, name, current->name, subs, __VA_ARGS__)
 
#define ss(width, name, subs, ...)   xs(width, name, current->name, subs, __VA_ARGS__)
 
#define READ
 
#define READWRITE   read
 
#define RWContext   GetBitContext
 
#define f(width, name)
 
#define xf(width, name, var, subs, ...)
 
#define xs(width, name, var, subs, ...)
 
#define increment(name, min, max)
 
#define fle(width, name, subs, ...)
 
#define delta_q(name)
 
#define prob(name, subs, ...)
 
#define fixed(width, name, value)
 
#define infer(name, value)
 
#define byte_alignment(rw)   (get_bits_count(rw) % 8)
 
#define WRITE
 
#define READWRITE   write
 
#define RWContext   PutBitContext
 
#define f(width, name)
 
#define xf(width, name, var, subs, ...)
 
#define xs(width, name, var, subs, ...)
 
#define increment(name, min, max)
 
#define fle(width, name, subs, ...)
 
#define delta_q(name)
 
#define prob(name, subs, ...)
 
#define fixed(width, name, value)
 
#define infer(name, value)
 
#define byte_alignment(rw)   (put_bits_count(rw) % 8)
 

Functions

static int cbs_vp9_read_s (CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, const int *subscripts, int32_t *write_to)
 
static int cbs_vp9_write_s (CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, const int *subscripts, int32_t value)
 
static int cbs_vp9_read_increment (CodedBitstreamContext *ctx, GetBitContext *gbc, uint32_t range_min, uint32_t range_max, const char *name, uint32_t *write_to)
 
static int cbs_vp9_write_increment (CodedBitstreamContext *ctx, PutBitContext *pbc, uint32_t range_min, uint32_t range_max, const char *name, uint32_t value)
 
static int cbs_vp9_read_le (CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, const int *subscripts, uint32_t *write_to)
 
static int cbs_vp9_write_le (CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, const int *subscripts, uint32_t value)
 
static int cbs_vp9_split_fragment (CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
 
static int cbs_vp9_read_unit (CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
 
static int cbs_vp9_write_unit (CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
 
static int cbs_vp9_assemble_fragment (CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
 
static void cbs_vp9_flush (CodedBitstreamContext *ctx)
 

Variables

static const CodedBitstreamUnitTypeDescriptor cbs_vp9_unit_types []
 
const CodedBitstreamType ff_cbs_type_vp9
 

Macro Definition Documentation

◆ HEADER

#define HEADER (   name)
Value:
do { \
ff_cbs_trace_header(ctx, name); \
} while (0)

Definition at line 182 of file cbs_vp9.c.

◆ CHECK

#define CHECK (   call)
Value:
do { \
err = (call); \
if (err < 0) \
return err; \
} while (0)

Definition at line 186 of file cbs_vp9.c.

◆ FUNC_NAME

#define FUNC_NAME (   rw,
  codec,
  name 
)    cbs_ ## codec ## _ ## rw ## _ ## name

Definition at line 192 of file cbs_vp9.c.

◆ FUNC_VP9

#define FUNC_VP9 (   rw,
  name 
)    FUNC_NAME(rw, vp9, name)

Definition at line 193 of file cbs_vp9.c.

◆ FUNC

#define FUNC (   name)    FUNC_VP9(READWRITE, name)

Definition at line 194 of file cbs_vp9.c.

◆ SUBSCRIPTS

#define SUBSCRIPTS (   subs,
  ... 
)    (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)

Definition at line 196 of file cbs_vp9.c.

◆ s

#define s (   width,
  name 
)    xs(width, name, current->name, 0, )

Definition at line 198 of file cbs_vp9.c.

◆ fs

#define fs (   width,
  name,
  subs,
  ... 
)    xf(width, name, current->name, subs, __VA_ARGS__)

Definition at line 200 of file cbs_vp9.c.

◆ ss

#define ss (   width,
  name,
  subs,
  ... 
)    xs(width, name, current->name, subs, __VA_ARGS__)

Definition at line 202 of file cbs_vp9.c.

◆ READ

#define READ

Definition at line 205 of file cbs_vp9.c.

◆ READWRITE [1/2]

#define READWRITE   read

Definition at line 293 of file cbs_vp9.c.

◆ RWContext [1/2]

#define RWContext   GetBitContext

Definition at line 294 of file cbs_vp9.c.

◆ f [1/2]

#define f (   width,
  name 
)
Value:
do { \
uint32_t value; \
&value)); \
current->name = value; \
} while (0)

Definition at line 296 of file cbs_vp9.c.

◆ xf [1/2]

#define xf (   width,
  name,
  var,
  subs,
  ... 
)
Value:
do { \
uint32_t value; \
SUBSCRIPTS(subs, __VA_ARGS__), \
&value, 0, (1 << width) - 1)); \
var = value; \
} while (0)

Definition at line 300 of file cbs_vp9.c.

◆ xs [1/2]

#define xs (   width,
  name,
  var,
  subs,
  ... 
)
Value:
do { \
int32_t value; \
CHECK(cbs_vp9_read_s(ctx, rw, width, #name, \
SUBSCRIPTS(subs, __VA_ARGS__), &value)); \
var = value; \
} while (0)

Definition at line 305 of file cbs_vp9.c.

◆ increment [1/2]

#define increment (   name,
  min,
  max 
)
Value:
do { \
uint32_t value; \
CHECK(cbs_vp9_read_increment(ctx, rw, min, max, #name, &value)); \
current->name = value; \
} while (0)

Definition at line 310 of file cbs_vp9.c.

◆ fle [1/2]

#define fle (   width,
  name,
  subs,
  ... 
)
Value:
do { \
CHECK(cbs_vp9_read_le(ctx, rw, width, #name, \
SUBSCRIPTS(subs, __VA_ARGS__), &current->name)); \
} while (0)

Definition at line 314 of file cbs_vp9.c.

◆ delta_q [1/2]

#define delta_q (   name)
Value:
do { \
uint8_t delta_coded; \
int8_t delta_q; \
xf(1, name.delta_coded, delta_coded, 0, ); \
if (delta_coded) \
xs(4, name.delta_q, delta_q, 0, ); \
else \
delta_q = 0; \
current->name = delta_q; \
} while (0)

Definition at line 319 of file cbs_vp9.c.

◆ prob [1/2]

#define prob (   name,
  subs,
  ... 
)
Value:
do { \
uint8_t prob_coded; \
uint8_t prob; \
xf(1, name.prob_coded, prob_coded, subs, __VA_ARGS__); \
if (prob_coded) \
xf(8, name.prob, prob, subs, __VA_ARGS__); \
else \
prob = 255; \
current->name = prob; \
} while (0)

Definition at line 325 of file cbs_vp9.c.

◆ fixed [1/2]

#define fixed (   width,
  name,
  value 
)
Value:
do { \
av_unused uint32_t fixed_value; \
0, &fixed_value, value, value)); \
} while (0)

Definition at line 331 of file cbs_vp9.c.

◆ infer [1/2]

#define infer (   name,
  value 
)
Value:
do { \
current->name = value; \
} while (0)

Definition at line 336 of file cbs_vp9.c.

◆ byte_alignment [1/2]

#define byte_alignment (   rw)    (get_bits_count(rw) % 8)

Definition at line 345 of file cbs_vp9.c.

◆ WRITE

#define WRITE

Definition at line 292 of file cbs_vp9.c.

◆ READWRITE [2/2]

#define READWRITE   write

Definition at line 293 of file cbs_vp9.c.

◆ RWContext [2/2]

#define RWContext   PutBitContext

Definition at line 294 of file cbs_vp9.c.

◆ f [2/2]

#define f (   width,
  name 
)
Value:
do { \
current->name)); \
} while (0)

Definition at line 296 of file cbs_vp9.c.

◆ xf [2/2]

#define xf (   width,
  name,
  var,
  subs,
  ... 
)
Value:
do { \
SUBSCRIPTS(subs, __VA_ARGS__), \
var, 0, (1 << width) - 1)); \
} while (0)

Definition at line 300 of file cbs_vp9.c.

◆ xs [2/2]

#define xs (   width,
  name,
  var,
  subs,
  ... 
)
Value:
do { \
CHECK(cbs_vp9_write_s(ctx, rw, width, #name, \
SUBSCRIPTS(subs, __VA_ARGS__), var)); \
} while (0)

Definition at line 305 of file cbs_vp9.c.

◆ increment [2/2]

#define increment (   name,
  min,
  max 
)
Value:
do { \
CHECK(cbs_vp9_write_increment(ctx, rw, min, max, #name, current->name)); \
} while (0)

Definition at line 310 of file cbs_vp9.c.

◆ fle [2/2]

#define fle (   width,
  name,
  subs,
  ... 
)
Value:
do { \
CHECK(cbs_vp9_write_le(ctx, rw, width, #name, \
SUBSCRIPTS(subs, __VA_ARGS__), current->name)); \
} while (0)

Definition at line 314 of file cbs_vp9.c.

◆ delta_q [2/2]

#define delta_q (   name)
Value:
do { \
xf(1, name.delta_coded, !!current->name, 0, ); \
if (current->name) \
xs(4, name.delta_q, current->name, 0, ); \
} while (0)

Definition at line 319 of file cbs_vp9.c.

◆ prob [2/2]

#define prob (   name,
  subs,
  ... 
)
Value:
do { \
xf(1, name.prob_coded, current->name != 255, subs, __VA_ARGS__); \
if (current->name != 255) \
xf(8, name.prob, current->name, subs, __VA_ARGS__); \
} while (0)

Definition at line 325 of file cbs_vp9.c.

◆ fixed [2/2]

#define fixed (   width,
  name,
  value 
)
Value:
do { \
0, value, value, value)); \
} while (0)

Definition at line 331 of file cbs_vp9.c.

◆ infer [2/2]

#define infer (   name,
  value 
)
Value:
do { \
if (current->name != (value)) { \
av_log(ctx->log_ctx, AV_LOG_WARNING, "Warning: " \
"%s does not match inferred value: " \
"%"PRId64", but should be %"PRId64".\n", \
#name, (int64_t)current->name, (int64_t)(value)); \
} \
} while (0)

Definition at line 336 of file cbs_vp9.c.

◆ byte_alignment [2/2]

#define byte_alignment (   rw)    (put_bits_count(rw) % 8)

Definition at line 345 of file cbs_vp9.c.

Function Documentation

◆ cbs_vp9_read_s()

static int cbs_vp9_read_s ( CodedBitstreamContext ctx,
GetBitContext gbc,
int  width,
const char *  name,
const int subscripts,
int32_t write_to 
)
static

Definition at line 26 of file cbs_vp9.c.

◆ cbs_vp9_write_s()

static int cbs_vp9_write_s ( CodedBitstreamContext ctx,
PutBitContext pbc,
int  width,
const char *  name,
const int subscripts,
int32_t  value 
)
static

Definition at line 52 of file cbs_vp9.c.

◆ cbs_vp9_read_increment()

static int cbs_vp9_read_increment ( CodedBitstreamContext ctx,
GetBitContext gbc,
uint32_t  range_min,
uint32_t  range_max,
const char *  name,
uint32_t *  write_to 
)
static

Definition at line 75 of file cbs_vp9.c.

◆ cbs_vp9_write_increment()

static int cbs_vp9_write_increment ( CodedBitstreamContext ctx,
PutBitContext pbc,
uint32_t  range_min,
uint32_t  range_max,
const char *  name,
uint32_t  value 
)
static

Definition at line 103 of file cbs_vp9.c.

◆ cbs_vp9_read_le()

static int cbs_vp9_read_le ( CodedBitstreamContext ctx,
GetBitContext gbc,
int  width,
const char *  name,
const int subscripts,
uint32_t *  write_to 
)
static

Definition at line 134 of file cbs_vp9.c.

◆ cbs_vp9_write_le()

static int cbs_vp9_write_le ( CodedBitstreamContext ctx,
PutBitContext pbc,
int  width,
const char *  name,
const int subscripts,
uint32_t  value 
)
static

Definition at line 161 of file cbs_vp9.c.

◆ cbs_vp9_split_fragment()

static int cbs_vp9_split_fragment ( CodedBitstreamContext ctx,
CodedBitstreamFragment frag,
int  header 
)
static

Definition at line 364 of file cbs_vp9.c.

◆ cbs_vp9_read_unit()

static int cbs_vp9_read_unit ( CodedBitstreamContext ctx,
CodedBitstreamUnit unit 
)
static

Definition at line 435 of file cbs_vp9.c.

◆ cbs_vp9_write_unit()

static int cbs_vp9_write_unit ( CodedBitstreamContext ctx,
CodedBitstreamUnit unit,
PutBitContext pbc 
)
static

Definition at line 474 of file cbs_vp9.c.

◆ cbs_vp9_assemble_fragment()

static int cbs_vp9_assemble_fragment ( CodedBitstreamContext ctx,
CodedBitstreamFragment frag 
)
static

Definition at line 500 of file cbs_vp9.c.

◆ cbs_vp9_flush()

static void cbs_vp9_flush ( CodedBitstreamContext ctx)
static

Definition at line 590 of file cbs_vp9.c.

Variable Documentation

◆ cbs_vp9_unit_types

const CodedBitstreamUnitTypeDescriptor cbs_vp9_unit_types[]
static
Initial value:

Definition at line 597 of file cbs_vp9.c.

◆ ff_cbs_type_vp9

const CodedBitstreamType ff_cbs_type_vp9
Initial value:
= {
.codec_id = AV_CODEC_ID_VP9,
.priv_data_size = sizeof(CodedBitstreamVP9Context),
.unit_types = cbs_vp9_unit_types,
.split_fragment = &cbs_vp9_split_fragment,
.read_unit = &cbs_vp9_read_unit,
.write_unit = &cbs_vp9_write_unit,
.assemble_fragment = &cbs_vp9_assemble_fragment,
}

Definition at line 602 of file cbs_vp9.c.

AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
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
SUBSCRIPTS
#define SUBSCRIPTS(subs,...)
Definition: cbs_vp9.c:196
int64_t
long long int64_t
Definition: coverity.c:34
cbs_vp9_write_increment
static int cbs_vp9_write_increment(CodedBitstreamContext *ctx, PutBitContext *pbc, uint32_t range_min, uint32_t range_max, const char *name, uint32_t value)
Definition: cbs_vp9.c:103
data
const char data[16]
Definition: mxf.c:148
cbs_vp9_split_fragment
static int cbs_vp9_split_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
Definition: cbs_vp9.c:364
max
#define max(a, b)
Definition: cuda_runtime.h:33
cbs_vp9_flush
static void cbs_vp9_flush(CodedBitstreamContext *ctx)
Definition: cbs_vp9.c:590
cbs_vp9_write_le
static int cbs_vp9_write_le(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, const int *subscripts, uint32_t value)
Definition: cbs_vp9.c:161
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: cbs.c:646
CBS_UNIT_TYPE_INTERNAL_REF
#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field)
Definition: cbs_internal.h:312
cbs_vp9_assemble_fragment
static int cbs_vp9_assemble_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Definition: cbs_vp9.c:500
cbs_vp9_read_s
static int cbs_vp9_read_s(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, const int *subscripts, int32_t *write_to)
Definition: cbs_vp9.c:26
cbs_vp9_unit_types
static const CodedBitstreamUnitTypeDescriptor cbs_vp9_unit_types[]
Definition: cbs_vp9.c:597
width
#define width
AV_CODEC_ID_VP9
@ AV_CODEC_ID_VP9
Definition: codec_id.h:220
ctx
AVFormatContext * ctx
Definition: movenc.c:48
cbs_vp9_read_unit
static int cbs_vp9_read_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Definition: cbs_vp9.c:435
flush
void(* flush)(AVBSFContext *ctx)
Definition: dts2pts.c:367
cbs_vp9_write_unit
static int cbs_vp9_write_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
Definition: cbs_vp9.c:474
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: cbs.c:639
VP9RawFrame
Definition: cbs_vp9.h:164
cbs_vp9_read_increment
static int cbs_vp9_read_increment(CodedBitstreamContext *ctx, GetBitContext *gbc, uint32_t range_min, uint32_t range_max, const char *name, uint32_t *write_to)
Definition: cbs_vp9.c:75
CodedBitstreamVP9Context
Definition: cbs_vp9.h:192
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
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: cbs.c:630
CBS_UNIT_TYPE_END_OF_LIST
#define CBS_UNIT_TYPE_END_OF_LIST
Definition: cbs_internal.h:335
cbs_vp9_read_le
static int cbs_vp9_read_le(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, const int *subscripts, uint32_t *write_to)
Definition: cbs_vp9.c:134
prob
#define prob(name, subs,...)
Definition: cbs_vp9.c:325
ff_cbs_write_simple_unsigned
int ff_cbs_write_simple_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, uint32_t value)
Definition: cbs.c:675
delta_q
#define delta_q(name)
Definition: cbs_vp9.c:319
cbs_vp9_write_s
static int cbs_vp9_write_s(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, const int *subscripts, int32_t value)
Definition: cbs_vp9.c:52
min
float min
Definition: vorbis_enc_data.h:429