[FFmpeg-soc] [soc]: r3749 - in mlp: libavcodec_lpc_min_shift.diff mlpenc.c

ramiro subversion at mplayerhq.hu
Mon Sep 22 03:27:57 CEST 2008


Author: ramiro
Date: Mon Sep 22 03:27:57 2008
New Revision: 3749

Log:
Filter shift is only allowed from 8 to 15.

Added:
   mlp/libavcodec_lpc_min_shift.diff
Modified:
   mlp/mlpenc.c

Added: mlp/libavcodec_lpc_min_shift.diff
==============================================================================
--- (empty file)
+++ mlp/libavcodec_lpc_min_shift.diff	Mon Sep 22 03:27:57 2008
@@ -0,0 +1,83 @@
+Index: libavcodec/alacenc.c
+===================================================================
+--- libavcodec/alacenc.c	(revision 15277)
++++ libavcodec/alacenc.c	(working copy)
+@@ -131,7 +131,7 @@
+     int opt_order;
+ 
+     opt_order = ff_lpc_calc_coefs(&s->dspctx, s->sample_buf[ch], s->avctx->frame_size, s->min_prediction_order, s->max_prediction_order,
+-                                   ALAC_MAX_LPC_PRECISION, coefs, shift, 1, ORDER_METHOD_EST, ALAC_MAX_LPC_SHIFT, 1);
++                                   ALAC_MAX_LPC_PRECISION, coefs, shift, 1, ORDER_METHOD_EST, 0, ALAC_MAX_LPC_SHIFT, 1);
+ 
+     s->lpc[ch].lpc_order = opt_order;
+     s->lpc[ch].lpc_quant = shift[opt_order-1];
+Index: libavcodec/flacenc.c
+===================================================================
+--- libavcodec/flacenc.c	(revision 15277)
++++ libavcodec/flacenc.c	(working copy)
+@@ -857,7 +857,7 @@
+     /* LPC */
+     opt_order = ff_lpc_calc_coefs(&ctx->dsp, smp, n, min_order, max_order,
+                                   precision, coefs, shift, ctx->options.use_lpc,
+-                                  omethod, MAX_LPC_SHIFT, 0);
++                                  omethod, 0, MAX_LPC_SHIFT, 0);
+ 
+     if(omethod == ORDER_METHOD_2LEVEL ||
+        omethod == ORDER_METHOD_4LEVEL ||
+Index: libavcodec/lpc.c
+===================================================================
+--- libavcodec/lpc.c	(revision 15277)
++++ libavcodec/lpc.c	(working copy)
+@@ -30,7 +30,7 @@
+  * Quantize LPC coefficients
+  */
+ static void quantize_lpc_coefs(double *lpc_in, int order, int precision,
+-                               int32_t *lpc_out, int *shift, int max_shift, int zero_shift)
++                               int32_t *lpc_out, int *shift, int min_shift, int max_shift, int zero_shift)
+ {
+     int i;
+     double cmax, error;
+@@ -55,7 +55,7 @@
+ 
+     /* calculate level shift which scales max coeff to available bits */
+     sh = max_shift;
+-    while((cmax * (1 << sh) > qmax) && (sh > 0)) {
++    while((cmax * (1 << sh) > qmax) && (sh > min_shift)) {
+         sh--;
+     }
+ 
+@@ -99,7 +99,7 @@
+                       const int32_t *samples, int blocksize, int min_order,
+                       int max_order, int precision,
+                       int32_t coefs[][MAX_LPC_ORDER], int *shift, int use_lpc,
+-                      int omethod, int max_shift, int zero_shift)
++                      int omethod, int min_shift, int max_shift, int zero_shift)
+ {
+     double autoc[MAX_LPC_ORDER+1];
+     double ref[MAX_LPC_ORDER];
+@@ -158,10 +158,10 @@
+     if(omethod == ORDER_METHOD_EST) {
+         opt_order = estimate_best_order(ref, min_order, max_order);
+         i = opt_order-1;
+-        quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], max_shift, zero_shift);
++        quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], min_shift, max_shift, zero_shift);
+     } else {
+         for(i=min_order-1; i<max_order; i++) {
+-            quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], max_shift, zero_shift);
++            quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], min_shift, max_shift, zero_shift);
+         }
+     }
+ 
+Index: libavcodec/lpc.h
+===================================================================
+--- libavcodec/lpc.h	(revision 15277)
++++ libavcodec/lpc.h	(working copy)
+@@ -43,7 +43,7 @@
+                       const int32_t *samples, int blocksize, int min_order,
+                       int max_order, int precision,
+                       int32_t coefs[][MAX_LPC_ORDER], int *shift, int use_lpc,
+-                      int omethod, int max_shift, int zero_shift);
++                      int omethod, int min_shift, int max_shift, int zero_shift);
+ 
+ #ifdef LPC_USE_DOUBLE
+ #define LPC_TYPE double

Modified: mlp/mlpenc.c
==============================================================================
--- mlp/mlpenc.c	(original)
+++ mlp/mlpenc.c	Mon Sep 22 03:27:57 2008
@@ -31,7 +31,8 @@
 
 #define MLP_MIN_LPC_ORDER      1
 #define MLP_MAX_LPC_ORDER      8
-#define MLP_MAX_LPC_SHIFT     16
+#define MLP_MIN_LPC_SHIFT      8
+#define MLP_MAX_LPC_SHIFT     15
 
 typedef struct {
     uint8_t         min_channel;         ///< The index of the first channel coded in this substream.
@@ -1394,7 +1395,7 @@ static void set_filter_params(MLPEncodeC
         order = ff_lpc_calc_coefs(&ctx->dsp, ctx->lpc_sample_buffer, ctx->number_of_samples,
                                   MLP_MIN_LPC_ORDER, MLP_MAX_LPC_ORDER, 7,
                                   coefs, shift, 1,
-                                  ORDER_METHOD_EST, MLP_MAX_LPC_SHIFT, 0);
+                                  ORDER_METHOD_EST, MLP_MIN_LPC_SHIFT, MLP_MAX_LPC_SHIFT, MLP_MIN_LPC_SHIFT);
 
         fp->order = order;
         fp->shift = shift[order-1];



More information about the FFmpeg-soc mailing list