[FFmpeg-cvslog] alac: eliminate 2 unneeded local variables in bastardized_rice_decompress()

Justin Ruggles git at videolan.org
Thu Jul 19 23:35:49 CEST 2012


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Mon Jul  9 10:53:28 2012 -0400| [7e6593e9773773b5f6ad19fe4cdb2334d492493c] | committer: Justin Ruggles

alac: eliminate 2 unneeded local variables in bastardized_rice_decompress()

x_modified is just unnecessary, and final_val can be removed by simplifying
the unsigned-to-signed conversion.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7e6593e9773773b5f6ad19fe4cdb2334d492493c
---

 libavcodec/alac.c |   23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index f27992d..2aab84c 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -110,32 +110,23 @@ static void bastardized_rice_decompress(ALACContext *alac,
     int sign_modifier = 0;
 
     for (output_count = 0; output_count < output_size; output_count++) {
-        int32_t x;
-        int32_t x_modified;
-        int32_t final_val;
-
-        /* standard rice encoding */
-        int k; /* size of extra bits */
+        int x, k;
 
         /* read k, that is bits as is */
         k = av_log2((history >> 9) + 3);
         k = FFMIN(k, alac->rice_limit);
         x = decode_scalar(&alac->gb, k, readsamplesize);
-
-        x_modified = sign_modifier + x;
-        final_val = (x_modified + 1) / 2;
-        if (x_modified & 1) final_val *= -1;
-
-        output_buffer[output_count] = final_val;
-
+        x += sign_modifier;
         sign_modifier = 0;
 
+        output_buffer[output_count] = (x >> 1) ^ -(x & 1);
+
         /* now update the history */
-        if (x_modified > 0xffff)
+        if (x > 0xffff)
             history = 0xffff;
         else
-            history += x_modified * rice_history_mult -
-                        ((history * rice_history_mult) >> 9);
+            history +=         x * rice_history_mult -
+                       ((history * rice_history_mult) >> 9);
 
         /* special case: there may be compressed blocks of 0 */
         if ((history < 128) && (output_count+1 < output_size)) {



More information about the ffmpeg-cvslog mailing list