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

Git pushed a commit to branch master
in repository ffmpeg.

commit 87bcbbff5722867d1d9e82c12299bd23382782c8
Author:     James Almer <[email protected]>
AuthorDate: Fri Jul 3 13:28:51 2026 -0300
Commit:     James Almer <[email protected]>
CommitDate: Sat Jul 11 11:10:12 2026 -0300

    avcodec/libfdk-aacenc: don't propagate a skip samples value higher than the 
frame size
    
    This puts the burden of keeping track of remaining samples on the user.
    It's best if we just report the exact amount of discardable samples
    within the packet's duration.
    
    Signed-off-by: James Almer <[email protected]>
---
 libavcodec/libfdk-aacenc.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
index 6c28633fba..168b9d775d 100644
--- a/libavcodec/libfdk-aacenc.c
+++ b/libavcodec/libfdk-aacenc.c
@@ -55,7 +55,7 @@ typedef struct AACContext {
     int prog_ref;
     int metadata_mode;
     AACENC_MetaData metaDataSetup;
-    int delay_sent;
+    int delay;
     int frame_length;
 
     AudioFrameQueue afq;
@@ -421,6 +421,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
     }
 
     avctx->frame_size = info.frameLength;
+    s->delay =
 #if FDKENC_VER_AT_LEAST(4, 0) // 4.0.0
     avctx->initial_padding = info.nDelay;
 #else
@@ -536,14 +537,16 @@ static int aac_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
         av_log(avctx, AV_LOG_ERROR, "discard padding overflow\n");
         return AVERROR(EINVAL);
     }
-    if ((!s->delay_sent && avctx->initial_padding > 0) || discard_padding > 0) 
{
+
+    if (s->delay > 0 || discard_padding > 0) {
         uint8_t *side_data =
             av_packet_new_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, 10);
         if (!side_data)
             return AVERROR(ENOMEM);
-        if (!s->delay_sent) {
-            AV_WL32(side_data, avctx->initial_padding);
-            s->delay_sent = 1;
+        if (s->delay) {
+            AV_WL32(side_data, FFMIN(s->delay, 
ff_samples_from_time_base(avctx, avpkt->duration)));
+            s->delay -= ff_samples_from_time_base(avctx, avpkt->duration);
+            s->delay = FFMAX(s->delay, 0);
         }
         AV_WL32(side_data + 4, discard_padding);
     }

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to