[Mplayer-cvslog] CVS: main/libvo vo_dga.c,1.4,1.5

Andreas Ackermann acki2 at users.sourceforge.net
Fri Mar 30 19:16:58 CEST 2001


Update of /cvsroot/mplayer/main/libvo
In directory usw-pr-cvs1:/tmp/cvs-serv1141

Modified Files:
	vo_dga.c 
Log Message:
Source cleanup. Improved resolution selection (I think :-)).


Index: vo_dga.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_dga.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** vo_dga.c	2001/03/28 19:58:45	1.4
--- vo_dga.c	2001/03/30 17:16:56	1.5
***************
*** 9,12 ****
--- 9,14 ----
   * <acki at acki-netz.de>
   *
+  * Sourceforge username: acki2
+  * 
   * note well: 
   *   
***************
*** 24,28 ****
  
  
! #include "linux/keycodes.h"
  #include "config.h"
  #include "video_out.h"
--- 26,30 ----
  
  
! //#include "linux/keycodes.h"
  #include "config.h"
  #include "video_out.h"
***************
*** 53,62 ****
  static int       vo_dga_bpp;             // bytes per pixel in framebuffer
  static int       vo_dga_src_offset=0;    // offset in src
! static int       vo_dga_vp_offset=0;   // offset in dest
  static int       vo_dga_bytes_per_line;  // longwords per line to copy
  static int       vo_dga_src_skip;        // bytes to skip after copying one line 
!                                   // (not supported yet) in src
! static int       vo_dga_vp_skip;       // dto. for dest 
! static int       vo_dga_lines;         // num of lines to copy
  static int       vo_dga_src_format;                                 
  
--- 55,64 ----
  static int       vo_dga_bpp;             // bytes per pixel in framebuffer
  static int       vo_dga_src_offset=0;    // offset in src
! static int       vo_dga_vp_offset=0;     // offset in dest
  static int       vo_dga_bytes_per_line;  // longwords per line to copy
  static int       vo_dga_src_skip;        // bytes to skip after copying one line 
!                                          // (not supported yet) in src
! static int       vo_dga_vp_skip;         // dto. for dest 
! static int       vo_dga_lines;           // num of lines to copy
  static int       vo_dga_src_format;                                 
  
***************
*** 64,76 ****
  static Display  *vo_dga_dpy;
  
  
! #include "mmx.h"
  
- #if defined (HAVE_SSE) || defined (HAVE_3DNOW)
- #define movntq "movntq" // use this for processors that have SSE or 3Dnow
- #else
- #define movntq "movq" // for MMX-only processors
- #endif
- 
  
  #define rep_movsl(dest, src, numwords, d_add, count) \
--- 66,78 ----
  static Display  *vo_dga_dpy;
  
+ //---------------------------------------------------------
  
! // I had tried to work with mmx/3dnow copy code but
! // there was not much speed gain and I didn't know
! // how to save the FPU/mmx registers - so the copy
! // code interferred with sound output ...
! // removed the leftovers
! // acki2 on 30/3/2001
  
  
  #define rep_movsl(dest, src, numwords, d_add, count) \
***************
*** 87,153 ****
  " \
                    : \
!                   : "a" (d_add), "b" (count), "S" (src), "D" (dest), "d" (numwords) \
                    : "memory" )
  
- #if 0
-                   : "S" (src), "D" (dest), "c" (numwords) \
- 	  movq (%%eax), %%mm0      \n\t \
-           add $64, %%edx            \n\t \
- 	  movq 8(%%eax), %%mm1     \n\t \
-           add $64, %%eax            \n\t \
- 	  movq -48(%%eax), %%mm2   \n\t \
-           movq %%mm0, -64(%%edx)   \n\t \
- 	  movq -40(%%eax), %%mm3   \n\t \
-           movq %%mm1, -56(%%edx)   \n\t \
- 	  movq -32(%%eax), %%mm4   \n\t \
-           movq %%mm2, -48(%%edx)   \n\t \
- 	  movq -24(%%eax), %%mm5   \n\t \
-           movq %%mm3, -40(%%edx)   \n\t \
- 	  movq -16(%%eax), %%mm6   \n\t \
-           movq %%mm4, -32(%%edx)   \n\t \
- 	  movq -8(%%eax), %%mm7    \n\t \
-           movq %%mm5, -24(%%edx)   \n\t \
-           movq %%mm6, -16(%%edx)   \n\t \
-           dec %%ecx                \n\t \
-           movq %%mm7, -8(%%edx)    \n\t \
-           jnz xfer                  \n\t \
  
