changeset 2384:814166bee8fd

3ivx YV12 direct rendering (one lss memcpy)
author arpi
date Mon, 22 Oct 2001 22:45:06 +0000
parents e13c63bc4151
children 78209b784fec
files dec_video.c xacodec.c xacodec.h
diffstat 3 files changed, 76 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/dec_video.c	Mon Oct 22 21:31:42 2001 +0000
+++ b/dec_video.c	Mon Oct 22 22:45:06 2001 +0000
@@ -1,3 +1,5 @@
+
+#define USE_XANIM
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -451,8 +453,12 @@
 switch(sh_video->codec->driver){
 #ifdef USE_XANIM
   case VFM_XANIM: {
-    int ret=xacodec_decode_frame(start,in_size,sh_video->our_out_buffer,drop_frame?1:0);
-    if(ret) blit_frame=3;
+    xacodec_image_t* image=xacodec_decode_frame(start,in_size,drop_frame?1:0);
+    if(image){
+	blit_frame=2;
+	planes=image->planes;
+	stride=image->stride;
+    }
     break;
   }
 #endif
--- a/xacodec.c	Mon Oct 22 21:31:42 2001 +0000
+++ b/xacodec.c	Mon Oct 22 22:45:06 2001 +0000
@@ -60,6 +60,7 @@
     unsigned int (*dec_func)(unsigned char *image, unsigned char *delta,
 	unsigned int dsize, XA_DEC_INFO *dec_info);
     void *close_func[XA_CLOSE_FUNCS];
+    xacodec_image_t image;
 } xacodec_driver_t;
 
 xacodec_driver_t *xacodec_driver = NULL;
@@ -303,16 +304,23 @@
     xacodec_driver->decinfo->extra = codec_hdr.extra;
 
 //    vidinfo->our_out_buffer = malloc(codec_hdr.y * codec_hdr.x * ((codec_hdr.depth+7)/8));
-    vidinfo->our_out_buffer = malloc(codec_hdr.y * codec_hdr.x * codec_hdr.depth);
+//    vidinfo->our_out_buffer = malloc(codec_hdr.y * codec_hdr.x * codec_hdr.depth);
+    xacodec_driver->image.out_fmt=out_format;
+    xacodec_driver->image.bpp=codec_hdr.depth;
+    xacodec_driver->image.width=codec_hdr.x;
+    xacodec_driver->image.height=codec_hdr.y;
+    xacodec_driver->image.mem=malloc(codec_hdr.y * codec_hdr.x * ((codec_hdr.depth+7)/8));
 
 //    printf("out_buf size: %d\n", codec_hdr.y * codec_hdr.x * codec_hdr.depth);
 
+#if 0
     if (vidinfo->our_out_buffer == NULL)
     {
 	mp_msg(MSGT_DECVIDEO, MSGL_ERR, "cannot allocate memory for output: %s",
 	    strerror(errno));
 	return(0);
     }
+#endif
 
     mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "extra: %08x - %dx%d %dbit\n", codec_hdr.extra,
 	codec_hdr.x, codec_hdr.y, codec_hdr.depth);
@@ -330,23 +338,23 @@
 //    unsigned int (*dec_func)(unsigned char *image, unsigned char *delta,
 //	unsigned int dsize, XA_DEC_INFO *dec_info);
 
-int xacodec_decode_frame(uint8_t *frame, int frame_size,
-			uint8_t *dest, int skip_flag)
+xacodec_image_t* xacodec_decode_frame(uint8_t *frame, int frame_size, int skip_flag)
 {
     unsigned int ret;
     int i;
-    
+
     if (skip_flag > 0)
 	printf("frame will be dropped..\n");
 
     xacodec_driver->decinfo->skip_flag = skip_flag;
 
-    printf("frame: %08x (size: %d) - dest: %08x\n", frame, frame_size, dest);
+//    printf("frame: %08x (size: %d) - dest: %08x\n", frame, frame_size, dest);
+
+    ret = xacodec_driver->dec_func((uint8_t*)&xacodec_driver->image, frame, frame_size, xacodec_driver->decinfo);
 
-    ret = xacodec_driver->dec_func(dest, frame, frame_size, xacodec_driver->decinfo);
-
-    printf("ret: %lu : ", ret);
+//    printf("ret: %lu : ", ret);
     
+#if 0
     for (i = 0; i < 10; i++)
     {
 	if (frame[i] != dest[i])
@@ -354,11 +362,12 @@
 	else
 	    printf("%d: [%02x] ", frame[i]);
     }
+#endif
 
     if (ret == ACT_DLT_NORM)
     {
 	printf("norm\n");
-	return(TRUE);
+	return &xacodec_driver->image;
     }
 
 /*
@@ -374,35 +383,35 @@
     if (ret & ACT_DLT_NOP)
     {
 	printf("nop\n");
-	return(FALSE); /* dst = 0 */
+	return NULL; /* dst = 0 */
     }
 
     if (ret & ACT_DLT_DROP) /* by skip frames and errors */
     {
 	printf("drop\n");
-	return(FALSE);
+	return NULL;
     }
 
 
     if (ret & ACT_DLT_BAD)
     {
 	printf("bad\n");
-	return(FALSE);
+	return NULL;
     }
 
     if (ret & ACT_DLT_BODY)
     {
 	printf("body\n");
-	return(TRUE);
+	return NULL;
     }
     
     if (ret & ACT_DLT_XOR)
     {
 	printf("xor\n");
-	return(TRUE);
+	return &xacodec_driver->image;
     }
 
