1 /*
2 * Maxis XA (.xa) File Demuxer
3 * Copyright (c) 2008 Robert Marston
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 /**
23 * @file
24 * Maxis XA File Demuxer
25 * by Robert Marston (rmarston@gmail.com)
26 * for more information on the XA audio format see
27 * http://wiki.multimedia.cx/index.php?title=Maxis_XA
28 */
29
33
34 #define XA00_TAG MKTAG('X', 'A', 0, 0)
35 #define XAI0_TAG MKTAG('X', 'A', 'I', 0)
36 #define XAJ0_TAG MKTAG('X', 'A', 'J', 0)
37
42
44 {
45 int channels, srate, bits_per_sample;
47 return 0;
52 break;
53 default:
54 return 0;
55 }
59 if (!channels || channels > 8 || !srate || srate > 192000 ||
60 bits_per_sample < 4 || bits_per_sample > 32)
61 return 0;
63 }
64
66 {
70
71 /*Set up the XA Audio Decoder*/
73 if (!st)
75
83 avio_skip(pb, 4);
/* Skip average byte rate */
85 avio_skip(pb, 2);
/* Skip bits-per-sample */
86
89
92
95
96 return 0;
97 }
98
101 {
105 unsigned int packet_size;
106 int ret;
107
110 /* 1 byte header and 14 bytes worth of samples * number channels per block */
112
114 if(ret < 0)
115 return ret;
116
120
121 return ret;
122 }
123
131 };
static int xa_probe(AVProbeData *p)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t bit_rate
the average bitrate
int index
stream index in AVFormatContext
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
AVInputFormat ff_xa_demuxer
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
#define AVERROR_EOF
End of file.
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int xa_read_packet(AVFormatContext *s, AVPacket *pkt)
AVCodecContext * codec
Codec context associated with this stream.
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
static int read_header(FFV1Context *f)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
enum AVMediaType codec_type
int sample_rate
samples per second
AVIOContext * pb
I/O context.
This structure contains the data a format has to probe a file.
unsigned int avio_rl16(AVIOContext *s)
static int xa_read_header(AVFormatContext *s)
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
int channels
number of audio channels
void * priv_data
Format private data.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.