! #endif
  
- #define mmx_movsl(dest, src, numwords) \
- __asm__ __volatile__(  \
- " \
-                                   \n\t \
- xfer:                              \n\t \
- 	  movq (%%eax), %%mm0      \n\t \
-           add $64, %%edx            \n\t \
- 	  movq 8(%%eax), %%mm1     \n\t \
-           add $64, %%eax            \n\t \
- 	  movq -48(%%eax), %%mm2   \n\t \
-           movq %%mm0, -64(%%edx)   \n\t \
- 	  movq -40(%%eax), %%mm3   \n\t \
-           movq %%mm1, -56(%%edx)   \n\t \
- 	  movq -32(%%eax), %%mm4   \n\t \
-           movq %%mm2, -48(%%edx)   \n\t \
- 	  movq -24(%%eax), %%mm5   \n\t \
-           movq %%mm3, -40(%%edx)   \n\t \
- 	  movq -16(%%eax), %%mm6   \n\t \
-           movq %%mm4, -32(%%edx)   \n\t \
- 	  movq -8(%%eax), %%mm7    \n\t \
-           movq %%mm5, -24(%%edx)   \n\t \
-           movq %%mm6, -16(%%edx)   \n\t \
-           dec %%ecx                \n\t \
-           movq %%mm7, -8(%%edx)    \n\t \
-           jnz xfer                  \n\t \
-              \
- " \
-       : \
-       : "a" (src), "d" (dest), "c" (numwords) \
-       :  "memory" )
- 
-      // src <= eax
-      // dst <= edx
-      // num <= ecx  
-  
  static uint32_t draw_frame( uint8_t *src[] ){
  
--- 89,99 ----
  " \
                    : \
!                   : "a" (d_add), "b" (count), "S" (src), "D" (dest), \
! 		    "d" (numwords) \
                    : "memory" )
  
  
! //---------------------------------------------------------
  
  static uint32_t draw_frame( uint8_t *src[] ){
  
***************
*** 159,163 ****
  
    if( vo_dga_src_format==IMGFMT_YV12 ){
!     // We'll never reach this point, because YV12 codecs always calls draw_slice
      printf("vo_dga: draw_frame() doesn't support IMGFMT_YV12 (yet?)\n");
    }else{
--- 105,110 ----
  
    if( vo_dga_src_format==IMGFMT_YV12 ){
!     // We'll never reach this point, because YV12 codecs always
!     // calls draw_slice
      printf("vo_dga: draw_frame() doesn't support IMGFMT_YV12 (yet?)\n");
    }else{
***************
*** 170,189 ****
  }
  
  static void check_events(void)
  {
!     int e=vo_x11_check_events(vo_dga_dpy);
  }
  
! static void flip_page( void ){
!     check_events(); 
!   //  printf("vo_dga: In flippage\n");
  
  }
  
  static uint32_t draw_slice( uint8_t *src[],int stride[],
                              int w,int h,int x,int y )
  {
-   //  printf("vo_dga: draw_slice() not implemented (yet?)\n");
- 
    yuv2rgb( vo_dga_base + vo_dga_vp_offset + 
            (vo_dga_width * y +x) * vo_dga_bpp,
--- 117,138 ----
  }
  
+ //---------------------------------------------------------
+ 
  static void check_events(void)
  {
!   int e=vo_x11_check_events(vo_dga_dpy);
  }
  
! //---------------------------------------------------------
  
+ static void flip_page( void ){
+   check_events();
  }
  
+ //---------------------------------------------------------
+ 
  static uint32_t draw_slice( uint8_t *src[],int stride[],
                              int w,int h,int x,int y )
  {
    yuv2rgb( vo_dga_base + vo_dga_vp_offset + 
            (vo_dga_width * y +x) * vo_dga_bpp,
***************
*** 191,208 ****
             w,h, vo_dga_width * vo_dga_bpp,
             stride[0],stride[1] );
-  return 0;
- 
- 
    return 0;
  };
  
! static void Terminate_Display_Process( void ){
  
    printf("vo_dga: Terminating display process\n");
  }
  
  static const vo_info_t* get_info( void )
  { return &vo_info; }
  
  static uint32_t query_format( uint32_t format )
  {
--- 140,160 ----
             w,h, vo_dga_width * vo_dga_bpp,
             stride[0],stride[1] );
    return 0;
  };
  
! //---------------------------------------------------------
! 
  
+ static void Terminate_Display_Process( void ){
    printf("vo_dga: Terminating display process\n");
  }
  
+ //---------------------------------------------------------
+ 
  static const vo_info_t* get_info( void )
  { return &vo_info; }
  
+ //---------------------------------------------------------
+ 
  static uint32_t query_format( uint32_t format )
  {
***************
*** 218,221 ****
--- 170,174 ----
  }
  
+ //---------------------------------------------------------
  
  static void
***************
*** 230,236 ****
    XCloseDisplay(vo_dga_dpy);
  }
- 
- 
  
  
  static uint32_t init( uint32_t width,  uint32_t height,
--- 183,188 ----
    XCloseDisplay(vo_dga_dpy);
  }
  
+ //---------------------------------------------------------
  
  static uint32_t init( uint32_t width,  uint32_t height,
***************
*** 244,250 ****
  #ifdef HAVE_DGA2
  // needed to change DGA video mode
!   int modecount,mX, mY, i,j;
    int X,Y;
!   XDGAMode *modelines=NULL;
    XDGADevice *dgadevice;
  #endif
--- 196,202 ----
  #ifdef HAVE_DGA2
  // needed to change DGA video mode
!   int modecount,mX, mY, mVBI, i,j;
    int X,Y;
!   XDGAMode   *modelines=NULL;
    XDGADevice *dgadevice;
  #endif
***************
*** 271,295 ****
    mX=modelines[0].imageWidth;
    mY=modelines[0].imageHeight;
    X=d_width; Y=d_height; 
    
    j=0; 
!   for (i=1; i<=modecount; i++)
    {
!     if ( (modelines[i].bitsPerPixel == vo_depthonscreen) && 
!          (modelines[i].maxViewportX) && 
!          (modelines[i].viewportWidth >= X) && 
!          (modelines[i].viewportHeight >= Y) && 
!          (modelines[i].viewportWidth < mX) &&
!          (modelines[i].viewportHeight < mY) ) 
!         {
             mX=modelines[i].viewportWidth;
             mY=modelines[i].viewportHeight;
             j=i;
!         }
!    }
    X=(modelines[j].imageWidth-mX)/2;
    Y=(modelines[j].imageHeight-mY)/2;
!   printf("vo_dga: Using DGA 2.0 mode changing support\n");
!   printf("vo_dga: Selected video mode %dx%d for image size %dx%d.\n", mX, mY,width, height);  
  
    XF86DGASetViewPort (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), X,Y);
--- 223,300 ----
    mX=modelines[0].imageWidth;
    mY=modelines[0].imageHeight;
+   mVBI = modelines[0].verticalRefresh;
    X=d_width; Y=d_height; 
    
+   printf("vo_dga: Using DGA 2.0 mode changing support\n");	
    j=0; 
!   // offbyone-error !!! i<=modecount is WRONG !!!
!   for (i=1; i<modecount; i++)
    {
!      if( modelines[i].bitsPerPixel == vo_depthonscreen &&
! 	 modelines[i].maxViewportX)
!      {
!        printf("vo_dga: (%3d) Trying %4d x %4d @ %3d Hz @ %2d bpp ..",
! 		     i,
! 		     modelines[i].viewportWidth, 
! 		     modelines[i].viewportHeight,
! 		     (unsigned int) modelines[i].verticalRefresh,
! 		     modelines[i].bitsPerPixel );
!      
!        if (
!           (modelines[i].viewportWidth >= X) && 
!           (modelines[i].viewportHeight >= Y) &&
! 	  ( 
! 	   // prefer a better resolution either in X or in Y
! 	   // as long as the other dimension is at least the same
! 	   // 
! 	   // hmm ... MAYBE it would be more clever to focus on the 
! 	   // x-resolution; I had 712x400 and 640x480 and the movie 
! 	   // was 640x360; 640x480 would be the 'right thing' here
! 	   // but since 712x400 was queried first I got this one. 
! 	   // I think there should be a cmd-line switch to let the
! 	   // user choose the mode he likes ...   (acki2)
! 	   
! 	   (
!             ((modelines[i].viewportWidth < mX) &&
! 	    !(modelines[i].viewportHeight > mY)) ||
! 	    ((modelines[i].viewportHeight < mY) &&
! 	    !(modelines[i].viewportWidth > mX)) 
! 	   ) 
! 	   // but if we get an identical resolution choose
! 	   // the one with the lower refreshrate (saves bandwidth !!!)
! 	   // as long as it's above 50 Hz (acki2 on 30/3/2001)
! 	   ||
! 	   (
! 	    (modelines[i].viewportWidth == mX) &&
! 	    (modelines[i].viewportHeight == mY) &&
! 	      (
! 	       (
! 		modelines[i].verticalRefresh >= mVBI && mVBI < 50
! 	       )  
! 	       ||
!                (
! 		mVBI >= 50 && 
! 		modelines[i].verticalRefresh < mVBI &&
! 		modelines[i].verticalRefresh >= 50
! 	       )
! 	      )
! 	     )
! 	    )
! 	  )  
! 	  {
             mX=modelines[i].viewportWidth;
             mY=modelines[i].viewportHeight;
+ 	   mVBI = modelines[i].verticalRefresh;
             j=i;
! 	   printf(".ok!!\n");
!         }else{
!            printf(".no\n");
! 	}
!     }
!   }
    X=(modelines[j].imageWidth-mX)/2;
    Y=(modelines[j].imageHeight-mY)/2;
!   printf("vo_dga: Selected video mode %4d x %4d @ %3d Hz for image size %3d x %3d.\n", 
! 		  mX, mY, mVBI, width, height);  
  
    XF86DGASetViewPort (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), X,Y);
***************
*** 301,316 ****
    // end mode change code
  #else
! printf("vo_dga: DGA 1.0 compatibility code\n");
  #endif
  
! XF86DGAGetViewPortSize(vo_dga_dpy,XDefaultScreen(vo_dga_dpy),
! 			&vo_dga_vp_width,
! 			&vo_dga_vp_height); 
  
! XF86DGAGetVideo (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 
!                 (char **)&vo_dga_base, &vo_dga_width, &bank, &ram);
  
  #ifndef HAVE_DGA2
! XF86DGASetViewPort (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 0, 0);
  #endif
  
--- 306,321 ----
    // end mode change code
  #else
!   printf("vo_dga: DGA 1.0 compatibility code\n");
  #endif
  
!   XF86DGAGetViewPortSize(vo_dga_dpy,XDefaultScreen(vo_dga_dpy),
! 		         &vo_dga_vp_width,
! 			 &vo_dga_vp_height); 
  
!   XF86DGAGetVideo (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 
! 		   (char **)&vo_dga_base, &vo_dga_width, &bank, &ram);
  
  #ifndef HAVE_DGA2
!   XF86DGASetViewPort (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 0, 0);
  #endif
  
***************
*** 370,431 ****
    return 0;
  }
