Go to the documentation of this file.
29 const int *subscripts,
int32_t *write_to)
35 if (
ctx->trace_enable)
40 "%s: bitstream ended.\n",
name);
48 if (
ctx->trace_enable) {
52 bits[
i] = magnitude >> (
width -
i - 1) & 1 ?
'1' :
'0';
53 bits[
i] = sign ?
'1' :
'0';
77 if (
ctx->trace_enable) {
81 bits[
i] = magnitude >> (
width -
i - 1) & 1 ?
'1' :
'0';
82 bits[
i] = sign ?
'1' :
'0';
96 uint32_t range_min, uint32_t range_max,
97 const char *
name, uint32_t *write_to)
103 av_assert0(range_min <= range_max && range_max - range_min <
sizeof(
bits) - 1);
104 if (
ctx->trace_enable)
107 for (
i = 0,
value = range_min;
value < range_max;) {
110 "%s: bitstream ended.\n",
name);
122 if (
ctx->trace_enable) {
132 uint32_t range_min, uint32_t range_max,
137 av_assert0(range_min <= range_max && range_max - range_min < 8);
138 if (value < range_min || value > range_max) {
140 "%"PRIu32
", but must be in [%"PRIu32
",%"PRIu32
"].\n",
145 if (
value == range_max)
146 len = range_max - range_min;
152 if (
ctx->trace_enable) {
155 for (
i = 0;
i <
len;
i++) {
156 if (range_min +
i ==
value)
174 const int *subscripts, uint32_t *write_to)
181 if (
ctx->trace_enable)
186 "%s: bitstream ended.\n",
name);
194 if (
ctx->trace_enable) {
198 for (
i = 0;
i < 8;
i++)
212 const int *subscripts, uint32_t
value)
221 if (
ctx->trace_enable) {
225 for (
i = 0;
i < 8;
i++)
239 #define HEADER(name) do { \
240 ff_cbs_trace_header(ctx, name); \
243 #define CHECK(call) do { \
249 #define FUNC_NAME(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name
250 #define FUNC_VP9(rw, name) FUNC_NAME(rw, vp9, name)
251 #define FUNC(name) FUNC_VP9(READWRITE, name)
253 #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
255 #define f(width, name) \
256 xf(width, name, current->name, 0, )
257 #define s(width, name) \
258 xs(width, name, current->name, 0, )
259 #define fs(width, name, subs, ...) \
260 xf(width, name, current->name, subs, __VA_ARGS__)
261 #define ss(width, name, subs, ...) \
262 xs(width, name, current->name, subs, __VA_ARGS__)
265 #define READWRITE read
266 #define RWContext GetBitContext
268 #define xf(width, name, var, subs, ...) do { \
270 CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \
271 SUBSCRIPTS(subs, __VA_ARGS__), \
272 &value, 0, (1 << width) - 1)); \
275 #define xs(width, name, var, subs, ...) do { \
277 CHECK(cbs_vp9_read_s(ctx, rw, width, #name, \
278 SUBSCRIPTS(subs, __VA_ARGS__), &value)); \
283 #define increment(name, min, max) do { \
285 CHECK(cbs_vp9_read_increment(ctx, rw, min, max, #name, &value)); \
286 current->name = value; \
289 #define fle(width, name, subs, ...) do { \
290 CHECK(cbs_vp9_read_le(ctx, rw, width, #name, \
291 SUBSCRIPTS(subs, __VA_ARGS__), ¤t->name)); \
294 #define delta_q(name) do { \
295 uint8_t delta_coded; \
297 xf(1, name.delta_coded, delta_coded, 0, ); \
299 xs(4, name.delta_q, delta_q, 0, ); \
302 current->name = delta_q; \
305 #define prob(name, subs, ...) do { \
306 uint8_t prob_coded; \
308 xf(1, name.prob_coded, prob_coded, subs, __VA_ARGS__); \
310 xf(8, name.prob, prob, subs, __VA_ARGS__); \
313 current->name = prob; \
316 #define fixed(width, name, value) do { \
317 av_unused uint32_t fixed_value; \
318 CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \
319 0, &fixed_value, value, value)); \
322 #define infer(name, value) do { \
323 current->name = value; \
326 #define byte_alignment(rw) (get_bits_count(rw) % 8)
341 #undef byte_alignment
345 #define READWRITE write
346 #define RWContext PutBitContext
348 #define xf(width, name, var, subs, ...) do { \
349 CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \
350 SUBSCRIPTS(subs, __VA_ARGS__), \
351 var, 0, (1 << width) - 1)); \
353 #define xs(width, name, var, subs, ...) do { \
354 CHECK(cbs_vp9_write_s(ctx, rw, width, #name, \
355 SUBSCRIPTS(subs, __VA_ARGS__), var)); \
358 #define increment(name, min, max) do { \
359 CHECK(cbs_vp9_write_increment(ctx, rw, min, max, #name, current->name)); \
362 #define fle(width, name, subs, ...) do { \
363 CHECK(cbs_vp9_write_le(ctx, rw, width, #name, \
364 SUBSCRIPTS(subs, __VA_ARGS__), current->name)); \
367 #define delta_q(name) do { \
368 xf(1, name.delta_coded, !!current->name, 0, ); \
370 xs(4, name.delta_q, current->name, 0, ); \
373 #define prob(name, subs, ...) do { \
374 xf(1, name.prob_coded, current->name != 255, subs, __VA_ARGS__); \
375 if (current->name != 255) \
376 xf(8, name.prob, current->name, subs, __VA_ARGS__); \
379 #define fixed(width, name, value) do { \
380 CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \
381 0, value, value, value)); \
384 #define infer(name, value) do { \
385 if (current->name != (value)) { \
386 av_log(ctx->log_ctx, AV_LOG_WARNING, "Warning: " \
387 "%s does not match inferred value: " \
388 "%"PRId64", but should be %"PRId64".\n", \
389 #name, (int64_t)current->name, (int64_t)(value)); \
393 #define byte_alignment(rw) (put_bits_count(rw) % 8)
408 #undef byte_alignment
415 uint8_t superframe_header;
424 if ((superframe_header & 0xe0) == 0xc0) {
427 size_t index_size,
pos;
430 index_size = 2 + (((superframe_header & 0x18) >> 3) + 1) *
431 ((superframe_header & 0x07) + 1);
441 err = cbs_vp9_read_superframe_index(
ctx, &gbc, &sfi);
449 "in superframe: %"PRIu32
" bytes.\n",
498 err = cbs_vp9_read_frame(
ctx, &gbc,
frame);
511 if (!
frame->data_ref)
528 err = cbs_vp9_write_frame(
ctx, pbc,
frame);
576 "make superframe: %d.\n", frag->
nb_units);
582 if (max < frag->units[
i].data_size)
618 err = cbs_vp9_write_superframe_index(
ctx, &pbc, &sfi);
621 "superframe index.\n");
641 memset(vp9->
ref, 0,
sizeof(vp9->
ref));
#define AV_LOG_WARNING
Something somehow does not look correct.
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
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
void * content
Pointer to the decomposed form of this unit.
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static int get_bits_count(const GetBitContext *s)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
static int cbs_vp9_write_increment(CodedBitstreamContext *ctx, PutBitContext *pbc, uint32_t range_min, uint32_t range_max, const char *name, uint32_t value)
Context structure for coded bitstream operations.
static int cbs_vp9_split_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Allocate a new internal content buffer matching the type of the unit.
uint32_t frame_sizes[VP9_MAX_FRAMES_IN_SUPERFRAME]
static void cbs_vp9_flush(CodedBitstreamContext *ctx)
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
VP9ReferenceFrameState ref[VP9_NUM_REF_FRAMES]
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static int cbs_vp9_write_le(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, const int *subscripts, uint32_t value)
Coded bitstream unit structure.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field)
static int cbs_vp9_assemble_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
static int put_bits_left(PutBitContext *s)
uint8_t * data
Pointer to the directly-parsable bitstream form of this unit.
static int cbs_vp9_read_s(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, const int *subscripts, int32_t *write_to)
static const CodedBitstreamUnitTypeDescriptor cbs_vp9_unit_types[]
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
const CodedBitstreamType ff_cbs_type_vp9
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Coded bitstream fragment structure, combining one or more units.
size_t data_size
The number of bytes in the bitstream.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
uint8_t frames_in_superframe_minus_1
static void flush(AVCodecContext *avctx)
static int cbs_vp9_read_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
static unsigned int get_bits1(GetBitContext *s)
size_t data_size
The number of bytes in the bitstream (including any padding bits in the final byte).
static int cbs_vp9_write_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
uint8_t bytes_per_framesize_minus_1
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)
uint8_t * data
Pointer to the bitstream form of this fragment.
static const uint8_t header[24]
int ff_cbs_insert_unit_data(CodedBitstreamFragment *frag, int position, CodedBitstreamUnitType type, uint8_t *data, size_t data_size, AVBufferRef *data_buf)
Insert a new unit into a fragment with the given data bitstream.
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
void ff_cbs_trace_syntax_element(CodedBitstreamContext *ctx, int position, const char *str, const int *subscripts, const char *bits, int64_t value)
AVBufferRef * data_ref
A reference to the buffer containing data.
#define i(width, name, range_min, range_max)
static int put_bits_count(PutBitContext *s)
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
#define CBS_UNIT_TYPE_END_OF_LIST
static int cbs_vp9_read_le(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, const int *subscripts, uint32_t *write_to)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#define AV_INPUT_BUFFER_PADDING_SIZE
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
uint8_t superframe_marker
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
static int ref[MAX_W *MAX_W]
A reference to a data buffer.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int cbs_vp9_write_s(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, const int *subscripts, int32_t value)
AVBufferRef * data_ref
A reference to the buffer containing data.
void * priv_data
Format private data.
int nb_units
Number of units in this fragment.