[Mplayer-cvslog] CVS: main/libvo vo_svga.c,1.16,1.17

Zoltan Mark Vician se7encode at users.sourceforge.net
Tue Apr 17 19:35:29 CEST 2001


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

Modified Files:
	vo_svga.c 
Log Message:
Tons of code rewrites.

Index: vo_svga.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_svga.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** vo_svga.c	2001/04/17 06:22:48	1.16
--- vo_svga.c	2001/04/17 17:35:27	1.17
***************
*** 13,16 ****
--- 13,18 ----
  #include <vgagl.h>
  
+ #include <limits.h>
+ 
  #include "config.h"
  #include "video_out.h"
***************
*** 21,24 ****
--- 23,27 ----
  
  extern void rgb15to16_mmx(char* s0,char* d0,int count);
+ extern int vo_dbpp;
  
  LIBVO_EXTERN(svga)
***************
*** 63,83 ****
  static uint8_t checked = 0;
  
! static int add_mode(uint16_t mode, vga_modeinfo minfo) {
    vga_modelist_t *list;
  
    if (modelist == NULL) {
!     modelist = malloc(sizeof(vga_modelist_t));
!     modelist->modenum = mode;
!     modelist->modeinfo = minfo;
!     modelist->next = NULL;
      if (modelist == NULL) {
        printf("vo_svga: add_mode() failed. Not enough memory for modelist.");
        return(1); // error
      }
    } else {
        list = modelist;
        while (list->next != NULL)
          list = list->next;
!       list->next = malloc(sizeof(vga_modelist_t));
        if (list->next == NULL) {
          printf("vo_svga: add_mode() failed. Not enough memory for modelist.");
--- 66,86 ----
  static uint8_t checked = 0;
  
! static uint32_t add_mode(uint16_t mode, vga_modeinfo minfo) {
    vga_modelist_t *list;
  
    if (modelist == NULL) {
!     modelist = (vga_modelist_t *) malloc(sizeof(vga_modelist_t));
      if (modelist == NULL) {
        printf("vo_svga: add_mode() failed. Not enough memory for modelist.");
        return(1); // error
      }
+     modelist->modenum = mode;
+     modelist->modeinfo = minfo;
+     modelist->next = NULL;
    } else {
        list = modelist;
        while (list->next != NULL)
          list = list->next;
!       list->next = (vga_modelist_t *) malloc(sizeof(vga_modelist_t));
        if (list->next == NULL) {
          printf("vo_svga: add_mode() failed. Not enough memory for modelist.");
***************
*** 89,96 ****
        list->next = NULL;
      }  
  }
  
  static int checksupportedmodes() {
!   uint16_t i;
    vga_modeinfo *minfo;
    
--- 92,100 ----
        list->next = NULL;
      }  
+   return (0);
  }
  
  static int checksupportedmodes() {
!   uint16_t i, max;
    vga_modeinfo *minfo;
    
***************
*** 98,102 ****
    vga_init();
    vga_disabledriverreport();
!   for (i = 1; i < vga_lastmodenumber(); i++)
      if (vga_hasmode(i) > 0) {
        minfo = vga_getmodeinfo(i);
--- 102,107 ----
    vga_init();
    vga_disabledriverreport();
!   max = vga_lastmodenumber();
!   for (i = 1; i < max; i++)
      if (vga_hasmode(i) > 0) {
        minfo = vga_getmodeinfo(i);
***************
*** 112,115 ****
--- 117,121 ----
          return(1);
      }
+   return(0);
  }
  
***************
*** 121,128 ****
    uint16_t vid_mode = 0;
    uint8_t widescreen = (((req_w*1.0)/req_h) > (4.0/3)) ? 1 : 0;
    vga_modelist_t *list = modelist;
    
    if (!checked) {
!     if (checksupportedmodes()) // Looking for available video modes
        return(1);
    }
--- 127,135 ----
    uint16_t vid_mode = 0;
    uint8_t widescreen = (((req_w*1.0)/req_h) > (4.0/3)) ? 1 : 0;
+   uint16_t buf_w = USHRT_MAX, buf_h = USHRT_MAX;
    vga_modelist_t *list = modelist;
    
    if (!checked) {
!     if (checksupportedmodes()) // Looking for available video modes 
        return(1);
    }
***************
*** 131,134 ****
--- 138,142 ----
    while (list != NULL) {
      if ((list->modeinfo.width >= req_w) && (list->modeinfo.height >= req_h)) {
+ //	printf("w: %d, h: %d, bpp: %d, colors: %d\n",list->modeinfo.width,list->modeinfo.height,list->modeinfo.bytesperpixel,list->modeinfo.colors);
        switch (list->modeinfo.colors) {
          case 32768: bpp_avail |= BPP_15; break;
***************
*** 150,157 ****
      if (format == IMGFMT_YV12) bpp = 32;
      else bpp = format & 255;
      switch (bpp) {
        case 32: if (!(bpp_avail & BPP_32)) {
  	         printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp);
! 		 printf("vo_svga: Maybe you should try -bpp\n");
  		 return(1);
  	       } 
--- 158,166 ----
      if (format == IMGFMT_YV12) bpp = 32;
      else bpp = format & 255;
+ //    printf("bpp: %d\n",bpp);
      switch (bpp) {
        case 32: if (!(bpp_avail & BPP_32)) {
  	         printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp);
!                  printf("vo_svga: Maybe you should try -bpp\n");
  		 return(1);
  	       } 
***************
*** 160,164 ****
                   if (!(bpp_avail & BPP_32)) {
  	           printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp);
! 		   printf("vo_svga: Maybe you should try -bpp\n");
  		   return(1);
  		 } else {
--- 169,173 ----
                   if (!(bpp_avail & BPP_32)) {
  	           printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp);
!                    printf("vo_svga: Maybe you should try -bpp\n");
  		   return(1);
  		 } else {
***************
*** 188,233 ****
        switch (bpp) {
          case 32: if (!(bpp_avail & BPP_32)) {
! 	           printf("vo_svga: %dbpp not supported by HW or SVGAlib\n",bpp);
  		   return(1);
                   }
          case 24: if (!(bpp_avail & BPP_24)) {
! 	           printf("vo_svga: %dbpp not supported by HW or SVGAlib\n",bpp);
  		   return(1);
                   }
          case 16: if (!(bpp_avail & BPP_16)) {
! 	           printf("vo_svga: %dbpp not supported by HW or SVGAlib\n",bpp);
  		   return(1);
                   }
          case 15: if (!(bpp_avail & BPP_15)) {
! 	           printf("vo_svga: %dbpp not supported by HW or SVGAlib\n",bpp);
  		   return(1);
                   }
        }
      }
  
    list = modelist;
!   while ((list != NULL) && (!vid_mode)) {
      if ((list->modeinfo.width >= req_w) && (list->modeinfo.height >= req_h)) {
        switch (bpp) {
          case 32: if (list->modeinfo.bytesperpixel == 4)
! 	           vid_mode = list->modenum;
          case 24: if (list->modeinfo.bytesperpixel == 3)
! 	           vid_mode = list->modenum;
          case 16: if (list->modeinfo.colors == 65536)
! 	           vid_mode = list->modenum;
          case 15: if (list->modeinfo.colors == 32768)
! 	           vid_mode = list->modenum;
        }
      }
      list = list->next;
    }
!   
    vga_setlinearaddressing();
!   if (vga_setmode(vid_mode) == -1){
      printf("vo_svga: vga_setmode(%d) failed.\n",vid_mode);
      uninit();
      return(1); // error
!   }
!   if (gl_setcontextvga(vid_mode)){
      printf("vo_svga: gl_setcontextvga(%d) failed.\n",vid_mode);
      uninit();
--- 197,269 ----
        switch (bpp) {
          case 32: if (!(bpp_avail & BPP_32)) {
! 	           printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h);
  		   return(1);
                   }
+ 		 break;
          case 24: if (!(bpp_avail & BPP_24)) {
! 	           printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h);
  		   return(1);
                   }
+ 		 break;
          case 16: if (!(bpp_avail & BPP_16)) {
! 	           printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h);
  		   return(1);
                   }
+ 		 break;
          case 15: if (!(bpp_avail & BPP_15)) {
! 	           printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h);
  		   return(1);
                   }
+ 		 break;
        }
      }
  
    list = modelist;
! //  printf("req_w: %d, req_h: %d\n",req_w,req_h);
!   while (list != NULL) {
      if ((list->modeinfo.width >= req_w) && (list->modeinfo.height >= req_h)) {
+ //      printf("w: %d, h: %d, bpp: %d, colors: %d, req_bpp: %d\n",list->modeinfo.width,list->modeinfo.height,list->modeinfo.bytesperpixel,list->modeinfo.colors,bpp);
        switch (bpp) {
          case 32: if (list->modeinfo.bytesperpixel == 4)
!                    if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) {
!                      vid_mode = list->modenum;
!                      buf_w = list->modeinfo.width;
!                      buf_h = list->modeinfo.height;
! 		   }
! 		 break;
          case 24: if (list->modeinfo.bytesperpixel == 3)
!                    if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) {
!                      vid_mode = list->modenum;
!                      buf_w = list->modeinfo.width;
!                      buf_h = list->modeinfo.height;
! 		   }
! 		 break;
          case 16: if (list->modeinfo.colors == 65536)
!                    if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) {
!                      vid_mode = list->modenum;
!                      buf_w = list->modeinfo.width;
!                      buf_h = list->modeinfo.height;
! 		   }
! 		 break;
          case 15: if (list->modeinfo.colors == 32768)
!                    if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) {
!                      vid_mode = list->modenum;
!                      buf_w = list->modeinfo.width;
!                      buf_h = list->modeinfo.height;
! 		   }
! 		 break;
        }
      }
      list = list->next;
    }
