comparison libvo/vo_xv.c @ 5935:5074aa8fae5a

printf to mp_msg
author albeu
date Thu, 02 May 2002 10:49:55 +0000
parents 104fce2b92b6
children f9fe22a52e80
comparison
equal deleted inserted replaced
5934:42127864a2b3 5935:5074aa8fae5a
20 #include <stdio.h> 20 #include <stdio.h>
21 #include <stdlib.h> 21 #include <stdlib.h>
22 #include <string.h> 22 #include <string.h>
23 23
24 #include "config.h" 24 #include "config.h"
25 #include "mp_msg.h"
25 #include "video_out.h" 26 #include "video_out.h"
26 #include "video_out_internal.h" 27 #include "video_out_internal.h"
27 28
28 LIBVO_EXTERN(xv) 29 LIBVO_EXTERN(xv)
29 30
77 #include <sys/ipc.h> 78 #include <sys/ipc.h>
78 #include <sys/shm.h> 79 #include <sys/shm.h>
79 #include <X11/extensions/XShm.h> 80 #include <X11/extensions/XShm.h>
80 81
81 static int Shmem_Flag; 82 static int Shmem_Flag;
82 static int Quiet_Flag; 83 //static int Quiet_Flag; <-- What is that for ? Albeu.
83 static XShmSegmentInfo Shminfo[NUM_BUFFERS]; 84 static XShmSegmentInfo Shminfo[NUM_BUFFERS];
84 static int gXErrorFlag; 85 static int gXErrorFlag;
85 static int CompletionType = -1; 86 static int CompletionType = -1;
86 87
87 static uint32_t image_width; 88 static uint32_t image_width;
124 { 125 {
125 if (attributes[i].flags & XvSettable && !strcmp(attributes[i].name,"XV_SET_DEFAULTS" 126 if (attributes[i].flags & XvSettable && !strcmp(attributes[i].name,"XV_SET_DEFAULTS"
126 )) 127 ))
127 { 128 {
128 was_reset = 1; 129 was_reset = 1;
129 if(verbose > 1) printf("vo_xv: reset gamma correction\n"); 130 mp_msg(MSGT_VO,MSGL_V,"vo_xv: reset gamma correction\n");
130 xv_atomka = XInternAtom(mDisplay, attributes[i].name, True); 131 xv_atomka = XInternAtom(mDisplay, attributes[i].name, True);
131 XvSetPortAttribute(mDisplay, xv_port, xv_atomka, attributes[i].max_value); 132 XvSetPortAttribute(mDisplay, xv_port, xv_atomka, attributes[i].max_value);
132 } 133 }
133 } 134 }
134 /* for safety purposes */ 135 /* for safety purposes */
180 if(!port_value && use_reset) continue; 181 if(!port_value && use_reset) continue;
181 port_min = xv_min; 182 port_min = xv_min;
182 port_max = xv_max; 183 port_max = xv_max;
183 port_mid = (port_min + port_max) / 2; 184 port_mid = (port_min + port_max) / 2;
184 port_value = port_mid + (port_value * (port_max - port_min)) / 2000; 185 port_value = port_mid + (port_value * (port_max - port_min)) / 2000;
185 if(verbose > 1) 186 mp_msg(MSGT_VO,MSGL_V,"vo_xv: set gamma %s to %i (min %i max %i mid %i)\n",attributes[i].name,port_value,port_min,port_max,port_mid);
186 printf("vo_xv: set gamma %s to %i (min %i max %i mid %i)\n",attributes[i].name,port_value,port_min,port_max,port_mid);
187 XvSetPortAttribute(mDisplay, xv_port, xv_atomka, port_value); 187 XvSetPortAttribute(mDisplay, xv_port, xv_atomka, port_value);
188 } 188 }
189 } 189 }
190 } 190 }
191 return 0; 191 return 0;
215 then trigger it if it's ok so that the other values are at default upon query */ 215 then trigger it if it's ok so that the other values are at default upon query */
216 if (xv_atomka != None) 216 if (xv_atomka != None)
217 { 217 {
218 int port_value,port_min,port_max,port_mid; 218 int port_value,port_min,port_max,port_mid;
219 XvGetPortAttribute(mDisplay, xv_port, xv_atomka, &port_value); 219 XvGetPortAttribute(mDisplay, xv_port, xv_atomka, &port_value);
220 if(verbose>1) printf("vo_xv: get: %s = %i\n",attributes[i].name,port_value); 220 mp_msg(MSGT_VO,MSGL_V,"vo_xv: get: %s = %i\n",attributes[i].name,port_value);
221 221
222 port_min = xv_min; 222 port_min = xv_min;
223 port_max = xv_max; 223 port_max = xv_max;
224 port_mid = (port_min + port_max) / 2; 224 port_mid = (port_min + port_max) / 2;
225 port_value = ((port_value - port_mid)*2000)/(port_max-port_min); 225 port_value = ((port_value - port_mid)*2000)/(port_max-port_min);
226 226
227 if(verbose>1) printf("vo_xv: assume: %s = %i\n",attributes[i].name,port_value); 227 mp_msg(MSGT_VO,MSGL_V,"vo_xv: assume: %s = %i\n",attributes[i].name,port_value);
228 228
229 if(strcmp(attributes[i].name,"XV_BRIGHTNESS") == 0) 229 if(strcmp(attributes[i].name,"XV_BRIGHTNESS") == 0)
230 { 230 {
231 info->cap |= VEQ_CAP_BRIGHTNESS; 231 info->cap |= VEQ_CAP_BRIGHTNESS;
232 info->brightness = port_value; 232 info->brightness = port_value;
344 /* check image formats */ 344 /* check image formats */
345 fo = XvListImageFormats(mDisplay, xv_port, (int*)&formats); 345 fo = XvListImageFormats(mDisplay, xv_port, (int*)&formats);
346 xv_format=0; 346 xv_format=0;
347 if(format==IMGFMT_BGR24) format=IMGFMT_YV12; 347 if(format==IMGFMT_BGR24) format=IMGFMT_YV12;
348 for(i = 0; i < formats; i++){ 348 for(i = 0; i < formats; i++){
349 printf("Xvideo image format: 0x%x (%4.4s) %s\n", fo[i].id,(char*)&fo[i].id, (fo[i].format == XvPacked) ? "packed" : "planar"); 349 mp_msg(MSGT_VO,MSGL_V,"Xvideo image format: 0x%x (%4.4s) %s\n", fo[i].id,(char*)&fo[i].id, (fo[i].format == XvPacked) ? "packed" : "planar");
350 if (fo[i].id == format) xv_format = fo[i].id; 350 if (fo[i].id == format) xv_format = fo[i].id;
351 } 351 }
352 if (!xv_format) return -1; 352 if (!xv_format) return -1;
353 353
354 aspect_save_screenres(vo_screenwidth,vo_screenheight); 354 aspect_save_screenres(vo_screenwidth,vo_screenheight);
445 #endif 445 #endif
446 #ifdef HAVE_NEW_GUI 446 #ifdef HAVE_NEW_GUI
447 } 447 }
448 #endif 448 #endif
449 449
450 printf( "using Xvideo port %d for hw scaling\n",xv_port ); 450 mp_msg(MSGT_VO,MSGL_V, "using Xvideo port %d for hw scaling\n",xv_port );
451 451
452 switch (xv_format){ 452 switch (xv_format){
453 case IMGFMT_YV12: 453 case IMGFMT_YV12:
454 case IMGFMT_I420: 454 case IMGFMT_I420:
455 case IMGFMT_IYUV: draw_alpha_fnc=draw_alpha_yv12; break; 455 case IMGFMT_IYUV: draw_alpha_fnc=draw_alpha_yv12; break;
467 set_gamma_correction(); 467 set_gamma_correction();
468 468
469 XGetGeometry( mDisplay,vo_window,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth ); 469 XGetGeometry( mDisplay,vo_window,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
470 drwX=0; drwY=0; 470 drwX=0; drwY=0;
471 XTranslateCoordinates( mDisplay,vo_window,mRoot,0,0,&drwcX,&drwcY,&mRoot ); 471 XTranslateCoordinates( mDisplay,vo_window,mRoot,0,0,&drwcX,&drwcY,&mRoot );
472 printf( "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); 472 mp_msg(MSGT_VO,MSGL_V, "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
473 473
474 aspect(&dwidth,&dheight,A_NOZOOM); 474 aspect(&dwidth,&dheight,A_NOZOOM);
475 if ( vo_fs ) 475 if ( vo_fs )
476 { 476 {
477 aspect(&dwidth,&dheight,A_ZOOM); 477 aspect(&dwidth,&dheight,A_ZOOM);
479 drwcX+=drwX; 479 drwcX+=drwX;
480 drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2; 480 drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2;
481 drwcY+=drwY; 481 drwcY+=drwY;
482 drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth); 482 drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth);
483 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight); 483 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight);
484 printf( "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); 484 mp_msg(MSGT_VO,MSGL_V, "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
485 } 485 }
486 saver_off(mDisplay); // turning off screen saver 486 saver_off(mDisplay); // turning off screen saver
487 return 0; 487 return 0;
488 } 488 }
489 489
498 */ 498 */
499 if ( mLocalDisplay && XShmQueryExtension( mDisplay ) ) Shmem_Flag = 1; 499 if ( mLocalDisplay && XShmQueryExtension( mDisplay ) ) Shmem_Flag = 1;
500 else 500 else
501 { 501 {
502 Shmem_Flag = 0; 502 Shmem_Flag = 0;
503 if ( !Quiet_Flag ) printf( "Shared memory not supported\nReverting to normal Xv\n" ); 503 mp_msg(MSGT_VO,MSGL_INFO, "Shared memory not supported\nReverting to normal Xv\n" );
504 } 504 }
505 if ( Shmem_Flag ) 505 if ( Shmem_Flag )
506 { 506 {
507 xvimage[foo] = XvShmCreateImage(mDisplay, xv_port, xv_format, 0, image_width, image_height, &Shminfo[foo]); 507 xvimage[foo] = XvShmCreateImage(mDisplay, xv_port, xv_format, 0, image_width, image_height, &Shminfo[foo]);
508 508
549 if(e&VO_EVENT_RESIZE) 549 if(e&VO_EVENT_RESIZE)
550 { 550 {
551 XGetGeometry( mDisplay,vo_window,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth ); 551 XGetGeometry( mDisplay,vo_window,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
552 drwX=0; drwY=0; 552 drwX=0; drwY=0;
553 XTranslateCoordinates( mDisplay,vo_window,mRoot,0,0,&drwcX,&drwcY,&mRoot ); 553 XTranslateCoordinates( mDisplay,vo_window,mRoot,0,0,&drwcX,&drwcY,&mRoot );
554 printf( "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); 554 mp_msg(MSGT_VO,MSGL_V, "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
555 555
556 aspect(&dwidth,&dheight,A_NOZOOM); 556 aspect(&dwidth,&dheight,A_NOZOOM);
557 if ( vo_fs ) 557 if ( vo_fs )
558 { 558 {
559 aspect(&dwidth,&dheight,A_ZOOM); 559 aspect(&dwidth,&dheight,A_ZOOM);
561 drwcX+=drwX; 561 drwcX+=drwX;
562 drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2; 562 drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2;
563 drwcY+=drwY; 563 drwcY+=drwY;
564 drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth); 564 drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth);
565 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight); 565 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight);
566 printf( "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); 566 mp_msg(MSGT_VO,MSGL_V, "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
567 } 567 }
568 } 568 }
569 if ( e & VO_EVENT_EXPOSE ) 569 if ( e & VO_EVENT_EXPOSE )
570 { 570 {
571 if ( Shmem_Flag ) 571 if ( Shmem_Flag )
795 static uint32_t preinit(const char *arg) 795 static uint32_t preinit(const char *arg)
796 { 796 {
797 XvPortID xv_p; 797 XvPortID xv_p;
798 if(arg) 798 if(arg)
799 { 799 {
800 printf("vo_xv: Unknown subdevice: %s\n",arg); 800 mp_msg(MSGT_VO,MSGL_ERR,"vo_xv: Unknown subdevice: %s\n",arg);
801 return ENOSYS; 801 return ENOSYS;
802 } 802 }
803 if (!vo_init()) return -1; 803 if (!vo_init()) return -1;
804 804
805 xv_port = 0; 805 xv_port = 0;
806 /* check for Xvideo extension */ 806 /* check for Xvideo extension */
807 if (Success != XvQueryExtension(mDisplay,&ver,&rel,&req,&ev,&err)){ 807 if (Success != XvQueryExtension(mDisplay,&ver,&rel,&req,&ev,&err)){
808 printf("Sorry, Xv not supported by this X11 version/driver\n"); 808 mp_msg(MSGT_VO,MSGL_ERR,"Sorry, Xv not supported by this X11 version/driver\n");
809 printf("******** Try with -vo x11 or -vo sdl *********\n"); 809 mp_msg(MSGT_VO,MSGL_ERR,"******** Try with -vo x11 or -vo sdl *********\n");
810 return -1; 810 return -1;
811 } 811 }
812 812
813 /* check for Xvideo support */ 813 /* check for Xvideo support */
814 if (Success != XvQueryAdaptors(mDisplay,DefaultRootWindow(mDisplay), &adaptors,&ai)){ 814 if (Success != XvQueryAdaptors(mDisplay,DefaultRootWindow(mDisplay), &adaptors,&ai)){
815 printf("Xv: XvQueryAdaptors failed"); 815 mp_msg(MSGT_VO,MSGL_ERR,"Xv: XvQueryAdaptors failed");
816 return -1; 816 return -1;
817 } 817 }
818 818
819 /* check adaptors */ 819 /* check adaptors */
820 for (i = 0; i < adaptors && xv_port == 0; i++){ 820 for (i = 0; i < adaptors && xv_port == 0; i++){
821 if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask)) 821 if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask)) {
822 for (xv_p = ai[i].base_id; xv_p < ai[i].base_id+ai[i].num_ports; ++xv_p) 822 for (xv_p = ai[i].base_id; xv_p < ai[i].base_id+ai[i].num_ports; ++xv_p)
823 if (!XvGrabPort(mDisplay, xv_p, CurrentTime)) { 823 if (!XvGrabPort(mDisplay, xv_p, CurrentTime)) {
824 xv_port = xv_p; 824 xv_port = xv_p;
825 break; 825 break;
826 } else { 826 } else {
827 printf("Xv: could not grab port %i\n", (int)xv_p); 827 mp_msg(MSGT_VO,MSGL_ERR,"Xv: could not grab port %i\n", (int)xv_p);
828 } 828 }
829 }
829 } 830 }
830 if(!xv_port){ 831 if(!xv_port){
831 printf("Couldn't find free Xvideo port - maybe other applications keep open it\n"); 832 mp_msg(MSGT_VO,MSGL_ERR,"Couldn't find free Xvideo port - maybe other applications keep open it\n");
832 return -1; 833 return -1;
833 } 834 }
834 835
835 fo = XvListImageFormats(mDisplay, xv_port, (int*)&formats); 836 fo = XvListImageFormats(mDisplay, xv_port, (int*)&formats);
836 837