27#define DEFAULT_PROB 0x80
75 const uint8_t
prob, uint8_t *output)
112 for (; num_bits > 0; --num_bits) {
113 uint8_t bit_output = 0;
115 &bit_output)) != 0) {
119 *output = (*output << 1) | bit_output;
127 uint8_t
prob,
const char *
name,
const int *subscripts, uint32_t *write_to,
153 uint8_t
prob,
const char *
name,
const int *subscripts,
int32_t *write_to)
186 const char *
name,
const int *subscripts,
187 uint32_t *write_to, uint32_t range_min,
208 "%" PRIu32
", but must be in [%" PRIu32
",%" PRIu32
"].\n",
217#define HEADER(name) \
219 ff_cbs_trace_header(ctx, name); \
229#define FUNC_NAME(rw, codec, name) cbs_##codec##_##rw##_##name
230#define FUNC_VP8(rw, name) FUNC_NAME(rw, vp8, name)
231#define FUNC(name) FUNC_VP8(READWRITE, name)
233#define SUBSCRIPTS(subs, ...) \
234 (subs > 0 ? ((int[subs + 1]){subs, __VA_ARGS__}) : NULL)
236#define f(width, name) xf(width, name, 0, )
239#define bc_f(width, name) bc_unsigned_subs(width, DEFAULT_PROB, true, name, 0, )
240#define bc_s(width, name) bc_signed_subs(width, DEFAULT_PROB, name, 0, )
241#define bc_fs(width, name, subs, ...) \
242 bc_unsigned_subs(width, DEFAULT_PROB, true, name, subs, __VA_ARGS__)
243#define bc_ss(width, name, subs, ...) \
244 bc_signed_subs(width, DEFAULT_PROB, name, subs, __VA_ARGS__)
247#define bc_b(name) bc_unsigned_subs(1, DEFAULT_PROB, false, name, 0, )
248#define bc_b_prob(prob, name) bc_unsigned_subs(1, prob, false, name, 0, )
251#define READWRITE read
252#define RWContext GetBitContext
253#define CBSVP8BoolCodingRW CBSVP8BoolDecoder
255#define xf(width, name, subs, ...) \
258 CHECK(cbs_vp8_read_unsigned_le(ctx, rw, width, #name, \
259 SUBSCRIPTS(subs, __VA_ARGS__), &value, \
260 0, MAX_UINT_BITS(width))); \
261 current->name = value; \
264#define fixed(width, name, value) \
266 uint32_t fixed_value; \
267 CHECK(cbs_vp8_read_unsigned_le(ctx, rw, width, #name, 0, &fixed_value, \
271#define bc_unsigned_subs(width, prob, enable_trace, name, subs, ...) \
274 CHECK(cbs_vp8_bool_decoder_read_unsigned( \
275 ctx, bool_coding_rw, width, prob, #name, \
276 SUBSCRIPTS(subs, __VA_ARGS__), &value, enable_trace)); \
277 current->name = value; \
280#define bc_signed_subs(width, prob, name, subs, ...) \
283 CHECK(cbs_vp8_bool_decoder_read_signed( \
284 ctx, bool_coding_rw, width, prob, #name, \
285 SUBSCRIPTS(subs, __VA_ARGS__), &value)); \
286 current->name = value; \
299 err = ff_cbs_append_unit_data(frag, 0, frag->
data, frag->
data_size,
315 err = ff_cbs_alloc_unit_content(
ctx, unit);
325 err = cbs_vp8_read_uncompressed_header(
ctx, &gbc,
frame);
337 err = cbs_vp8_read_compressed_header(
ctx, &bool_decoder,
frame);
348 if (!
frame->data_ref)
static char * split(char *message, char delim)
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define CBS_TRACE_READ_END()
#define CBS_UNIT_TYPE_END_OF_LIST
#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field)
#define CBS_TRACE_READ_START()
static int cbs_vp8_assemble_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
static int cbs_vp8_read_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
static int cbs_vp8_write_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
static int cbs_vp8_bool_decoder_init(CBSVP8BoolDecoder *decoder, GetBitContext *gbc)
static CodedBitstreamUnitTypeDescriptor cbs_vp8_unit_types[]
static int cbs_vp8_bool_decoder_read_bool(CBSVP8BoolDecoder *decoder, const uint8_t prob, uint8_t *output)
static int cbs_vp8_bool_decoder_read_literal(CBSVP8BoolDecoder *decoder, const uint8_t prob, uint32_t num_bits, uint32_t *output)
static int cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, const int *subscripts, uint32_t *write_to, uint32_t range_min, uint32_t range_max)
static int cbs_vp8_split_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
const uint8_t ff_vp8_token_update_probs[4][8][3][11]
static int cbs_vp8_bool_decoder_read_signed(CodedBitstreamContext *ctx, CBSVP8BoolDecoder *bool_decoder, int width, uint8_t prob, const char *name, const int *subscripts, int32_t *write_to)
const CodedBitstreamType ff_cbs_type_vp8
static bool cbs_vp8_bool_decoder_fill_value(CBSVP8BoolDecoder *decoder)
static int cbs_vp8_bool_decoder_read_unsigned(CodedBitstreamContext *ctx, CBSVP8BoolDecoder *bool_decoder, int width, uint8_t prob, const char *name, const int *subscripts, uint32_t *write_to, bool trace_enable)
#define prob(name, subs,...)
static const uint8_t bits[8]
static unsigned int get_bits_le(GetBitContext *s, int n)
static int init_get_bits8_le(GetBitContext *s, const uint8_t *buffer, int byte_size)
static int get_bits_left(GetBitContext *gb)
static int get_bits_count(const GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const chunk_decoder decoder[8]
static const uint8_t header[24]
Context structure for coded bitstream operations.
Coded bitstream fragment structure, combining one or more units.
size_t data_size
The number of bytes in the bitstream.
uint8_t * data
Pointer to the bitstream form of this fragment.
AVBufferRef * data_ref
A reference to the buffer containing data.
Coded bitstream unit structure.
void * content
Pointer to the decomposed form of this unit.
uint8_t * data
Pointer to the directly-parsable bitstream form of this unit.
size_t data_size
The number of bytes in the bitstream (including any padding bits in the final byte).
AVBufferRef * data_ref
A reference to the buffer containing data.