[FFmpeg-cvslog] avcodec/lpc_functions: compute_lpc_coefs: add starting lpc order and err cache parameters
Peter Ross
git at videolan.org
Mon Jun 23 10:47:59 EEST 2025
ffmpeg | branch: master | Peter Ross <pross at xvid.org> | Sat Dec 21 20:43:53 2024 +1100| [a3c900a0c48910b55b0e07f05eeaeda55ed2268f] | committer: Peter Ross
avcodec/lpc_functions: compute_lpc_coefs: add starting lpc order and err cache parameters
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a3c900a0c48910b55b0e07f05eeaeda55ed2268f
---
libavcodec/aac/aacdec_dsp_template.c | 2 +-
libavcodec/aacenc_tns.c | 2 +-
libavcodec/lpc.c | 2 +-
libavcodec/lpc_functions.h | 18 +++++++++++++-----
libavcodec/ra288.c | 2 +-
5 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/libavcodec/aac/aacdec_dsp_template.c b/libavcodec/aac/aacdec_dsp_template.c
index 8d31af22f8..b64944d548 100644
--- a/libavcodec/aac/aacdec_dsp_template.c
+++ b/libavcodec/aac/aacdec_dsp_template.c
@@ -185,7 +185,7 @@ static void AAC_RENAME(apply_tns)(void *_coef_param, TemporalNoiseShaping *tns,
continue;
// tns_decode_coef
- compute_lpc_coefs(tns->AAC_RENAME(coef)[w][filt], order, lpc, 0, 0, 0);
+ compute_lpc_coefs(tns->AAC_RENAME(coef)[w][filt], 0, order, lpc, 0, 0, 0, NULL);
start = ics->swb_offset[FFMIN(bottom, mmm)];
end = ics->swb_offset[FFMIN( top, mmm)];
diff --git a/libavcodec/aacenc_tns.c b/libavcodec/aacenc_tns.c
index 7884c035cb..2f27444025 100644
--- a/libavcodec/aacenc_tns.c
+++ b/libavcodec/aacenc_tns.c
@@ -117,7 +117,7 @@ void ff_aac_apply_tns(AACEncContext *s, SingleChannelElement *sce)
continue;
// tns_decode_coef
- compute_lpc_coefs(tns->coef[w][filt], order, lpc, 0, 0, 0);
+ compute_lpc_coefs(tns->coef[w][filt], 0, order, lpc, 0, 0, 0, NULL);
start = ics->swb_offset[FFMIN(bottom, mmm)];
end = ics->swb_offset[FFMIN( top, mmm)];
diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c
index e793e54038..38c78d9521 100644
--- a/libavcodec/lpc.c
+++ b/libavcodec/lpc.c
@@ -267,7 +267,7 @@ int ff_lpc_calc_coefs(LPCContext *s,
s->lpc_compute_autocorr(s->windowed_samples, blocksize, max_order, autoc);
- compute_lpc_coefs(autoc, max_order, &lpc[0][0], MAX_LPC_ORDER, 0, 1);
+ compute_lpc_coefs(autoc, 0, max_order, &lpc[0][0], MAX_LPC_ORDER, 0, 1, NULL);
for(i=0; i<max_order; i++)
ref[i] = fabs(lpc[i][i]);
diff --git a/libavcodec/lpc_functions.h b/libavcodec/lpc_functions.h
index 57bcfab900..ea5f8868b9 100644
--- a/libavcodec/lpc_functions.h
+++ b/libavcodec/lpc_functions.h
@@ -51,22 +51,27 @@ typedef float LPC_TYPE_U;
* Levinson-Durbin recursion.
* Produce LPC coefficients from autocorrelation data.
*/
-static inline int compute_lpc_coefs(const LPC_TYPE *autoc, int max_order,
+static inline int compute_lpc_coefs(const LPC_TYPE *autoc, int i, int max_order,
LPC_TYPE *lpc, int lpc_stride, int fail,
- int normalize)
+ int normalize, LPC_TYPE *err_ptr)
{
LPC_TYPE err = 0;
LPC_TYPE *lpc_last = lpc;
av_assert2(normalize || !fail);
- if (normalize)
- err = *autoc++;
+ if (normalize) {
+ if (i == 0)
+ err = *autoc++;
+ else {
+ err = *err_ptr;
+ }
+ }
if (fail && (autoc[max_order - 1] == 0 || err <= 0))
return -1;
- for(int i = 0; i < max_order; i++) {
+ for( ; i < max_order; i++) {
LPC_TYPE r = LPC_SRA_R(-autoc[i], 5);
if (normalize) {
@@ -94,6 +99,9 @@ static inline int compute_lpc_coefs(const LPC_TYPE *autoc, int max_order,
lpc += lpc_stride;
}
+ if (err_ptr)
+ *err_ptr = err;
+
return 0;
}
diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c
index a1ee3f7eba..550af7f29f 100644
--- a/libavcodec/ra288.c
+++ b/libavcodec/ra288.c
@@ -138,7 +138,7 @@ static void backward_filter(RA288Context *ractx,
do_hybrid_window(ractx->vector_fmul, order, n, non_rec, temp, hist, rec, window);
- if (!compute_lpc_coefs(temp, order, lpc, 0, 1, 1))
+ if (!compute_lpc_coefs(temp, 0, order, lpc, 0, 1, 1, NULL))
ractx->vector_fmul(lpc, lpc, tab, FFALIGN(order, 16));
memmove(hist, hist + n, move_size*sizeof(*hist));
More information about the ffmpeg-cvslog
mailing list