FFmpeg
cbs_mpeg2.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_mpeg2.h"
24 #include "startcode.h"
25 
26 
27 #define HEADER(name) do { \
28  ff_cbs_trace_header(ctx, name); \
29  } while (0)
30 
31 #define CHECK(call) do { \
32  err = (call); \
33  if (err < 0) \
34  return err; \
35  } while (0)
36 
37 #define FUNC_NAME(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name
38 #define FUNC_MPEG2(rw, name) FUNC_NAME(rw, mpeg2, name)
39 #define FUNC(name) FUNC_MPEG2(READWRITE, name)
40 
41 #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
42 
43 #define ui(width, name) \
44  xui(width, name, current->name, 0, MAX_UINT_BITS(width), 0, )
45 #define uir(width, name) \
46  xui(width, name, current->name, 1, MAX_UINT_BITS(width), 0, )
47 #define uis(width, name, subs, ...) \
48  xui(width, name, current->name, 0, MAX_UINT_BITS(width), subs, __VA_ARGS__)
49 #define uirs(width, name, subs, ...) \
50  xui(width, name, current->name, 1, MAX_UINT_BITS(width), subs, __VA_ARGS__)
51 #define xui(width, name, var, range_min, range_max, subs, ...) \
52  xuia(width, #name, var, range_min, range_max, subs, __VA_ARGS__)
53 #define sis(width, name, subs, ...) \
54  xsi(width, name, current->name, subs, __VA_ARGS__)
55 
56 #define marker_bit() \
57  bit("marker_bit", 1)
58 #define bit(string, value) do { \
59  av_unused uint32_t bit = value; \
60  xuia(1, string, bit, value, value, 0, ); \
61  } while (0)
62 
63 
64 #define READ
65 #define READWRITE read
66 #define RWContext GetBitContext
67 
68 #define xuia(width, string, var, range_min, range_max, subs, ...) do { \
69  uint32_t value; \
70  CHECK(ff_cbs_read_unsigned(ctx, rw, width, string, \
71  SUBSCRIPTS(subs, __VA_ARGS__), \
72  &value, range_min, range_max)); \
73  var = value; \
74  } while (0)
75 
76 #define xsi(width, name, var, subs, ...) do { \
77  int32_t value; \
78  CHECK(ff_cbs_read_signed(ctx, rw, width, #name, \
79  SUBSCRIPTS(subs, __VA_ARGS__), &value, \
80  MIN_INT_BITS(width), \
81  MAX_INT_BITS(width))); \
82  var = value; \
83  } while (0)
84 
85 #define nextbits(width, compare, var) \
86  (get_bits_left(rw) >= width && \
87  (var = show_bits(rw, width)) == (compare))
88 
89 #define infer(name, value) do { \
90  current->name = value; \
91  } while (0)
92 
94 
95 #undef READ
96 #undef READWRITE
97 #undef RWContext
98 #undef xuia
99 #undef xsi
100 #undef nextbits
101 #undef infer
102 
103 
104 #define WRITE
105 #define READWRITE write
106 #define RWContext PutBitContext
107 
108 #define xuia(width, string, var, range_min, range_max, subs, ...) do { \
109  CHECK(ff_cbs_write_unsigned(ctx, rw, width, string, \
110  SUBSCRIPTS(subs, __VA_ARGS__), \
111  var, range_min, range_max)); \
112  } while (0)
113 
114 #define xsi(width, name, var, subs, ...) do { \
115  CHECK(ff_cbs_write_signed(ctx, rw, width, #name, \
116  SUBSCRIPTS(subs, __VA_ARGS__), var, \
117  MIN_INT_BITS(width), \
118  MAX_INT_BITS(width))); \
119  } while (0)
120 
121 #define nextbits(width, compare, var) (var)
122 
123 #define infer(name, value) do { \
124  if (current->name != (value)) { \
125  av_log(ctx->log_ctx, AV_LOG_WARNING, "Warning: " \
126  "%s does not match inferred value: " \
127  "%"PRId64", but should be %"PRId64".\n", \
128  #name, (int64_t)current->name, (int64_t)(value)); \
129  } \
130  } while (0)
131 
133 
134 #undef WRITE
135 #undef READWRITE
136 #undef RWContext
137 #undef xuia
138 #undef xsi
139 #undef nextbits
140 #undef infer
141 
142 
145  int header)
146 {
147  const uint8_t *start;
148  uint32_t start_code = -1;
149  int err;
150 
151  start = avpriv_find_start_code(frag->data, frag->data + frag->data_size,
152  &start_code);
153  if (start_code >> 8 != 0x000001) {
154  // No start code found.
155  return AVERROR_INVALIDDATA;
156  }
157 
158  do {
159  CodedBitstreamUnitType unit_type = start_code & 0xff;
160  const uint8_t *end;
161  size_t unit_size;
162 
163  // Reset start_code to ensure that avpriv_find_start_code()
164  // really reads a new start code and does not reuse the old
165  // start code in any way (as e.g. happens when there is a
166  // Sequence End unit at the very end of a packet).
167  start_code = UINT32_MAX;
168  end = avpriv_find_start_code(start--, frag->data + frag->data_size,
169  &start_code);
170 
171  // start points to the byte containing the start_code_identifier
172  // (may be the last byte of fragment->data); end points to the byte
173  // following the byte containing the start code identifier (or to
174  // the end of fragment->data).
175  if (start_code >> 8 == 0x000001) {
176  // Unit runs from start to the beginning of the start code
177  // pointed to by end (including any padding zeroes).
178  unit_size = (end - 4) - start;
179  } else {
180  // We didn't find a start code, so this is the final unit.
181  unit_size = end - start;
182  }
183 
184  err = ff_cbs_append_unit_data(frag, unit_type, (uint8_t*)start,
185  unit_size, frag->data_ref);
186  if (err < 0)
187  return err;
188 
189  start = end;
190 
191  // Do we have a further unit to add to the fragment?
192  } while ((start_code >> 8) == 0x000001);
193 
194  return 0;
195 }
196 
198  CodedBitstreamUnit *unit)
199 {
200  GetBitContext gbc;
201  int err;
202 
203  err = init_get_bits(&gbc, unit->data, 8 * unit->data_size);
204  if (err < 0)
205  return err;
206 
207  err = ff_cbs_alloc_unit_content(ctx, unit);
208  if (err < 0)
209  return err;
210 
211  if (MPEG2_START_IS_SLICE(unit->type)) {
212  MPEG2RawSlice *slice = unit->content;
213  int pos, len;
214 
215  err = cbs_mpeg2_read_slice_header(ctx, &gbc, &slice->header);
216  if (err < 0)
217  return err;
218 
219  if (!get_bits_left(&gbc))
220  return AVERROR_INVALIDDATA;
221 
222  pos = get_bits_count(&gbc);
223  len = unit->data_size;
224 
225  slice->data_size = len - pos / 8;
226  slice->data_ref = av_buffer_ref(unit->data_ref);
227  if (!slice->data_ref)
228  return AVERROR(ENOMEM);
229  slice->data = unit->data + pos / 8;
230 
231  slice->data_bit_start = pos % 8;
232 
233  } else {
234  switch (unit->type) {
235 #define START(start_code, type, read_func, free_func) \
236  case start_code: \
237  { \
238  type *header = unit->content; \
239  err = cbs_mpeg2_read_ ## read_func(ctx, &gbc, header); \
240  if (err < 0) \
241  return err; \
242  } \
243  break;
245  picture_header, &cbs_mpeg2_free_picture_header);
247  user_data, &cbs_mpeg2_free_user_data);
255  sequence_end, NULL);
256 #undef START
257  default:
258  return AVERROR(ENOSYS);
259  }
260  }
261 
262  return 0;
263 }
264 
266  CodedBitstreamUnit *unit,
267  PutBitContext *pbc)
268 {
269  int err;
270 
271  switch (unit->type) {
272 #define START(start_code, type, func) \
273  case start_code: \
274  err = cbs_mpeg2_write_ ## func(ctx, pbc, unit->content); \
275  break;
283 #undef START
284  default:
285  av_log(ctx->log_ctx, AV_LOG_ERROR, "Write unimplemented for start "
286  "code %02"PRIx32".\n", unit->type);
287  return AVERROR_PATCHWELCOME;
288  }
289 
290  return err;
291 }
292 
294  CodedBitstreamUnit *unit,
295  PutBitContext *pbc)
296 {
297  MPEG2RawSlice *slice = unit->content;
298  int err;
299 
300  err = cbs_mpeg2_write_slice_header(ctx, pbc, &slice->header);
301  if (err < 0)
302  return err;
303 
304  if (slice->data) {
305  size_t rest = slice->data_size - (slice->data_bit_start + 7) / 8;
306  uint8_t *pos = slice->data + slice->data_bit_start / 8;
307 
308  av_assert0(slice->data_bit_start >= 0 &&
309  slice->data_size > slice->data_bit_start / 8);
310 
311  if (slice->data_size * 8 + 8 > put_bits_left(pbc))
312  return AVERROR(ENOSPC);
313 
314  // First copy the remaining bits of the first byte
315  if (slice->data_bit_start % 8)
316  put_bits(pbc, 8 - slice->data_bit_start % 8,
317  *pos++ & MAX_UINT_BITS(8 - slice->data_bit_start % 8));
318 
319  if (put_bits_count(pbc) % 8 == 0) {
320  // If the writer is aligned at this point,
321  // memcpy can be used to improve performance.
322  // This is the normal case.
323  flush_put_bits(pbc);
324  memcpy(put_bits_ptr(pbc), pos, rest);
325  skip_put_bytes(pbc, rest);
326  } else {
327  // If not, we have to copy manually:
328  for (; rest > 3; rest -= 4, pos += 4)
329  put_bits32(pbc, AV_RB32(pos));
330 
331  for (; rest; rest--, pos++)
332  put_bits(pbc, 8, *pos);
333 
334  // Align with zeros
335  put_bits(pbc, 8 - put_bits_count(pbc) % 8, 0);
336  }
337  }
338 
339  return 0;
340 }
341 
343  CodedBitstreamUnit *unit,
344  PutBitContext *pbc)
345 {
346  if (MPEG2_START_IS_SLICE(unit->type))
347  return cbs_mpeg2_write_slice (ctx, unit, pbc);
348  else
349  return cbs_mpeg2_write_header(ctx, unit, pbc);
350 }
351 
354 {
355  uint8_t *data;
356  size_t size, dp;
357  int i;
358 
359  size = 0;
360  for (i = 0; i < frag->nb_units; i++)
361  size += 3 + frag->units[i].data_size;
362 
364  if (!frag->data_ref)
365  return AVERROR(ENOMEM);
366  data = frag->data_ref->data;
367 
368  dp = 0;
369  for (i = 0; i < frag->nb_units; i++) {
370  CodedBitstreamUnit *unit = &frag->units[i];
371 
372  data[dp++] = 0;
373  data[dp++] = 0;
374  data[dp++] = 1;
375 
376  memcpy(data + dp, unit->data, unit->data_size);
377  dp += unit->data_size;
378  }
379 
380  av_assert0(dp == size);
381 
382  memset(data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
383  frag->data = data;
384  frag->data_size = size;
385 
386  return 0;
387 }
388 
391  extra_information_picture.extra_information),
392 
393  {
394  .nb_unit_types = CBS_UNIT_TYPE_RANGE,
395  .unit_type.range.start = 0x01,
396  .unit_type.range.end = 0xaf,
397 
398  .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS,
399  .content_size = sizeof(MPEG2RawSlice),
400  .type.ref = { .nb_offsets = 2,
401  .offsets = { offsetof(MPEG2RawSlice, header.extra_information_slice.extra_information),
402  offsetof(MPEG2RawSlice, data) } },
403  },
404 
406  user_data),
407 
412 
414 };
415 
418 
419  .priv_data_size = sizeof(CodedBitstreamMPEG2Context),
420 
421  .unit_types = cbs_mpeg2_unit_types,
422 
423  .split_fragment = &cbs_mpeg2_split_fragment,
424  .read_unit = &cbs_mpeg2_read_unit,
425  .write_unit = &cbs_mpeg2_write_unit,
426  .assemble_fragment = &cbs_mpeg2_assemble_fragment,
427 };
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:664
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
put_bits32
static void av_unused put_bits32(PutBitContext *s, uint32_t value)
Write exactly 32 bits into a bitstream.
Definition: put_bits.h:291
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
MPEG2_START_GROUP
@ MPEG2_START_GROUP
Definition: cbs_mpeg2.h:37
CodedBitstreamUnit::content
void * content
Pointer to the decomposed form of this unit.
Definition: cbs.h:106
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:256
MPEG2RawPictureHeader
Definition: cbs_mpeg2.h:123
start_code
static const uint8_t start_code[]
Definition: videotoolboxenc.c:198
put_bits
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:221
CodedBitstreamContext
Context structure for coded bitstream operations.
Definition: cbs.h:173
data
const char data[16]
Definition: mxf.c:146
picture_header
static int FUNC() picture_header(CodedBitstreamContext *ctx, RWContext *rw, MPEG2RawPictureHeader *current)
Definition: cbs_mpeg2_syntax_template.c:210
CodedBitstreamUnit::type
CodedBitstreamUnitType type
Codec-specific type of this unit.
Definition: cbs.h:73
cbs.h
MPEG2RawExtensionData
Definition: cbs_mpeg2.h:177
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
MPEG2_START_SEQUENCE_HEADER
@ MPEG2_START_SEQUENCE_HEADER
Definition: cbs_mpeg2.h:33
MPEG2RawUserData
Definition: cbs_mpeg2.h:76
init_get_bits
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition: get_bits.h:493
CodedBitstreamUnit
Coded bitstream unit structure.
Definition: cbs.h:69
MPEG2RawSlice::data
uint8_t * data
Definition: cbs_mpeg2.h:209
cbs_mpeg2_syntax_template.c
MPEG2RawSlice
Definition: cbs_mpeg2.h:206
ff_cbs_type_mpeg2
const CodedBitstreamType ff_cbs_type_mpeg2
Definition: cbs_mpeg2.c:416
CBS_UNIT_TYPE_INTERNAL_REF
#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field)
Definition: cbs_internal.h:219
MPEG2RawGroupOfPicturesHeader
Definition: cbs_mpeg2.h:109
GetBitContext
Definition: get_bits.h:107
CBS_CONTENT_TYPE_INTERNAL_REFS
@ CBS_CONTENT_TYPE_INTERNAL_REFS
Definition: cbs_internal.h:37
put_bits_left
static int put_bits_left(PutBitContext *s)
Definition: put_bits.h:125
MPEG2_START_EXTENSION
@ MPEG2_START_EXTENSION
Definition: cbs_mpeg2.h:35
type
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 type
Definition: writing_filters.txt:86
CodedBitstreamUnit::data
uint8_t * data
Pointer to the directly-parsable bitstream form of this unit.
Definition: cbs.h:80
CodedBitstreamFragment::units
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
Definition: cbs.h:167
avassert.h
CodedBitstreamUnitTypeDescriptor
Definition: cbs_internal.h:55
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
extension_data
static int FUNC() extension_data(CodedBitstreamContext *ctx, RWContext *rw, H265RawExtensionData *current)
Definition: cbs_h265_syntax_template.c:61
CodedBitstreamFragment
Coded bitstream fragment structure, combining one or more units.
Definition: cbs.h:121
CodedBitstreamFragment::data_size
size_t data_size
The number of bytes in the bitstream.
Definition: cbs.h:134
MPEG2RawSlice::header
MPEG2RawSliceHeader header
Definition: cbs_mpeg2.h:207
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
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:813
cbs_internal.h
CodedBitstreamType::codec_id
enum AVCodecID codec_id
Definition: cbs_internal.h:102
MAX_UINT_BITS
#define MAX_UINT_BITS(length)
Definition: cbs_internal.h:184
PutBitContext
Definition: put_bits.h:50
CBS_UNIT_TYPE_RANGE
@ CBS_UNIT_TYPE_RANGE
Definition: cbs_internal.h:52
MPEG2_START_IS_SLICE
#define MPEG2_START_IS_SLICE(type)
Definition: cbs_mpeg2.h:40
NULL
#define NULL
Definition: coverity.c:32
cbs_mpeg2_write_unit
static int cbs_mpeg2_write_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
Definition: cbs_mpeg2.c:342
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
START
#define START(start_code, type, read_func, free_func)
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
avpriv_find_start_code
const uint8_t * avpriv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state)
cbs_mpeg2.h
cbs_mpeg2_write_slice
static int cbs_mpeg2_write_slice(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
Definition: cbs_mpeg2.c:293
cbs_mpeg2_split_fragment
static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
Definition: cbs_mpeg2.c:143
startcode.h
cbs_mpeg2_write_header
static int cbs_mpeg2_write_header(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
Definition: cbs_mpeg2.c:265
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
AV_RB32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
Definition: bytestream.h:96
user_data
static int FUNC() user_data(CodedBitstreamContext *ctx, RWContext *rw, MPEG2RawUserData *current)
Definition: cbs_mpeg2_syntax_template.c:59
header
static const uint8_t header[24]
Definition: sdr2.c:67
cbs_mpeg2_assemble_fragment
static int cbs_mpeg2_assemble_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Definition: cbs_mpeg2.c:352
CBS_UNIT_TYPE_POD
#define CBS_UNIT_TYPE_POD(type_, structure)
Definition: cbs_internal.h:195
CodedBitstreamType
Definition: cbs_internal.h:101
MPEG2RawSequenceEnd
Definition: cbs_mpeg2.h:215
MPEG2RawSequenceHeader
Definition: cbs_mpeg2.h:59
av_buffer_alloc
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
Definition: buffer.c:77
MPEG2_START_USER_DATA
@ MPEG2_START_USER_DATA
Definition: cbs_mpeg2.h:32
MPEG2RawSlice::data_bit_start
int data_bit_start
Definition: cbs_mpeg2.h:212
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
CodedBitstreamUnit::data_ref
AVBufferRef * data_ref
A reference to the buffer containing data.
Definition: cbs.h:97
put_bits_count
static int put_bits_count(PutBitContext *s)
Definition: put_bits.h:80
sequence_end
static int FUNC() sequence_end(CodedBitstreamContext *ctx, RWContext *rw, MPEG2RawSequenceEnd *current)
Definition: cbs_mpeg2_syntax_template.c:415
len
int len
Definition: vorbis_enc_data.h:426
CodedBitstreamMPEG2Context
Definition: cbs_mpeg2.h:220
CBS_UNIT_TYPE_END_OF_LIST
#define CBS_UNIT_TYPE_END_OF_LIST
Definition: cbs_internal.h:242
MPEG2_START_SEQUENCE_END
@ MPEG2_START_SEQUENCE_END
Definition: cbs_mpeg2.h:36
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:878
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
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
CodedBitstreamUnitType
uint32_t CodedBitstreamUnitType
The codec-specific type of a bitstream unit.
Definition: cbs.h:46
cbs_mpeg2_read_unit
static int cbs_mpeg2_read_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Definition: cbs_mpeg2.c:197
skip_put_bytes
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
Definition: put_bits.h:386
MPEG2RawSlice::data_ref
AVBufferRef * data_ref
Definition: cbs_mpeg2.h:210
flush_put_bits
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition: put_bits.h:143
cbs_mpeg2_unit_types
static const CodedBitstreamUnitTypeDescriptor cbs_mpeg2_unit_types[]
Definition: cbs_mpeg2.c:389
MPEG2_START_PICTURE
@ MPEG2_START_PICTURE
Definition: cbs_mpeg2.h:29
group_of_pictures_header
static int FUNC() group_of_pictures_header(CodedBitstreamContext *ctx, RWContext *rw, MPEG2RawGroupOfPicturesHeader *current)
Definition: cbs_mpeg2_syntax_template.c:160
sequence_header
static int FUNC() sequence_header(CodedBitstreamContext *ctx, RWContext *rw, MPEG2RawSequenceHeader *current)
Definition: cbs_mpeg2_syntax_template.c:19
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
CodedBitstreamFragment::data_ref
AVBufferRef * data_ref
A reference to the buffer containing data.
Definition: cbs.h:144
MPEG2RawSlice::data_size
size_t data_size
Definition: cbs_mpeg2.h:211
AV_CODEC_ID_MPEG2VIDEO
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
Definition: codec_id.h:54
CodedBitstreamFragment::nb_units
int nb_units
Number of units in this fragment.
Definition: cbs.h:152