[FFmpeg-devel] [PATCH] Issue 636 : ALAC encoding sometimes fails
Vitor Sessak
vitor1001
Fri Dec 5 18:07:21 CET 2008
M?ns Rullg?rd wrote:
> Michael Niedermayer wrote:
>> On Fri, Dec 05, 2008 at 10:09:16AM +0530, Jai Menon wrote:
>>> Hi,
>>>
>>> Attached patch fixes issue 636 and a few other fringe cases where the
>>> alac encoder produces
>>> lossy output. I'm behind a NAT and svn doesn't work, so could someone
>>> please apply. Thanks.
>>>
>>> Regards,
>>>
>>> Jai
>>> Index: libavcodec/alacenc.c
>>> ===================================================================
>>> --- libavcodec/alacenc.c (revision 15797)
>>> +++ libavcodec/alacenc.c (working copy)
>>> @@ -253,7 +253,8 @@
>>>
>>> sum >>= lpc.lpc_quant;
>>> sum += samples[0];
>>> - residual[i] = samples[lpc.lpc_order+1] - sum;
>>> + residual[i] = (samples[lpc.lpc_order+1] - sum) << (32 -
> s->write_sample_size) >>
>>> + (32 - s->write_sample_size);
>>> res_val = residual[i];
>> you are missing a int32_t cast in there, without it this wont work on
>> systems where int is not exactly 32bit
>
> Alternatively substitute 8*sizeof(int) for 32. For maximum portability,
> use CHAR_BIT rather than 8.
>
> I assume the intent here is to sign-extend a smaller value to 32 bits.
> Are compilers clever enough to realise this and use more efficient
> methods where available? If not, we should add a macro or inline
> function doing it properly.
In alac.c there is an inline function extend_sign32() for this.
Efficiency issues were discussed at thread "[PATCH] Yet more ALAC
cleanup (#define removal)" circa september 2007. Note that in alac.c
case, the function did masking+bit extension...
-Vitor
More information about the ffmpeg-devel
mailing list