FFmpeg: libavformat/brstm.c Source File
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
26
31
46
48 {
53 return 0;
54 }
55
57 {
63 return 0;
64 }
65
67 {
69
71
72 return 0;
73 }
74
76 {
80 }
81
83 {
87 else
89 }
90
92 {
96 else
98 }
99
101 {
104 int64_t h1offset,
pos, toffset;
105 uint32_t
size, asize, start = 0;
108 int bfstm = !strcmp(
"bfstm",
s->iformat->name);
109
111 if (!st)
114
116
118 if (
bom != 0xFEFF &&
bom != 0xFFFE) {
121 }
122
124 b->little_endian = 1;
125
126 if (!bfstm) {
133
138 } else {
139 uint32_t info_offset = 0;
140 uint16_t section_count, header_size,
i;
141
143
144 avio_skip(
s->pb, 4);
// Unknown constant 0x00030000
149 && !(start && info_offset)
150 &&
i < section_count;
i++) {
154 case 0x4000:
157 break;
158 case 0x4001:
161 break;
162 case 0x4002:
165 break;
166 case 0x4003:
169 break;
170 }
171 }
172
173 if (!info_offset || !start)
175
180 }
181
193
196
197 switch (codec) {
199 case 1: codec =
b->little_endian ?
202 case 2: codec =
b->little_endian ?
205 default:
208 }
209
215
217
221
222 if (!bfstm)
224
229 0) < 0)
231 } else {
233 }
234
238
239 if (!bfstm)
241 b->current_block = 0;
243 if (
b->block_count > UINT16_MAX) {
246 }
247
251
253 b->last_block_used_bytes =
read32(
s);
258 if (
b->last_block_used_bytes >
b->last_block_size)
260
261
263 int ch;
264
266 if (!bfstm)
268 else
272
273 if (!bfstm) {
277 b->offsets[ch].channel = ch;
279 }
280
282 }
283
285
287 if (!bfstm)
289
290 if (
avio_read(
s->pb,
b->table + ch * 32, 32) != 32)
292
293 if (bfstm)
295 }
296 }
297
300
302
309 switch (chunk) {
310 case MKTAG(
'S',
'E',
'E',
'K'):
311 case MKTAG(
'A',
'D',
'P',
'C'):
314 goto skip;
315
321 goto skip;
322 } else {
327 // Big-endian BFSTMs have little-endian SEEK tables
328 // for some strange reason.
330 for (
i = 0;
i < asize;
i += 2) {
333 }
334 } else {
336 }
338 }
339 break;
340 case MKTAG(
'D',
'A',
'T',
'A'):
346
350
352
355
356 return 0;
357 default:
359 skip:
361 }
362 }
363
365 }
366
368 {
373
377 if (
b->current_block ==
b->block_count) {
378 size =
b->last_block_used_bytes;
380 skip =
b->last_block_size -
b->last_block_used_bytes;
381
383 uint32_t adjusted_size =
samples / 14 * 8;
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;
393 } else {
395 }
396
399 uint8_t *dst;
400
404 }
405
406 if (
size > (INT_MAX - 32 - 4) ||
415 bytestream_put_le32(&dst,
samples);
416 } else {
418 bytestream_put_be32(&dst,
samples);
419 }
422 (
b->current_block - 1), 4 * par->
channels);
423
430 }
431 }
433 } else {
436 }
437
439
442
444 }
445
447 int64_t timestamp,
int flags)
448 {
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;
462
463 b->current_block = timestamp;
465 return 0;
466 }
467
478 .extensions = "brstm",
479 };
480
491 .extensions = "bfstm,bcstm",
492 };
#define AV_LOG_WARNING
Something somehow does not look correct.
static int sort_offsets(const void *a, const void *b)
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
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
enum AVMediaType codec_type
General type of the encoded data.
static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
uint32_t last_block_used_bytes
This struct describes the properties of an encoded stream.
#define AVERROR_EOF
End of file.
const AVInputFormat ff_brstm_demuxer
@ AV_CODEC_ID_PCM_S16BE_PLANAR
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
uint32_t last_block_samples
@ AV_CODEC_ID_PCM_S16LE_PLANAR
@ AV_CODEC_ID_ADPCM_THP_LE
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int64_t duration
Decoding: duration of the stream, in stream time base.
unsigned int avio_rl16(AVIOContext *s)
#define FFDIFFSIGN(x, y)
Comparator.
unsigned int avio_rb32(AVIOContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
const AVInputFormat ff_bfstm_demuxer
static int read_close(AVFormatContext *s)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
This structure contains the data a format has to probe a file.
uint32_t samples_per_block
int sample_rate
Audio only.
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int avio_r8(AVIOContext *s)
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
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
#define i(width, name, range_min, range_max)
#define AV_TIME_BASE
Internal time base represented as integer.
BRSTMCoeffOffset offsets[256]
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
unsigned int avio_rb16(AVIOContext *s)
static av_always_inline unsigned int read32(AVFormatContext *s)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
static int probe(const AVProbeData *p)
static int probe_bfstm(const AVProbeData *p)
static int read_packet(AVFormatContext *s, AVPacket *pkt)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Filter the word "frame" indicates either a video frame or a group of audio samples
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
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 avpriv_request_sample(...)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
@ AV_CODEC_ID_PCM_S8_PLANAR
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
static int read_header(AVFormatContext *s)
static av_always_inline unsigned int read16(AVFormatContext *s)
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Generated on Wed Aug 24 2022 21:38:20 for FFmpeg by
doxygen
1.8.17