add the possibility to choose aac profile
authorNicolas George <nicola.george@normalesup.org>
Wed, 2 May 2007 13:49:08 +0000 (13:49 +0000)
committerBenoit Fouet <benoit.fouet@free.fr>
Wed, 2 May 2007 13:49:08 +0000 (13:49 +0000)
patch by Nicolas George nicolas george chez normalesup org
original thread: [Ffmpeg-devel] [PATCH] FAAC profile selection
date: 04/27/2007 08:11 PM

Originally committed as revision 8872 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavcodec/avcodec.h
libavcodec/faac.c
libavcodec/utils.c

index 3a90098..85d7712 100644 (file)
@@ -1820,6 +1820,10 @@ typedef struct AVCodecContext {
      */
      int profile;
 #define FF_PROFILE_UNKNOWN -99
+#define FF_PROFILE_AAC_MAIN 0
+#define FF_PROFILE_AAC_LOW 1
+#define FF_PROFILE_AAC_SSR 2
+#define FF_PROFILE_AAC_LTP 3
 
     /**
      * level
index 9ff9f5e..ae1db1f 100644 (file)
@@ -54,7 +54,25 @@ static int Faac_encode_init(AVCodecContext *avctx)
     }
 
     /* put the options in the configuration struct */
-    faac_cfg->aacObjectType = LOW;
+    switch(avctx->profile) {
+        case FF_PROFILE_AAC_MAIN:
+            faac_cfg->aacObjectType = MAIN;
+            break;
+        case FF_PROFILE_UNKNOWN:
+        case FF_PROFILE_AAC_LOW:
+            faac_cfg->aacObjectType = LOW;
+            break;
+        case FF_PROFILE_AAC_SSR:
+            faac_cfg->aacObjectType = SSR;
+            break;
+        case FF_PROFILE_AAC_LTP:
+            faac_cfg->aacObjectType = LTP;
+            break;
+        default:
+            av_log(avctx, AV_LOG_ERROR, "invalid AAC profile\n");
+            faacEncClose(s->faac_handle);
+            return -1;
+    }
     faac_cfg->mpegVersion = MPEG4;
     faac_cfg->useTns = 0;
     faac_cfg->allowMidside = 1;
index d1b1f6a..b17c456 100644 (file)
@@ -670,6 +670,10 @@ static const AVOption options[]={
 {"skip_bottom", "number of macroblock rows at the bottom which are skipped", OFFSET(skip_bottom), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D},
 {"profile", NULL, OFFSET(profile), FF_OPT_TYPE_INT, FF_PROFILE_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "profile"},
 {"unknown", NULL, 0, FF_OPT_TYPE_CONST, FF_PROFILE_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "profile"},
+{"aac_main", NULL, 0, FF_OPT_TYPE_CONST, FF_PROFILE_AAC_MAIN, INT_MIN, INT_MAX, A|E, "profile"},
+{"aac_low", NULL, 0, FF_OPT_TYPE_CONST, FF_PROFILE_AAC_LOW, INT_MIN, INT_MAX, A|E, "profile"},
+{"aac_ssr", NULL, 0, FF_OPT_TYPE_CONST, FF_PROFILE_AAC_SSR, INT_MIN, INT_MAX, A|E, "profile"},
+{"aac_ltp", NULL, 0, FF_OPT_TYPE_CONST, FF_PROFILE_AAC_LTP, INT_MIN, INT_MAX, A|E, "profile"},
 {"level", NULL, OFFSET(level), FF_OPT_TYPE_INT, FF_LEVEL_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "level"},
 {"unknown", NULL, 0, FF_OPT_TYPE_CONST, FF_LEVEL_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "level"},
 {"lowres", "decode at 1= 1/2, 2=1/4, 3=1/8 resolutions", OFFSET(lowres), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|D},