Go to the documentation of this file.
28 const int *subscripts,
int32_t *write_to)
34 if (
ctx->trace_enable)
39 "%s: bitstream ended.\n",
name);
47 if (
ctx->trace_enable) {
51 bits[
i] = magnitude >> (
width -
i - 1) & 1 ?
'1' :
'0';
52 bits[
i] = sign ?
'1' :
'0';
76 if (
ctx->trace_enable) {
80 bits[
i] = magnitude >> (
width -
i - 1) & 1 ?
'1' :
'0';
81 bits[
i] = sign ?
'1' :
'0';
95 uint32_t range_min, uint32_t range_max,
96 const char *
name, uint32_t *write_to)
102 av_assert0(range_min <= range_max && range_max - range_min <
sizeof(
bits) - 1);
103 if (
ctx->trace_enable)
106 for (
i = 0,
value = range_min;
value < range_max;) {
109 "%s: bitstream ended.\n",
name);
121 if (
ctx->trace_enable) {
131 uint32_t range_min, uint32_t range_max,
136 av_assert0(range_min <= range_max && range_max - range_min < 8);
137 if (value < range_min || value > range_max) {
139 "%"PRIu32
", but must be in [%"PRIu32
",%"PRIu32
"].\n",
144 if (
value == range_max)
145 len = range_max - range_min;
151 if (
ctx->trace_enable) {
154 for (
i = 0;
i <
len;
i++) {
155 if (range_min +
i ==
value)
173 const int *subscripts, uint32_t *write_to)
180 if (
ctx->trace_enable)
185 "%s: bitstream ended.\n",
name);
193 if (
ctx->trace_enable) {
197 for (
i = 0;
i < 8;
i++)
211 const int *subscripts, uint32_t
value)
220 if (
ctx->trace_enable) {
224 for (
i = 0;
i < 8;
i++)
238 #define HEADER(name) do { \
239 ff_cbs_trace_header(ctx, name); \
242 #define CHECK(call) do { \
248 #define FUNC_NAME(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name
249 #define FUNC_VP9(rw, name) FUNC_NAME(rw, vp9, name)
250 #define FUNC(name) FUNC_VP9(READWRITE, name)
252 #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
254 #define f(width, name) \
255 xf(width, name, current->name, 0, )
256 #define s(width, name) \
257 xs(width, name, current->name, 0, )
258 #define fs(width, name, subs, ...) \
259 xf(width, name, current->name, subs, __VA_ARGS__)
260 #define ss(width, name, subs, ...) \
261 xs(width, name, current->name, subs, __VA_ARGS__)
264 #define READWRITE read
265 #define RWContext GetBitContext
267 #define xf(width, name, var, subs, ...) do { \
269 CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \
270 SUBSCRIPTS(subs, __VA_ARGS__), \
271 &value, 0, (1 << width) - 1)); \
274 #define xs(width, name, var, subs, ...) do { \
276 CHECK(cbs_vp9_read_s(ctx, rw, width, #name, \
277 SUBSCRIPTS(subs, __VA_ARGS__), &value)); \
282 #define increment(name, min, max) do { \
284 CHECK(cbs_vp9_read_increment(ctx, rw, min, max, #name, &value)); \
285 current->name = value; \
288 #define fle(width, name, subs, ...) do { \
289 CHECK(cbs_vp9_read_le(ctx, rw, width, #name, \
290 SUBSCRIPTS(subs, __VA_ARGS__), ¤t->name)); \
293 #define delta_q(name) do { \
294 uint8_t delta_coded; \
296 xf(1, name.delta_coded, delta_coded, 0, ); \
298 xs(4, name.delta_q, delta_q, 0, ); \
301 current->name = delta_q; \
304 #define prob(name, subs, ...) do { \
305 uint8_t prob_coded; \
307 xf(1, name.prob_coded, prob_coded, subs, __VA_ARGS__); \
309 xf(8, name.prob, prob, subs, __VA_ARGS__); \
312 current->name = prob; \
315 #define fixed(width, name, value) do { \
316 av_unused uint32_t fixed_value; \
317 CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \
318 0, &fixed_value, value, value)); \
321 #define infer(name, value) do { \
322 current->name = value; \
325 #define byte_alignment(rw) (get_bits_count(rw) % 8)
340 #undef byte_alignment
344 #define READWRITE write
345 #define RWContext PutBitContext
347 #define xf(width, name, var, subs, ...) do { \
348 CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \
349 SUBSCRIPTS(subs, __VA_ARGS__), \
350 var, 0, (1 << width) - 1)); \
352 #define xs(width, name, var, subs, ...) do { \
353 CHECK(cbs_vp9_write_s(ctx, rw, width, #name, \
354 SUBSCRIPTS(subs, __VA_ARGS__), var)); \
357 #define increment(name, min, max) do { \
358 CHECK(cbs_vp9_write_increment(ctx, rw, min, max, #name, current->name)); \
361 #define fle(width, name, subs, ...) do { \
362 CHECK(cbs_vp9_write_le(ctx, rw, width, #name, \
363 SUBSCRIPTS(subs, __VA_ARGS__), current->name)); \
366 #define delta_q(name) do { \
367 xf(1, name.delta_coded, !!current->name, 0, ); \
369 xs(4, name.delta_q, current->name, 0, ); \
372 #define prob(name, subs, ...) do { \
373 xf(1, name.prob_coded, current->name != 255, subs, __VA_ARGS__); \
374 if (current->name != 255) \
375 xf(8, name.prob, current->name, subs, __VA_ARGS__); \
378 #define fixed(width, name, value) do { \
379 CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \
380 0, value, value, value)); \
383 #define infer(name, value) do { \
384 if (current->name != (value)) { \
385 av_log(ctx->log_ctx, AV_LOG_WARNING, "Warning: " \
386 "%s does not match inferred value: " \
387 "%"PRId64", but should be %"PRId64".\n", \
388 #name, (int64_t)current->name, (int64_t)(value)); \
392 #define byte_alignment(rw) (put_bits_count(rw) % 8)
407 #undef byte_alignment
414 uint8_t superframe_header;
423 if ((superframe_header & 0xe0) == 0xc0) {
426 size_t index_size,
pos;
429 index_size = 2 + (((superframe_header & 0x18) >> 3) + 1) *
430 ((superframe_header & 0x07) + 1);
440 err = cbs_vp9_read_superframe_index(
ctx, &gbc, &sfi);
448 "in superframe: %"PRIu32
" bytes.\n",
497 err = cbs_vp9_read_frame(
ctx, &gbc,
frame);
510 if (!
frame->data_ref)
527 err = cbs_vp9_write_frame(
ctx, pbc,
frame);
575 "make superframe: %d.\n", frag->
nb_units);
581 if (max < frag->units[
i].data_size)
617 err = cbs_vp9_write_superframe_index(
ctx, &pbc, &sfi);
620 "superframe index.\n");
640 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.
int ff_cbs_append_unit_data(CodedBitstreamFragment *frag, CodedBitstreamUnitType type, uint8_t *data, size_t data_size, AVBufferRef *data_buf)
Add a new unit to a fragment with the given data bitstream.
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]
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.