[FFmpeg-devel] [PATCH] raw demuxer for Chinese AVS elementary streams

Måns Rullgård mans
Thu Feb 19 22:23:02 CET 2009


Stefan Gehrer <stefan.gehrer at gmx.de> writes:

> Hi,
>
> attached patch adds $subject. This makes it possible to test the
> two samples at
> http://samples.mplayerhq.hu/AVS/issue767/
> Unfortunately these samples do not work properly yet, only the
> I-Frames.
> You can see that the patch contains a probe function and I was
> trying to make that probing fairly restrictive. However, my feeling
> is that a probing function is a slightly dangerous addition unless
> tested against a large number of samples, which I didn't do.
> So it might be better to consider the patch for after the release ...
>
> Stefan
>
> Index: libavformat/raw.c
> ===================================================================
> --- libavformat/raw.c	(revision 17458)
> +++ libavformat/raw.c	(working copy)
> @@ -365,6 +365,35 @@
>          return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg
>      return 0;
>  }
> +
> +#define CAVS_SEQ_START_CODE       0x000001b0
> +#define CAVS_PIC_I_START_CODE     0x000001b3
> +#define CAVS_PIC_PB_START_CODE    0x000001b6
> +#define CAVS_VIDEO_EDIT_CODE      0x000001b7
> +
> +static int cavsvideo_probe(AVProbeData *p)
> +{
> +    uint32_t code= -1;
> +    int pic=0, seq=0;
> +    int i;
> +
> +    for(i=0; i<p->buf_size; i++){
> +        code = (code<<8) + p->buf[i];
> +        if ((code & 0xffffff00) == 0x100) {
> +            switch(code){
> +            case     CAVS_SEQ_START_CODE:   seq++; break;
> +            case   CAVS_PIC_I_START_CODE:
> +            case  CAVS_PIC_PB_START_CODE:   pic++; break;
> +            default:
> +                if(code > CAVS_VIDEO_EDIT_CODE)
> +                    return 0;
> +            }
> +        }
> +    }
> +    if(seq && seq*9<=pic*10)
> +        return AVPROBE_SCORE_MAX/2;
> +    return 0;
> +}
>  #endif

Those start codes b0, b3, and b6 unfortunately have roughly the same
meanings in MPEG4 part 2 video.  I wouldn't be too surprised if this
triggered in error on an MPEG4 video elementary stream.

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




More information about the ffmpeg-devel mailing list