FFmpeg
brstm.c
Go to the documentation of this file.
1 /*
2  * BRSTM demuxer
3  * Copyright (c) 2012 Paul B Mahol
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "libavutil/intreadwrite.h"
23 #include "libavutil/mem.h"
24 #include "libavcodec/bytestream.h"
25 #include "avformat.h"
26 #include "demux.h"
27 #include "internal.h"
28 
29 typedef struct BRSTMCoeffOffset {
30  uint8_t channel;
31  uint32_t offset;
33 
34 typedef struct BRSTMDemuxContext {
35  uint32_t block_size;
36  uint32_t block_count;
37  uint32_t current_block;
40  uint32_t last_block_size;
42  uint32_t data_start;
43  uint8_t table[256 * 32];
44  uint8_t *adpc;
48 
49 static int probe(const AVProbeData *p)
50 {
51  if (AV_RL32(p->buf) == MKTAG('R','S','T','M') &&
52  (AV_RL16(p->buf + 4) == 0xFFFE ||
53  AV_RL16(p->buf + 4) == 0xFEFF))
54  return AVPROBE_SCORE_MAX / 3 * 2;
55  return 0;
56 }
57 
58 static int probe_bfstm(const AVProbeData *p)
59 {
60  if ((AV_RL32(p->buf) == MKTAG('F','S','T','M') ||
61  AV_RL32(p->buf) == MKTAG('C','S','T','M')) &&
62  (AV_RL16(p->buf + 4) == 0xFFFE ||
63  AV_RL16(p->buf + 4) == 0xFEFF))
64  return AVPROBE_SCORE_MAX / 3 * 2;
65  return 0;
66 }
67 
69 {
70  BRSTMDemuxContext *b = s->priv_data;
71 
72  av_freep(&b->adpc);
73 
74  return 0;
75 }
76 
77 static int sort_offsets(const void *a, const void *b)
78 {
79  const BRSTMCoeffOffset *s1 = a;
80  const BRSTMCoeffOffset *s2 = b;
81  return FFDIFFSIGN(s1->offset, s2->offset);
82 }
83 
85 {
86  BRSTMDemuxContext *b = s->priv_data;
87  if (b->little_endian)
88  return avio_rl16(s->pb);
89  else
90  return avio_rb16(s->pb);
91 }
92 
94 {
95  BRSTMDemuxContext *b = s->priv_data;
96  if (b->little_endian)
97  return avio_rl32(s->pb);
98  else
99  return avio_rb32(s->pb);
100 }
101 
103 {
104  BRSTMDemuxContext *b = s->priv_data;
105  int bom, major, minor, codec, chunk;
106  int64_t h1offset, pos, toffset;
107  uint32_t size, asize, start = 0;
108  AVStream *st;
109  int loop = 0;
110  int bfstm = !strcmp("bfstm", s->iformat->name);
111 
112  st = avformat_new_stream(s, NULL);
113  if (!st)
114  return AVERROR(ENOMEM);
116 
117  avio_skip(s->pb, 4);
118 
119  bom = avio_rb16(s->pb);
120  if (bom != 0xFEFF && bom != 0xFFFE) {
121  av_log(s, AV_LOG_ERROR, "invalid byte order: %X\n", bom);
122  return AVERROR_INVALIDDATA;
123  }
124 
125  if (bom == 0xFFFE)
126  b->little_endian = 1;
127 
128  if (!bfstm) {
129  major = avio_r8(s->pb);
130  minor = avio_r8(s->pb);
131  avio_skip(s->pb, 4); // size of file
132  size = read16(s);
133  if (size < 14)
134  return AVERROR_INVALIDDATA;
135 
136  avio_skip(s->pb, size - 14);
137  pos = avio_tell(s->pb);
138  if (avio_rl32(s->pb) != MKTAG('H','E','A','D'))
139  return AVERROR_INVALIDDATA;
140  } else {
141  uint32_t info_offset = 0;
142  uint16_t section_count, header_size, i;
143 
144  header_size = read16(s); // 6
145 
146  avio_skip(s->pb, 4); // Unknown constant 0x00030000
147  avio_skip(s->pb, 4); // size of file
148  section_count = read16(s);
149  avio_skip(s->pb, 2); // padding
150  for (i = 0; avio_tell(s->pb) < header_size
151  && !(start && info_offset)
152  && i < section_count; i++) {
153  uint16_t flag = read16(s);
154  avio_skip(s->pb, 2);
155  switch (flag) {
156  case 0x4000:
157  info_offset = read32(s);
158  /*info_size =*/ read32(s);
159  break;
160  case 0x4001:
161  avio_skip(s->pb, 4); // seek offset
162  avio_skip(s->pb, 4); // seek size
163  break;
164  case 0x4002:
165  start = read32(s) + 8;
166  avio_skip(s->pb, 4); //data_size = read32(s);
167  break;
168  case 0x4003:
169  avio_skip(s->pb, 4); // REGN offset
170  avio_skip(s->pb, 4); // REGN size
171  break;
172  }
173  }
174 
175  if (!info_offset || !start)
176  return AVERROR_INVALIDDATA;
177 
178  avio_skip(s->pb, info_offset - avio_tell(s->pb));
179  pos = avio_tell(s->pb);
180  if (avio_rl32(s->pb) != MKTAG('I','N','F','O'))
181  return AVERROR_INVALIDDATA;
182  }
183 
184  size = read32(s);
185  if (size < 40)
186  return AVERROR_INVALIDDATA;
187  avio_skip(s->pb, 4); // unknown
188  h1offset = read32(s);
189  if (h1offset > size)
190  return AVERROR_INVALIDDATA;
191  avio_skip(s->pb, 12);
192  toffset = read32(s) + 16LL;
193  if (toffset > size)
194  return AVERROR_INVALIDDATA;
195 
196  avio_skip(s->pb, pos + h1offset + 8 - avio_tell(s->pb));
197  codec = avio_r8(s->pb);
198 
199  switch (codec) {
200  case 0: codec = AV_CODEC_ID_PCM_S8_PLANAR; break;
201  case 1: codec = b->little_endian ?
204  case 2: codec = b->little_endian ?
206  AV_CODEC_ID_ADPCM_THP; break;
207  default:
208  avpriv_request_sample(s, "codec %d", codec);
209  return AVERROR_PATCHWELCOME;
210  }
211 
212  loop = avio_r8(s->pb); // loop flag
213  st->codecpar->codec_id = codec;
214  st->codecpar->ch_layout.nb_channels = avio_r8(s->pb);
215  if (!st->codecpar->ch_layout.nb_channels)
216  return AVERROR_INVALIDDATA;
217 
218  avio_skip(s->pb, 1); // padding
219 
220  st->codecpar->sample_rate = bfstm ? read32(s) : read16(s);
221  if (st->codecpar->sample_rate <= 0)
222  return AVERROR_INVALIDDATA;
223 
224  if (!bfstm)
225  avio_skip(s->pb, 2); // padding
226 
227  if (loop) {
228  if (av_dict_set_int(&s->metadata, "loop_start",
230  st->codecpar->sample_rate),
231  0) < 0)
232  return AVERROR(ENOMEM);
233  } else {
234  avio_skip(s->pb, 4);
235  }
236 
237  st->start_time = 0;
238  st->duration = read32(s);
239  avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
240 
241  if (!bfstm)
242  start = read32(s);
243  b->current_block = 0;
244  b->block_count = read32(s);
245  if (b->block_count > UINT16_MAX) {
246  av_log(s, AV_LOG_WARNING, "too many blocks: %"PRIu32"\n", b->block_count);
247  return AVERROR_INVALIDDATA;
248  }
249 
250  b->block_size = read32(s);
251  if (b->block_size > UINT32_MAX / st->codecpar->ch_layout.nb_channels)
252  return AVERROR_INVALIDDATA;
253 
254  b->samples_per_block = read32(s);
255  b->last_block_used_bytes = read32(s);
256  b->last_block_samples = read32(s);
257  b->last_block_size = read32(s);
258  if (b->last_block_size > UINT32_MAX / st->codecpar->ch_layout.nb_channels)
259  return AVERROR_INVALIDDATA;
260  if (b->last_block_used_bytes > b->last_block_size)
261  return AVERROR_INVALIDDATA;
262 
263 
264  if (codec == AV_CODEC_ID_ADPCM_THP || codec == AV_CODEC_ID_ADPCM_THP_LE) {
265  int ch;
266 
267  avio_skip(s->pb, pos + toffset - avio_tell(s->pb));
268  if (!bfstm)
269  toffset = read32(s) + 16LL;
270  else
271  toffset = toffset + read32(s) + st->codecpar->ch_layout.nb_channels * 8 - 8;
272  if (toffset > size)
273  return AVERROR_INVALIDDATA;
274 
275  if (!bfstm) {
276  avio_skip(s->pb, pos + toffset - avio_tell(s->pb) - 8LL * (st->codecpar->ch_layout.nb_channels + 1));
277  for (ch = 0; ch < st->codecpar->ch_layout.nb_channels; ch++) {
278  avio_skip(s->pb, 4);
279  b->offsets[ch].channel = ch;
280  b->offsets[ch].offset = read32(s);
281  }
282 
283  qsort(b->offsets, st->codecpar->ch_layout.nb_channels, sizeof(*b->offsets), sort_offsets);
284  }
285 
286  avio_skip(s->pb, pos + toffset - avio_tell(s->pb));
287 
288  for (ch = 0; ch < st->codecpar->ch_layout.nb_channels; ch++) {
289  if (!bfstm)
290  avio_skip(s->pb, pos + 16LL + b->offsets[ch].offset - avio_tell(s->pb));
291 
292  if (avio_read(s->pb, b->table + ch * 32, 32) != 32)
293  return AVERROR_INVALIDDATA;
294 
295  if (bfstm)
296  avio_skip(s->pb, 14);
297  }
298  }
299 
300  if (size < (avio_tell(s->pb) - pos))
301  return AVERROR_INVALIDDATA;
302 
303  avio_skip(s->pb, size - (avio_tell(s->pb) - pos));
304 
305  while (!avio_feof(s->pb)) {
306  chunk = avio_rl32(s->pb);
307  size = read32(s);
308  if (size < 8)
309  return AVERROR_INVALIDDATA;
310  size -= 8;
311  switch (chunk) {
312  case MKTAG('S','E','E','K'):
313  case MKTAG('A','D','P','C'):
314  if (codec != AV_CODEC_ID_ADPCM_THP &&
315  codec != AV_CODEC_ID_ADPCM_THP_LE)
316  goto skip;
317 
318  asize = b->block_count * st->codecpar->ch_layout.nb_channels * 4;
319  if (size < asize)
320  return AVERROR_INVALIDDATA;
321  if (b->adpc) {
322  av_log(s, AV_LOG_WARNING, "skipping additional ADPC chunk\n");
323  goto skip;
324  } else {
325  b->adpc = av_mallocz(asize);
326  if (!b->adpc)
327  return AVERROR(ENOMEM);
328  if (bfstm && codec != AV_CODEC_ID_ADPCM_THP_LE) {
329  // Big-endian BFSTMs have little-endian SEEK tables
330  // for some strange reason.
331  int i;
332  for (i = 0; i < asize; i += 2) {
333  b->adpc[i+1] = avio_r8(s->pb);
334  b->adpc[i] = avio_r8(s->pb);
335  }
336  } else {
337  avio_read(s->pb, b->adpc, asize);
338  }
339  avio_skip(s->pb, size - asize);
340  }
341  break;
342  case MKTAG('D','A','T','A'):
343  if ((start < avio_tell(s->pb)) ||
344  (!b->adpc && (codec == AV_CODEC_ID_ADPCM_THP ||
345  codec == AV_CODEC_ID_ADPCM_THP_LE)))
346  return AVERROR_INVALIDDATA;
347  avio_skip(s->pb, start - avio_tell(s->pb));
348 
349  if (bfstm && (codec == AV_CODEC_ID_ADPCM_THP ||
350  codec == AV_CODEC_ID_ADPCM_THP_LE))
351  avio_skip(s->pb, 24);
352 
353  b->data_start = avio_tell(s->pb);
354 
355  if (!bfstm && (major != 1 || minor))
356  avpriv_request_sample(s, "Version %d.%d", major, minor);
357 
358  return 0;
359  default:
360  av_log(s, AV_LOG_WARNING, "skipping unknown chunk: %X\n", chunk);
361 skip:
362  avio_skip(s->pb, size);
363  }
364  }
365 
366  return AVERROR_EOF;
367 }
368 
370 {
371  AVCodecParameters *par = s->streams[0]->codecpar;
372  BRSTMDemuxContext *b = s->priv_data;
373  uint32_t samples, size, skip = 0;
374  int channels = par->ch_layout.nb_channels;
375  int ret, i;
376 
377  if (avio_feof(s->pb))
378  return AVERROR_EOF;
379  b->current_block++;
380  if (b->current_block == b->block_count) {
381  size = b->last_block_used_bytes;
382  samples = b->last_block_samples;
383  skip = b->last_block_size - b->last_block_used_bytes;
384 
385  if (samples < size * 14 / 8) {
386  uint32_t adjusted_size = samples / 14 * 8;
387  if (samples % 14)
388  adjusted_size += (samples % 14 + 1) / 2 + 1;
389 
390  skip += size - adjusted_size;
391  size = adjusted_size;
392  }
393  } else if (b->current_block < b->block_count) {
394  size = b->block_size;
395  samples = b->samples_per_block;
396  } else {
397  return AVERROR_EOF;
398  }
399 
400  if (par->codec_id == AV_CODEC_ID_ADPCM_THP ||
402  uint8_t *dst;
403 
404  if (!b->adpc) {
405  av_log(s, AV_LOG_ERROR, "adpcm_thp requires ADPC chunk, but none was found.\n");
406  return AVERROR_INVALIDDATA;
407  }
408 
409  if (size > (INT_MAX - 32 - 4) ||
410  (32 + 4 + size) > (INT_MAX / channels) ||
411  (32 + 4 + size) * channels > INT_MAX - 8)
412  return AVERROR_INVALIDDATA;
413  if ((ret = av_new_packet(pkt, 8 + (32 + 4 + size) * channels)) < 0)
414  return ret;
415  dst = pkt->data;
416  if (par->codec_id == AV_CODEC_ID_ADPCM_THP_LE) {
417  bytestream_put_le32(&dst, size * channels);
418  bytestream_put_le32(&dst, samples);
419  } else {
420  bytestream_put_be32(&dst, size * channels);
421  bytestream_put_be32(&dst, samples);
422  }
423  bytestream_put_buffer(&dst, b->table, 32 * channels);
424  bytestream_put_buffer(&dst, b->adpc + 4 * channels *
425  (b->current_block - 1), 4 * channels);
426 
427  for (i = 0; i < channels; i++) {
428  ret = avio_read(s->pb, dst, size);
429  dst += size;
430  avio_skip(s->pb, skip);
431  if (ret != size) {
432  return AVERROR(EIO);
433  }
434  }
435  pkt->duration = samples;
436  } else {
437  size *= channels;
438  ret = av_get_packet(s->pb, pkt, size);
439  }
440 
441  pkt->stream_index = 0;
442 
443  if (ret != size)
444  ret = AVERROR(EIO);
445 
446  return ret;
447 }
448 
449 static int read_seek(AVFormatContext *s, int stream_index,
450  int64_t timestamp, int flags)
451 {
452  AVStream *st = s->streams[stream_index];
453  BRSTMDemuxContext *b = s->priv_data;
454  int64_t ret = 0;
455 
456  if (timestamp < 0)
457  timestamp = 0;
458  timestamp /= b->samples_per_block;
459  if (timestamp >= b->block_count)
460  timestamp = b->block_count - 1;
461  ret = avio_seek(s->pb, b->data_start + timestamp * b->block_size *
462  st->codecpar->ch_layout.nb_channels, SEEK_SET);
463  if (ret < 0)
464  return ret;
465 
466  b->current_block = timestamp;
467  avpriv_update_cur_dts(s, st, timestamp * b->samples_per_block);
468  return 0;
469 }
470 
472  .p.name = "brstm",
473  .p.long_name = NULL_IF_CONFIG_SMALL("BRSTM (Binary Revolution Stream)"),
474  .p.extensions = "brstm",
475  .priv_data_size = sizeof(BRSTMDemuxContext),
476  .flags_internal = FF_INFMT_FLAG_INIT_CLEANUP,
477  .read_probe = probe,
481  .read_seek = read_seek,
482 };
483 
485  .p.name = "bfstm",
486  .p.long_name = NULL_IF_CONFIG_SMALL("BFSTM (Binary Cafe Stream)"),
487  .p.extensions = "bfstm,bcstm",
488  .priv_data_size = sizeof(BRSTMDemuxContext),
489  .flags_internal = FF_INFMT_FLAG_INIT_CLEANUP,
494  .read_seek = read_seek,
495 };
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:215
sort_offsets
static int sort_offsets(const void *a, const void *b)
Definition: brstm.c:77
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
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:51
read_seek
static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition: brstm.c:449
BRSTMDemuxContext::last_block_used_bytes
uint32_t last_block_used_bytes
Definition: brstm.c:39
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:47
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
int64_t
long long int64_t
Definition: coverity.c:34
AVPacket::data
uint8_t * data
Definition: packet.h:539
AV_CODEC_ID_PCM_S16BE_PLANAR
@ AV_CODEC_ID_PCM_S16BE_PLANAR
Definition: codec_id.h:364
b
#define b
Definition: input.c:41
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:557
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:321
BRSTMDemuxContext::last_block_size
uint32_t last_block_size
Definition: brstm.c:40
BRSTMDemuxContext::last_block_samples
uint32_t last_block_samples
Definition: brstm.c:41
avpriv_update_cur_dts
void avpriv_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp)
Update cur_dts of all streams based on the given timestamp and AVStream.
Definition: seek.c:37
AV_CODEC_ID_PCM_S16LE_PLANAR
@ AV_CODEC_ID_PCM_S16LE_PLANAR
Definition: codec_id.h:352
AV_CODEC_ID_ADPCM_THP_LE
@ AV_CODEC_ID_ADPCM_THP_LE
Definition: codec_id.h:409
AVPROBE_SCORE_MAX
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:463
avpriv_set_pts_info
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: avformat.c:867
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:494
BRSTMCoeffOffset::offset
uint32_t offset
Definition: brstm.c:31
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:807
loop
static int loop
Definition: ffplay.c:335
avio_rl16
unsigned int avio_rl16(AVIOContext *s)
Definition: aviobuf.c:714
BRSTMDemuxContext::block_size
uint32_t block_size
Definition: brstm.c:35
BRSTMCoeffOffset
Definition: brstm.c:29
FFDIFFSIGN
#define FFDIFFSIGN(x, y)
Comparator.
Definition: macros.h:45
BRSTMDemuxContext::current_block
uint32_t current_block
Definition: brstm.c:37
avio_rb32
unsigned int avio_rb32(AVIOContext *s)
Definition: aviobuf.c:761
pkt
AVPacket * pkt
Definition: movenc.c:60
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
av_new_packet
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: packet.c:98
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:553
AVProbeData::buf
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:453
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
channels
channels
Definition: aptx.h:31
AV_RL16
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
Definition: bytestream.h:94
read_close
static int read_close(AVFormatContext *s)
Definition: brstm.c:68
FF_INFMT_FLAG_INIT_CLEANUP
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
Definition: demux.h:35
AVFormatContext
Format I/O context.
Definition: avformat.h:1300
internal.h
ff_brstm_demuxer
const FFInputFormat ff_brstm_demuxer
Definition: brstm.c:471
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:771
NULL
#define NULL
Definition: coverity.c:32
BRSTMDemuxContext::adpc
uint8_t * adpc
Definition: brstm.c:44
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
ff_bfstm_demuxer
const FFInputFormat ff_bfstm_demuxer
Definition: brstm.c:484
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:451
AVCodecParameters::ch_layout
AVChannelLayout ch_layout
Audio only.
Definition: codec_par.h:180
BRSTMDemuxContext::samples_per_block
uint32_t samples_per_block
Definition: brstm.c:38
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:184
avio_rl32
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:730
BRSTMCoeffOffset::channel
uint8_t channel
Definition: brstm.c:30
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
size
int size
Definition: twinvq_data.h:10344
FFInputFormat::p
AVInputFormat p
The public AVInputFormat.
Definition: demux.h:46
avio_r8
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:603
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
flag
#define flag(name)
Definition: cbs_av1.c:474
bytestream_put_buffer
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
Definition: bytestream.h:372
BRSTMDemuxContext::block_count
uint32_t block_count
Definition: brstm.c:36
BRSTMDemuxContext
Definition: brstm.c:34
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
BRSTMDemuxContext::table
uint8_t table[256 *32]
Definition: brstm.c:43
AV_TIME_BASE
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:254
BRSTMDemuxContext::offsets
BRSTMCoeffOffset offsets[256]
Definition: brstm.c:45
av_always_inline
#define av_always_inline
Definition: attributes.h:49
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:256
demux.h
av_rescale
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:129
BRSTMDemuxContext::data_start
uint32_t data_start
Definition: brstm.c:42
av_get_packet
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
Allocate and read the payload of a packet and initialize its fields with default values.
Definition: utils.c:91
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:748
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:231
avio_rb16
unsigned int avio_rb16(AVIOContext *s)
Definition: aviobuf.c:746
pos
unsigned int pos
Definition: spdifenc.c:414
avformat.h
read32
static av_always_inline unsigned int read32(AVFormatContext *s)
Definition: brstm.c:93
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
probe
static int probe(const AVProbeData *p)
Definition: brstm.c:49
probe_bfstm
static int probe_bfstm(const AVProbeData *p)
Definition: brstm.c:58
BRSTMDemuxContext::little_endian
int little_endian
Definition: brstm.c:46
read_packet
static int read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: brstm.c:369
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:612
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
AVPacket::stream_index
int stream_index
Definition: packet.h:541
avio_skip
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:318
av_dict_set_int
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set() that converts the value to a string and stores it.
Definition: dict.c:167
AV_CODEC_ID_ADPCM_THP
@ AV_CODEC_ID_ADPCM_THP
Definition: codec_id.h:391
read_probe
static int read_probe(const AVProbeData *p)
Definition: cdg.c:30
mem.h
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:36
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:55
AVPacket
This structure stores compressed data.
Definition: packet.h:516
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
FFInputFormat
Definition: demux.h:42
AV_CODEC_ID_PCM_S8_PLANAR
@ AV_CODEC_ID_PCM_S8_PLANAR
Definition: codec_id.h:361
bytestream.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
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
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
AVStream::start_time
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
Definition: avformat.h:797
read_header
static int read_header(AVFormatContext *s)
Definition: brstm.c:102
read16
static av_always_inline unsigned int read16(AVFormatContext *s)
Definition: brstm.c:84
skip
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
Definition: bitstream_template.h:375
bom
static const char * bom
Definition: microdvddec.c:78
avio_feof
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:346