mirror of
https://github.com/mpv-player/mpv
synced 2025-04-01 23:00:41 +00:00
mga_vid fixes, code cleanup
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@57 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
376833ee20
commit
838cf97bcb
@ -1,7 +1,12 @@
|
||||
|
||||
// mga_vid drawing functions
|
||||
|
||||
extern int mga_next_frame;
|
||||
static int mga_next_frame=0;
|
||||
|
||||
static mga_vid_config_t mga_vid_config;
|
||||
static uint8_t *vid_data, *frames[4];
|
||||
static int f;
|
||||
|
||||
|
||||
static void
|
||||
write_frame_g200(uint8_t *y,uint8_t *cr, uint8_t *cb)
|
||||
@ -161,7 +166,7 @@ vo_mga_flip_page(void)
|
||||
|
||||
#if 1
|
||||
ioctl(f,MGA_VID_FSEL,&mga_next_frame);
|
||||
mga_next_frame=(mga_next_frame+1)&3;
|
||||
mga_next_frame=(mga_next_frame+1)%mga_vid_config.num_frames;
|
||||
vid_data=frames[mga_next_frame];
|
||||
#endif
|
||||
|
||||
@ -218,3 +223,29 @@ query_format(uint32_t format)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mga_init(){
|
||||
char *frame_mem;
|
||||
|
||||
mga_vid_config.num_frames=4;
|
||||
mga_vid_config.version=MGA_VID_VERSION;
|
||||
if (ioctl(f,MGA_VID_CONFIG,&mga_vid_config))
|
||||
{
|
||||
perror("Error in mga_vid_config ioctl");
|
||||
return -1;
|
||||
}
|
||||
ioctl(f,MGA_VID_ON,0);
|
||||
|
||||
frames[0] = (char*)mmap(0,mga_vid_config.frame_size*mga_vid_config.num_frames,PROT_WRITE,MAP_SHARED,f,0);
|
||||
frames[1] = frames[0] + 1*mga_vid_config.frame_size;
|
||||
frames[2] = frames[0] + 2*mga_vid_config.frame_size;
|
||||
frames[3] = frames[0] + 3*mga_vid_config.frame_size;
|
||||
mga_next_frame = 0;
|
||||
vid_data = frames[mga_next_frame];
|
||||
|
||||
//clear the buffer
|
||||
memset(frames[0],0x80,mga_vid_config.frame_size*mga_vid_config.num_frames);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,6 @@
|
||||
// Externally visible list of all vo drivers
|
||||
//
|
||||
|
||||
int mga_next_frame=0;
|
||||
|
||||
extern vo_functions_t video_out_mga;
|
||||
extern vo_functions_t video_out_xmga;
|
||||
extern vo_functions_t video_out_x11;
|
||||
|
@ -49,20 +49,14 @@ static vo_info_t vo_info =
|
||||
""
|
||||
};
|
||||
|
||||
static mga_vid_config_t mga_vid_config;
|
||||
static uint8_t *vid_data, *frames[4];
|
||||
static int f;
|
||||
|
||||
#include "mga_common.c"
|
||||
|
||||
static uint32_t
|
||||
init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
|
||||
{
|
||||
char *frame_mem;
|
||||
uint32_t frame_size;
|
||||
|
||||
f = open("/dev/mga_vid",O_RDWR);
|
||||
|
||||
if(f == -1)
|
||||
{
|
||||
fprintf(stderr,"Couldn't open /dev/mga_vid\n");
|
||||
@ -71,8 +65,10 @@ init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint3
|
||||
|
||||
switch(format){
|
||||
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_YUY2:
|
||||
mga_vid_config.frame_size = ((width + 31) & ~31) * height * 2;
|
||||
mga_vid_config.format=MGA_VID_FORMAT_YUY2; break;
|
||||
default:
|
||||
fprintf(stderr,"mga: invalid output format %0X\n",format);
|
||||
@ -81,34 +77,14 @@ init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint3
|
||||
|
||||
mga_vid_config.src_width = width;
|
||||
mga_vid_config.src_height= height;
|
||||
// mga_vid_config.dest_width = width;
|
||||
// mga_vid_config.dest_height= height;
|
||||
mga_vid_config.dest_width = d_width;
|
||||
// (width<704)?704:width; // HACK
|
||||
mga_vid_config.dest_height= d_height;
|
||||
// (height<576)?576:height; // HACK
|
||||
mga_vid_config.x_org= 0; // (720-mga_vid_config.dest_width)/2;
|
||||
mga_vid_config.y_org= 0; // (576-mga_vid_config.dest_height)/2;
|
||||
|
||||
mga_vid_config.version=MGA_VID_VERSION;
|
||||
|
||||
if (ioctl(f,MGA_VID_CONFIG,&mga_vid_config))
|
||||
{
|
||||
perror("Error in mga_vid_config ioctl");
|
||||
}
|
||||
ioctl(f,MGA_VID_ON,0);
|
||||
|
||||
frame_size = ((width + 31) & ~31) * height + (((width + 31) & ~31) * height) / 2;
|
||||
frame_mem = (char*)mmap(0,frame_size*4,PROT_WRITE,MAP_SHARED,f,0);
|
||||
frames[0] = frame_mem;
|
||||
frames[1] = frame_mem + 1*frame_size;
|
||||
frames[2] = frame_mem + 2*frame_size;
|
||||
frames[3] = frame_mem + 3*frame_size;
|
||||
mga_next_frame = 0;
|
||||
vid_data = frames[mga_next_frame];
|
||||
|
||||
//clear the buffer
|
||||
memset(frame_mem,0x80,frame_size*4);
|
||||
|
||||
return 0;
|
||||
return mga_init();
|
||||
}
|
||||
|
||||
static const vo_info_t*
|
||||
|
@ -53,11 +53,6 @@ static vo_info_t vo_info =
|
||||
""
|
||||
};
|
||||
|
||||
static mga_vid_config_t mga_vid_config;
|
||||
static uint8_t * vid_data;
|
||||
static uint8_t * frames[4];
|
||||
static int f;
|
||||
|
||||
static Display * mDisplay;
|
||||
static Window mWindow;
|
||||
static GC mGC;
|
||||
@ -142,7 +137,7 @@ static void flip_page(void){
|
||||
static uint32_t init( uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format )
|
||||
{
|
||||
char * frame_mem;
|
||||
uint32_t frame_size;
|
||||
// uint32_t frame_size;
|
||||
int mScreen;
|
||||
unsigned int fg, bg;
|
||||
char * mTitle=(title == NULL) ? "XMGA render" : title;
|
||||
@ -163,8 +158,14 @@ static uint32_t init( uint32_t width, uint32_t height, uint32_t d_width, uint32_
|
||||
|
||||
switch(format)
|
||||
{
|
||||
case IMGFMT_YV12: mga_vid_config.format=MGA_VID_FORMAT_YV12; break;
|
||||
case IMGFMT_YUY2: mga_vid_config.format=MGA_VID_FORMAT_YUY2; break;
|
||||
case IMGFMT_YV12:
|
||||
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_YUY2:
|
||||
mga_vid_config.format=MGA_VID_FORMAT_YUY2;
|
||||
mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height * 2;
|
||||
break;
|
||||
default: fprintf(stderr,"mga: invalid output format %0X\n",format); return (-1);
|
||||
}
|
||||
|
||||
@ -253,10 +254,10 @@ static uint32_t init( uint32_t width, uint32_t height, uint32_t d_width, uint32_
|
||||
|
||||
mga_vid_config.src_width=width;
|
||||
mga_vid_config.src_height=height;
|
||||
mga_vid_config.x_org=drwcX;
|
||||
mga_vid_config.y_org=drwcY;
|
||||
mga_vid_config.dest_width=drwWidth;
|
||||
mga_vid_config.dest_height=drwHeight;
|
||||
mga_vid_config.x_org=drwcX;
|
||||
mga_vid_config.y_org=drwcY;
|
||||
|
||||
fprintf( stderr,"[xmga] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
|
||||
|
||||
@ -265,30 +266,11 @@ static uint32_t init( uint32_t width, uint32_t height, uint32_t d_width, uint32_
|
||||
mga_vid_config.colkey_green=0;
|
||||
mga_vid_config.colkey_blue=255;
|
||||
|
||||
#if 1
|
||||
if ( ioctl( f,MGA_VID_CONFIG,&mga_vid_config ) )
|
||||
{
|
||||
fprintf( stderr,"Error in mga_vid_config ioctl" );
|
||||
return -1;
|
||||
}
|
||||
ioctl( f,MGA_VID_ON,0 );
|
||||
#endif
|
||||
|
||||
frame_size=( ( width + 31 ) & ~31 ) * height + ( ( ( width + 31 ) & ~31 ) * height ) / 2;
|
||||
frame_mem=(char*)mmap( 0,frame_size*4,PROT_WRITE,MAP_SHARED,f,0 );
|
||||
frames[0] = frame_mem;
|
||||
frames[1] = frame_mem + 1*frame_size;
|
||||
frames[2] = frame_mem + 2*frame_size;
|
||||
frames[3] = frame_mem + 3*frame_size;
|
||||
mga_next_frame=0;
|
||||
vid_data=frames[mga_next_frame];
|
||||
memset( frame_mem,0x80,frame_size * 4 );
|
||||
if(mga_init()) return -1;
|
||||
|
||||
XFlush( mDisplay );
|
||||
XSync( mDisplay,False );
|
||||
|
||||
// vo_initthread( mThread );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -302,6 +284,3 @@ uninit(void)
|
||||
ioctl( f,MGA_VID_OFF,0 );
|
||||
printf("vo: uninit!\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user