]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/alac.c
Add mipsel architecture that differs from mips in endianness.
[ffmpeg] / libavcodec / alac.c
index 942f6865d4de4c18c28431c52c5270c4fb27686d..b9edf596a9cdae858366a3c241c2c2805262cd51 100644 (file)
@@ -201,9 +201,9 @@ static void bastardized_rice_decompress(ALACContext *alac,
 
                 if (extrabits > 1) {
                     x += extrabits - 1;
-                    get_bits(&alac->gb, k);
+                    skip_bits(&alac->gb, k);
                 } else
-                    get_bits(&alac->gb, k - 1);
+                    skip_bits(&alac->gb, k - 1);
             }
         }
 
@@ -250,9 +250,9 @@ static void bastardized_rice_decompress(ALACContext *alac,
                 if (extrabits < 2) {
                     x = 1 - extrabits;
                     block_size += x;
-                    get_bits(&alac->gb, k - 1);
+                    skip_bits(&alac->gb, k - 1);
                 } else {
-                    get_bits(&alac->gb, k);
+                    skip_bits(&alac->gb, k);
                 }
             }
 
@@ -399,11 +399,11 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer,
     }
 }
 
-static void deinterlace_16(int32_t *buffer[MAX_CHANNELS],
-                           int16_t *buffer_out,
-                           int numchannels, int numsamples,
-                           uint8_t interlacing_shift,
-                           uint8_t interlacing_leftweight)
+static void reconstruct_stereo_16(int32_t *buffer[MAX_CHANNELS],
+                                  int16_t *buffer_out,
+                                  int numchannels, int numsamples,
+                                  uint8_t interlacing_shift,
+                                  uint8_t interlacing_leftweight)
 {
     int i;
     if (numsamples <= 0)
@@ -412,19 +412,16 @@ static void deinterlace_16(int32_t *buffer[MAX_CHANNELS],
     /* weighted interlacing */
     if (interlacing_leftweight) {
         for (i = 0; i < numsamples; i++) {
-            int32_t difference, midright;
-            int16_t left;
-            int16_t right;
+            int32_t a, b;
 
-            midright = buffer[0][i];
-            difference = buffer[1][i];
+            a = buffer[0][i];
+            b = buffer[1][i];
 
+            a -= (b * interlacing_leftweight) >> interlacing_shift;
+            b += a;
 
-            right = midright - ((difference * interlacing_leftweight) >> interlacing_shift);
-            left = right + difference;
-
-            buffer_out[i*numchannels] = left;
-            buffer_out[i*numchannels + 1] = right;
+            buffer_out[i*numchannels] = b;
+            buffer_out[i*numchannels + 1] = a;
         }
 
         return;
@@ -487,17 +484,17 @@ static int alac_decode_frame(AVCodecContext *avctx,
     /* 2^result = something to do with output waiting.
      * perhaps matters if we read > 1 frame in a pass?
      */
-    get_bits(&alac->gb, 4);
+    skip_bits(&alac->gb, 4);
 
-    get_bits(&alac->gb, 12); /* unknown, skip 12 bits */
+    skip_bits(&alac->gb, 12); /* unknown, skip 12 bits */
 
     /* the output sample size is stored soon */
-    hassize = get_bits(&alac->gb, 1);
+    hassize = get_bits1(&alac->gb);
 
     wasted_bytes = get_bits(&alac->gb, 2); /* unknown ? */
 
     /* whether the frame is compressed */
-    isnotcompressed = get_bits(&alac->gb, 1);
+    isnotcompressed = get_bits1(&alac->gb);
 
     if (hassize) {
         /* now read the number of samples as a 32bit integer */
@@ -532,9 +529,8 @@ static int alac_decode_frame(AVCodecContext *avctx,
                 predictor_coef_table[chan][i] = (int16_t)get_bits(&alac->gb, 16);
         }
 
-        if (wasted_bytes) {
+        if (wasted_bytes)
             av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented, unhandling of wasted_bytes\n");
-        }
 
         for (chan = 0; chan < channels; chan++) {
             bastardized_rice_decompress(alac,
@@ -600,14 +596,14 @@ static int alac_decode_frame(AVCodecContext *avctx,
     }
 
     switch(alac->setinfo_sample_size) {
-    case 16: {
+    case 16:
         if (channels == 2) {
-            deinterlace_16(alac->outputsamples_buffer,
-                           (int16_t*)outbuffer,
-                           alac->numchannels,
-                           outputsamples,
-                           interlacing_shift,
-                           interlacing_leftweight);
+            reconstruct_stereo_16(alac->outputsamples_buffer,
+                                  (int16_t*)outbuffer,
+                                  alac->numchannels,
+                                  outputsamples,
+                                  interlacing_shift,
+                                  interlacing_leftweight);
         } else {
             int i;
             for (i = 0; i < outputsamples; i++) {
@@ -616,7 +612,6 @@ static int alac_decode_frame(AVCodecContext *avctx,
             }
         }
         break;
-    }
     case 20:
     case 24:
     case 32: