From f7813a5324be39d13ab536c245d15dfc602a7849 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sun, 29 Dec 2013 12:19:38 +0000 Subject: basic type mechanism working --- ffmpeg/libavcodec/libfaac.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'ffmpeg/libavcodec/libfaac.c') diff --git a/ffmpeg/libavcodec/libfaac.c b/ffmpeg/libavcodec/libfaac.c index ac18fe2..477669a 100644 --- a/ffmpeg/libavcodec/libfaac.c +++ b/ffmpeg/libavcodec/libfaac.c @@ -151,9 +151,20 @@ static av_cold int Faac_encode_init(AVCodecContext *avctx) } if (!faacEncSetConfiguration(s->faac_handle, faac_cfg)) { - av_log(avctx, AV_LOG_ERROR, "libfaac doesn't support this output format!\n"); - ret = AVERROR(EINVAL); - goto error; + int i; + for (i = avctx->bit_rate/1000; i ; i--) { + faac_cfg->bitRate = 1000*i / avctx->channels; + if (faacEncSetConfiguration(s->faac_handle, faac_cfg)) + break; + } + if (!i) { + av_log(avctx, AV_LOG_ERROR, "libfaac doesn't support this output format!\n"); + ret = AVERROR(EINVAL); + goto error; + } else { + avctx->bit_rate = 1000*i; + av_log(avctx, AV_LOG_WARNING, "libfaac doesn't support the specified bitrate, using %dkbit/s instead\n", i); + } } avctx->delay = FAAC_DELAY_SAMPLES; @@ -222,6 +233,7 @@ static const uint64_t faac_channel_layouts[] = { AVCodec ff_libfaac_encoder = { .name = "libfaac", + .long_name = NULL_IF_CONFIG_SMALL("libfaac AAC (Advanced Audio Coding)"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_AAC, .priv_data_size = sizeof(FaacAudioContext), @@ -231,7 +243,6 @@ AVCodec ff_libfaac_encoder = { .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, - .long_name = NULL_IF_CONFIG_SMALL("libfaac AAC (Advanced Audio Coding)"), .profiles = NULL_IF_CONFIG_SMALL(profiles), .channel_layouts = faac_channel_layouts, }; -- cgit v1.2.3