[FFmpeg-devel] [PATCH] libmp3lame: 32 bit encoding

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Apr 16 22:16:40 CEST 2011


On Sat, Apr 16, 2011 at 08:12:35PM +0200, Peter Belkner wrote:
> On 16.04.2011 17:14, Michael Niedermayer wrote:
> >>On the other hand I corrected casting the frame buffer provided by
> >>FFmpeg to (int32_t *).
> >your mono code looks like it would fail with 64bit long
> 
> Fixed it with it's own copy loop, cf. revised patch below.

Why are you not just using the lame_encode_buffer_int function?

> +    if (AV_SAMPLE_FMT_S32 == avctx->sample_fmt) {
> +        s->s32_data.left = av_malloc(avctx->frame_size * sizeof(long));
> +        s->s32_data.right = av_malloc(avctx->frame_size * sizeof(long));
> +
> +        if (NULL == s->s32_data.left || NULL == s->s32_data.right)
> +            return AVERROR_NOMEM;

That's a memleak if only one allocation fails.
Also in FFmpeg we don't usually do the comparisons in this
switched-around way and use e.g. !s->s32_data.left instead
of the comparison with NULL.


More information about the ffmpeg-devel mailing list