[FFmpeg-devel] [PATCH 2/3] oggparsecelt: use ff_alloc_extradata()

James Almer jamrial at gmail.com
Mon Oct 14 10:11:54 CEST 2013


On 14/10/13 4:43 AM, Nicolas George wrote:
> Le duodi 22 vendémiaire, an CCXXII, James Almer a écrit :
>> Signed-off-by: James Almer <jamrial at gmail.com>
>> ---
>>  libavformat/oggparsecelt.c | 14 ++++----------
>>  1 file changed, 4 insertions(+), 10 deletions(-)
>>
>> diff --git a/libavformat/oggparsecelt.c b/libavformat/oggparsecelt.c
>> index afc4392..3c5f7ba 100644
>> --- a/libavformat/oggparsecelt.c
>> +++ b/libavformat/oggparsecelt.c
>> @@ -44,13 +44,10 @@ static int celt_header(AVFormatContext *s, int idx)
>>  
>>          uint32_t version, sample_rate, nb_channels, frame_size;
>>          uint32_t overlap, extra_headers;
>> -        uint8_t *extradata;
>>  
>> -        extradata = av_malloc(2 * sizeof(uint32_t) +
>> -                              FF_INPUT_BUFFER_PADDING_SIZE);
>>          priv = av_malloc(sizeof(struct oggcelt_private));
>> -        if (!extradata || !priv) {
>> -            av_free(extradata);
> 
>> +        if (ff_alloc_extradata(st->codec, 2 * sizeof(uint32_t)) || !priv) {
>> +            av_free(st->codec->extradata);
> 
> Unless I am mistaken, if you swap the branches of the ||, it becomes
> slightly more efficient and you can remove the av_free().

You're right. I'll send an updated patch in a moment.

Thanks.


More information about the ffmpeg-devel mailing list