* [FFmpeg-devel] [PATCH] Add option to encode short aac ld/eld frames with libfdk_aac
@ 2023-03-27 12:28 Raphael Schlarb
2023-03-27 12:39 ` James Almer
0 siblings, 1 reply; 8+ messages in thread
From: Raphael Schlarb @ 2023-03-27 12:28 UTC (permalink / raw)
To: ffmpeg-devel
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 boolean short_frame option to encode ld/eld frames of
size 480.
Signed-off-by: Raphael Schlarb <info@raphael.schlarb.one>
---
libavcodec/libfdk-aacenc.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
index eb97e0fb41..bd719850dd 100644
--- a/libavcodec/libfdk-aacenc.c
+++ b/libavcodec/libfdk-aacenc.c
@@ -55,6 +55,7 @@ typedef struct AACContext {
int metadata_mode;
AACENC_MetaData metaDataSetup;
int delay_sent;
+ int short_frame;
AudioFrameQueue afq;
} 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_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 },
+ { "short_frame", "Encode short LD/ELD frames, using 480 instead of 512 samples per frame", offsetof(AACContext, short_frame), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
FF_AAC_PROFILE_OPTS
{ NULL }
};
@@ -166,6 +168,17 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
}
}
+ if (s->short_frame) {
+ if (aot == FF_PROFILE_AAC_LD + 1 || aot == FF_PROFILE_AAC_ELD + 1) {
+ if ((err = aacEncoder_SetParam(s->handle, AACENC_GRANULE_LENGTH,
+ 480)) != 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,
avctx->sample_rate)) != AACENC_OK) {
av_log(avctx, AV_LOG_ERROR, "Unable to set the sample rate %d: %s\n",
--
2.40.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH] Add option to encode short aac ld/eld frames with libfdk_aac
2023-03-27 12:28 [FFmpeg-devel] [PATCH] Add option to encode short aac ld/eld frames with libfdk_aac Raphael Schlarb
@ 2023-03-27 12:39 ` James Almer
2023-03-27 14:37 ` [FFmpeg-devel] [PATCH v2] Add option to set frame length when encoding " Raphael Schlarb
0 siblings, 1 reply; 8+ messages in thread
From: James Almer @ 2023-03-27 12:39 UTC (permalink / raw)
To: ffmpeg-devel
On 3/27/2023 9:28 AM, Raphael Schlarb wrote:
> 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 boolean short_frame option to encode ld/eld frames of
> size 480.
>
> Signed-off-by: Raphael Schlarb <info@raphael.schlarb.one>
> ---
> libavcodec/libfdk-aacenc.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
> index eb97e0fb41..bd719850dd 100644
> --- a/libavcodec/libfdk-aacenc.c
> +++ b/libavcodec/libfdk-aacenc.c
> @@ -55,6 +55,7 @@ typedef struct AACContext {
> int metadata_mode;
> AACENC_MetaData metaDataSetup;
> int delay_sent;
> + int short_frame;
>
> AudioFrameQueue afq;
> } 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_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 },
> + { "short_frame", "Encode short LD/ELD frames, using 480 instead of 512 samples per frame", offsetof(AACContext, short_frame), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
> FF_AAC_PROFILE_OPTS
> { NULL }
> };
> @@ -166,6 +168,17 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
> }
> }
>
> + if (s->short_frame) {
> + if (aot == FF_PROFILE_AAC_LD + 1 || aot == FF_PROFILE_AAC_ELD + 1) {
> + if ((err = aacEncoder_SetParam(s->handle, AACENC_GRANULE_LENGTH,
> + 480)) != AACENC_OK) {
Why hardcode it to 480 if the parameter accepts arbitrary values? The
documentation states the currently supported values are 120, 128, 240,
256, 480, 512 and 1024.
Call the option frame_length, and set the range to 120-1024, with 1024
as default value. Then in here change it to 512 if it's 1024 and profile
is FF_PROFILE_AAC_LD or FF_PROFILE_AAC_ELD (otherwise don't change it),
always set it, and have the library reject or accept the value.
> + 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,
> avctx->sample_rate)) != AACENC_OK) {
> av_log(avctx, AV_LOG_ERROR, "Unable to set the sample rate %d: %s\n",
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* [FFmpeg-devel] [PATCH v2] Add option to set frame length when encoding with libfdk_aac
2023-03-27 12:39 ` James Almer
@ 2023-03-27 14:37 ` Raphael Schlarb
2023-03-29 15:59 ` [FFmpeg-devel] [PATCH v3] avcodec/libfdk-accenc: " Raphael Schlarb
0 siblings, 1 reply; 8+ messages in thread
From: Raphael Schlarb @ 2023-03-27 14:37 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Raphael Schlarb
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.
---
Thank you, this really makes more sense. Here an updated version.
libavcodec/libfdk-aacenc.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
index eb97e0fb41..93c26ee082 100644
--- a/libavcodec/libfdk-aacenc.c
+++ b/libavcodec/libfdk-aacenc.c
@@ -55,6 +55,7 @@ typedef struct AACContext {
int metadata_mode;
AACENC_MetaData metaDataSetup;
int delay_sent;
+ int frame_length;
AudioFrameQueue afq;
} 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_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 },
+ { "frame_length", "The desired frame length", offsetof(AACContext, frame_length), AV_OPT_TYPE_INT, { .i64 = 1024 }, 120, 1024, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
FF_AAC_PROFILE_OPTS
{ NULL }
};
@@ -166,6 +168,18 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
}
}
+ if (s->frame_length == 1024 &&
+ (aot == FF_PROFILE_AAC_LD + 1 || aot == FF_PROFILE_AAC_ELD + 1)) {
+ s->frame_length = 512;
+ }
+
+ 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,
avctx->sample_rate)) != AACENC_OK) {
av_log(avctx, AV_LOG_ERROR, "Unable to set the sample rate %d: %s\n",
--
2.40.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* [FFmpeg-devel] [PATCH v3] avcodec/libfdk-accenc: Add option to set frame length when encoding with libfdk_aac
2023-03-27 14:37 ` [FFmpeg-devel] [PATCH v2] Add option to set frame length when encoding " Raphael Schlarb
@ 2023-03-29 15:59 ` Raphael Schlarb
2023-03-30 20:30 ` Martin Storsjö
0 siblings, 1 reply; 8+ messages in thread
From: Raphael Schlarb @ 2023-03-29 15:59 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Raphael Schlarb
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.
---
Added missing context to commit message
libavcodec/libfdk-aacenc.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
index eb97e0fb41..93c26ee082 100644
--- a/libavcodec/libfdk-aacenc.c
+++ b/libavcodec/libfdk-aacenc.c
@@ -55,6 +55,7 @@ typedef struct AACContext {
int metadata_mode;
AACENC_MetaData metaDataSetup;
int delay_sent;
+ int frame_length;
AudioFrameQueue afq;
} 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_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 },
+ { "frame_length", "The desired frame length", offsetof(AACContext, frame_length), AV_OPT_TYPE_INT, { .i64 = 1024 }, 120, 1024, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
FF_AAC_PROFILE_OPTS
{ NULL }
};
@@ -166,6 +168,18 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
}
}
+ if (s->frame_length == 1024 &&
+ (aot == FF_PROFILE_AAC_LD + 1 || aot == FF_PROFILE_AAC_ELD + 1)) {
+ s->frame_length = 512;
+ }
+
+ 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,
avctx->sample_rate)) != AACENC_OK) {
av_log(avctx, AV_LOG_ERROR, "Unable to set the sample rate %d: %s\n",
--
2.40.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3] avcodec/libfdk-accenc: Add option to set frame length when encoding with libfdk_aac
2023-03-29 15:59 ` [FFmpeg-devel] [PATCH v3] avcodec/libfdk-accenc: " Raphael Schlarb
@ 2023-03-30 20:30 ` Martin Storsjö
2023-03-30 12:27 ` [FFmpeg-devel] [PATCH v4] " Raphael Schlarb
0 siblings, 1 reply; 8+ messages in thread
From: Martin Storsjö @ 2023-03-30 20:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Raphael Schlarb
On Wed, 29 Mar 2023, Raphael Schlarb wrote:
> 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.
> ---
> Added missing context to commit message
> libavcodec/libfdk-aacenc.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
> index eb97e0fb41..93c26ee082 100644
> --- a/libavcodec/libfdk-aacenc.c
> +++ b/libavcodec/libfdk-aacenc.c
> @@ -55,6 +55,7 @@ typedef struct AACContext {
> int metadata_mode;
> AACENC_MetaData metaDataSetup;
> int delay_sent;
> + int frame_length;
>
> AudioFrameQueue afq;
> } 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_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 },
> + { "frame_length", "The desired frame length", offsetof(AACContext, frame_length), AV_OPT_TYPE_INT, { .i64 = 1024 }, 120, 1024, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
> FF_AAC_PROFILE_OPTS
> { NULL }
> };
> @@ -166,6 +168,18 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
> }
> }
>
> + if (s->frame_length == 1024 &&
> + (aot == FF_PROFILE_AAC_LD + 1 || aot == FF_PROFILE_AAC_ELD + 1)) {
> + s->frame_length = 512;
> + }
I'm not a fan of having to trying to guess the default like this here.
> +
> + 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;
> + }
Instead of always, unconditionally setting this parameter, can't we make
it optional - set the default value of the option to e.g. -1 or something
like that, and only set the parameter if the user actually has set it?
That way there's no risk of any behaviour change introduced by this patch
in any current existing case, and any issues brought by the parameter only
affect users that actually do set the option.
// Martin
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* [FFmpeg-devel] [PATCH v4] avcodec/libfdk-accenc: Add option to set frame length when encoding with libfdk_aac
2023-03-30 20:30 ` Martin Storsjö
@ 2023-03-30 12:27 ` Raphael Schlarb
2023-03-31 6:51 ` Martin Storsjö
0 siblings, 1 reply; 8+ messages in thread
From: Raphael Schlarb @ 2023-03-30 12:27 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Raphael Schlarb
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>
---
Adjusted according to Martin's suggestion
libavcodec/libfdk-aacenc.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
index eb97e0fb41..954b8e06d0 100644
--- a/libavcodec/libfdk-aacenc.c
+++ b/libavcodec/libfdk-aacenc.c
@@ -55,6 +55,7 @@ typedef struct AACContext {
int metadata_mode;
AACENC_MetaData metaDataSetup;
int delay_sent;
+ int frame_length;
AudioFrameQueue afq;
} 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_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 },
+ { "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
{ NULL }
};
@@ -166,6 +168,15 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
}
}
+ if (s->frame_length != -1) {
+ 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,
avctx->sample_rate)) != AACENC_OK) {
av_log(avctx, AV_LOG_ERROR, "Unable to set the sample rate %d: %s\n",
--
2.40.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH v4] avcodec/libfdk-accenc: Add option to set frame length when encoding with libfdk_aac
2023-03-30 12:27 ` [FFmpeg-devel] [PATCH v4] " Raphael Schlarb
@ 2023-03-31 6:51 ` Martin Storsjö
2023-03-31 11:54 ` James Almer
0 siblings, 1 reply; 8+ messages in thread
From: Martin Storsjö @ 2023-03-31 6:51 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Raphael Schlarb
On Thu, 30 Mar 2023, Raphael Schlarb wrote:
> 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>
> ---
> Adjusted according to Martin's suggestion
> libavcodec/libfdk-aacenc.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
> index eb97e0fb41..954b8e06d0 100644
> --- a/libavcodec/libfdk-aacenc.c
> +++ b/libavcodec/libfdk-aacenc.c
> @@ -55,6 +55,7 @@ typedef struct AACContext {
> int metadata_mode;
> AACENC_MetaData metaDataSetup;
> int delay_sent;
> + int frame_length;
>
> AudioFrameQueue afq;
> } 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_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 },
> + { "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
> { NULL }
> };
> @@ -166,6 +168,15 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
> }
> }
>
> + if (s->frame_length != -1) {
I would kinda have used > 0 or >= 0 as comparison here, but that's just a
nitpick (no need to resubmit just for that).
> + 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;
> + }
> + }
> +
Overall this looks fine to me, thanks!
// Martin
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH v4] avcodec/libfdk-accenc: Add option to set frame length when encoding with libfdk_aac
2023-03-31 6:51 ` Martin Storsjö
@ 2023-03-31 11:54 ` James Almer
0 siblings, 0 replies; 8+ messages in thread
From: James Almer @ 2023-03-31 11:54 UTC (permalink / raw)
To: ffmpeg-devel
On 3/31/2023 3:51 AM, Martin Storsjö wrote:
> On Thu, 30 Mar 2023, Raphael Schlarb wrote:
>
>> 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>
>> ---
>> Adjusted according to Martin's suggestion
>> libavcodec/libfdk-aacenc.c | 11 +++++++++++
>> 1 file changed, 11 insertions(+)
>>
>> diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
>> index eb97e0fb41..954b8e06d0 100644
>> --- a/libavcodec/libfdk-aacenc.c
>> +++ b/libavcodec/libfdk-aacenc.c
>> @@ -55,6 +55,7 @@ typedef struct AACContext {
>> int metadata_mode;
>> AACENC_MetaData metaDataSetup;
>> int delay_sent;
>> + int frame_length;
>>
>> AudioFrameQueue afq;
>> } 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_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 },
>> + { "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
>> { NULL }
>> };
>> @@ -166,6 +168,15 @@ static av_cold int aac_encode_init(AVCodecContext
>> *avctx)
>> }
>> }
>>
>> + if (s->frame_length != -1) {
>
> I would kinda have used > 0 or >= 0 as comparison here, but that's just
> a nitpick (no need to resubmit just for that).
Made that change, bumped micro version, and applied.
>
>> + 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;
>> + }
>> + }
>> +
>
> Overall this looks fine to me, thanks!
>
> // Martin
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-03-31 11:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-27 12:28 [FFmpeg-devel] [PATCH] Add option to encode short aac ld/eld frames with libfdk_aac Raphael Schlarb
2023-03-27 12:39 ` James Almer
2023-03-27 14:37 ` [FFmpeg-devel] [PATCH v2] Add option to set frame length when encoding " Raphael Schlarb
2023-03-29 15:59 ` [FFmpeg-devel] [PATCH v3] avcodec/libfdk-accenc: " Raphael Schlarb
2023-03-30 20:30 ` Martin Storsjö
2023-03-30 12:27 ` [FFmpeg-devel] [PATCH v4] " Raphael Schlarb
2023-03-31 6:51 ` Martin Storsjö
2023-03-31 11:54 ` James Almer
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git