[FFmpeg-devel] [PATCH] Reduce default FDK decoder delay by one frame
Omer Osman
omer.osman at iis.fraunhofer.de
Wed Feb 26 16:48:41 CET 2014
The default concealment method in the FDK decoder is Energy
Interpolation. This method requires one frame delay to the output. To
reduce the default output delay, use Noise Substitution as the default
concealment method.
Signed-off-by: Omer Osman <omer.osman at iis.fraunhofer.de>
---
libavcodec/libfdk-aacdec.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/libavcodec/libfdk-aacdec.c b/libavcodec/libfdk-aacdec.c
index c833a98..c848aaa 100644
--- a/libavcodec/libfdk-aacdec.c
+++ b/libavcodec/libfdk-aacdec.c
@@ -1,18 +1,20 @@
/*
* AAC decoder wrapper
* Copyright (c) 2012 Martin Storsjo
+ * Copyright (c) 2014 Fraunhofer IIS (Authors: Conrad Benndorf, Omer Osman)
*
* This file is part of FFmpeg.
+ * Do not use non-GPL-compatible AAC decoders if you also use FFmpeg
+ * together with GPL-licensed modules, such as the FFmpeg GPL modules.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
+ * License, version 2.1 (only) as published by the Free Software Foundation.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
+ * Lesser General Public License, version 2.1, for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
@@ -45,8 +47,7 @@ typedef struct FDKAACDecContext {
#define OFFSET(x) offsetof(FDKAACDecContext, x)
#define AD AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
static const AVOption fdk_aac_dec_options[] = {
- { "conceal", "Error concealment method", OFFSET(conceal_method), AV_OPT_TYPE_INT, { .i64 = CONCEAL_METHOD_DEFAULT }, CONCEAL_METHOD_DEFAULT, CONCEAL_METHOD_NB - 1, AD, "conceal" },
- { "default", "Default", 0, AV_OPT_TYPE_CONST, { .i64 = CONCEAL_METHOD_DEFAULT }, INT_MIN, INT_MAX, AD, "conceal" },
+ { "conceal", "Error concealment method", OFFSET(conceal_method), AV_OPT_TYPE_INT, { .i64 = CONCEAL_METHOD_NOISE_SUBSTITUTION }, CONCEAL_METHOD_DEFAULT, CONCEAL_METHOD_NB - 1, AD, "conceal" },
{ "spectral", "Spectral muting", 0, AV_OPT_TYPE_CONST, { .i64 = CONCEAL_METHOD_SPECTRAL_MUTING }, INT_MIN, INT_MAX, AD, "conceal" },
{ "noise", "Noise Substitution", 0, AV_OPT_TYPE_CONST, { .i64 = CONCEAL_METHOD_NOISE_SUBSTITUTION }, INT_MIN, INT_MAX, AD, "conceal" },
{ "energy", "Energy Interpolation", 0, AV_OPT_TYPE_CONST, { .i64 = CONCEAL_METHOD_ENERGY_INTERPOLATION }, INT_MIN, INT_MAX, AD, "conceal" },
@@ -220,12 +221,15 @@ static int fdk_aac_decode_frame(AVCodecContext *avctx, void *data,
UINT valid = avpkt->size;
uint8_t *buf, *tmpptr = NULL;
int buf_size;
+ int decode_flag = avpkt->flags & AV_PKT_FLAG_CORRUPT ? AACDEC_CONCEAL : 0 ;
+ if (decode_flag != AACDEC_CONCEAL){
err = aacDecoder_Fill(s->handle, &avpkt->data, &avpkt->size, &valid);
if (err != AAC_DEC_OK) {
av_log(avctx, AV_LOG_ERROR, "aacDecoder_Fill() failed: %x\n", err);
return AVERROR_INVALIDDATA;
}
+ }
if (s->initialized) {
frame->nb_samples = avctx->frame_size;
@@ -241,7 +245,7 @@ static int fdk_aac_decode_frame(AVCodecContext *avctx, void *data,
return AVERROR(ENOMEM);
}
- err = aacDecoder_DecodeFrame(s->handle, (INT_PCM *) buf, buf_size, 0);
+ err = aacDecoder_DecodeFrame(s->handle, (INT_PCM *) buf, buf_size, decode_flag);
if (err == AAC_DEC_NOT_ENOUGH_BITS) {
ret = avpkt->size - valid;
goto end;
--
1.7.10.4
More information about the ffmpeg-devel
mailing list