-    return(FALSE);
+    return NULL;
 }
 
 int xacodec_exit()
@@ -433,7 +442,7 @@
 
 unsigned long XA_Time_Read()
 {
-    return(GetRelativeTime());
+    return GetTimer(); //(GetRelativeTime());
 }
 
 void XA_dummy()
@@ -707,21 +716,46 @@
     return((void *)color_func);
 }
 
-void XA_YUV221111_To_CLR8(image,imagex,imagey,i_x,i_y,yuv,yuv_tabs,map_flag,map,chdr)
-xaUBYTE *image;		xaULONG imagex,imagey,i_x,i_y;
+void XA_YUV221111_To_CLR8(image_p,imagex,imagey,i_x,i_y,yuv,yuv_tabs,map_flag,map,chdr)
+xaUBYTE *image_p;		xaULONG imagex,imagey,i_x,i_y;
 YUVBufs *yuv;	YUVTabs *yuv_tabs;
 xaULONG map_flag,*map;	XA_CHDR *chdr;
 {
-    printf("XA_YUV221111_To_CLR8(%p  %dx%d %d;%d  %p %p %d %p %p)\n",
-	image,imagex,imagey,i_x,i_y,yuv,yuv_tabs,map_flag,map,chdr);
+    xacodec_image_t *image=(xacodec_image_t*)image_p;
+
+#if 0
+    printf("XA_YUV221111_To_CLR8(%p  %dx%d %d;%d [%dx%d]  %p %p %d %p %p)\n",
+	image,imagex,imagey,i_x,i_y, image->width,image->height,
+	yuv,yuv_tabs,map_flag,map,chdr);
 
     printf("YUV: %p %p %p %X (%X) %Xx%X %Xx%X\n",
 	yuv->Ybuf,yuv->Ubuf,yuv->Vbuf,yuv->the_buf,yuv->the_buf_size,
 	yuv->y_w,yuv->y_h,yuv->uv_w,yuv->uv_h);
+#endif
 
-    memcpy(image,yuv->Ybuf,imagex*imagey);
-    memcpy(image+imagex*imagey,yuv->Vbuf,imagex*imagey/4);
-    memcpy(image+imagex*imagey*5/4,yuv->Ubuf,imagex*imagey/4);
+if(imagex==image->width && imagey==image->height){
+//    printf("Direct render!!!\n");
+    image->planes[0]=yuv->Ybuf;
+    if(image->out_fmt==IMGFMT_YV12){
+	image->planes[1]=yuv->Ubuf;
+	image->planes[2]=yuv->Vbuf;
+    } else {
+	image->planes[1]=yuv->Vbuf;
+	image->planes[2]=yuv->Ubuf;
+    }
+    image->stride[0]=imagex; // yuv->y_w
+    image->stride[1]=image->stride[2]=imagex/2; // yuv->uv_w
+} else {
+    int y;
+    printf("partial YV12 not implemented!!!!!!\n");
+//    image->planes[0]=image->mem;
+//    image->planes[1]=image->planes[0]+image->width*image->height;
+//    image->planes[2]=image->planes[1]+image->width*image->height/4;
+}
+
+//    memcpy(image,yuv->Ybuf,imagex*imagey);
+//    memcpy(image+imagex*imagey,yuv->Vbuf,imagex*imagey/4);
+//    memcpy(image+imagex*imagey*5/4,yuv->Ubuf,imagex*imagey/4);
 
 /*
     unsigned char *Ybuf;
--- a/xacodec.h	Mon Oct 22 21:31:42 2001 +0000
+++ b/xacodec.h	Mon Oct 22 22:45:06 2001 +0000
@@ -101,3 +101,14 @@
     unsigned int	imagec;
     unsigned int	imaged;
 } XA_ANIM_HDR;
+
+// Added by A'rpi
+typedef struct {
+    unsigned int out_fmt;
+    int bpp;
+    int width,height;
+    unsigned char* planes[3];
+    int stride[3];
+    unsigned char *mem;
+} xacodec_image_t;
+