1
mirror of https://github.com/mpv-player/mpv synced 2025-01-13 00:06:25 +01:00

I420/IYUV support

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@471 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi_esp 2001-04-16 03:33:35 +00:00
parent 46bf0d7566
commit 10f985abb2
6 changed files with 76 additions and 6 deletions

View File

@ -395,6 +395,8 @@ static int mga_vid_set_config(mga_vid_config_t *config)
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 @@ switch(config->format){
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 @@ if(config->format==MGA_VID_FORMAT_YV12){
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);

View File

@ -38,6 +38,8 @@ uint32_t num_frames;
} 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')

View File

@ -14,6 +14,8 @@ static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned
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 @@ query_format(uint32_t format)
{
switch(format){
case IMGFMT_YV12:
case IMGFMT_I420:
case IMGFMT_IYUV:
case IMGFMT_YUY2:
case IMGFMT_UYVY:
// case IMGFMT_RGB|24:

View File

@ -67,6 +67,12 @@ init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint3
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;

View File

@ -185,6 +185,14 @@ static uint32_t init( uint32_t width, uint32_t height, uint32_t d_width, uint32_
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;

View File

@ -909,11 +909,17 @@ switch(sh_video->codec->driver){
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 @@ make_pipe(&keyb_fifo_get,&keyb_fifo_put);
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 @@ switch(sh_video->codec->driver){
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 @@ switch(sh_video->codec->driver){
&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;