[FFmpeg-devel] FFmpeg source code is no longer C99 because of GNUism called case ranges

Måns Rullgård mans
Thu Jul 5 09:28:59 CEST 2007


Benoit Fouet <benoit.fouet at purplelabs.com> writes:

> Roman Shaposhnik wrote:
>> On Thu, 2007-07-05 at 08:02 +0100, M?ns Rullg?rd wrote:
>>   
>>>>  static int mpeg4video_probe(AVProbeData *probe_packet)
>>>>  {
>>>>      uint32_t temp_buffer= -1;
>>>> +    uint8_t b;
>>>>      int VO=0, VOL=0, VOP = 0, VISO = 0, res=0;
>>>>      int i;
>>>>  
>>>>      for(i=0; i<probe_packet->buf_size; i++){
>>>>          temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];
>>>> -        if ((temp_buffer & 0xffffff00) == 0x100) {
>>>> -            switch(temp_buffer){
>>>> -            case VOP_START_CODE:             VOP++; break;
>>>> -            case VISUAL_OBJECT_START_CODE:  VISO++; break;
>>>> -            case 0x100 ... 0x11F:             VO++; break;
>>>> -            case 0x120 ... 0x12F:            VOL++; break;
>>>> -            case 0x130 ... 0x1AF:
>>>> -            case 0x1B7 ... 0x1B9:
>>>> -            case 0x1C4 ... 0x1FF:            res++; break;
>>>> -            }
>>>> -        }
>>>> +        if ((temp_buffer & 0xffffff00) != 0x100)
>>>> +            continue;
>>>> +
>>>> +        b = probe_packet->buf[i];
>>>> +        if (b == VOP_START_CODE)
>>>> +            VOP++;
>>>> +        else if (b == VISUAL_OBJECT_START_CODE)
>>>> +            VISO++;
>>>> +        else if (b < 0x20)
>>>> +            VO++;
>>>> +        else if (b < 0x30)
>>>> +            VOL++;
>>>> +        else
>>>> +            res += !((b > 0xAF && b < 0xB7) || (b > 0xB9 && b < 0xC4));
>>>>      }
>>>>  
>>>>      if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0)
>>>>       
>>> Why the new variable?  The logic looks correct though.
>>>     
>>
>>   As a precaution and cosmetics. Precaution against stupid compilers,
>> cosmetics because:
>>         if (b == ....)
>> looks nicer (IMHO) than:
>>         if ((temp_buffer & 0xffffff00) == ...)
>>
>>   
>
> i don't see why you would have to do the bitmask anyway...
> when you reach the b variable, (temp_buffer & 0xffffff00) == temp_buffer

Not exactly true.  You mean (temp_buffer & 0x1ff) == temp_buffer.

> also, not introducing this new b variable would leave start code
> constant definitions as is, which is their "real" values :)

I'm not so sure about that.  I don't have the MPEG4 spec at hand, but
MPEG2 calls the 24 leading bits (0x000001) the "start code prefix",
the "start code" being the following 8 bits.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list