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 f(width, name)   xf(width, name, current->name, 0, )
 
#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 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 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 238 of file cbs_vp9.c.

◆ CHECK

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

Definition at line 242 of file cbs_vp9.c.

◆ FUNC_NAME

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

Definition at line 248 of file cbs_vp9.c.

◆ FUNC_VP9

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

Definition at line 249 of file cbs_vp9.c.

◆ FUNC

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

Definition at line 250 of file cbs_vp9.c.

◆ SUBSCRIPTS

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

Definition at line 252 of file cbs_vp9.c.

◆ f

#define f (   width,
  name 
)    xf(width, name, current->name, 0, )

Definition at line 254 of file cbs_vp9.c.

◆ s

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

Definition at line 256 of file cbs_vp9.c.

◆ fs

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

Definition at line 258 of file cbs_vp9.c.

◆ ss

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

Definition at line 260 of file cbs_vp9.c.

◆ READ

#define READ

Definition at line 263 of file cbs_vp9.c.

◆ READWRITE [1/2]

#define READWRITE   read

Definition at line 344 of file cbs_vp9.c.

◆ RWContext [1/2]

#define RWContext   GetBitContext

Definition at line 345 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 347 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 352 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 357 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 361 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 366 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 372 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 378 of file cbs_vp9.c.

◆ infer [1/2]

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

Definition at line 383 of file cbs_vp9.c.

◆ byte_alignment [1/2]

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

Definition at line 392 of file cbs_vp9.c.

◆ WRITE

#define WRITE

Definition at line 343 of file cbs_vp9.c.

◆ READWRITE [2/2]

#define READWRITE   write

Definition at line 344 of file cbs_vp9.c.

◆ RWContext [2/2]

#define RWContext   PutBitContext

Definition at line 345 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 347 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 352 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 357 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 361 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 366 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 372 of file cbs_vp9.c.

◆ fixed [2/2]

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

Definition at line 378 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 383 of file cbs_vp9.c.

◆ byte_alignment [2/2]

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

Definition at line 392 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 63 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 94 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 130 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 171 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 209 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 410 of file cbs_vp9.c.

◆ cbs_vp9_read_unit()

static int cbs_vp9_read_unit ( CodedBitstreamContext ctx,
CodedBitstreamUnit unit 
)
static

Definition at line 481 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 520 of file cbs_vp9.c.

◆ cbs_vp9_assemble_fragment()

static int cbs_vp9_assemble_fragment ( CodedBitstreamContext ctx,
CodedBitstreamFragment frag 
)
static

Definition at line 546 of file cbs_vp9.c.

◆ cbs_vp9_flush()

static void cbs_vp9_flush ( CodedBitstreamContext ctx)
static

Definition at line 636 of file cbs_vp9.c.

Variable Documentation

◆ cbs_vp9_unit_types

const CodedBitstreamUnitTypeDescriptor cbs_vp9_unit_types[]
static
Initial value:

Definition at line 643 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 648 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:252
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:130
data
const char data[16]
Definition: mxf.c:146
cbs_vp9_split_fragment
static int cbs_vp9_split_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
Definition: cbs_vp9.c:410
max
#define max(a, b)
Definition: cuda_runtime.h:33
cbs_vp9_flush
static void cbs_vp9_flush(CodedBitstreamContext *ctx)
Definition: cbs_vp9.c:636
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:209
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:586
CBS_UNIT_TYPE_INTERNAL_REF
#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field)
Definition: cbs_internal.h:219
cbs_vp9_assemble_fragment
static int cbs_vp9_assemble_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Definition: cbs_vp9.c:546
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:643
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:481
cbs_vp9_write_unit
static int cbs_vp9_write_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
Definition: cbs_vp9.c:520
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:94
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:543
CBS_UNIT_TYPE_END_OF_LIST
#define CBS_UNIT_TYPE_END_OF_LIST
Definition: cbs_internal.h:242
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:171
prob
#define prob(name, subs,...)
Definition: cbs_vp9.c:372
flush
void(* flush)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:367
delta_q
#define delta_q(name)
Definition: cbs_vp9.c:366
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:63
min
float min
Definition: vorbis_enc_data.h:429