[MPlayer-users] [BUG] incorrect detection of VP3/VP6 keyframes in NSV demux

Chris Dolan chris at chrisdolan.net
Tue Jul 25 20:20:40 CEST 2006


As of SVN r18890, the NSV demuxer uses an incorrect algorithm to  
detect keyframes in a VP31, VP61 or VP62 stream.  As documented for  
VP3 (http://www.multimedia.cx/vp3-format.txt) the keyframe/interframe  
distingisher is bit 7 of the frame header, that is, "buf[7] & 0x80"  
in the notation of the code below.  The below code looks for a magic  
number in bits 9-11 for VP6x and bits 8-23 for VP31, both of which  
are incorrect.  While keyframes should always pass those tests,  
interframes may accidentally pass them too.

I've examined several FLVs containing VP62 video and discovered that  
bit 7 is the only consistent distinguisher between keyframes and  
interframes.  I don't have any authoritative documentation for VP61  
or VP62, so this conclusion is empirical.


Current code:
http://svn.mplayerhq.hu/mplayer/trunk/libmpdemux/demux_nsv.c? 
view=markup&pathrev=18890

             // here we search for the correct keyframe
             // vp6 keyframe is when the 2nd byte of the vp6 header is
             // 0x36 for VP61 and 0x46 for VP62
             if((priv->v_format==mmioFOURCC('V','P','6','1')) ||
                (priv->v_format==mmioFOURCC('V','P','6','2')) ||
                (priv->v_format==mmioFOURCC('V','P','3','1'))) {
                 stream_read(demuxer->stream,buf,10);
                 if (((((priv->v_format>>16) & 0xff) == '6') && ((buf 
[8]&0x0e)!=0x06)) ||
                     ((((priv->v_format>>16) & 0xff) == '3') && (buf 
[8]!=0x00 || buf[9]!=0x08))) {

Speculative fix (untested):

             // here we search for the correct keyframe
             // vp3/6 keyframe is indicated by bit 7 of the frame header
             if((priv->v_format==mmioFOURCC('V','P','6','1')) ||
                (priv->v_format==mmioFOURCC('V','P','6','2')) ||
                (priv->v_format==mmioFOURCC('V','P','3','1'))) {
                 stream_read(demuxer->stream,buf,10);
                 if ((buf[7]&0x80)==0) {

Please note that all of my experiments have been on FLV files, not  
NSV files, but in the VP62 case, they contain similar payload.

Chris

--
Chris Dolan, Software Developer, http://www.chrisdolan.net/
Public key: http://www.chrisdolan.net/public.key
vCard: http://www.chrisdolan.net/ChrisDolan.vcf






More information about the MPlayer-users mailing list