[FFmpeg-cvslog] libfdk-aacdec: Apply the decoder's output delay on timestamps

Martin Storsjö git at videolan.org
Tue Feb 11 11:40:41 EET 2020


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Tue Feb  4 16:03:57 2020 +0200| [0f2b6594fc893c84e383e28136af5c9a3631e311] | committer: Martin Storsjö

libfdk-aacdec: Apply the decoder's output delay on timestamps

The delay is normally zero when the level limiter is disabled,
but if enabled, there's a small delay.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0f2b6594fc893c84e383e28136af5c9a3631e311
---

 libavcodec/libfdk-aacdec.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavcodec/libfdk-aacdec.c b/libavcodec/libfdk-aacdec.c
index 1abe1d8438..d9b080cf3e 100644
--- a/libavcodec/libfdk-aacdec.c
+++ b/libavcodec/libfdk-aacdec.c
@@ -57,6 +57,7 @@ typedef struct FDKAACDecContext {
     int drc_effect;
     int drc_cut;
     int level_limit;
+    int output_delay;
 } FDKAACDecContext;
 
 
@@ -115,6 +116,9 @@ static int get_stream_info(AVCodecContext *avctx)
     }
     avctx->sample_rate = info->sampleRate;
     avctx->frame_size  = info->frameSize;
+#if FDKDEC_VER_AT_LEAST(2, 5) // 2.5.10
+    s->output_delay    = info->outputDelay;
+#endif
 
     for (i = 0; i < info->numChannels; i++) {
         AUDIO_CHANNEL_TYPE ctype = info->pChannelType[i];
@@ -367,6 +371,11 @@ static int fdk_aac_decode_frame(AVCodecContext *avctx, void *data,
     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         goto end;
 
+    if (frame->pts != AV_NOPTS_VALUE)
+        frame->pts -= av_rescale_q(s->output_delay,
+                                   (AVRational){1, avctx->sample_rate},
+                                   avctx->time_base);
+
     memcpy(frame->extended_data[0], s->decoder_buffer,
            avctx->channels * avctx->frame_size *
            av_get_bytes_per_sample(avctx->sample_fmt));



More information about the ffmpeg-cvslog mailing list