53 (
AV_RL16(p->buf + 4) == 0xFFFE ||
63 (
AV_RL16(p->buf + 4) == 0xFFFE ||
106 int bom, major, minor, codec, chunk;
108 uint32_t
size, asize, start = 0;
111 int bfstm = !strcmp(
"bfstm",
s->iformat->name);
121 if (
bom != 0xFEFF &&
bom != 0xFFFE) {
127 b->little_endian = 1;
142 uint32_t info_offset = 0;
143 uint16_t section_count, header_size,
i;
152 && !(start && info_offset)
153 &&
i < section_count;
i++) {
176 if (!info_offset || !start)
202 case 1: codec =
b->little_endian ?
205 case 2: codec =
b->little_endian ?
244 b->current_block = 0;
246 if (
b->block_count > UINT16_MAX) {
256 b->last_block_used_bytes =
read32(
s);
261 if (
b->last_block_used_bytes >
b->last_block_size)
280 b->offsets[ch].channel = ch;
293 if (
avio_read(
s->pb,
b->table + ch * 32, 32) != 32)
313 case MKTAG(
'S',
'E',
'E',
'K'):
314 case MKTAG(
'A',
'D',
'P',
'C'):
333 for (
i = 0;
i < asize;
i += 2) {
343 case MKTAG(
'D',
'A',
'T',
'A'):
356 if (!bfstm && (major != 1 || minor))
381 if (
b->current_block ==
b->block_count) {
382 size =
b->last_block_used_bytes;
383 samples =
b->last_block_samples;
384 skip =
b->last_block_size -
b->last_block_used_bytes;
386 if (samples <
size * 14 / 8) {
387 uint32_t adjusted_size = samples / 14 * 8;
389 adjusted_size += (samples % 14 + 1) / 2 + 1;
392 size = adjusted_size;
394 }
else if (
b->current_block <
b->block_count) {
395 size =
b->block_size;
396 samples =
b->samples_per_block;
410 if (
size > (INT_MAX - 32 - 4) ||
419 bytestream_put_le32(&
dst, samples);
422 bytestream_put_be32(&
dst, samples);
436 pkt->duration = samples;
442 pkt->stream_index = 0;
459 timestamp /=
b->samples_per_block;
460 if (timestamp >=
b->block_count)
461 timestamp =
b->block_count - 1;
462 ret =
avio_seek(
s->pb,
b->data_start + timestamp *
b->block_size *
467 b->current_block = timestamp;
475 .p.extensions =
"brstm",
488 .p.extensions =
"bfstm,bcstm",
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static int probe(const AVProbeData *p)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
unsigned int avio_rb16(AVIOContext *s)
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
unsigned int avio_rl16(AVIOContext *s)
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
unsigned int avio_rl32(AVIOContext *s)
unsigned int avio_rb32(AVIOContext *s)
int avio_r8(AVIOContext *s)
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
static int sort_offsets(const void *a, const void *b)
static int read_close(AVFormatContext *s)
static av_always_inline unsigned int read32(AVFormatContext *s)
static int read_packet(AVFormatContext *s, AVPacket *pkt)
static int probe_bfstm(const AVProbeData *p)
static int read_header(AVFormatContext *s)
static int probe(const AVProbeData *p)
static av_always_inline unsigned int read16(AVFormatContext *s)
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
#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...
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.
static int read_header(FFV1Context *f, RangeCoder *c)
@ AV_CODEC_ID_PCM_S16BE_PLANAR
@ AV_CODEC_ID_ADPCM_THP_LE
@ AV_CODEC_ID_PCM_S16LE_PLANAR
@ AV_CODEC_ID_PCM_S8_PLANAR
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
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.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_TIME_BASE
Internal time base represented as integer.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int read_close(AVFormatContext *ctx)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
#define MKTAG(a, b, c, d)
#define FFDIFFSIGN(x, y)
Comparator.
Memory handling functions.
int nb_channels
Number of channels in this layout.
This struct describes the properties of an encoded stream.
AVChannelLayout ch_layout
The channel layout and number of channels.
enum AVMediaType codec_type
General type of the encoded data.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
This structure stores compressed data.
This structure contains the data a format has to probe a file.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int64_t duration
Decoding: duration of the stream, in stream time base.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
uint32_t last_block_used_bytes
uint32_t samples_per_block
uint32_t last_block_samples
BRSTMCoeffOffset offsets[256]
#define avpriv_request_sample(...)