This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit d332cdafecf141e6d9c2de4f18b8b5f3891d81fc
Author:     Romain Beauxis <[email protected]>
AuthorDate: Thu Nov 19 22:14:40 2026 -0600
Commit:     Romain Beauxis <[email protected]>
CommitDate: Tue Nov 24 14:22:04 2026 +0000

    avcodec/libshine: declare the encoder delay
    
    shine starts from a zeroed filterbank and pads nothing, so its delay is
    that of its analysis filterbank: 528 samples, polyphase 240 and MDCT 288
    as LAME's libmp3lame/encoder.h breaks it down. With the decoder's, the
    decoded output lags the input by 1057 samples, which matches the lag
    measured by cross-correlating a decode with its input, and which was
    reported as 529.
---
 libavcodec/libshine.c                         | 9 ++++++++-
 tests/ref/fate/gaplessenc-pcm-to-mp3-libshine | 2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libshine.c b/libavcodec/libshine.c
index e7edc5b03f..efd5665f57 100644
--- a/libavcodec/libshine.c
+++ b/libavcodec/libshine.c
@@ -32,6 +32,12 @@
 
 #define BUFFER_SIZE (4096 * 20)
 
+/**
+ * Delay of the analysis filterbank, polyphase (240) and MDCT (288), as broken
+ * down in LAME's libmp3lame/encoder.h. shine adds no padding of its own.
+ */
+#define SHINE_ENCODER_DELAY 528
+
 typedef struct SHINEContext {
     shine_config_t  config;
     shine_t         shine;
@@ -57,7 +63,8 @@ static av_cold int libshine_encode_init(AVCodecContext *avctx)
     s->shine = shine_initialise(&s->config);
     if (!s->shine)
         return AVERROR(ENOMEM);
-    avctx->frame_size = shine_samples_per_pass(s->shine);
+    avctx->frame_size      = shine_samples_per_pass(s->shine);
+    avctx->initial_padding = SHINE_ENCODER_DELAY + MP3_DECODER_DELAY;
     ff_af_queue_init(avctx, &s->afq);
     return 0;
 }
diff --git a/tests/ref/fate/gaplessenc-pcm-to-mp3-libshine 
b/tests/ref/fate/gaplessenc-pcm-to-mp3-libshine
index c6273b9945..4873f593b7 100644
--- a/tests/ref/fate/gaplessenc-pcm-to-mp3-libshine
+++ b/tests/ref/fate/gaplessenc-pcm-to-mp3-libshine
@@ -1 +1 @@
-stream|start_pts=169280
+stream|start_pts=338240

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to