[FFmpeg-devel] [PATCH] RoQ encoder

Robert Swain robert.swain
Sat May 5 01:57:35 CEST 2007


Hey,

On 4 May 2007, at 22:57, Michael Niedermayer wrote:
> On Fri, May 04, 2007 at 06:56:31PM +0200, Vitor wrote:
> [...]
>> +    diff = result*result;
>> +    if(negative)
>> +        diff = -diff;
>> +    predicted = (int)(*previous) + diff;
>> +
>> +    // If it overflows, back off a step
>> +    if(predicted > 32767 || predicted < -32768)
>> +    {
>> +        result--;
>> +        diff = result*result;
>> +        if(negative)
>> +            diff = -diff;
>> +        predicted = (int)(*previous) + diff;
>> +    }
>
>
> retry:
>     diff = result*result;
>     if(negative)
>         diff = -diff;
>     predicted = *previous + diff;
>
>     if(predicted > 32767 || predicted < -32768){
>         result--;
>         goto retry;
>     }

Out of personal interest and being a lesser experienced programmer,  
I've always been lead to believe that 'goto' shouldn't be used unless  
absolutely necessary. Grepping the FFmpeg source throws up far more  
results than I expected so now I'm wondering - why have you suggested  
the use of goto over something like a 'while' loop? If it's better to  
use a goto in some cases, I'd like to know when and why. :)

Thanks,
Rob




More information about the ffmpeg-devel mailing list