! 
! //  printf("vid_mode: %d\n",vid_mode);
    vga_setlinearaddressing();
!   if (vga_setmode(vid_mode) == -1) {
      printf("vo_svga: vga_setmode(%d) failed.\n",vid_mode);
      uninit();
      return(1); // error
!   } 
!   if (gl_setcontextvga(vid_mode)) {
      printf("vo_svga: gl_setcontextvga(%d) failed.\n",vid_mode);
      uninit();
***************
*** 236,240 ****
    screen = gl_allocatecontext();
    gl_getcontext(screen);
!   if (gl_setcontextvgavirtual(vid_mode)){
      printf("vo_svga: gl_setcontextvgavirtual(%d) failed.\n",vid_mode);
      uninit();
--- 272,276 ----
    screen = gl_allocatecontext();
    gl_getcontext(screen);
!   if (gl_setcontextvgavirtual(vid_mode)) {
      printf("vo_svga: gl_setcontextvgavirtual(%d) failed.\n",vid_mode);
      uninit();
***************
*** 246,255 ****
    gl_clearscreen(0);
    
!   if (bpp_conv)
      bppbuf = malloc(maxw * maxh * BYTESPERPIXEL);
!   if (bppbuf == NULL) {
!     printf("vo_svga: Not enough memory for buffering!\n");
!     uninit();
!     return (1);
    }
  
--- 282,292 ----
    gl_clearscreen(0);
    
!   if (bpp_conv) {
      bppbuf = malloc(maxw * maxh * BYTESPERPIXEL);
!     if (bppbuf == NULL) {
!       printf("vo_svga: bppbuf -> Not enough memory for buffering!\n");
!       uninit();
!       return (1);
!     }  
    }
  
***************
*** 263,267 ****
        scalebuf = malloc(maxw * maxh * BYTESPERPIXEL);
        if (scalebuf == NULL) {
!         printf("vo_svga: Not enough memory for buffering!\n");
  	uninit();
  	return (1);
--- 300,304 ----
        scalebuf = malloc(maxw * maxh * BYTESPERPIXEL);
        if (scalebuf == NULL) {
!         printf("vo_svga: scalebuf -> Not enough memory for buffering!\n");
  	uninit();
  	return (1);
***************
*** 273,277 ****
          scalebuf = malloc(maxw * maxh * BYTESPERPIXEL);
          if (scalebuf == NULL) {
!           printf("vo_svga: Not enough memory for buffering!\n");
  	  uninit();
  	  return (1);
--- 310,314 ----
          scalebuf = malloc(maxw * maxh * BYTESPERPIXEL);
          if (scalebuf == NULL) {
!           printf("vo_svga: scalebuf -> Not enough memory for buffering!\n");
  	  uninit();
  	  return (1);
***************
*** 289,293 ****
      yuvbuf = malloc(maxw * maxh * BYTESPERPIXEL);
      if (yuvbuf == NULL) {
!       printf("vo_svga: Not enough memory for buffering!\n");
        uninit();
        return (1);
--- 326,330 ----
      yuvbuf = malloc(maxw * maxh * BYTESPERPIXEL);
      if (yuvbuf == NULL) {
!       printf("vo_svga: yuvbuf -> Not enough memory for buffering!\n");
        uninit();
        return (1);
***************
*** 295,298 ****
--- 332,336 ----
    }
  
+ //  printf("bpp_conv: %d\n",bpp_conv);
    printf("SVGAlib resolution: %dx%d %dbpp - ", WIDTH, HEIGHT, bpp);
    if (maxw != orig_w || maxh != orig_h) printf("Video scaled to: %dx%d\n",maxw,maxh);
***************
*** 303,307 ****
  
  static uint32_t query_format(uint32_t format) {
!   uint8_t res = 0;
  
    if (!checked) {
--- 341,345 ----
  
  static uint32_t query_format(uint32_t format) {
!   uint32_t res = 0;
  
    if (!checked) {
***************
*** 309,341 ****
        return(0);
    }
!   switch (format) {
!     case IMGFMT_RGB32: 
!     case IMGFMT_BGR|32: {
!       return ((bpp_avail & BPP_32) ? 1 : 0);
!     }
!     case IMGFMT_RGB24: 
!     case IMGFMT_BGR|24: {
!       res = (bpp_avail & BPP_24) ? 1 : 0;
!       if (!res) {
!         res = (bpp_avail & BPP_32) ? 1 : 0;
! 	bpp_conv = 1;
!       }
!       return (res);
!     }
!     case IMGFMT_RGB16: 
!     case IMGFMT_BGR|16: {
!       return ((bpp_avail & BPP_16) ? 1 : 0);
!     }
!     case IMGFMT_RGB15: 
!     case IMGFMT_BGR|15: {
!       res = (bpp_avail & BPP_15) ? 1 : 0;
!       if (!res) {
!         res = (bpp_avail & BPP_16) ? 1 : 0;
!         bpp_conv = 1;
        }
-       return (res);
-     }
-     case IMGFMT_YV12: return (1);
-   }
    return (0);
  }
--- 347,389 ----
        return(0);
    }
! 
!   // if (vo_dbpp) => There is NO conversion!!!
!   if (vo_dbpp) {
!     switch (vo_dbpp) {
!       case 32: if ((format == IMGFMT_RGB32) || (format == IMGFMT_BGR|32))
!                  return ((bpp_avail & BPP_32) ? 1 : 0);
! 	       break;
!       case 24: if ((format == IMGFMT_RGB24) || (format == IMGFMT_BGR|24))
!                  return ((bpp_avail & BPP_24) ? 1 : 0);
! 	       break;
!       case 16: if ((format == IMGFMT_RGB16) || (format == IMGFMT_BGR|16))
!                  return ((bpp_avail & BPP_16) ? 1 : 0);
! 	       break;
!       case 15: if ((format == IMGFMT_RGB15) || (format == IMGFMT_BGR|15))
!                  return ((bpp_avail & BPP_15) ? 1 : 0);
! 	       break;
!     }
!   } else
!       switch (format) {
!         case IMGFMT_RGB32: 
!         case IMGFMT_BGR|32: return ((bpp_avail & BPP_32) ? 1 : 0); break;
!         case IMGFMT_RGB24: 
!         case IMGFMT_BGR|24: {
!           res = (bpp_avail & BPP_24) ? 1 : 0;
!           if (!res)
!             res = (bpp_avail & BPP_32) ? 1 : 0;
!           return (res);
!         } break;
!         case IMGFMT_RGB16: 
!         case IMGFMT_BGR|16: return ((bpp_avail & BPP_16) ? 1 : 0); break;
!         case IMGFMT_RGB15: 
!         case IMGFMT_BGR|15: {
!           res = (bpp_avail & BPP_15) ? 1 : 0;
!           if (!res)
!             res = (bpp_avail & BPP_16) ? 1 : 0;
!           return (res);
!         } break;
!         case IMGFMT_YV12: return (1); break;
        }
    return (0);
  }
***************
*** 373,391 ****
    }
    if (bpp_conv) {
!     uint16_t *src = (uint16_t *) src[0];
      uint16_t *dest = (uint16_t *) bppbuf;
      uint16_t *end;
      
      switch(bpp) {
!       case 32:
! 	end = src + (maxw * maxh * 2);
!         while (src < end) {
! 	  *dest++ = *src++;
! 	  (uint8_t *)dest = (uint8_t *)src;
  	  *(((uint8_t *)dest)+1) = 0;
  	  dest++;
! 	  src++;
  	}
!       case 16:
  #ifdef HAVE_MMX
          rgb15to16_mmx(src[0],bppbuf,maxw * maxh * 2);
--- 421,440 ----
    }
    if (bpp_conv) {
!     uint16_t *source = (uint16_t *) src[0];
      uint16_t *dest = (uint16_t *) bppbuf;
      uint16_t *end;
      
      switch(bpp) {
!       case 32: {
! 	end = source + (maxw * maxh * 2);
!         while (source < end) {
! 	  *dest++ = *source++;
! 	  (uint8_t *)dest = (uint8_t *)source;
  	  *(((uint8_t *)dest)+1) = 0;
  	  dest++;
! 	  source++;
  	}
!       } break;
!       case 16: {
  #ifdef HAVE_MMX
          rgb15to16_mmx(src[0],bppbuf,maxw * maxh * 2);
***************
*** 393,402 ****
  	register uint16_t srcdata;
  	
! 	end = src + (maxw * maxh);
! 	while (src < end) {
! 	  srcdata = *src++;
  	  *dest++ = (srcdata & 0x1f) | ((srcdata & 0x7fe0) << 1);
  	}
  #endif
      }
      src[0] = bppbuf;
--- 442,452 ----
  	register uint16_t srcdata;
  	
! 	end = source + (maxw * maxh);
! 	while (source < end) {
! 	  srcdata = *source++;
  	  *dest++ = (srcdata & 0x1f) | ((srcdata & 0x7fe0) << 1);
  	}
  #endif
+       } break;
      }
      src[0] = bppbuf;
***************
*** 429,433 ****
        gl_fillbox(WIDTH - x_pos, 0, x_pos, HEIGHT, 0);
      }
!   vo_draw_text(WIDTH, HEIGHT, draw_alpha);
    gl_copyscreen(screen);
  }
--- 479,483 ----
        gl_fillbox(WIDTH - x_pos, 0, x_pos, HEIGHT, 0);
      }
! //  vo_draw_text(WIDTH, HEIGHT, draw_alpha);
    gl_copyscreen(screen);
  }


_______________________________________________
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