[FFmpeg-cvslog] alac: reduce the number of local variables needed in lpc prediction

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


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Mon Jul  9 11:18:21 2012 -0400| [abc4376b31b672f8f38c30851cbe1acd016b6e18] | committer: Justin Ruggles

alac: reduce the number of local variables needed in lpc prediction

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

 libavcodec/alac.c |   24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index b19973d..7306e57 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -204,28 +204,27 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer,
     /* general case */
     for (i = predictor_coef_num + 1; i < output_size; i++) {
         int j;
-        int sum = 0;
-        int outval;
+        int val = 0;
         int error_val = error_buffer[i];
 
         for (j = 0; j < predictor_coef_num; j++) {
-            sum += (buffer_out[predictor_coef_num-j] - buffer_out[0]) *
+            val += (buffer_out[predictor_coef_num-j] - buffer_out[0]) *
                    predictor_coef_table[j];
         }
 
-        outval = (1 << (predictor_quantitization-1)) + sum;
-        outval = outval >> predictor_quantitization;
-        outval = outval + buffer_out[0] + error_val;
-        outval = sign_extend(outval, readsamplesize);
+        val = (val + (1 << (predictor_quantitization - 1))) >>
+              predictor_quantitization;
+        val += buffer_out[0] + error_val;
 
-        buffer_out[predictor_coef_num+1] = outval;
+        buffer_out[predictor_coef_num + 1] = sign_extend(val, readsamplesize);
 
         if (error_val > 0) {
             int predictor_num = predictor_coef_num - 1;
 
             while (predictor_num >= 0 && error_val > 0) {
-                int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num];
-                int sign = sign_only(val);
+                int sign;
+                val  = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num];
+                sign = sign_only(val);
 
                 predictor_coef_table[predictor_num] -= sign;
 
@@ -240,8 +239,9 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer,
             int predictor_num = predictor_coef_num - 1;
 
             while (predictor_num >= 0 && error_val < 0) {
-                int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num];
-                int sign = - sign_only(val);
+                int sign;
+                val  = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num];
+                sign = -sign_only(val);
 
                 predictor_coef_table[predictor_num] -= sign;
 



More information about the ffmpeg-cvslog mailing list