Commit 0f2b6594 authored by Martin Storsjö's avatar 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: 's avatarMartin Storsjö <martin@martin.st>
parent dd81f739
......@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment