Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Peter Ross <pross@xvid.org>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCHv3 3/8] avcodec/lpc_functions: compute_lpc_coefs: add starting lpc order and err cache parameters
Date: Mon, 9 Jun 2025 20:06:37 +1000
Message-ID: <8b3f1791f97ed6dfc04a570ecfa8e0d51e3ddc83.1749463495.git.pross@xvid.org> (raw)
In-Reply-To: <cover.1749463495.git.pross@xvid.org>


[-- Attachment #1.1: Type: text/plain, Size: 4169 bytes --]

---
 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));
-- 
2.47.2

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2025-06-09 10:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-09 10:05 [FFmpeg-devel] [PATCHv3 0/8] G.728 decoding Peter Ross
2025-06-09 10:06 ` [FFmpeg-devel] [PATCHv3 1/8] avcodec/g728_template: do_hybrid_window() template Peter Ross
2025-06-09 21:56   ` Tomas Härdin
2025-06-09 10:06 ` [FFmpeg-devel] [PATCHv3 2/8] avcodec/g728_template: make hist parameter constant Peter Ross
2025-06-09 10:06 ` Peter Ross [this message]
2025-06-09 10:07 ` [FFmpeg-devel] [PATCHv3 4/8] avcodec/g728dec: G.728 decoder Peter Ross
2025-06-09 10:07 ` [FFmpeg-devel] [PATCHv3 5/8] avformat/g728dec: raw G.728 demuxer Peter Ross
2025-06-09 10:08 ` [FFmpeg-devel] [PATCHv3 6/8] avformat/riff: G.728 muxing and demuxing Peter Ross
2025-06-09 10:08 ` [FFmpeg-devel] [PATCHv3 7/8] avformat/aiff: " Peter Ross
2025-06-09 22:25   ` Andreas Rheinhardt
2025-06-10  0:07     ` compn
2025-06-10  0:29     ` Peter Ross
2025-06-11 14:45       ` compn
2025-06-09 10:08 ` [FFmpeg-devel] [PATCHv3 8/8] avformat/rtp: " Peter Ross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8b3f1791f97ed6dfc04a570ecfa8e0d51e3ddc83.1749463495.git.pross@xvid.org \
    --to=pross@xvid.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git