- 
- #if 0
- int vo_dga_query_event(void){
- 
-   XEvent  myevent;
-   char    text[10];
-   KeySym  mykey;
-   int     retval = 0;
-   int     i;
- 
-   if( vo_dga_is_running ){  
-      if(XPending(vo_dga_dpy)>0)
-       {
- 	XNextEvent(vo_dga_dpy, &myevent);
- 	switch (myevent.type)
- 	  {
- 	  case ButtonPress:
- 	    /* Reaktion auf Knopfdruck ---> Textausgabe an der 
- 	       Mauscursorposition */ 
- 	   
- 	    retval = 'q';
-             break;
- 	  case KeyPress:
- 	    /* Reaktion auf Tastendruck --> Testen ob Taste == "q",
- 	       falls ja: Programmende */
- 	    i=XLookupString(&myevent, text, 10, &mykey, 0);
- 
-             if (mykey&0xff00 != 0) mykey=mykey&0x00ff + 256;
- 	
-             switch ( mykey )
-             {
- 	    case wsLeft:      retval=KEY_LEFT; break;
- 	    case wsRight:     retval=KEY_RIGHT; break;
- 	    case wsUp:        retval=KEY_UP; break;
- 	    case wsDown:      retval=KEY_DOWN; break;
- 	    case wsSpace:     retval=' '; break;
- 	    case wsEscape:    retval=KEY_ESC; break;
- 	    case wsEnter:     retval=KEY_ENTER; break;
- 	    case wsq:
- 	    case wsQ:         retval='q'; break;
- 	    case wsp:
- 	    case wsP:         retval='p'; break;
- 	    case wsMinus:
- 	    case wsGrayMinus: retval='-'; break;
- 	    case wsPlus:
- 	    case wsGrayPlus:  retval='+'; break;
- 	    }
- 	    break;
- 	  }
-       }
-   }
-   return retval;
- }
- #endif
- 
- 
- 
- 
  
  
--- 375,382 ----
    return 0;
  }
  
+ //---------------------------------------------------------
  
+ // deleted the old vo_dga_query_event() routine 'cause it is obsolete  
+ // since using check_events()
+ // acki2 on 30/3/2001


_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog



More information about the MPlayer-cvslog mailing list