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