From 93768f46e5d1b42a8a74c302c0f3d8e0899cbab6 Mon Sep 17 00:00:00 2001
From: arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>
Date: Tue, 1 Oct 2002 21:30:10 +0000
Subject: [PATCH] fixing RV10 streamcopy - detect packet format (simple single
 frame vs. slices with extra header + offset tab) based on codec header
 instead of demuxer type

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7575 b3059339-0415-0410-9bf9-f77b7e298cf2
---
 libmpcodecs/vd_ffmpeg.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c
index 03558896ed..60cf4a7681 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -200,19 +200,21 @@ static int init(sh_video_t *sh){
 #endif
     if(   sh->format == mmioFOURCC('R', 'V', '1', '0')
        || sh->format == mmioFOURCC('R', 'V', '1', '3')){
-        unsigned int* extrahdr=(unsigned int*)(sh->bih+1);
         avctx->extradata_size= 8;
         avctx->extradata = malloc(avctx->extradata_size);
-        if(sh->ds->demuxer->type != DEMUXER_TYPE_REAL){
-            /* not .rm container -> only 1 packet per frame & sub_id from fourcc */
-            if (sh->format == mmioFOURCC('R', 'V', '1', '3'))
-	        extrahdr[1] = 0x10003001;
-            else
-	        extrahdr[1] = 0x10000000;
-        }
-        ((uint32_t*)avctx->extradata)[0] = extrahdr[0];
-        ((uint32_t*)avctx->extradata)[1] = extrahdr[1];
-        avctx->sub_id= extrahdr[1];
+        if(sh->bih->biSize!=sizeof(*sh->bih)+8){
+            /* only 1 packet per frame & sub_id from fourcc */
+	    ((uint32_t*)avctx->extradata)[0] = 0;
+	    avctx->sub_id=
+	    ((uint32_t*)avctx->extradata)[1] =
+        	(sh->format == mmioFOURCC('R', 'V', '1', '3')) ? 0x10003001 : 0x10000000;
+        } else {
+	    /* has extra slice header (demux_rm or rm->avi streamcopy) */
+	    unsigned int* extrahdr=(unsigned int*)(sh->bih+1);
+	    ((uint32_t*)avctx->extradata)[0] = extrahdr[0];
+	    avctx->sub_id=
+	    ((uint32_t*)avctx->extradata)[1] = extrahdr[1];
+	}
 
 //        printf("%X %X %d %d\n", extrahdr[0], extrahdr[1]);
     }
@@ -473,7 +475,10 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
 #endif
 
 #if LIBAVCODEC_BUILD >= 4630
-    if(sh->ds->demuxer->type == DEMUXER_TYPE_REAL){
+//    if(sh->ds->demuxer->type == DEMUXER_TYPE_REAL){
+    if(   sh->format == mmioFOURCC('R', 'V', '1', '0')
+       || sh->format == mmioFOURCC('R', 'V', '1', '3'))
+    if(sh->bih->biSize==sizeof(*sh->bih)+8){
         int i;
         dp_hdr_t *hdr= (dp_hdr_t*)data;