[FFmpeg-devel] [PATCH 1/3] aacenc: use constants to set AAC coder

Stefano Sabatini stefasab at gmail.com
Thu Sep 12 09:17:00 CEST 2013


On date Tuesday 2013-09-10 20:28:07 -0700, Timothy Gu encoded:
> On Tue, Sep 10, 2013 at 2:59 AM, Stefano Sabatini <stefasab at gmail.com> wrote:
> 
> > Yes, and probably while at it also:
> >
> > AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB] = {
> >     [AAC_CODER_FAAC] = {
> >         search_for_quantizers_faac,
> >         encode_window_bands_info,
> >         quantize_and_encode_band,
> >         search_for_ms,
> >     },
> >     [AAC_CODER_ANMR] = {
> >         search_for_quantizers_anmr,
> >         encode_window_bands_info,
> >         quantize_and_encode_band,
> >         search_for_ms,
> >     },
> >     ...
> 
> I honestly didn't know that you can do this before you told me this
> (due to my very poor C skills and experience) ...
> 
> New patched attached.
> 
> [...]
> 
> Timothy

> From 36902a0b03c61b6aff1ae1be469a12db914e4a89 Mon Sep 17 00:00:00 2001
> From: Timothy Gu <timothygu99 at gmail.com>
> Date: Tue, 10 Sep 2013 20:23:32 -0700
> Subject: [PATCH 1/4] aacenc: add AAC_CODER_(FAAC|ANMR|etc.) macros
> 
> Signed-off-by: Timothy Gu <timothygu99 at gmail.com>
> ---
>  libavcodec/aaccoder.c | 8 ++++----
>  libavcodec/aacenc.h   | 7 ++++++-
>  2 files changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
> index 45fbc2d..50a246f 100644
> --- a/libavcodec/aaccoder.c
> +++ b/libavcodec/aaccoder.c
> @@ -1113,25 +1113,25 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe,
>  }
>  
>  AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB] = {
> -    {
> +    [AAC_CODER_FAAC] = {
>          search_for_quantizers_faac,
>          encode_window_bands_info,
>          quantize_and_encode_band,
>          search_for_ms,
>      },
> -    {
> +    [AAC_CODER_ANMR] = {
>          search_for_quantizers_anmr,
>          encode_window_bands_info,
>          quantize_and_encode_band,
>          search_for_ms,
>      },
> -    {
> +    [AAC_CODER_TWOLOOP] = {
>          search_for_quantizers_twoloop,
>          codebook_trellis_rate,
>          quantize_and_encode_band,
>          search_for_ms,
>      },
> -    {
> +    [AAC_CODER_FAST] = {
>          search_for_quantizers_fast,
>          encode_window_bands_info,
>          quantize_and_encode_band,
> diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h
> index cebdd18..19e442a 100644
> --- a/libavcodec/aacenc.h
> +++ b/libavcodec/aacenc.h
> @@ -30,7 +30,12 @@
>  #include "audio_frame_queue.h"
>  #include "psymodel.h"
>  
> -#define AAC_CODER_NB 4
> +#define AAC_CODER_FAAC    0
> +#define AAC_CODER_ANMR    1
> +#define AAC_CODER_TWOLOOP 2
> +#define AAC_CODER_FAST    3
> +
> +#define AAC_CODER_NB      4
>  
>  typedef struct AACEncOptions {
>      int stereo_mode;
> -- 
> 1.8.1.2
> 

> From a99002384f0c62b4cfb724eb363462b38070a4be Mon Sep 17 00:00:00 2001
> From: Timothy Gu <timothygu99 at gmail.com>
> Date: Tue, 10 Sep 2013 20:24:39 -0700
> Subject: [PATCH 2/4] aacenc: use constants to set AAC coder
> 
> Signed-off-by: Timothy Gu <timothygu99 at gmail.com>
> ---
>  libavcodec/aacenc.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
> index 362f02b..3227edb 100644
> --- a/libavcodec/aacenc.c
> +++ b/libavcodec/aacenc.c
> @@ -791,7 +791,11 @@ static const AVOption aacenc_options[] = {
>          {"auto",     "Selected by the Encoder", 0, AV_OPT_TYPE_CONST, {.i64 = -1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"},
>          {"ms_off",   "Disable Mid/Side coding", 0, AV_OPT_TYPE_CONST, {.i64 =  0 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"},
>          {"ms_force", "Force Mid/Side for the whole frame if possible", 0, AV_OPT_TYPE_CONST, {.i64 =  1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"},
> -    {"aac_coder", "", offsetof(AACEncContext, options.aac_coder), AV_OPT_TYPE_INT, {.i64 = 2}, 0, AAC_CODER_NB-1, AACENC_FLAGS},
> +    {"aac_coder", "", offsetof(AACEncContext, options.aac_coder), AV_OPT_TYPE_INT, {.i64 = AAC_CODER_TWOLOOP}, 0, AAC_CODER_NB-1, AACENC_FLAGS, "aac_coder"},
> +        {"faac",     "FAAC-inspired method",      0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_FAAC},    INT_MIN, INT_MAX, AACENC_FLAGS, "aac_coder"},
> +        {"anmr",     "ANMR method",               0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_ANMR},    INT_MIN, INT_MAX, AACENC_FLAGS, "aac_coder"},
> +        {"twoloop",  "Two loop searching method", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_TWOLOOP}, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_coder"},
> +        {"fast",     "Constant quantizer",        0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_FAST},    INT_MIN, INT_MAX, AACENC_FLAGS, "aac_coder"},
>      {NULL}
>  };

Both patches look good, but I'm no aacenc maintainer, thanks.
-- 
FFmpeg = Forgiving and Faithless Martial Philosofic Everlasting Glue


More information about the ffmpeg-devel mailing list