summaryrefslogtreecommitdiff
path: root/libavcodec/libfdk-aacdec.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2020-02-04 16:03:57 +0200
committerMartin Storsjö <martin@martin.st>2020-02-11 11:39:44 +0200
commit0f2b6594fc893c84e383e28136af5c9a3631e311 (patch)
tree1fa4c7498add073a659902fc78d4a404aa47065d /libavcodec/libfdk-aacdec.c
parentdd81f73946b85134441c0a917dc4dadf7b70ba85 (diff)
downloadffmpeg-0f2b6594fc893c84e383e28136af5c9a3631e311.tar.gz
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@martin.st>
Diffstat (limited to 'libavcodec/libfdk-aacdec.c')
-rw-r--r--libavcodec/libfdk-aacdec.c9
1 files changed, 9 insertions, 0 deletions
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));