changeset 470:8e101a5d9dc2

I420/IYUV support
author arpi_esp
date Mon, 16 Apr 2001 03:33:35 +0000
parents 434889ca2340
children 50e990d816f9
files drivers/mga_vid.c drivers/mga_vid.h libvo/mga_common.c libvo/vo_mga.c libvo/vo_xmga.c mplayer.c
diffstat 6 files changed, 76 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/drivers/mga_vid.c	Mon Apr 16 03:01:46 2001 +0000
+++ b/drivers/mga_vid.c	Mon Apr 16 03:33:35 2001 +0000
@@ -395,6 +395,8 @@
 
 switch(config->format){
     case MGA_VID_FORMAT_YV12:	
+    case MGA_VID_FORMAT_I420:	
+    case MGA_VID_FORMAT_IYUV:	
 	regs.besctl = 1         // BES enabled
                     + (0<<6)    // even start polarity
                     + (1<<10)   // x filtering enabled
@@ -484,13 +486,17 @@
 	regs.besb1org = (uint32_t) mga_src_base + baseadrofs + 2*frame_size;
 	regs.besb2org = (uint32_t) mga_src_base + baseadrofs + 3*frame_size;
 
-if(config->format==MGA_VID_FORMAT_YV12){
+if(config->format==MGA_VID_FORMAT_YV12
+ ||config->format==MGA_VID_FORMAT_IYUV
+ ||config->format==MGA_VID_FORMAT_I420
+ ){
         // planar YUV frames:
 	if (is_g400) 
 		baseadrofs = (((ofstop*regs.besviscal)/4)>>16)*regs.bespitch;
 	else 
 		baseadrofs = (((ofstop*regs.besviscal)/2)>>16)*regs.bespitch;
 
+    if(config->format==MGA_VID_FORMAT_YV12){
 	regs.besa1corg = (uint32_t) mga_src_base + baseadrofs + regs.bespitch * sh ;
 	regs.besa2corg = (uint32_t) mga_src_base + baseadrofs + 1*frame_size + regs.bespitch * sh;
 	regs.besb1corg = (uint32_t) mga_src_base + baseadrofs + 2*frame_size + regs.bespitch * sh;
@@ -499,6 +505,17 @@
 	regs.besa2c3org = regs.besa2corg + ((regs.bespitch * sh) / 4);
 	regs.besb1c3org = regs.besb1corg + ((regs.bespitch * sh) / 4);
 	regs.besb2c3org = regs.besb2corg + ((regs.bespitch * sh) / 4);
+    } else {
+	regs.besa1c3org = (uint32_t) mga_src_base + baseadrofs + regs.bespitch * sh ;
+	regs.besa2c3org = (uint32_t) mga_src_base + baseadrofs + 1*frame_size + regs.bespitch * sh;
+	regs.besb1c3org = (uint32_t) mga_src_base + baseadrofs + 2*frame_size + regs.bespitch * sh;
+	regs.besb2c3org = (uint32_t) mga_src_base + baseadrofs + 3*frame_size + regs.bespitch * sh;
+	regs.besa1corg = regs.besa1c3org + ((regs.bespitch * sh) / 4);
+	regs.besa2corg = regs.besa2c3org + ((regs.bespitch * sh) / 4);
+	regs.besb1corg = regs.besb1c3org + ((regs.bespitch * sh) / 4);
+	regs.besb2corg = regs.besb2c3org + ((regs.bespitch * sh) / 4);
+    }
+
 }
 
 	weight = ofstop * (regs.besviscal >> 2);
--- a/drivers/mga_vid.h	Mon Apr 16 03:01:46 2001 +0000
+++ b/drivers/mga_vid.h	Mon Apr 16 03:33:35 2001 +0000
@@ -38,6 +38,8 @@
 } mga_vid_config_t;
 
 #define MGA_VID_FORMAT_YV12 0x32315659
+#define MGA_VID_FORMAT_IYUV (('I'<<24)|('Y'<<16)|('U'<<8)|'V')
+#define MGA_VID_FORMAT_I420 (('I'<<24)|('4'<<16)|('2'<<8)|'0')
 #define MGA_VID_FORMAT_YUY2 (('Y'<<24)|('U'<<16)|('Y'<<8)|'2')
 #define MGA_VID_FORMAT_UYVY (('U'<<24)|('Y'<<16)|('V'<<8)|'Y')
 
--- a/libvo/mga_common.c	Mon Apr 16 03:01:46 2001 +0000
+++ b/libvo/mga_common.c	Mon Apr 16 03:33:35 2001 +0000
@@ -14,6 +14,8 @@
     uint32_t bespitch = (mga_vid_config.src_width + 31) & ~31;
     switch(mga_vid_config.format){
     case MGA_VID_FORMAT_YV12:
+    case MGA_VID_FORMAT_IYUV:
+    case MGA_VID_FORMAT_I420:
         vo_draw_alpha_yv12(w,h,src,srca,stride,vid_data+bespitch*y0+x0,bespitch);
         break;
     case MGA_VID_FORMAT_YUY2:
@@ -171,6 +173,8 @@
 {
     switch(format){
     case IMGFMT_YV12:
+    case IMGFMT_I420:
+    case IMGFMT_IYUV:
     case IMGFMT_YUY2:
     case IMGFMT_UYVY:
 //    case IMGFMT_RGB|24:
--- a/libvo/vo_mga.c	Mon Apr 16 03:01:46 2001 +0000
+++ b/libvo/vo_mga.c	Mon Apr 16 03:33:35 2001 +0000
@@ -67,6 +67,12 @@
         case IMGFMT_YV12:
 	    mga_vid_config.frame_size = ((width + 31) & ~31) * height + (((width + 31) & ~31) * height) / 2;
             mga_vid_config.format=MGA_VID_FORMAT_YV12; break;
+        case IMGFMT_I420:
+	    mga_vid_config.frame_size = ((width + 31) & ~31) * height + (((width + 31) & ~31) * height) / 2;
+            mga_vid_config.format=MGA_VID_FORMAT_I420; break;
+        case IMGFMT_IYUV:
+	    mga_vid_config.frame_size = ((width + 31) & ~31) * height + (((width + 31) & ~31) * height) / 2;
+            mga_vid_config.format=MGA_VID_FORMAT_IYUV; break;
         case IMGFMT_YUY2:
 	    mga_vid_config.frame_size = ((width + 31) & ~31) * height * 2;
             mga_vid_config.format=MGA_VID_FORMAT_YUY2; break;
--- a/libvo/vo_xmga.c	Mon Apr 16 03:01:46 2001 +0000
+++ b/libvo/vo_xmga.c	Mon Apr 16 03:33:35 2001 +0000
@@ -185,6 +185,14 @@
         mga_vid_config.format=MGA_VID_FORMAT_YV12;
         mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height + ( ( ( width + 31 ) & ~31 ) * height ) / 2;
         break;
+   case IMGFMT_I420:
+        mga_vid_config.format=MGA_VID_FORMAT_I420;
+        mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height + ( ( ( width + 31 ) & ~31 ) * height ) / 2;
+        break;
+   case IMGFMT_IYUV:
+        mga_vid_config.format=MGA_VID_FORMAT_IYUV;
+        mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height + ( ( ( width + 31 ) & ~31 ) * height ) / 2;
+        break;
    case IMGFMT_YUY2:
         mga_vid_config.format=MGA_VID_FORMAT_YUY2;
         mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height * 2;
--- a/mplayer.c	Mon Apr 16 03:01:46 2001 +0000
+++ b/mplayer.c	Mon Apr 16 03:33:35 2001 +0000
@@ -909,11 +909,17 @@
         exit(1);
    }
    
-   if(out_fmt==IMGFMT_YUY2)
-     DS_VideoDecoder_SetDestFmt(16,mmioFOURCC('Y', 'U', 'Y', '2'));
-//     DS_VideoDecoder_SetDestFmt(16,mmioFOURCC('Y', 'V', '1', '2'));
-   else
-     DS_VideoDecoder_SetDestFmt(out_fmt&255,0);
+   switch(out_fmt){
+   case IMGFMT_YUY2:
+   case IMGFMT_UYVY:
+     DS_VideoDecoder_SetDestFmt(16,out_fmt);break;        // packed YUV
+   case IMGFMT_YV12:
+   case IMGFMT_I420:
+   case IMGFMT_IYUV:
+     DS_VideoDecoder_SetDestFmt(12,out_fmt);break;        // planar YUV
+   default:
+     DS_VideoDecoder_SetDestFmt(out_fmt&255,0);           // RGB/BGR
+   }
 
    DS_VideoDecoder_Start();
 
@@ -1023,6 +1029,9 @@
      if((out_fmt&IMGFMT_BGR_MASK)==IMGFMT_RGB)
        printf("RGB%d\n",out_fmt&255); else
      if(out_fmt==IMGFMT_YUY2) printf("YUY2\n"); else
+     if(out_fmt==IMGFMT_UYVY) printf("UYVY\n"); else
+     if(out_fmt==IMGFMT_I420) printf("I420\n"); else
+     if(out_fmt==IMGFMT_IYUV) printf("IYUV\n"); else
      if(out_fmt==IMGFMT_YV12) printf("YV12\n");
    }
 
@@ -1336,7 +1345,19 @@
     if(in_size>max_framesize) max_framesize=in_size;
 
     DS_VideoDecoder_DecodeFrame(start, in_size, 0, 1);
+    current_module="draw_frame";
+
       t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f;
+      if(out_fmt==IMGFMT_YV12||out_fmt==IMGFMT_IYUV||out_fmt==IMGFMT_I420){
+        uint8_t* dst[3];
+        int stride[3];
+        stride[0]=sh_video->disp_w;
+        stride[1]=stride[2]=sh_video->disp_w/2;
+        dst[0]=sh_video->our_out_buffer;
+        dst[2]=dst[0]+sh_video->disp_w*sh_video->disp_h;
+        dst[1]=dst[2]+sh_video->disp_w*sh_video->disp_h/4;
+        video_out->draw_slice(dst,stride,sh_video->disp_w,sh_video->disp_h,0,0);
+      } else
         video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer);
       t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f;
     break;
@@ -1359,7 +1380,19 @@
                         &sh_video->o_bih, sh_video->our_out_buffer);
       if(ret){ printf("Error decompressing frame, err=%d\n",ret);break; }
     }
+    current_module="draw_frame";
       t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f;
+//      if(out_fmt==IMGFMT_YV12){
+      if(out_fmt==IMGFMT_YV12||out_fmt==IMGFMT_IYUV||out_fmt==IMGFMT_I420){
+        uint8_t* dst[3];
+        int stride[3];
+        stride[0]=sh_video->disp_w;
+        stride[1]=stride[2]=sh_video->disp_w/2;
+        dst[0]=sh_video->our_out_buffer;
+        dst[2]=dst[0]+sh_video->disp_w*sh_video->disp_h;
+        dst[1]=dst[2]+sh_video->disp_w*sh_video->disp_h/4;
+        video_out->draw_slice(dst,stride,sh_video->disp_w,sh_video->disp_h,0,0);
+      } else
         video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer);
       t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f;