[FFmpeg-devel] [PATCH] Improve channel count and bitrate error handling in wmav* encode_init()

Tomas Härdin tomas.hardin at codemill.se
Mon Mar 21 15:46:26 CET 2011


Michael Niedermayer skrev 2011-03-21 15:18:
> On Mon, Mar 21, 2011 at 01:11:45PM +0100, Michael Niedermayer wrote:
>> On Mon, Mar 21, 2011 at 11:23:42AM +0100, Tomas Härdin wrote:
>>> Hi
>>>
>>> The wmav* encoders silently fail if the input has too many channels or
>>> too low bitrate. The attached patch adds some error logging and better
>>> return values.
>>>
>>> /Tomas
>>
>>>   wmaenc.c |   14 ++++++++++----
>>>   1 file changed, 10 insertions(+), 4 deletions(-)
>>> b0cfbf8949e446c14d59bc27b2bdb79dbe6a1976  0001-Improve-channel-count-and-bitrate-error-handling-in-.patch
>>>  From eda380ca1c8ca5b090cc69ad091d27df6ae9d3bf Mon Sep 17 00:00:00 2001
>>> From: =?UTF-8?q?Tomas=20H=C3=A4rdin?=<tomas.hardin at codemill.se>
>>> Date: Mon, 21 Mar 2011 10:52:36 +0100
>>> Subject: [PATCH] Improve channel count and bitrate error handling in wmav* encode_init()
>>>
>>> ---
>>>   libavcodec/wmaenc.c |   16 +++++++++++-----
>>>   1 files changed, 11 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c
>>> index 4e54a70..94ea9bb 100644
>>> --- a/libavcodec/wmaenc.c
>>> +++ b/libavcodec/wmaenc.c
>>> @@ -33,11 +33,17 @@ static int encode_init(AVCodecContext * avctx){
>>>
>>>       s->avctx = avctx;
>>>
>>> -    if(avctx->channels>  MAX_CHANNELS)
>>> -        return -1;
>>> +    if(avctx->channels>  MAX_CHANNELS) {
>>> +        av_log(avctx, AV_LOG_ERROR, "too many channels: got %i, need %i or fewer",
>>> +               avctx->channels, MAX_CHANNELS);
>>> +        return AVERROR(EINVAL);
>>> +    }
>>
>> ok
>>
>>
>>>
>>> -    if(avctx->bit_rate<  24*1000)
>>> -        return -1;
>>> +    if(avctx->bit_rate<  24*1000) {
>>> +        av_log(avctx, AV_LOG_ERROR, "bitrate too low: got %i, need 24000 or higher\n",
>>> +               avctx->bit_rate);
>>> +        return AVERROR(EINVAL);
>>> +    }
>>
>> i dont think this is correct, the minimum should depend on chan num&  samplerate
>> i think
>
> anyway,ive applied it as its improving the situation but teh 24kbps should
> probably be checked

Yes, most likely. I'm not familiar enough with wma to tell though.

/Tomas



More information about the ffmpeg-devel mailing list