[FFmpeg-devel] [PATCH] png parser

Peter Holik peter
Thu Jun 25 12:59:07 CEST 2009


Michael Niedermayer schrieb:
> On Wed, Jun 24, 2009 at 05:54:17PM +0200, Peter Holik wrote:
>> Michael Niedermayer schrieb:
> [...]
>> >> +            if (*state64_ptr == PNGSIG || *state64_ptr == MNGSIG) {
>> >> +                i++;
>> >> +                if (ppc->pc.index) {
>> >> +                    i -= 8;
>> >> +                    next = i;
>> >> +                } else {
>> >> +                    ppc->pc.frame_start_found = 1;
>> >> +                    ppc->chunk_index = 1;
>> >> +                    if (i == 8)
>> >> +                        break;
>> >> +                    else if (i > 8) {
>> >> +                        buf += i - 8;
>> >> +                        buf_size = 8;
>> >> +                    } else /* if (i < 8) */
>> >> +                        buf_size = i;
>> >> +                }
>> >> +                ff_combine_frame(&ppc->pc, next, &buf, &buf_size);
>> >> +                return i;
>> >
>> > could you explain why this is not just looking like lets say mpeg4:
>> >
>> >     if(!vop_found){
>> >         for(i=0; i<buf_size; i++){
>> >             state= (state<<8) | buf[i];
>> >             if(state == 0x1B6){
>> >                 i++;
>> >                 vop_found=1;
>> >                 break;
>> >             }
>> >         }
>> >     }
>>
>> png signature is 8 Bytes
>
> s/state/state64/ in the example, the question stays the same
>
>
>>
>>
>> > what is the point of all the special cases?
>>
>>
>> Because this png parser should filter out good png images.
>
> thats not the job of a parser, besides good is a fuzzy term, a
> png with a bit fliped in the signature is pretty good and easy to decode
> your code would drop it i think.

Following parser also drops:

mpegaudio_parser.c
mlp_parser.c
dvbsub_parser.c
pnm_parser.c

why may my parser not drop?

Anyway fighting against windmills is meaningless.

Here now a version without dropping anything and using 32 Bits for
signature check instead of 64 Bits.

cu Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: png_parser.diff
Type: text/x-diff
Size: 5484 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090625/645d6b60/attachment.diff>



More information about the ffmpeg-devel mailing list