libavformat/electronicarts.c
ad81a9fe
 /* Electronic Arts Multimedia File Demuxer
  * Copyright (c) 2004  The ffmpeg Project
b2f181c2
  * Copyright (c) 2006-2008 Peter Ross
ad81a9fe
  *
b78e7197
  * This file is part of FFmpeg.
  *
  * FFmpeg is free software; you can redistribute it and/or
ad81a9fe
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
b78e7197
  * version 2.1 of the License, or (at your option) any later version.
ad81a9fe
  *
b78e7197
  * FFmpeg is distributed in the hope that it will be useful,
ad81a9fe
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
b78e7197
  * License along with FFmpeg; if not, write to the Free Software
5509bffa
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
ad81a9fe
  */
 
 /**
ba87f080
  * @file
ad81a9fe
  * Electronic Arts Multimedia file demuxer (WVE/UV2/etc.)
  * by Robin Kay (komadori at gekkou.co.uk)
  */
 
6a5d31ac
 #include "libavutil/intreadwrite.h"
ad81a9fe
 #include "avformat.h"
 
 #define SCHl_TAG MKTAG('S', 'C', 'H', 'l')
7bb65d89
 #define SEAD_TAG MKTAG('S', 'E', 'A', 'D')    /* Sxxx header */
 #define SNDC_TAG MKTAG('S', 'N', 'D', 'C')    /* Sxxx data */
 #define SEND_TAG MKTAG('S', 'E', 'N', 'D')    /* Sxxx end */
ebc22cc2
 #define SHEN_TAG MKTAG('S', 'H', 'E', 'N')    /* SxEN header */
 #define SDEN_TAG MKTAG('S', 'D', 'E', 'N')    /* SxEN data */
 #define SEEN_TAG MKTAG('S', 'E', 'E', 'N')    /* SxEN end */
94e8c227
 #define ISNh_TAG MKTAG('1', 'S', 'N', 'h')    /* 1SNx header */
98168220
 #define EACS_TAG MKTAG('E', 'A', 'C', 'S')
94e8c227
 #define ISNd_TAG MKTAG('1', 'S', 'N', 'd')    /* 1SNx data */
 #define ISNe_TAG MKTAG('1', 'S', 'N', 'e')    /* 1SNx end */
ad81a9fe
 #define PT00_TAG MKTAG('P', 'T', 0x0, 0x0)
d3e412d0
 #define GSTR_TAG MKTAG('G', 'S', 'T', 'R')
ad81a9fe
 #define SCDl_TAG MKTAG('S', 'C', 'D', 'l')
 #define SCEl_TAG MKTAG('S', 'C', 'E', 'l')
968fc6b9
 #define kVGT_TAG MKTAG('k', 'V', 'G', 'T')    /* TGV i-frame */
bbf020e9
 #define fVGT_TAG MKTAG('f', 'V', 'G', 'T')    /* TGV p-frame */
d9d9a8c0
 #define mTCD_TAG MKTAG('m', 'T', 'C', 'D')    /* MDEC */
968fc6b9
 #define MADk_TAG MKTAG('M', 'A', 'D', 'k')    /* MAD i-frame */
eacfe858
 #define MADm_TAG MKTAG('M', 'A', 'D', 'm')    /* MAD p-frame */
 #define MADe_TAG MKTAG('M', 'A', 'D', 'e')    /* MAD lqp-frame */
968fc6b9
 #define MPCh_TAG MKTAG('M', 'P', 'C', 'h')    /* MPEG2 */
d2299316
 #define TGQs_TAG MKTAG('T', 'G', 'Q', 's')    /* TGQ i-frame (appears in .TGQ files) */
 #define pQGT_TAG MKTAG('p', 'Q', 'G', 'T')    /* TGQ i-frame (appears in .UV files) */
468d298d
 #define pIQT_TAG MKTAG('p', 'I', 'Q', 'T')    /* TQI/UV2 i-frame (.UV2/.WVE) */
d3e412d0
 #define MVhd_TAG MKTAG('M', 'V', 'h', 'd')
 #define MV0K_TAG MKTAG('M', 'V', '0', 'K')
 #define MV0F_TAG MKTAG('M', 'V', '0', 'F')
968fc6b9
 #define MVIh_TAG MKTAG('M', 'V', 'I', 'h')    /* CMV header */
