[FFmpeg-cvslog] lavc/lpc: Add min_shift parameter in LPC
Jai Luthra
git at videolan.org
Sun Aug 28 12:22:13 EEST 2016
ffmpeg | branch: master | Jai Luthra <me at jailuthra.in> | Tue Aug 23 02:50:04 2016 +0530| [0c023d181e581a0299d96a5edf7a736bdc66dc43] | committer: Michael Niedermayer
lavc/lpc: Add min_shift parameter in LPC
The min_shift parameter is needed by the MLP encoder
Signed-off-by: Jai Luthra <me at jailuthra.in>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0c023d181e581a0299d96a5edf7a736bdc66dc43
---
libavcodec/alacenc.c | 4 +++-
libavcodec/flacenc.c | 3 ++-
libavcodec/lpc.c | 13 ++++++++-----
libavcodec/lpc.h | 2 +-
libavcodec/ra144enc.c | 2 +-
5 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c
index 9095611..804cc7b 100644
--- a/libavcodec/alacenc.c
+++ b/libavcodec/alacenc.c
@@ -38,6 +38,7 @@
#define DEFAULT_MAX_PRED_ORDER 6
#define DEFAULT_MIN_PRED_ORDER 4
#define ALAC_MAX_LPC_PRECISION 9
+#define ALAC_MIN_LPC_SHIFT 0
#define ALAC_MAX_LPC_SHIFT 9
#define ALAC_CHMODE_LEFT_RIGHT 0
@@ -171,7 +172,8 @@ static void calc_predictor_params(AlacEncodeContext *s, int ch)
s->max_prediction_order,
ALAC_MAX_LPC_PRECISION, coefs, shift,
FF_LPC_TYPE_LEVINSON, 0,
- ORDER_METHOD_EST, ALAC_MAX_LPC_SHIFT, 1);
+ ORDER_METHOD_EST, ALAC_MIN_LPC_SHIFT,
+ ALAC_MAX_LPC_SHIFT, 1);
s->lpc[ch].lpc_order = opt_order;
s->lpc[ch].lpc_quant = shift[opt_order-1];
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index 9d6a742..3575f53 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -44,6 +44,7 @@
#define MAX_PARTITION_ORDER 8
#define MAX_PARTITIONS (1 << MAX_PARTITION_ORDER)
#define MAX_LPC_PRECISION 15
+#define MIN_LPC_SHIFT 0
#define MAX_LPC_SHIFT 15
enum CodingMode {
@@ -884,7 +885,7 @@ static int encode_residual_ch(FlacEncodeContext *s, int ch)
opt_order = ff_lpc_calc_coefs(&s->lpc_ctx, smp, n, min_order, max_order,
s->options.lpc_coeff_precision, coefs, shift, s->options.lpc_type,
s->options.lpc_passes, omethod,
- MAX_LPC_SHIFT, 0);
+ MIN_LPC_SHIFT, MAX_LPC_SHIFT, 0);
if (omethod == ORDER_METHOD_2LEVEL ||
omethod == ORDER_METHOD_4LEVEL ||
diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c
index 052aeaa..f8da1e1 100644
--- a/libavcodec/lpc.c
+++ b/libavcodec/lpc.c
@@ -93,7 +93,8 @@ static void lpc_compute_autocorr_c(const double *data, int len, int lag,
* 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;
@@ -118,7 +119,7 @@ static void quantize_lpc_coefs(double *lpc_in, int order, int precision,
/* 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--;
}
@@ -201,7 +202,7 @@ int ff_lpc_calc_coefs(LPCContext *s,
int max_order, int precision,
int32_t coefs[][MAX_LPC_ORDER], int *shift,
enum FFLPCType lpc_type, int lpc_passes,
- 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] = { 0 };
@@ -284,10 +285,12 @@ int ff_lpc_calc_coefs(LPCContext *s,
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);
}
}
diff --git a/libavcodec/lpc.h b/libavcodec/lpc.h
index edb1a6b..182adfa 100644
--- a/libavcodec/lpc.h
+++ b/libavcodec/lpc.h
@@ -95,7 +95,7 @@ int ff_lpc_calc_coefs(LPCContext *s,
int max_order, int precision,
int32_t coefs[][MAX_LPC_ORDER], int *shift,
enum FFLPCType lpc_type, int lpc_passes,
- int omethod, int max_shift, int zero_shift);
+ int omethod, int min_shift, int max_shift, int zero_shift);
int ff_lpc_calc_ref_coefs(LPCContext *s,
const int32_t *samples, int order, double *ref);
diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c
index d3a7fff..cc4f381 100644
--- a/libavcodec/ra144enc.c
+++ b/libavcodec/ra144enc.c
@@ -475,7 +475,7 @@ static int ra144_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
ff_lpc_calc_coefs(&ractx->lpc_ctx, lpc_data, NBLOCKS * BLOCKSIZE, LPC_ORDER,
LPC_ORDER, 16, lpc_coefs, shift, FF_LPC_TYPE_LEVINSON,
- 0, ORDER_METHOD_EST, 12, 0);
+ 0, ORDER_METHOD_EST, 0, 12, 0);
for (i = 0; i < LPC_ORDER; i++)
block_coefs[NBLOCKS - 1][i] = -(lpc_coefs[LPC_ORDER - 1][i] <<
(12 - shift[LPC_ORDER - 1]));
More information about the ffmpeg-cvslog
mailing list