[FFmpeg-devel] [PATCH] Issue 636 : ALAC encoding sometimes fails
Wed Jan 7 11:43:40 CET 2009
On Thu, Dec 11, 2008 at 3:05 PM, M?ns Rullg?rd <mans at mansr.com> wrote:
> "Jai Menon" <jmenon86 at gmail.com> writes:
>>>>> sum >>= lpc.lpc_quant;
>>>>> sum += samples;
>>>>> - residual[i] = (samples[lpc.lpc_order+1] - sum) << (32 -
>>>>> s->write_sample_size) >>
>>>>> + residual[i] = (int32_t)(samples[lpc.lpc_order+1] - sum) << (32
>>>>> - s->write_sample_size) >>
>>>>> (32 - s->write_sample_size);
>>>> id do the cast after the << because its the >> that differes from where
>>>> the sign bit is
>>> Put differently, if int is wider than 32 bits the left-hand argument
>>> to >> must be sign-extended from 32 bits to this size for the >> to
>>> work as intended.
>>> It would be more efficient if 32 were replaced with CHAR_BIT*sizeof(int)
>>> instead. This could be put in a nicely named macro, making it even more
>>> obvious what the intent of the code is.
>> Also done.
> With this variant the cast is wrong. Think about what happens if int
> is wider than 32 bits.
Is the attached patch okay?
Maybe this will help fix the regression failure on 64 bit systems.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 565 bytes
Desc: not available
More information about the ffmpeg-devel