[FFmpeg-soc] [soc]: r3204 - mlp/mlpenc.c

ramiro subversion at mplayerhq.hu
Wed Aug 13 01:10:51 CEST 2008


Author: ramiro
Date: Wed Aug 13 01:10:50 2008
New Revision: 3204

Log:
Add sign shift for codebook 3 to offset.

Modified:
   mlp/mlpenc.c

Modified: mlp/mlpenc.c
==============================================================================
--- mlp/mlpenc.c	(original)
+++ mlp/mlpenc.c	Wed Aug 13 01:10:50 2008
@@ -668,16 +668,6 @@ static const uint8_t *huffman_bits[] = {
     huffman_bits0, huffman_bits1, huffman_bits2,
 };
 
-static const uint8_t huffman_bitcount2[] = {
-    9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3,
-    1, 1,
-    3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
-};
-
-static const uint8_t *huffman_bitcount[] = {
-    huffman_bits0, huffman_bits1, huffman_bitcount2,
-};
-
 static const uint8_t huffman_codes0[] = {
     0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
     0x04, 0x05, 0x06, 0x07,
@@ -767,7 +757,8 @@ static inline void codebook_bits_offset(
     DecodingParams *dp = &ctx->decoding_params[substr];
     int32_t codebook_min = codebook_extremes[codebook][0];
     int32_t codebook_max = codebook_extremes[codebook][1];
-    int codebook_offset  = -codebook_min;
+    int codebook_offset  = codebook_offsets [codebook];
+    int32_t unsign_offset = offset;
     int lsb_bits = 0, bitcount = 0;
     int next = INT_MAX;
     int unsign, mask;
@@ -785,11 +776,16 @@ static inline void codebook_bits_offset(
     unsign = 1 << lsb_bits;
     mask   = unsign - 1;
 
+    if (codebook == 2) {
+        unsign_offset -= unsign;
+        lsb_bits++;
+    }
+
     for (i = 0; i < dp->blocksize; i++) {
         int32_t sample = ctx->sample_buffer[i][channel] >> dp->quant_step_size[channel];
         int temp_next;
 
-        sample -= offset;
+        sample -= unsign_offset;
 
         if (up)
             temp_next = unsign - (sample & mask);
@@ -801,12 +797,9 @@ static inline void codebook_bits_offset(
 
         sample >>= lsb_bits;
 
-        bitcount += huffman_bitcount[codebook][sample + codebook_offset];
+        bitcount += huffman_bits[codebook][sample + codebook_offset];
     }
 
-    if (codebook == 2)
-        lsb_bits++;
-
     bo->offset   = offset;
     bo->lsb_bits = lsb_bits;
     bo->bitcount = lsb_bits * dp->blocksize + bitcount;



More information about the FFmpeg-soc mailing list