1 /*
2 * Electronic Arts .cdata file Demuxer
3 * Copyright (c) 2007 Peter Ross
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 * Electronic Arts cdata Format Demuxer
25 * by Peter Ross (pross@xvid.org)
26 *
27 * Technical details here:
28 * http://wiki.multimedia.cx/index.php?title=EA_Command_And_Conquer_3_Audio_Codec
29 */
30
33
38
40 {
42
43 if (b[0] == 0x04 && (b[1] == 0x00 || b[1] == 0x04 || b[1] == 0x0C || b[1] == 0x14))
45 return 0;
46 }
47
49 {
54 int64_t channel_layout = 0;
55
57 switch (header) {
58 case 0x0400: cdata->
channels = 1;
break;
59 case 0x0404: cdata->
channels = 2;
break;
62 default:
64 return -1;
65 };
66
69
71 if (!st)
80
82 return 0;
83 }
84
86 {
88 int packet_size = 76*cdata->
channels;
89
91 if (ret < 0)
92 return ret;
94 return 0;
95 }
96
104 .extensions = "cdata",
105 };
static int cdata_read_packet(AVFormatContext *s, AVPacket *pkt)
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
unsigned int avio_rb16(AVIOContext *s)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
static const uint8_t header[24]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_CH_LAYOUT_QUAD
uint64_t channel_layout
Audio channel layout.
int avio_r8(AVIOContext *s)
AVCodecContext * codec
Codec context associated with this stream.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
AVInputFormat ff_ea_cdata_demuxer
#define AV_CH_LAYOUT_5POINT1_BACK
static int read_header(FFV1Context *f)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define AV_LOG_INFO
Standard information.
enum AVMediaType codec_type
int sample_rate
samples per second
AVIOContext * pb
I/O context.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
This structure contains the data a format has to probe a file.
int channels
number of audio channels
void * priv_data
Format private data.
static int cdata_probe(AVProbeData *p)
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static int cdata_read_header(AVFormatContext *s)