FFmpeg
cbs_vp9.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "libavutil/avassert.h"
20 
21 #include "cbs.h"
22 #include "cbs_internal.h"
23 #include "cbs_vp9.h"
24 
25 
27  int width, const char *name,
28  const int *subscripts, int32_t *write_to)
29 {
30  uint32_t magnitude;
31  int sign;
32  int32_t value;
33 
35 
36  if (get_bits_left(gbc) < width + 1) {
37  av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid signed value at "
38  "%s: bitstream ended.\n", name);
39  return AVERROR_INVALIDDATA;
40  }
41 
42  magnitude = get_bits(gbc, width);
43  sign = get_bits1(gbc);
44  value = sign ? -(int32_t)magnitude : magnitude;
45 
47 
48  *write_to = value;
49  return 0;
50 }
51 
53  int width, const char *name,
54  const int *subscripts, int32_t value)
55 {
56  uint32_t magnitude;
57  int sign;
58 
60 
61  if (put_bits_left(pbc) < width + 1)
62  return AVERROR(ENOSPC);
63 
64  sign = value < 0;
65  magnitude = sign ? -value : value;
66 
67  put_bits(pbc, width, magnitude);
68  put_bits(pbc, 1, sign);
69 
71 
72  return 0;
73 }
74 
76  uint32_t range_min, uint32_t range_max,
77  const char *name, uint32_t *write_to)
78 {
79  uint32_t value;
80 
82 
83  av_assert0(range_min <= range_max && range_max - range_min < 32);
84 
85  for (value = range_min; value < range_max;) {
86  if (get_bits_left(gbc) < 1) {
87  av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid increment value at "
88  "%s: bitstream ended.\n", name);
89  return AVERROR_INVALIDDATA;
90  }
91  if (get_bits1(gbc))
92  ++value;
93  else
94  break;
95  }
96 
98 
99  *write_to = value;
100  return 0;
101 }
102 
104  uint32_t range_min, uint32_t range_max,
105  const char *name, uint32_t value)
106 {
107  int len;
108 
110 
111  av_assert0(range_min <= range_max && range_max - range_min < 8);
112  if (value < range_min || value > range_max) {
113  av_log(ctx->log_ctx, AV_LOG_ERROR, "%s out of range: "
114  "%"PRIu32", but must be in [%"PRIu32",%"PRIu32"].\n",
115  name, value, range_min, range_max);
116  return AVERROR_INVALIDDATA;
117  }
118 
119  if (value == range_max)
120  len = range_max - range_min;
121  else
122  len = value - range_min + 1;
123  if (put_bits_left(pbc) < len)
124  return AVERROR(ENOSPC);
125 
126  if (len > 0)
127  put_bits(pbc, len, (1 << len) - 1 - (value != range_max));
128 
130 
131  return 0;
132 }
133 
135  int width, const char *name,
136  const int *subscripts, uint32_t *write_to)
137 {
138  uint32_t value;
139  int b;
140 
142 
143  av_assert0(width % 8 == 0);
144 
145  if (get_bits_left(gbc) < width) {
146  av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid le value at "
147  "%s: bitstream ended.\n", name);
148  return AVERROR_INVALIDDATA;
149  }
150 
151  value = 0;
152  for (b = 0; b < width; b += 8)
153  value |= get_bits(gbc, 8) << b;
154 
156 
157  *write_to = value;
158  return 0;
159 }
160 
162  int width, const char *name,
163  const int *subscripts, uint32_t value)
164 {
165  int b;
166 
168 
169  av_assert0(width % 8 == 0);
170 
171  if (put_bits_left(pbc) < width)
172  return AVERROR(ENOSPC);
173 
174  for (b = 0; b < width; b += 8)
175  put_bits(pbc, 8, value >> b & 0xff);
176 
178 
179  return 0;
180 }
181 
182 #define HEADER(name) do { \
183  ff_cbs_trace_header(ctx, name); \
184  } while (0)
185 
186 #define CHECK(call) do { \
187  err = (call); \
188  if (err < 0) \
189  return err; \
190  } while (0)
191 
192 #define FUNC_NAME(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name
193 #define FUNC_VP9(rw, name) FUNC_NAME(rw, vp9, name)
194 #define FUNC(name) FUNC_VP9(READWRITE, name)
195 
196 #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
197 
198 #define s(width, name) \
199  xs(width, name, current->name, 0, )
200 #define fs(width, name, subs, ...) \
201  xf(width, name, current->name, subs, __VA_ARGS__)
202 #define ss(width, name, subs, ...) \
203  xs(width, name, current->name, subs, __VA_ARGS__)
204 
205 #define READ
206 #define READWRITE read
207 #define RWContext GetBitContext
208 
209 #define f(width, name) do { \
210  uint32_t value; \
211  CHECK(ff_cbs_read_simple_unsigned(ctx, rw, width, #name, \
212  &value)); \
213  current->name = value; \
214  } while (0)
215 #define xf(width, name, var, subs, ...) do { \
216  uint32_t value; \
217  CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \
218  SUBSCRIPTS(subs, __VA_ARGS__), \
219  &value, 0, (1 << width) - 1)); \
220  var = value; \
221  } while (0)
222 #define xs(width, name, var, subs, ...) do { \
223  int32_t value; \
224  CHECK(cbs_vp9_read_s(ctx, rw, width, #name, \
225  SUBSCRIPTS(subs, __VA_ARGS__), &value)); \
226  var = value; \
227  } while (0)
228 
229 
230 #define increment(name, min, max) do { \
231  uint32_t value; \
232  CHECK(cbs_vp9_read_increment(ctx, rw, min, max, #name, &value)); \
233  current->name = value; \
234  } while (0)
235 
236 #define fle(width, name, subs, ...) do { \
237  CHECK(cbs_vp9_read_le(ctx, rw, width, #name, \
238  SUBSCRIPTS(subs, __VA_ARGS__), &current->name)); \
239  } while (0)
240 
241 #define delta_q(name) do { \
242  uint8_t delta_coded; \
243  int8_t delta_q; \
244  xf(1, name.delta_coded, delta_coded, 0, ); \
245  if (delta_coded) \
246  xs(4, name.delta_q, delta_q, 0, ); \
247  else \
248  delta_q = 0; \
249  current->name = delta_q; \
250  } while (0)
251 
252 #define prob(name, subs, ...) do { \
253  uint8_t prob_coded; \
254  uint8_t prob; \
255  xf(1, name.prob_coded, prob_coded, subs, __VA_ARGS__); \
256  if (prob_coded) \
257  xf(8, name.prob, prob, subs, __VA_ARGS__); \
258  else \
259  prob = 255; \
260  current->name = prob; \
261  } while (0)
262 
263 #define fixed(width, name, value) do { \
264  av_unused uint32_t fixed_value; \
265  CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \
266  0, &fixed_value, value, value)); \
267  } while (0)
268 
269 #define infer(name, value) do { \
270  current->name = value; \
271  } while (0)
272 
273 #define byte_alignment(rw) (get_bits_count(rw) % 8)
274 
275 #include "cbs_vp9_syntax_template.c"
276 
277 #undef READ
278 #undef READWRITE
279 #undef RWContext
280 #undef f
281 #undef xf
282 #undef xs
283 #undef increment
284 #undef fle
285 #undef delta_q
286 #undef prob
287 #undef fixed
288 #undef infer
289 #undef byte_alignment
290 
291 
292 #define WRITE
293 #define READWRITE write
294 #define RWContext PutBitContext
295 
296 #define f(width, name) do { \
297  CHECK(ff_cbs_write_simple_unsigned(ctx, rw, width, #name, \
298  current->name)); \
299  } while (0)
300 #define xf(width, name, var, subs, ...) do { \
301  CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \
302  SUBSCRIPTS(subs, __VA_ARGS__), \
303  var, 0, (1 << width) - 1)); \
304  } while (0)
305 #define xs(width, name, var, subs, ...) do { \
306  CHECK(cbs_vp9_write_s(ctx, rw, width, #name, \
307  SUBSCRIPTS(subs, __VA_ARGS__), var)); \
308  } while (0)
309 
310 #define increment(name, min, max) do { \
311  CHECK(cbs_vp9_write_increment(ctx, rw, min, max, #name, current->name)); \
312  } while (0)
313 
314 #define fle(width, name, subs, ...) do { \
315  CHECK(cbs_vp9_write_le(ctx, rw, width, #name, \
316  SUBSCRIPTS(subs, __VA_ARGS__), current->name)); \
317  } while (0)
318 
319 #define delta_q(name) do { \
320  xf(1, name.delta_coded, !!current->name, 0, ); \
321  if (current->name) \
322  xs(4, name.delta_q, current->name, 0, ); \
323  } while (0)
324 
325 #define prob(name, subs, ...) do { \
326  xf(1, name.prob_coded, current->name != 255, subs, __VA_ARGS__); \
327  if (current->name != 255) \
328  xf(8, name.prob, current->name, subs, __VA_ARGS__); \
329  } while (0)
330 
331 #define fixed(width, name, value) do { \
332  CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \
333  0, value, value, value)); \
334  } while (0)
335 
336 #define infer(name, value) do { \
337  if (current->name != (value)) { \
338  av_log(ctx->log_ctx, AV_LOG_WARNING, "Warning: " \
339  "%s does not match inferred value: " \
340  "%"PRId64", but should be %"PRId64".\n", \
341  #name, (int64_t)current->name, (int64_t)(value)); \
342  } \
343  } while (0)
344 
345 #define byte_alignment(rw) (put_bits_count(rw) % 8)
346 
347 #include "cbs_vp9_syntax_template.c"
348 
349 #undef WRITE
350 #undef READWRITE
351 #undef RWContext
352 #undef f
353 #undef xf
354 #undef xs
355 #undef increment
356 #undef fle
357 #undef delta_q
358 #undef prob
359 #undef fixed
360 #undef infer
361 #undef byte_alignment
362 
363 
366  int header)
367 {
368  uint8_t superframe_header;
369  int err;
370 
371  if (frag->data_size == 0)
372  return AVERROR_INVALIDDATA;
373 
374  // Last byte in the packet.
375  superframe_header = frag->data[frag->data_size - 1];
376 
377  if ((superframe_header & 0xe0) == 0xc0) {
379  GetBitContext gbc;
380  size_t index_size, pos;
381  int i;
382 
383  index_size = 2 + (((superframe_header & 0x18) >> 3) + 1) *
384  ((superframe_header & 0x07) + 1);
385 
386  if (index_size > frag->data_size)
387  return AVERROR_INVALIDDATA;
388 
389  err = init_get_bits(&gbc, frag->data + frag->data_size - index_size,
390  8 * index_size);
391  if (err < 0)
392  return err;
393 
394  err = cbs_vp9_read_superframe_index(ctx, &gbc, &sfi);
395  if (err < 0)
396  return err;
397 
398  pos = 0;
399  for (i = 0; i <= sfi.frames_in_superframe_minus_1; i++) {
400  if (pos + sfi.frame_sizes[i] + index_size > frag->data_size) {
401  av_log(ctx->log_ctx, AV_LOG_ERROR, "Frame %d too large "
402  "in superframe: %"PRIu32" bytes.\n",
403  i, sfi.frame_sizes[i]);
404  return AVERROR_INVALIDDATA;
405  }
406 
407  err = ff_cbs_append_unit_data(frag, 0,
408  frag->data + pos,
409  sfi.frame_sizes[i],
410  frag->data_ref);
411  if (err < 0)
412  return err;
413 
414  pos += sfi.frame_sizes[i];
415  }
416  if (pos + index_size != frag->data_size) {
417  av_log(ctx->log_ctx, AV_LOG_WARNING, "Extra padding at "
418  "end of superframe: %"SIZE_SPECIFIER" bytes.\n",
419  frag->data_size - (pos + index_size));
420  }
421 
422  return 0;
423 
424  } else {
425  err = ff_cbs_append_unit_data(frag, 0,
426  frag->data, frag->data_size,
427  frag->data_ref);
428  if (err < 0)
429  return err;
430  }
431 
432  return 0;
433 }
434 
436  CodedBitstreamUnit *unit)
437 {
439  GetBitContext gbc;
440  int err, pos;
441 
442  err = init_get_bits(&gbc, unit->data, 8 * unit->data_size);
443  if (err < 0)
444  return err;
445 
446  err = ff_cbs_alloc_unit_content(ctx, unit);
447  if (err < 0)
448  return err;
449  frame = unit->content;
450 
451  err = cbs_vp9_read_frame(ctx, &gbc, frame);
452  if (err < 0)
453  return err;
454 
455  pos = get_bits_count(&gbc);
456  av_assert0(pos % 8 == 0);
457  pos /= 8;
458  av_assert0(pos <= unit->data_size);
459 
460  if (pos == unit->data_size) {
461  // No data (e.g. a show-existing-frame frame).
462  } else {
463  frame->data_ref = av_buffer_ref(unit->data_ref);
464  if (!frame->data_ref)
465  return AVERROR(ENOMEM);
466 
467  frame->data = unit->data + pos;
468  frame->data_size = unit->data_size - pos;
469  }
470 
471  return 0;
472 }
473 
475  CodedBitstreamUnit *unit,
476  PutBitContext *pbc)
477 {
478  VP9RawFrame *frame = unit->content;
479  int err;
480 
481  err = cbs_vp9_write_frame(ctx, pbc, frame);
482  if (err < 0)
483  return err;
484 
485  // Frame must be byte-aligned.
486  av_assert0(put_bits_count(pbc) % 8 == 0);
487 
488  if (frame->data) {
489  if (frame->data_size > put_bits_left(pbc) / 8)
490  return AVERROR(ENOSPC);
491 
492  flush_put_bits(pbc);
493  memcpy(put_bits_ptr(pbc), frame->data, frame->data_size);
494  skip_put_bytes(pbc, frame->data_size);
495  }
496 
497  return 0;
498 }
499 
502 {
503  int err;
504 
505  if (frag->nb_units == 1) {
506  // Output is just the content of the single frame.
507 
508  CodedBitstreamUnit *frame = &frag->units[0];
509 
510  frag->data_ref = av_buffer_ref(frame->data_ref);
511  if (!frag->data_ref)
512  return AVERROR(ENOMEM);
513 
514  frag->data = frame->data;
515  frag->data_size = frame->data_size;
516 
517  } else {
518  // Build superframe out of frames.
519 
521  PutBitContext pbc;
522  AVBufferRef *ref;
523  uint8_t *data;
524  size_t size, max, pos;
525  int i, size_len;
526 
527  if (frag->nb_units > 8) {
528  av_log(ctx->log_ctx, AV_LOG_ERROR, "Too many frames to "
529  "make superframe: %d.\n", frag->nb_units);
530  return AVERROR(EINVAL);
531  }
532 
533  max = 0;
534  for (i = 0; i < frag->nb_units; i++)
535  if (max < frag->units[i].data_size)
536  max = frag->units[i].data_size;
537 
538  if (max < 2)
539  size_len = 1;
540  else
541  size_len = av_log2(max) / 8 + 1;
542  av_assert0(size_len <= 4);
543 
545  sfi.bytes_per_framesize_minus_1 = size_len - 1;
546  sfi.frames_in_superframe_minus_1 = frag->nb_units - 1;
547 
548  size = 2;
549  for (i = 0; i < frag->nb_units; i++) {
550  size += size_len + frag->units[i].data_size;
551  sfi.frame_sizes[i] = frag->units[i].data_size;
552  }
553 
555  if (!ref)
556  return AVERROR(ENOMEM);
557  data = ref->data;
558  memset(data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
559 
560  pos = 0;
561  for (i = 0; i < frag->nb_units; i++) {
562  av_assert0(size - pos > frag->units[i].data_size);
563  memcpy(data + pos, frag->units[i].data,
564  frag->units[i].data_size);
565  pos += frag->units[i].data_size;
566  }
567  av_assert0(size - pos == 2 + frag->nb_units * size_len);
568 
569  init_put_bits(&pbc, data + pos, size - pos);
570 
571  err = cbs_vp9_write_superframe_index(ctx, &pbc, &sfi);
572  if (err < 0) {
573  av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to write "
574  "superframe index.\n");
576  return err;
577  }
578 
579  av_assert0(put_bits_left(&pbc) == 0);
580  flush_put_bits(&pbc);
581 
582  frag->data_ref = ref;
583  frag->data = data;
584  frag->data_size = size;
585  }
586 
587  return 0;
588 }
589 
591 {
593 
594  memset(vp9->ref, 0, sizeof(vp9->ref));
595 }
596 
600 };
601 
604 
605  .priv_data_size = sizeof(CodedBitstreamVP9Context),
606 
607  .unit_types = cbs_vp9_unit_types,
608 
609  .split_fragment = &cbs_vp9_split_fragment,
610  .read_unit = &cbs_vp9_read_unit,
611  .write_unit = &cbs_vp9_write_unit,
612 
613  .flush = &cbs_vp9_flush,
614 
615  .assemble_fragment = &cbs_vp9_assemble_fragment,
616 };
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
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:694
AVERROR
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
CodedBitstreamUnit::content
void * content
Pointer to the decomposed form of this unit.
Definition: cbs.h:107
init_put_bits
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Definition: put_bits.h:62
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:266
put_bits
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:222
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
CodedBitstreamContext
Context structure for coded bitstream operations.
Definition: cbs.h:219
b
#define b
Definition: input.c:41
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
VP9RawSuperframeIndex::frame_sizes
uint32_t frame_sizes[VP9_MAX_FRAMES_IN_SUPERFRAME]
Definition: cbs_vp9.h:176
cbs.h
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
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
CodedBitstreamVP9Context::ref
VP9ReferenceFrameState ref[VP9_NUM_REF_FRAMES]
Definition: cbs_vp9.h:209
init_get_bits
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition: get_bits.h:514
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
CodedBitstreamUnit
Coded bitstream unit structure.
Definition: cbs.h:70
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:361
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:335
CBS_UNIT_TYPE_INTERNAL_REF
#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field)
Definition: cbs_internal.h:312
GetBitContext
Definition: get_bits.h:108
cbs_vp9_assemble_fragment
static int cbs_vp9_assemble_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Definition: cbs_vp9.c:500
put_bits_left
static int put_bits_left(PutBitContext *s)
Definition: put_bits.h:125
CodedBitstreamUnit::data
uint8_t * data
Pointer to the directly-parsable bitstream form of this unit.
Definition: cbs.h:81
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
VP9_SUPERFRAME_MARKER
@ VP9_SUPERFRAME_MARKER
Definition: cbs_vp9.h:79
CodedBitstreamFragment::units
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
Definition: cbs.h:168
ff_cbs_type_vp9
const CodedBitstreamType ff_cbs_type_vp9
Definition: cbs_vp9.c:602
avassert.h
CodedBitstreamUnitTypeDescriptor
Definition: cbs_internal.h:56
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
CodedBitstreamFragment
Coded bitstream fragment structure, combining one or more units.
Definition: cbs.h:122
width
#define width
cbs_vp9_syntax_template.c
CodedBitstreamFragment::data_size
size_t data_size
The number of bytes in the bitstream.
Definition: cbs.h:135
AV_CODEC_ID_VP9
@ AV_CODEC_ID_VP9
Definition: codec_id.h:220
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
cbs_vp9.h
ctx
AVFormatContext * ctx
Definition: movenc.c:48
ff_cbs_append_unit_data
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.
Definition: cbs.c:849
cbs_internal.h
CodedBitstreamType::codec_id
enum AVCodecID codec_id
Definition: cbs_internal.h:103
PutBitContext
Definition: put_bits.h:50
VP9RawSuperframeIndex::frames_in_superframe_minus_1
uint8_t frames_in_superframe_minus_1
Definition: cbs_vp9.h:175
CBS_TRACE_WRITE_END
#define CBS_TRACE_WRITE_END()
Definition: cbs_internal.h:254
frame
static AVFrame * frame
Definition: demux_decode.c:54
cbs_vp9_read_unit
static int cbs_vp9_read_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Definition: cbs_vp9.c:435
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
CBS_TRACE_READ_END_NO_SUBSCRIPTS
#define CBS_TRACE_READ_END_NO_SUBSCRIPTS()
Definition: cbs_internal.h:229
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:388
CodedBitstreamUnit::data_size
size_t data_size
The number of bytes in the bitstream (including any padding bits in the final byte).
Definition: cbs.h:86
VP9RawSuperframeIndex
Definition: cbs_vp9.h:172
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
VP9RawSuperframeIndex::bytes_per_framesize_minus_1
uint8_t bytes_per_framesize_minus_1
Definition: cbs_vp9.h:174
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
size
int size
Definition: twinvq_data.h:10344
CodedBitstreamFragment::data
uint8_t * data
Pointer to the bitstream form of this fragment.
Definition: cbs.h:128
header
static const uint8_t header[24]
Definition: sdr2.c:68
CodedBitstreamVP9Context
Definition: cbs_vp9.h:192
CodedBitstreamType
Definition: cbs_internal.h:102
av_buffer_alloc
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
Definition: buffer.c:77
CBS_TRACE_WRITE_END_NO_SUBSCRIPTS
#define CBS_TRACE_WRITE_END_NO_SUBSCRIPTS()
Definition: cbs_internal.h:266
CodedBitstreamUnit::data_ref
AVBufferRef * data_ref
A reference to the buffer containing data.
Definition: cbs.h:98
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
put_bits_count
static int put_bits_count(PutBitContext *s)
Definition: put_bits.h:80
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
len
int len
Definition: vorbis_enc_data.h:426
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
pos
unsigned int pos
Definition: spdifenc.c:413
ff_cbs_alloc_unit_content
int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Allocate a new internal content buffer matching the type of the unit.
Definition: cbs.c:922
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
SIZE_SPECIFIER
#define SIZE_SPECIFIER
Definition: internal.h:141
put_bits_ptr
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
Definition: put_bits.h:377
VP9RawSuperframeIndex::superframe_marker
uint8_t superframe_marker
Definition: cbs_vp9.h:173
skip_put_bytes
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
Definition: put_bits.h:386
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
flush_put_bits
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition: put_bits.h:143
int32_t
int32_t
Definition: audioconvert.c:56
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
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
CodedBitstreamFragment::data_ref
AVBufferRef * data_ref
A reference to the buffer containing data.
Definition: cbs.h:145
CBS_TRACE_READ_START
#define CBS_TRACE_READ_START()
Definition: cbs_internal.h:208
AVFormatContext::priv_data
void * priv_data
Format private data.
Definition: avformat.h:1283
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
CodedBitstreamFragment::nb_units
int nb_units
Number of units in this fragment.
Definition: cbs.h:153
CBS_TRACE_READ_END
#define CBS_TRACE_READ_END()
Definition: cbs_internal.h:216
CBS_TRACE_WRITE_START
#define CBS_TRACE_WRITE_START()
Definition: cbs_internal.h:246