changeset 21559:de2a96f41195

Fix realvideo size changes by using our own malloced buffer and export type mpi.
author reimar
date Sun, 10 Dec 2006 16:52:58 +0000
parents 7412d71880d5
children a16219e6d656
files libmpcodecs/vd_realvid.c
diffstat 1 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vd_realvid.c	Sun Dec 10 15:10:46 2006 +0000
+++ b/libmpcodecs/vd_realvid.c	Sun Dec 10 16:52:58 2006 +0000
@@ -59,6 +59,7 @@
 
 static void *rv_handle=NULL;
 static int inited=0;
+static uint8_t *buffer = NULL;
 #ifdef USE_WIN32DLL
 static int dll_type = 0; /* 0 = unix dlopen, 1 = win32 dll */
 #endif
@@ -296,6 +297,9 @@
 #endif
 	rv_handle=NULL;
 	inited = 0;
+	if (buffer)
+	    free(buffer);
+	buffer = NULL;
 }
 
 // copypaste from demux_real.c - it should match to get it working!
@@ -313,7 +317,6 @@
 	dp_hdr_t* dp_hdr=(dp_hdr_t*)data;
 	unsigned char* dp_data=((unsigned char*)data)+sizeof(dp_hdr_t);
 	uint32_t* extra=(uint32_t*)(((char*)data)+dp_hdr->chunktab);
-	unsigned char* buffer;
 
 	unsigned int transform_out[5];
 	transform_in_t transform_in={
@@ -327,12 +330,8 @@
 
 	if(len<=0 || flags&2) return NULL; // skipped frame || hardframedrop
 
-	if(inited){  // rv30 width/height not yet known
-	mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/,
-		sh->disp_w, sh->disp_h);
-	if(!mpi) return NULL;
-	    buffer=mpi->planes[0];
-	} else {
+	if (!inited) {
+	    if (buffer) free(buffer);
 	    buffer=malloc(sh->disp_w*sh->disp_h*3/2);
 	    if (!buffer) return 0;
 	}
@@ -351,13 +350,21 @@
 	    sh->disp_w=transform_out[3];
 	    sh->disp_h=transform_out[4];
 	    if (!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_I420)) return 0;
-	    mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/,
+	    inited=1;
+	} 
+	    mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/,
 		    sh->disp_w, sh->disp_h);
 	    if(!mpi) return NULL;
-	    memcpy(mpi->planes[0],buffer,sh->disp_w*sh->disp_h*3/2);
-	    free(buffer);
-	    inited=1;
-	} 
+	    mpi->planes[0] = buffer;
+	    mpi->stride[0] = sh->disp_w;
+	    mpi->planes[1] = buffer + sh->disp_w*sh->disp_h;
+	    mpi->stride[1] = sh->disp_w / 2;
+	    mpi->planes[2] = buffer + sh->disp_w*sh->disp_h*5/4;
+	    mpi->stride[2] = sh->disp_w / 2;
 
+	if(transform_out[0] &&
+	   (sh->disp_w != transform_out[3] || sh->disp_h != transform_out[4]))
+	    inited = 0;
+	
 	return (result?NULL:mpi);
 }