+/*
+ * 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;
+ ByteIOContext *pb = s->pb;
+ int compression_type;
+
+ ea->sample_rate = ea->big_endian ? get_be32(pb) : get_le32(pb);
+ ea->bytes = get_byte(pb); /* 1=8-bit, 2=16-bit */
+ ea->num_channels = get_byte(pb);
+ compression_type = get_byte(pb);
+ url_fskip(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;
+ ByteIOContext *pb = s->pb;
+
+ ea->sample_rate = get_le32(pb);
+ ea->bytes = get_le32(pb); /* 1=8-bit, 2=16-bit */
+ ea->num_channels = get_le32(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;
+ ByteIOContext *pb = s->pb;
+ url_fskip(pb, 4);
+ ea->width = get_le16(pb);
+ ea->height = get_le16(pb);
+ ea->time_base = (AVRational){1,15};
+ ea->video_codec = CODEC_ID_MDEC;
+ return 1;
+}
+