[FFmpeg-devel] [PATCH] avcodec/audiotoolboxenc: Fix compile error to support iOS

crosslesong at gmail.com crosslesong at gmail.com
Sun Mar 27 15:57:31 CEST 2016


From: Crossle Song <crosslesong at gmail.com>

Fix error libavcodec/audiotoolboxenc.c use of undeclared
'kAudioCodecPropertyBitRateControlMode' on iOS

AudioToolbox now support iOS
---
 libavcodec/audiotoolboxenc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
index c4d36f5..527e049 100644
--- a/libavcodec/audiotoolboxenc.c
+++ b/libavcodec/audiotoolboxenc.c
@@ -204,6 +204,7 @@ static av_cold int ffat_init_encoder(AVCodecContext *avctx)
                                   size, &avctx->bits_per_raw_sample);
     }
 
+#if !TARGET_OS_IPHONE
     if (at->mode == -1)
         at->mode = (avctx->flags & AV_CODEC_FLAG_QSCALE) ?
                    kAudioCodecBitRateControlMode_Variable :
@@ -227,6 +228,13 @@ static av_cold int ffat_init_encoder(AVCodecContext *avctx)
         AudioConverterSetProperty(at->converter, kAudioConverterEncodeBitRate,
                                   size, &rate);
     }
+#else
+    if (avctx->bit_rate > 0) {
+        UInt32 rate = avctx->bit_rate;
+        AudioConverterSetProperty(at->converter, kAudioConverterEncodeBitRate,
+                                  size, &rate);
+    }
+#endif
 
     at->quality = 96 - at->quality * 32;
     AudioConverterSetProperty(at->converter, kAudioConverterCodecQuality,
@@ -425,12 +433,14 @@ static const AVProfile aac_profiles[] = {
 
 #define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
+#if !TARGET_OS_IPHONE
     {"aac_at_mode", "ratecontrol mode", offsetof(ATDecodeContext, mode), AV_OPT_TYPE_INT, {.i64 = -1}, -1, kAudioCodecBitRateControlMode_Variable, AE, "mode"},
         {"auto", "VBR if global quality is given; CBR otherwise", 0, AV_OPT_TYPE_CONST, {.i64 = -1}, INT_MIN, INT_MAX, AE, "mode"},
         {"cbr",  "constant bitrate", 0, AV_OPT_TYPE_CONST, {.i64 = kAudioCodecBitRateControlMode_Constant}, INT_MIN, INT_MAX, AE, "mode"},
         {"abr",  "long-term average bitrate", 0, AV_OPT_TYPE_CONST, {.i64 = kAudioCodecBitRateControlMode_LongTermAverage}, INT_MIN, INT_MAX, AE, "mode"},
         {"cvbr", "constrained variable bitrate", 0, AV_OPT_TYPE_CONST, {.i64 = kAudioCodecBitRateControlMode_VariableConstrained}, INT_MIN, INT_MAX, AE, "mode"},
         {"vbr" , "variable bitrate", 0, AV_OPT_TYPE_CONST, {.i64 = kAudioCodecBitRateControlMode_Variable}, INT_MIN, INT_MAX, AE, "mode"},
+#endif
     {"aac_at_quality", "quality vs speed control", offsetof(ATDecodeContext, quality), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 2, AE},
     { NULL },
 };
-- 
2.7.0



More information about the ffmpeg-devel mailing list