[FFmpeg-devel] [PATCH] png parser

Michael Niedermayer michaelni
Wed Jun 24 21:52:04 CEST 2009


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.

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090624/b197cbaa/attachment.pgp>



More information about the ffmpeg-devel mailing list