Revision 98168220

View differences:

libavformat/electronicarts.c
27 27
#include "avformat.h"
28 28

  
29 29
#define SCHl_TAG MKTAG('S', 'C', 'H', 'l')
30
#define _SNh_TAG MKTAG('1', 'S', 'N', 'h')    /* 1SNx header */
31
#define EACS_TAG MKTAG('E', 'A', 'C', 'S')
32
#define _SNd_TAG MKTAG('1', 'S', 'N', 'd')    /* 1SNx data */
33
#define _SNe_TAG MKTAG('1', 'S', 'N', 'e')    /* 1SNx end */
30 34
#define PT00_TAG MKTAG('P', 'T', 0x0, 0x0)
31 35
#define GSTR_TAG MKTAG('G', 'S', 'T', 'R')
32 36
#define SCDl_TAG MKTAG('S', 'C', 'D', 'l')
......
170 174
    return 1;
171 175
}
172 176

  
177
/*
178
 * Process EACS sound header
179
 * return 1 if success, 0 if invalid format, otherwise AVERROR_xxx
180
 */
181
static int process_audio_header_eacs(AVFormatContext *s)
182
{
183
    EaDemuxContext *ea = s->priv_data;
184
    ByteIOContext *pb = &s->pb;
185
    int compression_type;
186

  
187
    ea->sample_rate  = ea->big_endian ? get_be32(pb) : get_le32(pb);
188
    ea->bytes        = get_byte(pb);   /* 1=8-bit, 2=16-bit */
189
    ea->num_channels = get_byte(pb);
190
    compression_type = get_byte(pb);
191
    url_fskip(pb, 13);
192

  
193
    switch (compression_type) {
194
    case 0:
195
        switch (ea->bytes) {
196
        case 1: ea->audio_codec = CODEC_ID_PCM_S8;    break;
197
        case 2: ea->audio_codec = CODEC_ID_PCM_S16LE; break;
198
        }
199
        break;
200
    case 1: ea->audio_codec = CODEC_ID_PCM_MULAW; ea->bytes = 1; break;
201
    default:
202
        av_log (s, AV_LOG_ERROR, "unsupported stream type; audio compression_type=%i\n", compression_type);
203
    }
204

  
205
    return 1;
206
}
207

  
173 208
static int process_video_header_vp6(AVFormatContext *s)
174 209
{
175 210
    EaDemuxContext *ea = s->priv_data;
......
205 240
            size = bswap_32(size);
206 241

  
207 242
        switch (blockid) {
243
            case _SNh_TAG:
244
                if (get_le32(pb) != EACS_TAG) {
245
                    av_log (s, AV_LOG_ERROR, "unknown 1SNh headerid\n");
246
                    return 0;
247
                }
248
                err = process_audio_header_eacs(s);
249
                break;
250

  
208 251
            case SCHl_TAG :
209 252
                blockid = get_le32(pb);
210 253
                if (blockid == GSTR_TAG) {
......
304 347

  
305 348
        switch (chunk_type) {
306 349
        /* audio data */
350
        case _SNh_TAG:
351
            /* header chunk also contains data; skip over the header portion*/
352
            url_fskip(pb, 32);
353
            chunk_size -= 32;
354
        case _SNd_TAG:
307 355
        case SCDl_TAG:
308 356
            if (!ea->audio_codec) {
309 357
                url_fskip(pb, chunk_size);
......
336 384

  
337 385
        /* ending tag */
338 386
        case 0:
387
        case _SNe_TAG:
339 388
        case SCEl_TAG:
340 389
            ret = AVERROR(EIO);
341 390
            packet_read = 1;

Also available in: Unified diff