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 position, sign;
32  int32_t value;
33 
34  if (ctx->trace_enable)
35  position = get_bits_count(gbc);
36 
37  if (get_bits_left(gbc) < width + 1) {
38  av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid signed value at "
39  "%s: bitstream ended.\n", name);
40  return AVERROR_INVALIDDATA;
41  }
42 
43  magnitude = get_bits(gbc, width);
44  sign = get_bits1(gbc);
45  value = sign ? -(int32_t)magnitude : magnitude;
46 
47  if (ctx->trace_enable) {
48  char bits[33];
49  int i;
50  for (i = 0; i < width; i++)
51  bits[i] = magnitude >> (width - i - 1) & 1 ? '1' : '0';
52  bits[i] = sign ? '1' : '0';
53  bits[i + 1] = 0;
54 
55  ff_cbs_trace_syntax_element(ctx, position, name, subscripts,
56  bits, value);
57  }
58 
59  *write_to = value;
60  return 0;
61 }
62 
64  int width, const char *name,
65  const int *subscripts, int32_t value)
66 {
67  uint32_t magnitude;
68  int sign;
69 
70  if (put_bits_left(pbc) < width + 1)
71  return AVERROR(ENOSPC);
72 
73  sign = value < 0;
74  magnitude = sign ? -value : value;
75 
76  if (ctx->trace_enable) {
77  char bits[33];
78  int i;
79  for (i = 0; i < width; i++)
80  bits[i] = magnitude >> (width - i - 1) & 1 ? '1' : '0';
81  bits[i] = sign ? '1' : '0';
82  bits[i + 1] = 0;
83 
85  name, subscripts, bits, value);
86  }
87 
88  put_bits(pbc, width, magnitude);
89  put_bits(pbc, 1, sign);
90 
91  return 0;
92 }
93 
95  uint32_t range_min, uint32_t range_max,
96  const char *name, uint32_t *write_to)
97 {
98  uint32_t value;
99  int position, i;
100  char bits[8];
101 
102  av_assert0(range_min <= range_max && range_max - range_min < sizeof(bits) - 1);
103  if (ctx->trace_enable)
104  position = get_bits_count(gbc);
105 
106  for (i = 0, value = range_min; value < range_max;) {
107  if (get_bits_left(gbc) < 1) {
108  av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid increment value at "
109  "%s: bitstream ended.\n", name);
110  return AVERROR_INVALIDDATA;
111  }
112  if (get_bits1(gbc)) {
113  bits[i++] = '1';
114  ++value;
115  } else {
116  bits[i++] = '0';
117  break;
118  }
119  }
120 
121  if (ctx->trace_enable) {
122  bits[i] = 0;
124  }
125 
126  *write_to = value;
127  return 0;
128 }
129 
131  uint32_t range_min, uint32_t range_max,
132  const char *name, uint32_t value)
133 {
134  int len;
135 
136  av_assert0(range_min <= range_max && range_max - range_min < 8);
137  if (value < range_min || value > range_max) {
138  av_log(ctx->log_ctx, AV_LOG_ERROR, "%s out of range: "
139  "%"PRIu32", but must be in [%"PRIu32",%"PRIu32"].\n",
140  name, value, range_min, range_max);
141  return AVERROR_INVALIDDATA;
142  }
143 
144  if (value == range_max)
145  len = range_max - range_min;
146  else
147  len = value - range_min + 1;
148  if (put_bits_left(pbc) < len)
149  return AVERROR(ENOSPC);
150 
151  if (ctx->trace_enable) {
152  char bits[8];
153  int i;
154  for (i = 0; i < len; i++) {
155  if (range_min + i == value)
156  bits[i] = '0';
157  else
158  bits[i] = '1';
159  }
160  bits[i] = 0;
162  name, NULL, bits, value);
163  }
164 
165  if (len > 0)
166  put_bits(pbc, len, (1 << len) - 1 - (value != range_max));
167 
168  return 0;
169 }
170 
172  int width, const char *name,
173  const int *subscripts, uint32_t *write_to)
174 {
175  uint32_t value;
176  int position, b;
177 
178  av_assert0(width % 8 == 0);
179 
180  if (ctx->trace_enable)
181  position = get_bits_count(gbc);
182 
183  if (get_bits_left(gbc) < width) {
184  av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid le value at "
185  "%s: bitstream ended.\n", name);
186  return AVERROR_INVALIDDATA;
187  }
188 
189  value = 0;
190  for (b = 0; b < width; b += 8)
191  value |= get_bits(gbc, 8) << b;
192 
193  if (ctx->trace_enable) {
194  char bits[33];
195  int i;
196  for (b = 0; b < width; b += 8)
197  for (i = 0; i < 8; i++)
198  bits[b + i] = value >> (b + i) & 1 ? '1' : '0';
199  bits[b] = 0;
200 
201  ff_cbs_trace_syntax_element(ctx, position, name, subscripts,
202  bits, value);
203  }
204 
205  *write_to = value;
206  return 0;
207 }
208 
210  int width, const char *name,
211  const int *subscripts, uint32_t value)
212 {
213  int b;
214 
215  av_assert0(width % 8 == 0);
216 
217  if (put_bits_left(pbc) < width)
218  return AVERROR(ENOSPC);
219 
220  if (ctx->trace_enable) {
221  char bits[33];
222  int i;
223  for (b = 0; b < width; b += 8)
224  for (i = 0; i < 8; i++)
225  bits[b + i] = value >> (b + i) & 1 ? '1' : '0';
226  bits[b] = 0;
227 
229  name, subscripts, bits, value);
230  }
231 
232  for (b = 0; b < width; b += 8)
233  put_bits(pbc, 8, value >> b & 0xff);
234 
235  return 0;
236 }
237 
238 #define HEADER(name) do { \
239  ff_cbs_trace_header(ctx, name); \
240  } while (0)
241 
242 #define CHECK(call) do { \
243  err = (call); \
244  if (err < 0) \
245  return err; \
246  } while (0)
247 
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)
251 
252 #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
253 
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__)
262 
263 #define READ
264 #define READWRITE read
265 #define RWContext GetBitContext
266 
267 #define xf(width, name, var, subs, ...) do { \
268  uint32_t value; \
269  CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \
270  SUBSCRIPTS(subs, __VA_ARGS__), \
271  &value, 0, (1 << width) - 1)); \
272  var = value; \
273  } while (0)
274 #define xs(width, name, var, subs, ...) do { \
275  int32_t value; \
276  CHECK(cbs_vp9_read_s(ctx, rw, width, #name, \
277  SUBSCRIPTS(subs, __VA_ARGS__), &value)); \
278  var = value; \
279  } while (0)
280 
281 
282 #define increment(name, min, max) do { \
283  uint32_t value; \
284  CHECK(cbs_vp9_read_increment(ctx, rw, min, max, #name, &value)); \
285  current->name = value; \
286  } while (0)
287 
288 #define fle(width, name, subs, ...) do { \
289  CHECK(cbs_vp9_read_le(ctx, rw, width, #name, \
290  SUBSCRIPTS(subs, __VA_ARGS__), &current->name)); \
291  } while (0)
292 
293 #define delta_q(name) do { \
294  uint8_t delta_coded; \
295  int8_t delta_q; \
296  xf(1, name.delta_coded, delta_coded, 0, ); \
297  if (delta_coded) \
298  xs(4, name.delta_q, delta_q, 0, ); \
299  else \
300  delta_q = 0; \
301  current->name = delta_q; \
302  } while (0)
303 
304 #define prob(name, subs, ...) do { \
305  uint8_t prob_coded; \
306  uint8_t prob; \
307  xf(1, name.prob_coded, prob_coded, subs, __VA_ARGS__); \
308  if (prob_coded) \
309  xf(8, name.prob, prob, subs, __VA_ARGS__); \
310  else \
311  prob = 255; \
312  current->name = prob; \
313  } while (0)
314 
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)); \
319  } while (0)
320 
321 #define infer(name, value) do { \
322  current->name = value; \
323  } while (0)
324 
325 #define byte_alignment(rw) (get_bits_count(rw) % 8)
326 
327 #include "cbs_vp9_syntax_template.c"
328 
329 #undef READ
330 #undef READWRITE
331 #undef RWContext
332 #undef xf
333 #undef xs
334 #undef increment
335 #undef fle
336 #undef delta_q
337 #undef prob
338 #undef fixed
339 #undef infer
340 #undef byte_alignment
341 
342 
343 #define WRITE
344 #define READWRITE write
345 #define RWContext PutBitContext
346 
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)); \
351  } while (0)
352 #define xs(width, name, var, subs, ...) do { \
353  CHECK(cbs_vp9_write_s(ctx, rw, width, #name, \
354  SUBSCRIPTS(subs, __VA_ARGS__), var)); \
355  } while (0)
356 
357 #define increment(name, min, max) do { \
358  CHECK(cbs_vp9_write_increment(ctx, rw, min, max, #name, current->name)); \
359  } while (0)
360 
361 #define fle(width, name, subs, ...) do { \
362  CHECK(cbs_vp9_write_le(ctx, rw, width, #name, \
363  SUBSCRIPTS(subs, __VA_ARGS__), current->name)); \
364  } while (0)
365 
366 #define delta_q(name) do { \
367  xf(1, name.delta_coded, !!current->name, 0, ); \
368  if (current->name) \
369  xs(4, name.delta_q, current->name, 0, ); \
370  } while (0)
371 
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__); \
376  } while (0)
377 
378 #define fixed(width, name, value) do { \
379  CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \
380  0, value, value, value)); \
381  } while (0)
382 
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)); \
389  } \
390  } while (0)
391 
392 #define byte_alignment(rw) (put_bits_count(rw) % 8)
393 
394 #include "cbs_vp9_syntax_template.c"
395 
396 #undef WRITE
397 #undef READWRITE
398 #undef RWContext
399 #undef xf
400 #undef xs
401 #undef increment
402 #undef fle
403 #undef delta_q
404 #undef prob
405 #undef fixed
406 #undef infer
407 #undef byte_alignment
408 
409 
412  int header)
413 {
414  uint8_t superframe_header;
415  int err;
416 
417  if (frag->data_size == 0)
418  return AVERROR_INVALIDDATA;
419 
420  // Last byte in the packet.
421  superframe_header = frag->data[frag->data_size - 1];
422 
423  if ((superframe_header & 0xe0) == 0xc0) {
425  GetBitContext gbc;
426  size_t index_size, pos;
427  int i;
428 
429  index_size = 2 + (((superframe_header & 0x18) >> 3) + 1) *
430  ((superframe_header & 0x07) + 1);
431 
432  if (index_size > frag->data_size)
433  return AVERROR_INVALIDDATA;
434 
435  err = init_get_bits(&gbc, frag->data + frag->data_size - index_size,
436  8 * index_size);
437  if (err < 0)
438  return err;
439 
440  err = cbs_vp9_read_superframe_index(ctx, &gbc, &sfi);
441  if (err < 0)
442  return err;
443 
444  pos = 0;
445  for (i = 0; i <= sfi.frames_in_superframe_minus_1; i++) {
446  if (pos + sfi.frame_sizes[i] + index_size > frag->data_size) {
447  av_log(ctx->log_ctx, AV_LOG_ERROR, "Frame %d too large "
448  "in superframe: %"PRIu32" bytes.\n",
449  i, sfi.frame_sizes[i]);
450  return AVERROR_INVALIDDATA;
451  }
452 
453  err = ff_cbs_append_unit_data(frag, 0,
454  frag->data + pos,
455  sfi.frame_sizes[i],
456  frag->data_ref);
457  if (err < 0)
458  return err;
459 
460  pos += sfi.frame_sizes[i];
461  }
462  if (pos + index_size != frag->data_size) {
463  av_log(ctx->log_ctx, AV_LOG_WARNING, "Extra padding at "
464  "end of superframe: %"SIZE_SPECIFIER" bytes.\n",
465  frag->data_size - (pos + index_size));
466  }
467 
468  return 0;
469 
470  } else {
471  err = ff_cbs_append_unit_data(frag, 0,
472  frag->data, frag->data_size,
473  frag->data_ref);
474  if (err < 0)
475  return err;
476  }
477 
478  return 0;
479 }
480 
482  CodedBitstreamUnit *unit)
483 {
485  GetBitContext gbc;
486  int err, pos;
487 
488  err = init_get_bits(&gbc, unit->data, 8 * unit->data_size);
489  if (err < 0)
490  return err;
491 
492  err = ff_cbs_alloc_unit_content(ctx, unit);
493  if (err < 0)
494  return err;
495  frame = unit->content;
496 
497  err = cbs_vp9_read_frame(ctx, &gbc, frame);
498  if (err < 0)
499  return err;
500 
501  pos = get_bits_count(&gbc);
502  av_assert0(pos % 8 == 0);
503  pos /= 8;
504  av_assert0(pos <= unit->data_size);
505 
506  if (pos == unit->data_size) {
507  // No data (e.g. a show-existing-frame frame).
508  } else {
509  frame->data_ref = av_buffer_ref(unit->data_ref);
510  if (!frame->data_ref)
511  return AVERROR(ENOMEM);
512 
513  frame->data = unit->data + pos;
514  frame->data_size = unit->data_size - pos;
515  }
516 
517  return 0;
518 }
519 
521  CodedBitstreamUnit *unit,
522  PutBitContext *pbc)
523 {
524  VP9RawFrame *frame = unit->content;
525  int err;
526 
527  err = cbs_vp9_write_frame(ctx, pbc, frame);
528  if (err < 0)
529  return err;
530 
531  // Frame must be byte-aligned.
532  av_assert0(put_bits_count(pbc) % 8 == 0);
533 
534  if (frame->data) {
535  if (frame->data_size > put_bits_left(pbc) / 8)
536  return AVERROR(ENOSPC);
537 
538  flush_put_bits(pbc);
539  memcpy(put_bits_ptr(pbc), frame->data, frame->data_size);
540  skip_put_bytes(pbc, frame->data_size);
541  }
542 
543  return 0;
544 }
545 
548 {
549  int err;
550 
551  if (frag->nb_units == 1) {
552  // Output is just the content of the single frame.
553 
554  CodedBitstreamUnit *frame = &frag->units[0];
555 
556  frag->data_ref = av_buffer_ref(frame->data_ref);
557  if (!frag->data_ref)
558  return AVERROR(ENOMEM);
559 
560  frag->data = frame->data;
561  frag->data_size = frame->data_size;
562 
563  } else {
564  // Build superframe out of frames.
565 
567  PutBitContext pbc;
568  AVBufferRef *ref;
569  uint8_t *data;
570  size_t size, max, pos;
571  int i, size_len;
572 
573  if (frag->nb_units > 8) {
574  av_log(ctx->log_ctx, AV_LOG_ERROR, "Too many frames to "
575  "make superframe: %d.\n", frag->nb_units);
576  return AVERROR(EINVAL);
577  }
578 
579  max = 0;
580  for (i = 0; i < frag->nb_units; i++)
581  if (max < frag->units[i].data_size)
582  max = frag->units[i].data_size;
583 
584  if (max < 2)
585  size_len = 1;
586  else
587  size_len = av_log2(max) / 8 + 1;
588  av_assert0(size_len <= 4);
589 
591  sfi.bytes_per_framesize_minus_1 = size_len - 1;
592  sfi.frames_in_superframe_minus_1 = frag->nb_units - 1;
593 
594  size = 2;
595  for (i = 0; i < frag->nb_units; i++) {
596  size += size_len + frag->units[i].data_size;
597  sfi.frame_sizes[i] = frag->units[i].data_size;
598  }
599 
601  if (!ref)
602  return AVERROR(ENOMEM);
603  data = ref->data;
604  memset(data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
605 
606  pos = 0;
607  for (i = 0; i < frag->nb_units; i++) {
608  av_assert0(size - pos > frag->units[i].data_size);
609  memcpy(data + pos, frag->units[i].data,
610  frag->units[i].data_size);
611  pos += frag->units[i].data_size;
612  }
613  av_assert0(size - pos == 2 + frag->nb_units * size_len);
614 
615  init_put_bits(&pbc, data + pos, size - pos);
616 
617  err = cbs_vp9_write_superframe_index(ctx, &pbc, &sfi);
618  if (err < 0) {
619  av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to write "
620  "superframe index.\n");
622  return err;
623  }
624 
625  av_assert0(put_bits_left(&pbc) == 0);
626  flush_put_bits(&pbc);
627 
628  frag->data_ref = ref;
629  frag->data = data;
630  frag->data_size = size;
631  }
632 
633  return 0;
634 }
635 
637 {
639 
640  memset(vp9->ref, 0, sizeof(vp9->ref));
641 }
642 
646 };
647 
650 
651  .priv_data_size = sizeof(CodedBitstreamVP9Context),
652 
653  .unit_types = cbs_vp9_unit_types,
654 
655  .split_fragment = &cbs_vp9_split_fragment,
656  .read_unit = &cbs_vp9_read_unit,
657  .write_unit = &cbs_vp9_write_unit,
658 
659  .flush = &cbs_vp9_flush,
660 
661  .assemble_fragment = &cbs_vp9_assemble_fragment,
662 };
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:839
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:106
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:219
put_bits
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:221
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
CodedBitstreamContext
Context structure for coded bitstream operations.
Definition: cbs.h:173
b
#define b
Definition: input.c:34
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
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:636
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:649
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
CodedBitstreamUnit
Coded bitstream unit structure.
Definition: cbs.h:69
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:379
CBS_UNIT_TYPE_INTERNAL_REF
#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field)
Definition: cbs_internal.h:216
GetBitContext
Definition: get_bits.h:61
cbs_vp9_assemble_fragment
static int cbs_vp9_assemble_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Definition: cbs_vp9.c:546
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:80
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
CodedBitstreamFragment::units
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
Definition: cbs.h:167
ff_cbs_type_vp9
const CodedBitstreamType ff_cbs_type_vp9
Definition: cbs_vp9.c:648
avassert.h
CodedBitstreamUnitTypeDescriptor
Definition: cbs_internal.h:57
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:121
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:134
AV_CODEC_ID_VP9
@ AV_CODEC_ID_VP9
Definition: codec_id.h:218
bits
uint8_t bits
Definition: vp3data.h:141
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
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:809
cbs_internal.h
VP9_SUPERFRAME_MARKER
@ VP9_SUPERFRAME_MARKER
Definition: cbs_vp9.h:79
CodedBitstreamType::codec_id
enum AVCodecID codec_id
Definition: cbs_internal.h:101
PutBitContext
Definition: put_bits.h:50
VP9RawSuperframeIndex::frames_in_superframe_minus_1
uint8_t frames_in_superframe_minus_1
Definition: cbs_vp9.h:175
flush
static void flush(AVCodecContext *avctx)
Definition: aacdec_template.c:606
NULL
#define NULL
Definition: coverity.c:32
cbs_vp9_read_unit
static int cbs_vp9_read_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Definition: cbs_vp9.c:481
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
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:498
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:85
VP9RawSuperframeIndex
Definition: cbs_vp9.h:172
cbs_vp9_write_unit
static int cbs_vp9_write_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
Definition: cbs_vp9.c:520
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:94
size
int size
Definition: twinvq_data.h:10344
CodedBitstreamFragment::data
uint8_t * data
Pointer to the bitstream form of this fragment.
Definition: cbs.h:127
header
static const uint8_t header[24]
Definition: sdr2.c:67
CodedBitstreamVP9Context
Definition: cbs_vp9.h:192
CodedBitstreamType
Definition: cbs_internal.h:100
av_buffer_alloc
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
Definition: buffer.c:77
ff_cbs_trace_syntax_element
void ff_cbs_trace_syntax_element(CodedBitstreamContext *ctx, int position, const char *str, const int *subscripts, const char *bits, int64_t value)
Definition: cbs.c:489
CodedBitstreamUnit::data_ref
AVBufferRef * data_ref
A reference to the buffer containing data.
Definition: cbs.h:97
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
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:239
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
frame
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
Definition: filter_design.txt:264
pos
unsigned int pos
Definition: spdifenc.c:412
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:876
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
SIZE_SPECIFIER
#define SIZE_SPECIFIER
Definition: internal.h:195
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:370
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:379
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:63
CodedBitstreamFragment::data_ref
AVBufferRef * data_ref
A reference to the buffer containing data.
Definition: cbs.h:144
AVFormatContext::priv_data
void * priv_data
Format private data.
Definition: avformat.h:1241
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:152