Mercurial > mplayer.hg
comparison libvo/vo_xv.c @ 6758:ecc71f27bfd7
DR1 IP/IPB supoprt (I/P only with -double) -- OSD *must be* disabled! :)
note: playing IPB mpeg (-vc ffmpeg12) looks broken due to bad frame display
order (differs from frame decoding order) - requires workaround or PUT_IMAGE
implementation...
author | arpi |
---|---|
date | Sat, 20 Jul 2002 15:49:38 +0000 |
parents | a31b9f15cbff |
children | d4db17f7271a |
comparison
equal
deleted
inserted
replaced
6757:f72fc85934e5 | 6758:ecc71f27bfd7 |
---|---|
1 | 1 |
2 // Number of buffers _FOR_DOUBLEBUFFERING_MODE_ | 2 // Number of buffers _FOR_DOUBLEBUFFERING_MODE_ |
3 // Use option -double to enable double buffering! (default: single buffer) | 3 // Use option -double to enable double buffering! (default: single buffer) |
4 #define NUM_BUFFERS 2 | 4 #define NUM_BUFFERS 3 |
5 | |
6 /* | |
7 Buffer allocation: | |
8 | |
9 -nodr: | |
10 1: TEMP | |
11 2: 2*TEMP | |
12 | |
13 -dr: | |
14 1: TEMP | |
15 3: 2*STATIC+TEMP | |
16 */ | |
17 | |
5 | 18 |
6 /* | 19 /* |
7 * vo_xv.c, X11 Xv interface | 20 * vo_xv.c, X11 Xv interface |
8 * | 21 * |
9 * Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. | 22 * Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. |
70 static unsigned int formats, adaptors,i,xv_port,xv_format; | 83 static unsigned int formats, adaptors,i,xv_port,xv_format; |
71 static XvAdaptorInfo *ai; | 84 static XvAdaptorInfo *ai; |
72 static XvImageFormatValues *fo; | 85 static XvImageFormatValues *fo; |
73 | 86 |
74 static int current_buf=0; | 87 static int current_buf=0; |
88 static int current_ip_buf=0; | |
75 static int num_buffers=1; // default | 89 static int num_buffers=1; // default |
76 static XvImage* xvimage[NUM_BUFFERS]; | 90 static XvImage* xvimage[NUM_BUFFERS]; |
77 | 91 |
78 #ifdef HAVE_SHM | 92 #ifdef HAVE_SHM |
79 #include <sys/ipc.h> | 93 #include <sys/ipc.h> |
346 | 360 |
347 #ifdef HAVE_XF86VM | 361 #ifdef HAVE_XF86VM |
348 if( flags&0x02 ) vm = 1; | 362 if( flags&0x02 ) vm = 1; |
349 #endif | 363 #endif |
350 flip_flag=flags&8; | 364 flip_flag=flags&8; |
351 num_buffers=vo_doublebuffering?NUM_BUFFERS:1; | 365 num_buffers=vo_doublebuffering?(vo_directrendering?NUM_BUFFERS:2):1; |
352 | 366 |
353 /* check image formats */ | 367 /* check image formats */ |
354 fo = XvListImageFormats(mDisplay, xv_port, (int*)&formats); | 368 fo = XvListImageFormats(mDisplay, xv_port, (int*)&formats); |
355 xv_format=0; | 369 xv_format=0; |
356 if(format==IMGFMT_BGR24) format=IMGFMT_YV12; | 370 if(format==IMGFMT_BGR24) format=IMGFMT_YV12; |
477 | 491 |
478 for(current_buf=0;current_buf<num_buffers;++current_buf) | 492 for(current_buf=0;current_buf<num_buffers;++current_buf) |
479 allocate_xvimage(current_buf); | 493 allocate_xvimage(current_buf); |
480 | 494 |
481 current_buf=0; | 495 current_buf=0; |
496 current_ip_buf=0; | |
482 | 497 |
483 set_gamma_correction(); | 498 set_gamma_correction(); |
484 | 499 |
485 aspect(&vo_dwidth,&vo_dheight,A_NOZOOM); | 500 aspect(&vo_dwidth,&vo_dheight,A_NOZOOM); |
486 if ( ( flags&1 )&&( !WinID ) ) | 501 if ( ( flags&1 )&&( !WinID ) ) |
618 XvPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], | 633 XvPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], |
619 0, 0, image_width, image_height, | 634 0, 0, image_width, image_height, |
620 drwX-(vo_panscan_x>>1),drwY-(vo_panscan_y>>1),vo_dwidth+vo_panscan_x,(vo_fs?vo_dheight - 1:vo_dheight)+vo_panscan_y); | 635 drwX-(vo_panscan_x>>1),drwY-(vo_panscan_y>>1),vo_dwidth+vo_panscan_x,(vo_fs?vo_dheight - 1:vo_dheight)+vo_panscan_y); |
621 } | 636 } |
622 if (num_buffers>1){ | 637 if (num_buffers>1){ |
623 current_buf=(current_buf+1)%num_buffers; | 638 current_buf=vo_directrendering?0:((current_buf+1)%num_buffers); |
624 XFlush(mDisplay); | 639 XFlush(mDisplay); |
625 } else | 640 } else |
626 XSync(mDisplay, False); | 641 XSync(mDisplay, False); |
627 return; | 642 return; |
628 } | 643 } |
731 | 746 |
732 return 0; | 747 return 0; |
733 } | 748 } |
734 | 749 |
735 static uint32_t get_image(mp_image_t *mpi){ | 750 static uint32_t get_image(mp_image_t *mpi){ |
751 int buf=current_buf; // we shouldn't change current_buf unless we do DR! | |
736 if(mpi->type==MP_IMGTYPE_STATIC && num_buffers>1) return VO_FALSE; // it is not static | 752 if(mpi->type==MP_IMGTYPE_STATIC && num_buffers>1) return VO_FALSE; // it is not static |
737 if(mpi->type==MP_IMGTYPE_IPB && num_buffers<3 && mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // not enough | |
738 if(mpi->type==MP_IMGTYPE_IP && num_buffers<2 && mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // not enough | |
739 if(mpi->imgfmt!=image_format || mpi->imgfmt==IMGFMT_BGR24) return VO_FALSE; // needs conversion :( | 753 if(mpi->imgfmt!=image_format || mpi->imgfmt==IMGFMT_BGR24) return VO_FALSE; // needs conversion :( |
740 if(mpi->height > xvimage[current_buf]->height) return VO_FALSE; //buffer to small | |
741 if(mpi->width*(mpi->bpp/8) > xvimage[current_buf]->pitches[0]) return VO_FALSE; //buffer to small | |
742 // if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram | 754 // if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram |
755 if(mpi->flags&MP_IMGFLAG_READABLE && | |
756 (mpi->type==MP_IMGTYPE_IPB || mpi->type==MP_IMGTYPE_IP)){ | |
757 // reference (I/P) frame of IP or IPB: | |
758 if(num_buffers<2) return VO_FALSE; // not enough | |
759 current_ip_buf^=1; | |
760 // for IPB with 2 buffers we can DR only one of the 2 P frames: | |
761 if(mpi->type==MP_IMGTYPE_IPB && num_buffers<3 && current_ip_buf) return VO_FALSE; | |
762 buf=current_ip_buf; | |
763 if(mpi->type==MP_IMGTYPE_IPB) ++buf; // preserve space for B | |
764 } | |
765 if(mpi->height > xvimage[buf]->height) return VO_FALSE; //buffer to small | |
766 if(mpi->width*(mpi->bpp/8) > xvimage[buf]->pitches[0]) return VO_FALSE; //buffer to small | |
743 if( (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH)) || | 767 if( (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH)) || |
744 (mpi->width*(mpi->bpp/8)==xvimage[current_buf]->pitches[0]) ){ | 768 (mpi->width*(mpi->bpp/8)==xvimage[buf]->pitches[0]) ){ |
769 current_buf=buf; | |
745 mpi->planes[0]=xvimage[current_buf]->data+xvimage[current_buf]->offsets[0]; | 770 mpi->planes[0]=xvimage[current_buf]->data+xvimage[current_buf]->offsets[0]; |
746 mpi->stride[0]=xvimage[current_buf]->pitches[0]; | 771 mpi->stride[0]=xvimage[current_buf]->pitches[0]; |
747 mpi->width=mpi->stride[0]/(mpi->bpp/8); | 772 mpi->width=mpi->stride[0]/(mpi->bpp/8); |
748 if(mpi->flags&MP_IMGFLAG_PLANAR){ | 773 if(mpi->flags&MP_IMGFLAG_PLANAR){ |
749 if(mpi->flags&MP_IMGFLAG_SWAPPED){ | 774 if(mpi->flags&MP_IMGFLAG_SWAPPED){ |