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 "libavcodec/bytestream.h"
24 #include "avformat.h"
25 #include "internal.h"
26 
27 typedef struct BRSTMCoeffOffset {
28  uint8_t channel;
29  uint32_t offset;
31 
32 typedef struct BRSTMDemuxContext {
33  uint32_t block_size;
34  uint32_t block_count;
35  uint32_t current_block;
38  uint32_t last_block_size;
40  uint32_t data_start;
41  uint8_t table[256 * 32];
42  uint8_t *adpc;
46 
47 static int probe(const AVProbeData *p)
48 {
49  if (AV_RL32(p->buf) == MKTAG('R','S','T','M') &&
50  (AV_RL16(p->buf + 4) == 0xFFFE ||
51  AV_RL16(p->buf + 4) == 0xFEFF))
52  return AVPROBE_SCORE_MAX / 3 * 2;
53  return 0;
54 }
55 
56 static int probe_bfstm(const AVProbeData *p)
57 {
58  if ((AV_RL32(p->buf) == MKTAG('F','S','T','M') ||
59  AV_RL32(p->buf) == MKTAG('C','S','T','M')) &&
60  (AV_RL16(p->buf + 4) == 0xFFFE ||
61  AV_RL16(p->buf + 4) == 0xFEFF))
62  return AVPROBE_SCORE_MAX / 3 * 2;
63  return 0;
64 }
65 
67 {
68  BRSTMDemuxContext *b = s->priv_data;
69 
70  av_freep(&b->adpc);
71 
72  return 0;
73 }
74 
75 static int sort_offsets(const void *a, const void *b)
76 {
77  const BRSTMCoeffOffset *s1 = a;
78  const BRSTMCoeffOffset *s2 = b;
79  return FFDIFFSIGN(s1->offset, s2->offset);
80 }
81 
83 {
84  BRSTMDemuxContext *b = s->priv_data;
85  if (b->little_endian)
86  return avio_rl16(s->pb);
87  else
88  return avio_rb16(s->pb);
89 }
90 
92 {
93  BRSTMDemuxContext *b = s->priv_data;
94  if (b->little_endian)
95  return avio_rl32(s->pb);
96  else
97  return avio_rb32(s->pb);
98 }
99 
101 {
102  BRSTMDemuxContext *b = s->priv_data;
103  int bom, major, minor, codec, chunk;
104  int64_t h1offset, pos, toffset;
105  uint32_t size, asize, start = 0;
106  AVStream *st;
107  int loop = 0;
108  int bfstm = !strcmp("bfstm", s->iformat->name);
109 
110  st = avformat_new_stream(s, NULL);
111  if (!st)
112  return AVERROR(ENOMEM);
114 
115  avio_skip(s->pb, 4);
116 
117  bom = avio_rb16(s->pb);
118  if (bom != 0xFEFF && bom != 0xFFFE) {
119  av_log(s, AV_LOG_ERROR, "invalid byte order: %X\n", bom);
120  return AVERROR_INVALIDDATA;
121  }
122 
123  if (bom == 0xFFFE)
124  b->little_endian = 1;
125 
126  if (!bfstm) {
127  major = avio_r8(s->pb);
128  minor = avio_r8(s->pb);
129  avio_skip(s->pb, 4); // size of file
130  size = read16(s);
131  if (size < 14)
132  return AVERROR_INVALIDDATA;
133 
134  avio_skip(s->pb, size - 14);
135  pos = avio_tell(s->pb);
136  if (avio_rl32(s->pb) != MKTAG('H','E','A','D'))
137  return AVERROR_INVALIDDATA;
138  } else {
139  uint32_t info_offset = 0;
140  uint16_t section_count, header_size, i;
141 
142  header_size = read16(s); // 6
143 
144  avio_skip(s->pb, 4); // Unknown constant 0x00030000
145  avio_skip(s->pb, 4); // size of file
146  section_count = read16(s);
147  avio_skip(s->pb, 2); // padding
148  for (i = 0; avio_tell(s->pb) < header_size
149  && !(start && info_offset)
150  && i < section_count; i++) {
151  uint16_t flag = read16(s);
152  avio_skip(s->pb, 2);
153  switch (flag) {
154  case 0x4000:
155  info_offset = read32(s);
156  /*info_size =*/ read32(s);
157  break;
158  case 0x4001:
159  avio_skip(s->pb, 4); // seek offset
160  avio_skip(s->pb, 4); // seek size
161  break;
162  case 0x4002:
163  start = read32(s) + 8;
164  avio_skip(s->pb, 4); //data_size = read32(s);
165  break;
166  case 0x4003:
167  avio_skip(s->pb, 4); // REGN offset
168  avio_skip(s->pb, 4); // REGN size
169  break;
170  }
171  }
172 
173  if (!info_offset || !start)
174  return AVERROR_INVALIDDATA;
175 
176  avio_skip(s->pb, info_offset - avio_tell(s->pb));
177  pos = avio_tell(s->pb);
178  if (avio_rl32(s->pb) != MKTAG('I','N','F','O'))
179  return AVERROR_INVALIDDATA;
180  }
181 
182  size = read32(s);
183  if (size < 40)
184  return AVERROR_INVALIDDATA;
185  avio_skip(s->pb, 4); // unknown
186  h1offset = read32(s);
187  if (h1offset > size)
188  return AVERROR_INVALIDDATA;
189  avio_skip(s->pb, 12);
190  toffset = read32(s) + 16LL;
191  if (toffset > size)
192  return AVERROR_INVALIDDATA;
193 
194  avio_skip(s->pb, pos + h1offset + 8 - avio_tell(s->pb));
195  codec = avio_r8(s->pb);
196 
197  switch (codec) {
198  case 0: codec = AV_CODEC_ID_PCM_S8_PLANAR; break;
199  case 1: codec = b->little_endian ?
202  case 2: codec = b->little_endian ?
204  AV_CODEC_ID_ADPCM_THP; break;
205  default:
206  avpriv_request_sample(s, "codec %d", codec);
207  return AVERROR_PATCHWELCOME;
208  }
209 
210  loop = avio_r8(s->pb); // loop flag
211  st->codecpar->codec_id = codec;
212  st->codecpar->channels = avio_r8(s->pb);
213  if (!st->codecpar->channels)
214  return AVERROR_INVALIDDATA;
215 
216  avio_skip(s->pb, 1); // padding
217 
218  st->codecpar->sample_rate = bfstm ? read32(s) : read16(s);
219  if (st->codecpar->sample_rate <= 0)
220  return AVERROR_INVALIDDATA;
221 
222  if (!bfstm)
223  avio_skip(s->pb, 2); // padding
224 
225  if (loop) {
226  if (av_dict_set_int(&s->metadata, "loop_start",
228  st->codecpar->sample_rate),
229  0) < 0)
230  return AVERROR(ENOMEM);
231  } else {
232  avio_skip(s->pb, 4);
233  }
234 
235  st->start_time = 0;
236  st->duration = read32(s);
237  avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
238 
239  if (!bfstm)
240  start = read32(s);
241  b->current_block = 0;
242  b->block_count = read32(s);
243  if (b->block_count > UINT16_MAX) {
244  av_log(s, AV_LOG_WARNING, "too many blocks: %"PRIu32"\n", b->block_count);
245  return AVERROR_INVALIDDATA;
246  }
247 
248  b->block_size = read32(s);
249  if (b->block_size > UINT32_MAX / st->codecpar->channels)
250  return AVERROR_INVALIDDATA;
251 
252  b->samples_per_block = read32(s);
253  b->last_block_used_bytes = read32(s);
254  b->last_block_samples = read32(s);
255  b->last_block_size = read32(s);
256  if (b->last_block_size > UINT32_MAX / st->codecpar->channels)
257  return AVERROR_INVALIDDATA;
258  if (b->last_block_used_bytes > b->last_block_size)
259  return AVERROR_INVALIDDATA;
260 
261 
262  if (codec == AV_CODEC_ID_ADPCM_THP || codec == AV_CODEC_ID_ADPCM_THP_LE) {
263  int ch;
264 
265  avio_skip(s->pb, pos + toffset - avio_tell(s->pb));
266  if (!bfstm)
267  toffset = read32(s) + 16LL;
268  else
269  toffset = toffset + read32(s) + st->codecpar->channels * 8 - 8;
270  if (toffset > size)
271  return AVERROR_INVALIDDATA;
272 
273  if (!bfstm) {
274  avio_skip(s->pb, pos + toffset - avio_tell(s->pb) - 8LL * (st->codecpar->channels + 1));
275  for (ch = 0; ch < st->codecpar->channels; ch++) {
276  avio_skip(s->pb, 4);
277  b->offsets[ch].channel = ch;
278  b->offsets[ch].offset = read32(s);
279  }
280 
281  qsort(b->offsets, st->codecpar->channels, sizeof(*b->offsets), sort_offsets);
282  }
283 
284  avio_skip(s->pb, pos + toffset - avio_tell(s->pb));
285 
286  for (ch = 0; ch < st->codecpar->channels; ch++) {
287  if (!bfstm)
288  avio_skip(s->pb, pos + 16LL + b->offsets[ch].offset - avio_tell(s->pb));
289 
290  if (avio_read(s->pb, b->table + ch * 32, 32) != 32)
291  return AVERROR_INVALIDDATA;
292 
293  if (bfstm)
294  avio_skip(s->pb, 14);
295  }
296  }
297 
298  if (size < (avio_tell(s->pb) - pos))
299  return AVERROR_INVALIDDATA;
300 
301  avio_skip(s->pb, size - (avio_tell(s->pb) - pos));
302 
303  while (!avio_feof(s->pb)) {
304  chunk = avio_rl32(s->pb);
305  size = read32(s);
306  if (size < 8)
307  return AVERROR_INVALIDDATA;
308  size -= 8;
309  switch (chunk) {
310  case MKTAG('S','E','E','K'):
311  case MKTAG('A','D','P','C'):
312  if (codec != AV_CODEC_ID_ADPCM_THP &&
313  codec != AV_CODEC_ID_ADPCM_THP_LE)
314  goto skip;
315 
316  asize = b->block_count * st->codecpar->channels * 4;
317  if (size < asize)
318  return AVERROR_INVALIDDATA;
319  if (b->adpc) {
320  av_log(s, AV_LOG_WARNING, "skipping additional ADPC chunk\n");
321  goto skip;
322  } else {
323  b->adpc = av_mallocz(asize);
324  if (!b->adpc)
325  return AVERROR(ENOMEM);
326  if (bfstm && codec != AV_CODEC_ID_ADPCM_THP_LE) {
327  // Big-endian BFSTMs have little-endian SEEK tables
328  // for some strange reason.
329  int i;
330  for (i = 0; i < asize; i += 2) {
331  b->adpc[i+1] = avio_r8(s->pb);
332  b->adpc[i] = avio_r8(s->pb);
333  }
334  } else {
335  avio_read(s->pb, b->adpc, asize);
336  }
337  avio_skip(s->pb, size - asize);
338  }
339  break;
340  case MKTAG('D','A','T','A'):
341  if ((start < avio_tell(s->pb)) ||
342  (!b->adpc && (codec == AV_CODEC_ID_ADPCM_THP ||
343  codec == AV_CODEC_ID_ADPCM_THP_LE)))
344  return AVERROR_INVALIDDATA;
345  avio_skip(s->pb, start - avio_tell(s->pb));
346 
347  if (bfstm && (codec == AV_CODEC_ID_ADPCM_THP ||
348  codec == AV_CODEC_ID_ADPCM_THP_LE))
349  avio_skip(s->pb, 24);
350 
351  b->data_start = avio_tell(s->pb);
352 
353  if (!bfstm && (major != 1 || minor))
354  avpriv_request_sample(s, "Version %d.%d", major, minor);
355 
356  return 0;
357  default:
358  av_log(s, AV_LOG_WARNING, "skipping unknown chunk: %X\n", chunk);
359 skip:
360  avio_skip(s->pb, size);
361  }
362  }
363 
364  return AVERROR_EOF;
365 }
366 
368 {
369  AVCodecParameters *par = s->streams[0]->codecpar;
370  BRSTMDemuxContext *b = s->priv_data;
371  uint32_t samples, size, skip = 0;
372  int ret, i;
373 
374  if (avio_feof(s->pb))
375  return AVERROR_EOF;
376  b->current_block++;
377  if (b->current_block == b->block_count) {
378  size = b->last_block_used_bytes;
379  samples = b->last_block_samples;
380  skip = b->last_block_size - b->last_block_used_bytes;
381 
382  if (samples < size * 14 / 8) {
383  uint32_t adjusted_size = samples / 14 * 8;
384  if (samples % 14)
385  adjusted_size += (samples % 14 + 1) / 2 + 1;
386 
387  skip += size - adjusted_size;
388  size = adjusted_size;
389  }
390  } else if (b->current_block < b->block_count) {
391  size = b->block_size;
392  samples = b->samples_per_block;
393  } else {
394  return AVERROR_EOF;
395  }
396 
397  if (par->codec_id == AV_CODEC_ID_ADPCM_THP ||
399  uint8_t *dst;
400 
401  if (!b->adpc) {
402  av_log(s, AV_LOG_ERROR, "adpcm_thp requires ADPC chunk, but none was found.\n");
403  return AVERROR_INVALIDDATA;
404  }
405 
406  if (size > (INT_MAX - 32 - 4) ||
407  (32 + 4 + size) > (INT_MAX / par->channels) ||
408  (32 + 4 + size) * par->channels > INT_MAX - 8)
409  return AVERROR_INVALIDDATA;
410  if ((ret = av_new_packet(pkt, 8 + (32 + 4 + size) * par->channels)) < 0)
411  return ret;
412  dst = pkt->data;
413  if (par->codec_id == AV_CODEC_ID_ADPCM_THP_LE) {
414  bytestream_put_le32(&dst, size * par->channels);
415  bytestream_put_le32(&dst, samples);
416  } else {
417  bytestream_put_be32(&dst, size * par->channels);
418  bytestream_put_be32(&dst, samples);
419  }
420  bytestream_put_buffer(&dst, b->table, 32 * par->channels);
421  bytestream_put_buffer(&dst, b->adpc + 4 * par->channels *
422  (b->current_block - 1), 4 * par->channels);
423 
424  for (i = 0; i < par->channels; i++) {
425  ret = avio_read(s->pb, dst, size);
426  dst += size;
427  avio_skip(s->pb, skip);
428  if (ret != size) {
429  return AVERROR(EIO);
430  }
431  }
432  pkt->duration = samples;
433  } else {
434  size *= par->channels;
435  ret = av_get_packet(s->pb, pkt, size);
436  }
437 
438  pkt->stream_index = 0;
439 
440  if (ret != size)
441  ret = AVERROR(EIO);
442 
443  return ret;
444 }
445 
446 static int read_seek(AVFormatContext *s, int stream_index,
447  int64_t timestamp, int flags)
448 {
449  AVStream *st = s->streams[stream_index];
450  BRSTMDemuxContext *b = s->priv_data;
451  int64_t ret = 0;
452 
453  if (timestamp < 0)
454  timestamp = 0;
455  timestamp /= b->samples_per_block;
456  if (timestamp >= b->block_count)
457  timestamp = b->block_count - 1;
458  ret = avio_seek(s->pb, b->data_start + timestamp * b->block_size *
459  st->codecpar->channels, SEEK_SET);
460  if (ret < 0)
461  return ret;
462 
463  b->current_block = timestamp;
464  avpriv_update_cur_dts(s, st, timestamp * b->samples_per_block);
465  return 0;
466 }
467 
469  .name = "brstm",
470  .long_name = NULL_IF_CONFIG_SMALL("BRSTM (Binary Revolution Stream)"),
471  .priv_data_size = sizeof(BRSTMDemuxContext),
472  .flags_internal = FF_FMT_INIT_CLEANUP,
473  .read_probe = probe,
477  .read_seek = read_seek,
478  .extensions = "brstm",
479 };
480 
482  .name = "bfstm",
483  .long_name = NULL_IF_CONFIG_SMALL("BFSTM (Binary Cafe Stream)"),
484  .priv_data_size = sizeof(BRSTMDemuxContext),
485  .flags_internal = FF_FMT_INIT_CLEANUP,
490  .read_seek = read_seek,
491  .extensions = "bfstm,bcstm",
492 };
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
sort_offsets
static int sort_offsets(const void *a, const void *b)
Definition: brstm.c:75
FF_FMT_INIT_CLEANUP
#define FF_FMT_INIT_CLEANUP
For an AVInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
Definition: internal.h:48
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
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:724
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
read_seek
static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition: brstm.c:446
BRSTMDemuxContext::last_block_used_bytes
uint32_t last_block_used_bytes
Definition: brstm.c:37
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:52
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
ff_brstm_demuxer
const AVInputFormat ff_brstm_demuxer
Definition: brstm.c:468
AVPacket::data
uint8_t * data
Definition: packet.h:373
AV_CODEC_ID_PCM_S16BE_PLANAR
@ AV_CODEC_ID_PCM_S16BE_PLANAR
Definition: codec_id.h:343
b
#define b
Definition: input.c:40
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:391
BRSTMDemuxContext::last_block_size
uint32_t last_block_size
Definition: brstm.c:38
BRSTMDemuxContext::last_block_samples
uint32_t last_block_samples
Definition: brstm.c:39
AV_CODEC_ID_PCM_S16LE_PLANAR
@ AV_CODEC_ID_PCM_S16LE_PLANAR
Definition: codec_id.h:331
AV_CODEC_ID_ADPCM_THP_LE
@ AV_CODEC_ID_ADPCM_THP_LE
Definition: codec_id.h:388
AVPROBE_SCORE_MAX
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:458
AVCodecParameters::channels
int channels
Audio only.
Definition: codec_par.h:166
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:486
BRSTMCoeffOffset::offset
uint32_t offset
Definition: brstm.c:29
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:888
loop
static int loop
Definition: ffplay.c:339
avio_rl16
unsigned int avio_rl16(AVIOContext *s)
Definition: aviobuf.c:726
BRSTMDemuxContext::block_size
uint32_t block_size
Definition: brstm.c:33
BRSTMCoeffOffset
Definition: brstm.c:27
FFDIFFSIGN
#define FFDIFFSIGN(x, y)
Comparator.
Definition: macros.h:45
BRSTMDemuxContext::current_block
uint32_t current_block
Definition: brstm.c:35
avio_rb32
unsigned int avio_rb32(AVIOContext *s)
Definition: aviobuf.c:773
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
AVInputFormat
Definition: avformat.h:626
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:257
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: avpacket.c:99
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:631
AVProbeData::buf
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:448
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
s1
#define s1
Definition: regdef.h:38
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
ff_bfstm_demuxer
const AVInputFormat ff_bfstm_demuxer
Definition: brstm.c:481
read_close
static int read_close(AVFormatContext *s)
Definition: brstm.c:66
AVFormatContext
Format I/O context.
Definition: avformat.h:1097
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:32
internal.h
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:992
NULL
#define NULL
Definition: coverity.c:32
BRSTMDemuxContext::adpc
uint8_t * adpc
Definition: brstm.c:42
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
read_probe
static int read_probe(const AVProbeData *pd)
Definition: jvdec.c:55
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:446
convert_header.major
int major
Definition: convert_header.py:23
BRSTMDemuxContext::samples_per_block
uint32_t samples_per_block
Definition: brstm.c:36
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:170
s2
#define s2
Definition: regdef.h:39
avio_rl32
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:742
BRSTMCoeffOffset::channel
uint8_t channel
Definition: brstm.c:28
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:117
size
int size
Definition: twinvq_data.h:10344
avio_r8
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:616
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:553
convert_header.minor
int minor
Definition: convert_header.py:26
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
i
int i
Definition: input.c:406
BRSTMDemuxContext::block_count
uint32_t block_count
Definition: brstm.c:34
BRSTMDemuxContext
Definition: brstm.c:32
BRSTMDemuxContext::table
uint8_t table[256 *32]
Definition: brstm.c:41
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:43
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:263
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:128
BRSTMDemuxContext::data_start
uint32_t data_start
Definition: brstm.c:40
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:196
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:845
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:246
avio_rb16
unsigned int avio_rb16(AVIOContext *s)
Definition: aviobuf.c:758
pos
unsigned int pos
Definition: spdifenc.c:412
avformat.h
read32
static av_always_inline unsigned int read32(AVFormatContext *s)
Definition: brstm.c:91
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:47
probe_bfstm
static int probe_bfstm(const AVProbeData *p)
Definition: brstm.c:56
BRSTMDemuxContext::little_endian
int little_endian
Definition: brstm.c:44
read_packet
static int read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: brstm.c:367
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:625
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
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: utils.c:1146
AVPacket::stream_index
int stream_index
Definition: packet.h:375
avio_skip
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:333
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:147
AV_CODEC_ID_ADPCM_THP
@ AV_CODEC_ID_ADPCM_THP
Definition: codec_id.h:370
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:37
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
AVPacket
This structure stores compressed data.
Definition: packet.h:350
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
AV_CODEC_ID_PCM_S8_PLANAR
@ AV_CODEC_ID_PCM_S8_PLANAR
Definition: codec_id.h:340
bytestream.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
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: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:878
read_header
static int read_header(AVFormatContext *s)
Definition: brstm.c:100
read16
static av_always_inline unsigned int read16(AVFormatContext *s)
Definition: brstm.c:82
bom
static const char * bom
Definition: microdvddec.c:77
avio_feof
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:360