[FFmpeg-devel] [PATCH 1/2] nsv: simplify probe function

Aurelien Jacobs aurel at gnuage.org
Tue May 17 00:13:30 CEST 2011


On Mon, May 16, 2011 at 10:23:50PM +0200, Reimar Döffinger wrote:
> Both look good to me, just some nits:
> 
> On Sun, May 15, 2011 at 11:04:58PM +0200, Aurelien Jacobs wrote:
> > @@ -751,19 +750,14 @@ static int nsv_probe(AVProbeData *p)
> >      /* seems the servers don't bother starting clean chunks... */
> >      /* sometimes even the first header is at 9KB or something :^) */
> >      for (i = 1; i < p->buf_size - 3; i++) {
> > -        if (p->buf[i+0] == 'N' && p->buf[i+1] == 'S' &&
> > -            p->buf[i+2] == 'V' && p->buf[i+3] == 's') {
> > +        if (AV_RL32(p->buf + i) == AV_RL32("NSVs")) {
> >              score = AVPROBE_SCORE_MAX/5;
> >              /* Get the chunk size and check if at the end we are getting 0xBEEF */
> > -            auxcount = p->buf[i+19];
> > -            vsize = p->buf[i+20]  | p->buf[i+21] << 8;
> > -            asize = p->buf[i+22]  | p->buf[i+23] << 8;
> > -            vsize = (vsize << 4) | (auxcount >> 4);
> > -            if ((asize + vsize + i + 23) <  p->buf_size - 2) {
> > -                if (p->buf[i+23+asize+vsize+1] == 0xEF &&
> > -                    p->buf[i+23+asize+vsize+2] == 0xBE)
> > -                    return AVPROBE_SCORE_MAX-20;
> > -            }
> > +            vsize = AV_RL24(p->buf+i+19) >> 4;
> > +            asize = AV_RL16(p->buf+i+22);
> 
> asize and vsize declaration could be moved into this block.

Indeed.

> > +            if ((asize + vsize + i + 23) < p->buf_size - 2
> > +                && AV_RL16(p->buf+i+23+asize+vsize+1) == 0xBEEF)
> 
> Maybe this could use a separate variable, but at least writing it
> as i + 23 + asize + vsize in both cases would be more readable.

I thought about it for a second, and now I don't remember why I didn't
do it at that time. Done now.

Updated patch attached.

Aurel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nsv_probe.diff
Type: text/x-diff
Size: 2242 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110517/f730e88a/attachment.bin>


More information about the ffmpeg-devel mailing list