b2f181c2
 #define MVIf_TAG MKTAG('M', 'V', 'I', 'f')    /* CMV i-frame */
ad81a9fe
 
 typedef struct EaDemuxContext {
97e5dcc0
     int big_endian;
 
696c3068
     enum CodecID video_codec;
d3e412d0
     AVRational time_base;
d9d9a8c0
     int width, height;
ad81a9fe
     int video_stream_index;
 
696c3068
     enum CodecID audio_codec;
ad81a9fe
     int audio_stream_index;
     int audio_frame_counter;
 
ffbd0bcd
     int bytes;
6c867e04
     int sample_rate;
ad81a9fe
     int num_channels;
     int num_samples;
 } EaDemuxContext;
 
471fe57e
 static uint32_t read_arbitary(AVIOContext *pb) {
ad81a9fe
     uint8_t size, byte;
     int i;
     uint32_t word;
 
e63a3628
     size = avio_r8(pb);
ad81a9fe
 
     word = 0;
     for (i = 0; i < size; i++) {
e63a3628
         byte = avio_r8(pb);
ad81a9fe
         word <<= 8;
         word |= byte;
     }
 
     return word;
 }
 
 /*
215eb102
  * Process PT/GSTR sound header
  * return 1 if success, 0 if invalid format, otherwise AVERROR_xxx
ad81a9fe
  */
215eb102
 static int process_audio_header_elements(AVFormatContext *s)
 {
a066c5b7
     int inHeader = 1;
e4141433
     EaDemuxContext *ea = s->priv_data;
471fe57e
     AVIOContext *pb = s->pb;
725d86bf
     int compression_type = -1, revision = -1, revision2 = -1;
ad81a9fe
 
ffbd0bcd
     ea->bytes = 2;
6c867e04
     ea->sample_rate = -1;
9853ce80
     ea->num_channels = 1;
 
1c4ac035
     while (!url_feof(pb) && inHeader) {
ad81a9fe
         int inSubheader;
         uint8_t byte;
e63a3628
         byte = avio_r8(pb);
ad81a9fe
 
         switch (byte) {
         case 0xFD:
c96495e7
             av_log (s, AV_LOG_DEBUG, "entered audio subheader\n");
ad81a9fe
             inSubheader = 1;
1c4ac035
             while (!url_feof(pb) && inSubheader) {
ad81a9fe
                 uint8_t subbyte;
e63a3628
                 subbyte = avio_r8(pb);
ad81a9fe
 
                 switch (subbyte) {
6c867e04
                 case 0x80:
                     revision = read_arbitary(pb);
c96495e7
                     av_log (s, AV_LOG_DEBUG, "revision (element 0x80) set to 0x%08x\n", revision);
6c867e04
                     break;
ad81a9fe
                 case 0x82:
                     ea->num_channels = read_arbitary(pb);
c96495e7
                     av_log (s, AV_LOG_DEBUG, "num_channels (element 0x82) set to 0x%08x\n", ea->num_channels);
ad81a9fe
                     break;
                 case 0x83:
e5d34ab6
                     compression_type = read_arbitary(pb);
c96495e7
                     av_log (s, AV_LOG_DEBUG, "compression_type (element 0x83) set to 0x%08x\n", compression_type);
ad81a9fe
                     break;
6c867e04
                 case 0x84:
                     ea->sample_rate = read_arbitary(pb);
c96495e7
                     av_log (s, AV_LOG_DEBUG, "sample_rate (element 0x84) set to %i\n", ea->sample_rate);
6c867e04
                     break;
ad81a9fe
                 case 0x85:
                     ea->num_samples = read_arbitary(pb);
c96495e7
                     av_log (s, AV_LOG_DEBUG, "num_samples (element 0x85) set to 0x%08x\n", ea->num_samples);
ad81a9fe
                     break;
                 case 0x8A:
c96495e7
                     av_log (s, AV_LOG_DEBUG, "element 0x%02x set to 0x%08x\n", subbyte, read_arbitary(pb));
                     av_log (s, AV_LOG_DEBUG, "exited audio subheader\n");
ad81a9fe
                     inSubheader = 0;
                     break;
725d86bf
                 case 0xA0:
                     revision2 = read_arbitary(pb);
c96495e7
                     av_log (s, AV_LOG_DEBUG, "revision2 (element 0xA0) set to 0x%08x\n", revision2);
725d86bf
                     break;
d3e412d0
                 case 0xFF:
c96495e7
                     av_log (s, AV_LOG_DEBUG, "end of header block reached (within audio subheader)\n");
d3e412d0
                     inSubheader = 0;
                     inHeader = 0;
                     break;
ad81a9fe
                 default:
c96495e7
                     av_log (s, AV_LOG_DEBUG, "element 0x%02x set to 0x%08x\n", subbyte, read_arbitary(pb));
ad81a9fe
                     break;
                 }
             }
             break;
         case 0xFF:
c96495e7
             av_log (s, AV_LOG_DEBUG, "end of header block reached\n");
ad81a9fe
             inHeader = 0;
             break;
         default:
c96495e7
             av_log (s, AV_LOG_DEBUG, "header element 0x%02x set to 0x%08x\n", byte, read_arbitary(pb));
ad81a9fe
             break;
         }
     }
 
93fa8b2b
     switch (compression_type) {
fd402a5a
     case  0: ea->audio_codec = CODEC_ID_PCM_S16LE; break;
93fa8b2b
     case  7: ea->audio_codec = CODEC_ID_ADPCM_EA; break;
e7583962
     case -1:
         switch (revision) {
         case  1: ea->audio_codec = CODEC_ID_ADPCM_EA_R1; break;
         case  2: ea->audio_codec = CODEC_ID_ADPCM_EA_R2; break;
         case  3: ea->audio_codec = CODEC_ID_ADPCM_EA_R3; break;
725d86bf
         case -1: break;
e7583962
         default:
             av_log(s, AV_LOG_ERROR, "unsupported stream type; revision=%i\n", revision);
             return 0;
         }
725d86bf
         switch (revision2) {
         case  8: ea->audio_codec = CODEC_ID_PCM_S16LE_PLANAR; break;
6819af82
         case 10: ea->audio_codec = CODEC_ID_ADPCM_EA_R2; break;
fc7ed9a6
         case 16: ea->audio_codec = CODEC_ID_MP3; break;
af8ed96f
         case -1: break;
725d86bf
         default:
e6a9dd6a
             ea->audio_codec = CODEC_ID_NONE;
725d86bf
             av_log(s, AV_LOG_ERROR, "unsupported stream type; revision2=%i\n", revision2);
             return 0;
         }
e7583962
         break;
93fa8b2b
     default:
         av_log(s, AV_LOG_ERROR, "unsupported stream type; compression_type=%i\n", compression_type);
         return 0;
     }
af704ee4
 
6c867e04
     if (ea->sample_rate == -1)
         ea->sample_rate = revision==3 ? 48000 : 22050;
 
215eb102
     return 1;
 }
 
