Do not error out if the bitrate requested is too high, return defined
errors on unsupported requests.
---
libavcodec/libaacplus.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/libavcodec/libaacplus.c b/libavcodec/libaacplus.c
index e90ad4c..0191455 100644
--- a/libavcodec/libaacplus.c
+++ b/libavcodec/libaacplus.c
@@ -43,14 +43,19 @@ static av_cold int aacPlus_encode_init(AVCodecContext
*avctx)
/* number of channels */
if (avctx->channels < 1 || avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed\n",
avctx->channels);
- return -1;
+ return AVERROR(ENOSYS);
+ }
+
+ if (avctx->bit_rate > 64*1024) {
+ av_log(avctx, AV_LOG_WARNING, "bitrate %d unsupported, downgrading to
the supported maximum\n", avctx->bit_rate);
+ avctx->bit_rate = 64*1024;
}
s->aacplus_handle = aacplusEncOpen(avctx->sample_rate, avctx->channels,
&s->samples_input,
&s->max_output_bytes);
if(!s->aacplus_handle) {
av_log(avctx, AV_LOG_ERROR, "can't open encoder\n");
- return -1;
+ return AVERROR(ENOMEM);
}
/* check aacplus version */
@@ -60,7 +65,7 @@ static av_cold int aacPlus_encode_init(AVCodecContext *avctx)
if(avctx->profile != FF_PROFILE_AAC_LOW && avctx->profile !=
FF_PROFILE_UNKNOWN) {
av_log(avctx, AV_LOG_ERROR, "invalid AAC profile: %d, only LC
supported\n", avctx->profile);
aacplusEncClose(s->aacplus_handle);
- return -1;
+ return AVERROR(ENOSYS);
}
aacplus_cfg->bitRate = avctx->bit_rate;
@@ -69,7 +74,7 @@ static av_cold int aacPlus_encode_init(AVCodecContext *avctx)
aacplus_cfg->inputFormat = AACPLUS_INPUT_16BIT;
if (!aacplusEncSetConfiguration(s->aacplus_handle, aacplus_cfg)) {
av_log(avctx, AV_LOG_ERROR, "libaacplus doesn't support this output
format!\n");
- return -1;
+ return AVERROR(ENOSYS);
}
avctx->frame_size = s->samples_input / avctx->channels;
--
1.7.8.rc1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel