+/*
+ * 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;
+ AVIOContext *pb = s->pb;
+ int compression_type;
+
+ 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);
+ avio_skip(pb, 13);
+
+ 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;
+ case 2: ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_EACS; break;
+ default:
+ av_log (s, AV_LOG_ERROR, "unsupported stream type; audio compression_type=%i\n", compression_type);
+ }
+
+ return 1;
+}
+
+/*
+ * 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;
+ AVIOContext *pb = s->pb;
+
+ ea->sample_rate = avio_rl32(pb);
+ ea->bytes = avio_rl32(pb); /* 1=8-bit, 2=16-bit */
+ ea->num_channels = avio_rl32(pb);
+ ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_SEAD;
+
+ return 1;
+}
+
+static int process_video_header_mdec(AVFormatContext *s)
+{
+ EaDemuxContext *ea = s->priv_data;
+ AVIOContext *pb = s->pb;
+ avio_skip(pb, 4);
+ ea->width = avio_rl16(pb);
+ ea->height = avio_rl16(pb);
+ ea->time_base = (AVRational){1,15};
+ ea->video_codec = CODEC_ID_MDEC;
+ return 1;
+}
+