98168220
 /*
  * Process EACS sound header
  * return 1 if success, 0 if invalid format, otherwise AVERROR_xxx
  */
 static int process_audio_header_eacs(AVFormatContext *s)
 {
     EaDemuxContext *ea = s->priv_data;
471fe57e
     AVIOContext *pb = s->pb;
98168220
     int compression_type;
 
e63a3628
     ea->sample_rate  = ea->big_endian ? avio_rb32(pb) : avio_rl32(pb);
     ea->bytes        = avio_r8(pb);   /* 1=8-bit, 2=16-bit */
     ea->num_channels = avio_r8(pb);
     compression_type = avio_r8(pb);
45a8a02a
     avio_skip(pb, 13);
98168220
 
     switch (compression_type) {
     case 0:
         switch (ea->bytes) {
         case 1: ea->audio_codec = CODEC_ID_PCM_S8;    break;
         case 2: ea->audio_codec = CODEC_ID_PCM_S16LE; break;
         }
         break;
     case 1: ea->audio_codec = CODEC_ID_PCM_MULAW; ea->bytes = 1; break;
fac84d3c
     case 2: ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_EACS; break;
98168220
     default:
         av_log (s, AV_LOG_ERROR, "unsupported stream type; audio compression_type=%i\n", compression_type);
     }
 
     return 1;
 }
 
7bb65d89
 /*
  * Process SEAD sound header
  * return 1 if success, 0 if invalid format, otherwise AVERROR_xxx
  */
 static int process_audio_header_sead(AVFormatContext *s)
 {
     EaDemuxContext *ea = s->priv_data;
471fe57e
     AVIOContext *pb = s->pb;
7bb65d89
 
e63a3628
     ea->sample_rate  = avio_rl32(pb);
     ea->bytes        = avio_rl32(pb);  /* 1=8-bit, 2=16-bit */
     ea->num_channels = avio_rl32(pb);
7bb65d89
     ea->audio_codec  = CODEC_ID_ADPCM_IMA_EA_SEAD;
 
     return 1;
 }
 
