diff electronicarts.c @ 2685:1774032af3e6 libavformat

EA IMA SEAD decoder original patch by Peter Ross
author aurel
date Tue, 30 Oct 2007 23:12:18 +0000
parents 43ca0db0aa92
children af608703bde1
line wrap: on
line diff
--- a/electronicarts.c	Tue Oct 30 08:10:45 2007 +0000
+++ b/electronicarts.c	Tue Oct 30 23:12:18 2007 +0000
@@ -27,6 +27,9 @@
 #include "avformat.h"
 
 #define SCHl_TAG MKTAG('S', 'C', 'H', 'l')
+#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 */
 #define ISNh_TAG MKTAG('1', 'S', 'N', 'h')    /* 1SNx header */
 #define EACS_TAG MKTAG('E', 'A', 'C', 'S')
 #define ISNd_TAG MKTAG('1', 'S', 'N', 'd')    /* 1SNx data */
@@ -205,6 +208,23 @@
     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_vp6(AVFormatContext *s)
 {
     EaDemuxContext *ea = s->priv_data;
@@ -259,6 +279,10 @@
                 err = process_audio_header_elements(s);
                 break;
 
+            case SEAD_TAG:
+                err = process_audio_header_sead(s);
+                break;
+
             case MVhd_TAG :
                 err = process_video_header_vp6(s);
                 break;
@@ -283,6 +307,7 @@
     switch (AV_RL32(&p->buf[0])) {
     case ISNh_TAG:
     case SCHl_TAG:
+    case SEAD_TAG:
     case MVhd_TAG:
         return AVPROBE_SCORE_MAX;
     }
@@ -354,6 +379,7 @@
             chunk_size -= 32;
         case ISNd_TAG:
         case SCDl_TAG:
+        case SNDC_TAG:
             if (!ea->audio_codec) {
                 url_fskip(pb, chunk_size);
                 break;
@@ -387,6 +413,7 @@
         case 0:
         case ISNe_TAG:
         case SCEl_TAG:
+        case SEND_TAG:
             ret = AVERROR(EIO);
             packet_read = 1;
             break;