comparison libvo/vo_x11.c @ 2218:d9ea650b2c24

yv12 scaling at 24/32bpp with -zoom
author arpi
date Mon, 15 Oct 2001 19:33:26 +0000
parents dc11de07b5e7
children 36fa77e785d4
comparison
equal deleted inserted replaced
2217:fd9311c3fa42 2218:d9ea650b2c24
37 #include "x11_common.h" 37 #include "x11_common.h"
38 38
39 #include "fastmemcpy.h" 39 #include "fastmemcpy.h"
40 #include "sub.h" 40 #include "sub.h"
41 41
42 #include "../postproc/swscale.h"
43
42 static vo_info_t vo_info = 44 static vo_info_t vo_info =
43 { 45 {
44 "X11 ( XImage/Shm )", 46 "X11 ( XImage/Shm )",
45 "x11", 47 "x11",
46 "Aaron Holtzman <aholtzma@ess.engr.uvic.ca>", 48 "Aaron Holtzman <aholtzma@ess.engr.uvic.ca>",
130 vo_draw_alpha_rgb15(w,h,src,srca,stride,ImageData+2*(y0*image_width+x0),2*image_width); 132 vo_draw_alpha_rgb15(w,h,src,srca,stride,ImageData+2*(y0*image_width+x0),2*image_width);
131 } 133 }
132 134
133 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ 135 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
134 } 136 }
137
138 static unsigned int scale_xinc=0;
139 static unsigned int scale_yinc=0;
135 140
136 static uint32_t init( uint32_t width,uint32_t height,uint32_t d_width,uint32_t d_height,uint32_t flags,char *title,uint32_t format ) 141 static uint32_t init( uint32_t width,uint32_t height,uint32_t d_width,uint32_t d_height,uint32_t flags,char *title,uint32_t format )
137 { 142 {
138 // int screen; 143 // int screen;
139 int fullscreen=0; 144 int fullscreen=0;
156 image_format=format; 161 image_format=format;
157 162
158 if( flags&0x03 ) fullscreen = 1; 163 if( flags&0x03 ) fullscreen = 1;
159 if( flags&0x02 ) vm = 1; 164 if( flags&0x02 ) vm = 1;
160 if( flags&0x08 ) Flip_Flag = 1; 165 if( flags&0x08 ) Flip_Flag = 1;
161 166
162 printf( "w: %d h: %d\n\n",vo_dwidth,vo_dheight ); 167 //printf( "w: %d h: %d\n\n",vo_dwidth,vo_dheight );
163 168
164 XGetWindowAttributes( mDisplay,DefaultRootWindow( mDisplay ),&attribs ); 169 XGetWindowAttributes( mDisplay,DefaultRootWindow( mDisplay ),&attribs );
165 depth=attribs.depth; 170 depth=attribs.depth;
166 171
167 if ( depth != 15 && depth != 16 && depth != 24 && depth != 32 ) depth=24; 172 if ( depth != 15 && depth != 16 && depth != 24 && depth != 32 ) depth=24;
168 XMatchVisualInfo( mDisplay,mScreen,depth,TrueColor,&vinfo ); 173 XMatchVisualInfo( mDisplay,mScreen,depth,TrueColor,&vinfo );
174
175 if( flags&0x04 && depth>=24 && format==IMGFMT_YV12 ) {
176 // software scale
177 scale_xinc=(width << 8) / d_width - 1; // -1 needed for proper rounding
178 scale_yinc=(height << 16) / d_height;
179 image_width=d_width;
180 image_height=d_height;
181 SwScale_Init();
182 }
169 183
170 #ifdef HAVE_NEW_GUI 184 #ifdef HAVE_NEW_GUI
171 if ( vo_window != None ) { mywindow=vo_window; mygc=vo_gc; } 185 if ( vo_window != None ) { mywindow=vo_window; mygc=vo_gc; }
172 else 186 else
173 #endif 187 #endif
362 { 376 {
363 shmemerror: 377 shmemerror:
364 Shmem_Flag=0; 378 Shmem_Flag=0;
365 #endif 379 #endif
366 myximage=XGetImage( mDisplay,mywindow,0,0, 380 myximage=XGetImage( mDisplay,mywindow,0,0,
367 width,image_height,AllPlanes,ZPixmap ); 381 image_width,image_height,AllPlanes,ZPixmap );
368 ImageData=myximage->data; 382 ImageData=myximage->data;
369 #ifdef SH_MEM 383 #ifdef SH_MEM
370 } 384 }
371 385
372 DeInstallXErrorHandler(); 386 DeInstallXErrorHandler();
461 XSync(mDisplay, False); 475 XSync(mDisplay, False);
462 } 476 }
463 477
464 static uint32_t draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y ) 478 static uint32_t draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y )
465 { 479 {
466 uint8_t *dst; 480
467 481 if(scale_xinc){
468 dst=ImageData + ( image_width * y + x ) * ( bpp/8 ); 482 SwScale_YV12slice_brg24(src,stride,y,h,
483 ImageData, image_width*((bpp+7)/8), image_width, ((bpp+7)/8),
484 scale_xinc, scale_yinc);
485 } else {
486 uint8_t *dst=ImageData + ( image_width * y + x ) * ( bpp/8 );
469 yuv2rgb( dst,src[0],src[1],src[2],w,h,image_width*( bpp/8 ),stride[0],stride[1] ); 487 yuv2rgb( dst,src[0],src[1],src[2],w,h,image_width*( bpp/8 ),stride[0],stride[1] );
488 }
470 return 0; 489 return 0;
471 } 490 }
472 491
473 void rgb15to16_mmx( char* s0,char* d0,int count ); 492 void rgb15to16_mmx( char* s0,char* d0,int count );
474 493