[FFmpeg-devel] [PATCH] convert to S16 when resampling is requested

Baptiste Coudurier baptiste.coudurier
Mon Feb 9 20:55:19 CET 2009


Michael Niedermayer wrote:
> [...]
>
>> @@ -153,6 +173,36 @@
>>      if (s->output_channels < s->filter_channels)
>>          s->filter_channels = s->output_channels;
>>  
>> +    s->sample_fmt [0] = sample_fmt_in;
>> +    s->sample_fmt [1] = sample_fmt_out;
>> +    s->sample_size[0] = av_get_bits_per_sample_format(s->sample_fmt[0])>>3;
>> +    s->sample_size[1] = av_get_bits_per_sample_format(s->sample_fmt[1])>>3;
>> +
> 
>> +    if (s->sample_fmt[0] != SAMPLE_FMT_S16) {
>> +        av_audio_convert_free(s->convert_ctx[0]);
>> +        if (!(s->convert_ctx[0] = av_audio_convert_alloc(SAMPLE_FMT_S16, 1,
>> +                                                         s->sample_fmt[0], 1, NULL, 0))) {
>> +            av_log(s, AV_LOG_ERROR,
>> +                   "Cannot convert %s sample format to s16 sample format\n",
>> +                   avcodec_get_sample_fmt_name(s->sample_fmt[0]));
>> +            av_free(s);
>> +            return NULL;
> 
> considering that there is
> av_audio_convert_free(s->convert_ctx[1]);
> below i wonder if it could be leaking here

I'm not sure to understand, do you want me to av_audio_convert_free like:

av_audio_convert_free(s->convert_ctx[0]);
av_audio_convert_free(s->convert_ctx[1]);

in the "if" ?

>> [...]
>>
>> +
>> +    if (s->sample_fmt[1] != SAMPLE_FMT_S16) {
>> +        av_audio_convert_free(s->convert_ctx[1]);
>> +        if (!(s->convert_ctx[1] = av_audio_convert_alloc(s->sample_fmt[1], 1,
>> +                                                         SAMPLE_FMT_S16, 1, NULL, 0))) {
>> +            av_log(s, AV_LOG_ERROR,
>> +                   "Cannot convert s16 sample format to %s sample format\n",
>> +                   avcodec_get_sample_fmt_name(s->sample_fmt[1]));
> 
>> +            av_free(s->convert_ctx[0]);
> 
> you use av_audio_convert_free() for it and av_free() here

Ah right.

-- 
Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
checking for life_signs in -lkenny... no
FFmpeg maintainer                                  http://www.ffmpeg.org




More information about the ffmpeg-devel mailing list