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

Reimar Döffinger Reimar.Doeffinger at gmx.de
Mon May 16 22:23:50 CEST 2011


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.

> +            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.


More information about the ffmpeg-devel mailing list