mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-03-04 03:28:05 +00:00
avcodec/libfdk-accenc: Add option to set frame length when encoding with libfdk_aac
Some specifications require the size of ld/eld frames to be 480 samples instead of the default 512. libfdk_aac provides an option to set an alternative frame size, but it's not exposed via the ffmpeg interface. This patch adds a frame_length option to solve this problem. Signed-off-by: Raphael Schlarb <info@raphael.schlarb.one> Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
412d43b09a
commit
d2e1389285
@ -55,6 +55,7 @@ typedef struct AACContext {
|
|||||||
int metadata_mode;
|
int metadata_mode;
|
||||||
AACENC_MetaData metaDataSetup;
|
AACENC_MetaData metaDataSetup;
|
||||||
int delay_sent;
|
int delay_sent;
|
||||||
|
int frame_length;
|
||||||
|
|
||||||
AudioFrameQueue afq;
|
AudioFrameQueue afq;
|
||||||
} AACContext;
|
} AACContext;
|
||||||
@ -78,6 +79,7 @@ static const AVOption aac_enc_options[] = {
|
|||||||
{ "comp_profile", "The desired compression profile for AAC DRC", offsetof(AACContext, comp_profile), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 256, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
|
{ "comp_profile", "The desired compression profile for AAC DRC", offsetof(AACContext, comp_profile), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 256, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
|
||||||
{ "comp_target_ref", "Expected target reference level at decoder side in dB (for clipping prevention/limiter)", offsetof(AACContext, comp_target_ref), AV_OPT_TYPE_INT, { .i64 = 0.0 }, -31.75, 0, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
|
{ "comp_target_ref", "Expected target reference level at decoder side in dB (for clipping prevention/limiter)", offsetof(AACContext, comp_target_ref), AV_OPT_TYPE_INT, { .i64 = 0.0 }, -31.75, 0, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
|
||||||
{ "prog_ref", "The program reference level or dialog level in dB", offsetof(AACContext, prog_ref), AV_OPT_TYPE_INT, { .i64 = 0.0 }, -31.75, 0, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
|
{ "prog_ref", "The program reference level or dialog level in dB", offsetof(AACContext, prog_ref), AV_OPT_TYPE_INT, { .i64 = 0.0 }, -31.75, 0, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
|
||||||
|
{ "frame_length", "The desired frame length", offsetof(AACContext, frame_length), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1024, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
|
||||||
FF_AAC_PROFILE_OPTS
|
FF_AAC_PROFILE_OPTS
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
@ -166,6 +168,15 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s->frame_length >= 0) {
|
||||||
|
if ((err = aacEncoder_SetParam(s->handle, AACENC_GRANULE_LENGTH,
|
||||||
|
s->frame_length)) != AACENC_OK) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Unable to set granule length: %s\n",
|
||||||
|
aac_get_error(err));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((err = aacEncoder_SetParam(s->handle, AACENC_SAMPLERATE,
|
if ((err = aacEncoder_SetParam(s->handle, AACENC_SAMPLERATE,
|
||||||
avctx->sample_rate)) != AACENC_OK) {
|
avctx->sample_rate)) != AACENC_OK) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Unable to set the sample rate %d: %s\n",
|
av_log(avctx, AV_LOG_ERROR, "Unable to set the sample rate %d: %s\n",
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include "version_major.h"
|
#include "version_major.h"
|
||||||
|
|
||||||
#define LIBAVCODEC_VERSION_MINOR 7
|
#define LIBAVCODEC_VERSION_MINOR 7
|
||||||
#define LIBAVCODEC_VERSION_MICRO 100
|
#define LIBAVCODEC_VERSION_MICRO 101
|
||||||
|
|
||||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||||
LIBAVCODEC_VERSION_MINOR, \
|
LIBAVCODEC_VERSION_MINOR, \
|
||||||
|
Loading…
Reference in New Issue
Block a user