d9d9a8c0
 static int process_video_header_mdec(AVFormatContext *s)
 {
     EaDemuxContext *ea = s->priv_data;
471fe57e
     AVIOContext *pb = s->pb;
45a8a02a
     avio_skip(pb, 4);
e63a3628
     ea->width  = avio_rl16(pb);
     ea->height = avio_rl16(pb);
d9d9a8c0
     ea->time_base = (AVRational){1,15};
     ea->video_codec = CODEC_ID_MDEC;
     return 1;
 }
 
f4097430
 static int process_video_header_vp6(AVFormatContext *s)
 {
     EaDemuxContext *ea = s->priv_data;
471fe57e
     AVIOContext *pb = s->pb;
f4097430
 
45a8a02a
     avio_skip(pb, 16);
e63a3628
     ea->time_base.den = avio_rl32(pb);
     ea->time_base.num = avio_rl32(pb);
af704ee4
     ea->video_codec = CODEC_ID_VP6;
f4097430
 
     return 1;
 }
 
215eb102
 /*
  * Process EA file header
  * Returns 1 if the EA file is valid and successfully opened, 0 otherwise
  */
 static int process_ea_header(AVFormatContext *s) {
     uint32_t blockid, size = 0;
     EaDemuxContext *ea = s->priv_data;
471fe57e
     AVIOContext *pb = s->pb;
f8cab062
     int i;
 
     for (i=0; i<5 && (!ea->audio_codec || !ea->video_codec); i++) {
384c9c2f
         unsigned int startpos = avio_tell(pb);
2c82386d
         int err = 0;
215eb102
 
e63a3628
         blockid = avio_rl32(pb);
         size = avio_rl32(pb);
97e5dcc0
         if (i == 0)
             ea->big_endian = size > 0x000FFFFF;
         if (ea->big_endian)
8fc0162a
             size = av_bswap32(size);
f8cab062
 
         switch (blockid) {
94e8c227
             case ISNh_TAG:
e63a3628
                 if (avio_rl32(pb) != EACS_TAG) {
98168220
                     av_log (s, AV_LOG_ERROR, "unknown 1SNh headerid\n");
                     return 0;
                 }
                 err = process_audio_header_eacs(s);
                 break;
 
f8cab062
             case SCHl_TAG :
ebc22cc2
             case SHEN_TAG :
e63a3628
                 blockid = avio_rl32(pb);
fa34563b
                 if (blockid == GSTR_TAG) {
45a8a02a
                     avio_skip(pb, 4);
a07f1178
                 } else if ((blockid & 0xFFFF)!=PT00_TAG) {
fa34563b
                     av_log (s, AV_LOG_ERROR, "unknown SCHl headerid\n");
                     return 0;
                 }
2c82386d
                 err = process_audio_header_elements(s);
f8cab062
                 break;
 
7bb65d89
             case SEAD_TAG:
                 err = process_audio_header_sead(s);
                 break;
 
b2f181c2
             case MVIh_TAG :
                 ea->video_codec = CODEC_ID_CMV;
                 break;
 
bbf020e9
             case kVGT_TAG:
                 ea->video_codec = CODEC_ID_TGV;
                 break;
 
d9d9a8c0
             case mTCD_TAG :
                 err = process_video_header_mdec(s);
                 break;
 
d3302b70
             case MPCh_TAG:
                 ea->video_codec = CODEC_ID_MPEG2VIDEO;
                 break;
 
d2299316
             case pQGT_TAG:
             case TGQs_TAG:
                 ea->video_codec = CODEC_ID_TGQ;
                 break;
 
468d298d
             case pIQT_TAG:
                 ea->video_codec = CODEC_ID_TQI;
                 break;
 
eacfe858
             case MADk_TAG :
                 ea->video_codec = CODEC_ID_MAD;
                 break;
 
f8cab062
             case MVhd_TAG :
2c82386d
                 err = process_video_header_vp6(s);
f8cab062
                 break;
         }
 
2c82386d
         if (err < 0) {
             av_log(s, AV_LOG_ERROR, "error parsing header: %i\n", err);
             return err;
         }
 
f59d8ff8
         avio_seek(pb, startpos + size, SEEK_SET);
f8cab062
     }
215eb102
 
f59d8ff8
     avio_seek(pb, 0, SEEK_SET);
ad81a9fe
 
     return 1;
 }
 
 
 static int ea_probe(AVProbeData *p)
 {
39fe9d79
     switch (AV_RL32(&p->buf[0])) {
97e6ee20
     case ISNh_TAG:
39fe9d79
     case SCHl_TAG:
7bb65d89
     case SEAD_TAG:
ebc22cc2
     case SHEN_TAG:
968fc6b9
     case kVGT_TAG:
     case MADk_TAG:
     case MPCh_TAG:
39fe9d79
     case MVhd_TAG:
968fc6b9
     case MVIh_TAG:
892d7e78
         break;
     default:
         return 0;
39fe9d79
     }
892d7e78
     if (AV_RL32(&p->buf[4]) > 0xfffff && AV_RB32(&p->buf[4]) > 0xfffff)
         return 0;
     return AVPROBE_SCORE_MAX;
ad81a9fe
 }
 
 static int ea_read_header(AVFormatContext *s,
                           AVFormatParameters *ap)
 {
e4141433
     EaDemuxContext *ea = s->priv_data;
ad81a9fe
     AVStream *st;
 
     if (!process_ea_header(s))
6f3e0b21
         return AVERROR(EIO);
ad81a9fe
 
ab89dbd4
     if (ea->video_codec) {
227a388d
         /* initialize the video decoder stream */
         st = av_new_stream(s, 0);
         if (!st)
             return AVERROR(ENOMEM);
         ea->video_stream_index = st->index;
72415b2a
         st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
af704ee4
         st->codec->codec_id = ea->video_codec;
f0a68a20
         // parsing is necessary to make FFmpeg generate correct timestamps
         if (st->codec->codec_id == CODEC_ID_MPEG2VIDEO)
             st->need_parsing = AVSTREAM_PARSE_HEADERS;
227a388d
         st->codec->codec_tag = 0;  /* no fourcc */
3c10843f
         if (ea->time_base.num)
             av_set_pts_info(st, 64, ea->time_base.num, ea->time_base.den);
d9d9a8c0
         st->codec->width = ea->width;
         st->codec->height = ea->height;
d3e412d0
     }
ad81a9fe
 
c611463f
     if (ea->audio_codec) {
42396c2e
         if (ea->num_channels <= 0) {
             av_log(s, AV_LOG_WARNING, "Unsupported number of channels: %d\n", ea->num_channels);
             ea->audio_codec = 0;
             return 1;
         }
         if (ea->sample_rate <= 0) {
             av_log(s, AV_LOG_ERROR, "Unsupported sample rate: %d\n", ea->sample_rate);
             ea->audio_codec = 0;
             return 1;
         }
 
a2c9473d
         /* initialize the audio decoder stream */
         st = av_new_stream(s, 0);
         if (!st)
             return AVERROR(ENOMEM);
         av_set_pts_info(st, 33, 1, ea->sample_rate);
72415b2a
         st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
a2c9473d
         st->codec->codec_id = ea->audio_codec;
         st->codec->codec_tag = 0;  /* no tag */
         st->codec->channels = ea->num_channels;
         st->codec->sample_rate = ea->sample_rate;
dd1c8f3e
         st->codec->bits_per_coded_sample = ea->bytes * 8;
a2c9473d
         st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
dd1c8f3e
             st->codec->bits_per_coded_sample / 4;
         st->codec->block_align = st->codec->channels*st->codec->bits_per_coded_sample;
a2c9473d
         ea->audio_stream_index = st->index;
         ea->audio_frame_counter = 0;
c611463f
     }
ad81a9fe
 
     return 1;
 }
 
 static int ea_read_packet(AVFormatContext *s,
                           AVPacket *pkt)
 {
     EaDemuxContext *ea = s->priv_data;
471fe57e
     AVIOContext *pb = s->pb;
ad81a9fe
     int ret = 0;
     int packet_read = 0;
     unsigned int chunk_type, chunk_size;
d3e412d0
     int key = 0;
b57ac115
     int av_uninit(num_samples);
ad81a9fe
 
     while (!packet_read) {
e63a3628
         chunk_type = avio_rl32(pb);
         chunk_size = (ea->big_endian ? avio_rb32(pb) : avio_rl32(pb)) - 8;
ad81a9fe
 
         switch (chunk_type) {
         /* audio data */
94e8c227
         case ISNh_TAG:
98168220
             /* header chunk also contains data; skip over the header portion*/
45a8a02a
             avio_skip(pb, 32);
98168220
             chunk_size -= 32;
94e8c227
         case ISNd_TAG:
ad81a9fe
         case SCDl_TAG:
7bb65d89
         case SNDC_TAG:
ebc22cc2
         case SDEN_TAG:
018d0ff9
             if (!ea->audio_codec) {
45a8a02a
                 avio_skip(pb, chunk_size);
018d0ff9
                 break;
fc7ed9a6
             } else if (ea->audio_codec == CODEC_ID_PCM_S16LE_PLANAR ||
                        ea->audio_codec == CODEC_ID_MP3) {
e63a3628
                 num_samples = avio_rl32(pb);
45a8a02a
                 avio_skip(pb, 8);
725d86bf
                 chunk_size -= 12;
018d0ff9
             }
2692067a
             ret = av_get_packet(pb, pkt, chunk_size);
f772b7fa
             if (ret < 0)
                 return ret;
46e97dc3
             pkt->stream_index = ea->audio_stream_index;
             pkt->pts = 90000;
             pkt->pts *= ea->audio_frame_counter;
             pkt->pts /= ea->sample_rate;
 
             switch (ea->audio_codec) {
             case CODEC_ID_ADPCM_EA:
                 /* 2 samples/byte, 1 or 2 samples per frame depending
                  * on stereo; chunk also has 12-byte header */
                 ea->audio_frame_counter += ((chunk_size - 12) * 2) /
                     ea->num_channels;
                 break;
             case CODEC_ID_PCM_S16LE_PLANAR:
             case CODEC_ID_MP3:
                 ea->audio_frame_counter += num_samples;
                 break;
             default:
                 ea->audio_frame_counter += chunk_size /
                     (ea->bytes * ea->num_channels);
             }
ad81a9fe
 
             packet_read = 1;
             break;
 
         /* ending tag */
44626387
         case 0:
94e8c227
         case ISNe_TAG:
ad81a9fe
         case SCEl_TAG:
7bb65d89
         case SEND_TAG:
ebc22cc2
         case SEEN_TAG:
6f3e0b21
             ret = AVERROR(EIO);
ad81a9fe
             packet_read = 1;
             break;
 
b2f181c2
         case MVIh_TAG:
bbf020e9
         case kVGT_TAG:
d2299316
         case pQGT_TAG:
         case TGQs_TAG:
eacfe858
         case MADk_TAG:
cc947f04
             key = AV_PKT_FLAG_KEY;
b2f181c2
         case MVIf_TAG:
bbf020e9
         case fVGT_TAG:
eacfe858
         case MADm_TAG:
         case MADe_TAG:
f59d8ff8
             avio_seek(pb, -8, SEEK_CUR);     // include chunk preamble
b2f181c2
             chunk_size += 8;
             goto get_video_packet;
 
d9d9a8c0
         case mTCD_TAG:
45a8a02a
             avio_skip(pb, 8);  // skip ea dct header
d9d9a8c0
             chunk_size -= 8;
             goto get_video_packet;
 
d3e412d0
         case MV0K_TAG:
d3302b70
         case MPCh_TAG:
468d298d
         case pIQT_TAG:
cc947f04
             key = AV_PKT_FLAG_KEY;
d3e412d0
         case MV0F_TAG:
b2f181c2
 get_video_packet:
d3e412d0
             ret = av_get_packet(pb, pkt, chunk_size);
f772b7fa
             if (ret < 0)
                 return ret;
46e97dc3
             pkt->stream_index = ea->video_stream_index;
             pkt->flags |= key;
d3e412d0
             packet_read = 1;
             break;
 
ad81a9fe
         default:
45a8a02a
             avio_skip(pb, chunk_size);
ad81a9fe
             break;
         }
     }
 
     return ret;
 }
 
66355be3
 AVInputFormat ff_ea_demuxer = {
ad81a9fe
     "ea",
bde15e74
     NULL_IF_CONFIG_SMALL("Electronic Arts Multimedia Format"),
ad81a9fe
     sizeof(EaDemuxContext),
     ea_probe,
     ea_read_header,
     ea_read_packet,
 };