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

Michael Niedermayer michaelni
Wed Feb 11 17:00:22 CET 2009


On Mon, Feb 09, 2009 at 05:50:57PM -0800, Baptiste Coudurier wrote:
> Michael Niedermayer wrote:
> > On Mon, Feb 09, 2009 at 11:55:19AM -0800, Baptiste Coudurier wrote:
> >> 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" ?
> > 
> > i thought that
> > av_audio_convert_free(s->convert_ctx[1]);
> > is needed inside the AV_LOG_ERROR if() quoted above
> > or
> > av_audio_convert_free(s->convert_ctx[1]);
> > is not needed in the if() (not quoted) below
> > 
> > but it seems more that the one below is unneeded and similarly the
> > av_audio_convert_free(s->convert_ctx[0]) quote above
> > 
> > but ive not re read the patch just a quick look at svn that allocated a
> > new "s" that shouldnt contain anything that might need freeing ...
> 
> Ok patch updated to be sure.

looks ok

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090211/9a639160/attachment.pgp>



More information about the ffmpeg-devel mailing list