Browse code

aiffdec: factor out handling of integer PCM for AIFF-C and plain AIFF

Justin Ruggles authored on 2012/03/22 03:48:35
Showing 1 changed files
... ...
@@ -110,17 +110,19 @@ static unsigned int get_aiff_header(AVFormatContext *s, int size,
110 110
     codec->sample_rate = sample_rate;
111 111
     size -= 18;
112 112
 
113
-    /* Got an AIFF-C? */
113
+    /* get codec id for AIFF-C */
114 114
     if (version == AIFF_C_VERSION1) {
115 115
         codec->codec_tag = avio_rl32(pb);
116 116
         codec->codec_id  = ff_codec_get_id(ff_codec_aiff_tags, codec->codec_tag);
117
+        size -= 4;
118
+    }
117 119
 
120
+    if (version != AIFF_C_VERSION1 || codec->codec_id == CODEC_ID_PCM_S16BE) {
121
+        codec->codec_id = aiff_codec_get_id(codec->bits_per_coded_sample);
122
+        codec->bits_per_coded_sample = av_get_bits_per_sample(codec->codec_id);
123
+        aiff->block_duration = 1;
124
+    } else {
118 125
         switch (codec->codec_id) {
119
-        case CODEC_ID_PCM_S16BE:
120
-            codec->codec_id = aiff_codec_get_id(codec->bits_per_coded_sample);
121
-            codec->bits_per_coded_sample = av_get_bits_per_sample(codec->codec_id);
122
-            aiff->block_duration = 1;
123
-            break;
124 126
         case CODEC_ID_ADPCM_IMA_QT:
125 127
             codec->block_align = 34*codec->channels;
126 128
             break;
... ...
@@ -139,16 +141,9 @@ static unsigned int get_aiff_header(AVFormatContext *s, int size,
139 139
         default:
140 140
             break;
141 141
         }
142
-        size -= 4;
143
-
144 142
         if (codec->block_align > 0)
145 143
             aiff->block_duration = av_get_audio_frame_duration(codec,
146 144
                                                                codec->block_align);
147
-    } else {
148
-        /* Need the codec type */
149
-        codec->codec_id = aiff_codec_get_id(codec->bits_per_coded_sample);
150
-        codec->bits_per_coded_sample = av_get_bits_per_sample(codec->codec_id);
151
-        aiff->block_duration = 1;
152 145
     }
153 146
 
154 147
     /* Block align needs to be computed in all cases, as the definition