diff libmpcodecs/vd_ffmpeg.c @ 7573:30e1c1f77737

rv10 cleanup
author michael
date Tue, 01 Oct 2002 20:01:04 +0000
parents 24165f770c0d
children 87f57e23e301
line wrap: on
line diff
--- a/libmpcodecs/vd_ffmpeg.c	Tue Oct 01 14:37:01 2002 +0000
+++ b/libmpcodecs/vd_ffmpeg.c	Tue Oct 01 20:01:04 2002 +0000
@@ -172,8 +172,6 @@
 #endif
     
     mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"libavcodec.size: %d x %d\n",avctx->width,avctx->height);
-    if (sh->format == mmioFOURCC('R', 'V', '1', '3'))
-	avctx->sub_id = 3;
 #if LIBAVCODEC_BUILD >= 4605
     /* AVRn stores huffman table in AVI header */
     /* Pegasus MJPEG stores it also in AVI header, but it uses the common
@@ -204,9 +202,18 @@
        || 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);
+        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];
+
 //        printf("%X %X %d %d\n", extrahdr[0], extrahdr[1]);
     }
 
@@ -231,6 +238,12 @@
 #if LIBAVCODEC_BUILD >= 4605
     if (avctx->extradata_size)
 	free(avctx->extradata);
+    avctx->extradata=NULL;
+#endif
+#if LIBAVCODEC_BUILD >= 4630
+    if(avctx->slice_offset!=NULL) 
+        free(avctx->slice_offset);
+    avctx->slice_offset=NULL;
 #endif
 
     if (avctx)
@@ -422,6 +435,15 @@
 }
 #endif
 
+// copypaste from demux_real.c - it should match to get it working!
+//FIXME put into some header
+typedef struct dp_hdr_s {
+    uint32_t chunks;	// number of chunks
+    uint32_t timestamp; // timestamp from packet header
+    uint32_t len;	// length of actual data
+    uint32_t chunktab;	// offset to chunk offset array
+} dp_hdr_t;
+
 // decode a frame
 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
     int got_picture=0;
@@ -450,6 +472,23 @@
     avctx->hurry_up=(flags&3)?((flags&2)?2:1):0;
 #endif
 
+#if LIBAVCODEC_BUILD >= 4630
+    if(sh->ds->demuxer->type == DEMUXER_TYPE_REAL){
+        int i;
+        dp_hdr_t *hdr= (dp_hdr_t*)data;
+
+        if(avctx->slice_offset==NULL) 
+            avctx->slice_offset= malloc(sizeof(int)*1000);
+        
+//        for(i=0; i<25; i++) printf("%02X ", ((uint8_t*)data)[i]);
+        
+        avctx->slice_count= hdr->chunks+1;
+        for(i=0; i<avctx->slice_count; i++)
+            avctx->slice_offset[i]= ((uint32_t*)(data+hdr->chunktab))[2*i+1];
+        data+= sizeof(dp_hdr_t);
+    }
+#endif
+
     ret = avcodec_decode_video(avctx, &lavc_picture,
 	     &got_picture, data, len);
     if(ret<0) mp_msg(MSGT_DECVIDEO,MSGL_WARN, "Error while decoding frame!\n");