[FFmpeg-devel] [PATCH]Improce auto-detection for cdata files

Måns Rullgård mans
Thu Dec 31 00:29:09 CET 2009


Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:

> On Wed, Dec 30, 2009 at 08:54:15PM +0100, Carl Eugen Hoyos wrote:
>> Hi!
>> 
>> Attached patch improves cdata auto-detection (and "fixes" issue 1634 by 
>> not trying to decode the sample any more).
>> Details from 
>> http://wiki.multimedia.cx/index.php?title=EA_Command_And_Conquer_3_Audio_Codec
>> 
>> The new detection passes probetest, and I would like to raise the score to 
>> 26, is that ok?
>> 
>> Please comment, Carl Eugen
>
>> Index: libavformat/eacdata.c
>> ===================================================================
>> --- libavformat/eacdata.c	(revision 20959)
>> +++ libavformat/eacdata.c	(working copy)
>> @@ -39,7 +39,8 @@
>>  {
>>      const uint8_t *b = p->buf;
>>  
>> -    if (b[0] == 0x04 && (b[1] == 0x00 || b[1] == 0x04 || b[1] == 0x0C))
>> +    if (b[0] == 0x04 && (b[1] == 0x00 || b[1] == 0x04 || b[1] == 0x0C) &&
>> +        ((uint32_t *)b)[1] == ((uint32_t *)b)[3] && ((uint32_t *)b)[1])
>>          return AVPROBE_SCORE_MAX/8;
>
> You should check for a valid sample_rate (since that is essential for
> decoding), and the new checks for "total samples" should only be used to
> raise the score above AVPROBE_SCORE_MAX/4 (since those are non-essential
> they should not be "required" by the probe if possible).
> Also since speed does not matter, I think
> AV_RB32(b + 4) == AV_RB32(b + 12)
> etc. is more readable than the casts.

Those casts WILL CRASH on some hardware if the data is unaligned.  Use
AV_RN32().

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



More information about the ffmpeg-devel mailing list