changeset 2504:13e1c5ab417a

vo_vesa: rgb2rgb support
author nick
date Sun, 28 Oct 2001 10:17:57 +0000
parents d21d8d5f2e23
children 2aaa11d22f91
files libvo/vo_vesa.c postproc/Makefile postproc/rgb2rgb.c postproc/rgb2rgb.h postproc/rgb2rgb_template.c
diffstat 5 files changed, 100 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_vesa.c	Sun Oct 28 03:03:49 2001 +0000
+++ b/libvo/vo_vesa.c	Sun Oct 28 10:17:57 2001 +0000
@@ -32,6 +32,7 @@
 #include "bswap.h"
 
 #include "../postproc/swscale.h"
+#include "../postproc/rgb2rgb.h"
 
 LIBVO_EXTERN(vesa)
 extern int verbose;
@@ -73,7 +74,7 @@
 static unsigned int scale_xinc=0;
 static unsigned int scale_yinc=0;
 
-static uint32_t image_width, image_height; /* source image dimension */
+static uint32_t image_bpp,image_width, image_height; /* source image dimension */
 static int32_t x_offset,y_offset; /* to center image on screen */
 static unsigned init_mode; /* mode before run of mplayer */
 static void *init_state = NULL; /* state before run of mplayer */
@@ -83,6 +84,7 @@
 static struct VesaModeInfoBlock video_mode_info;
 static int flip_trigger = 0;
 static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride);
+static void (*rgb2rgb_fnc)(uint8_t *src,uint8_t *dst,uint32_t src_size);
 
 #define MOVIE_MODE (MODE_ATTR_COLOR | MODE_ATTR_GRAPHICS)
 #define FRAME_MODE (MODE_WIN_RELOCATABLE | MODE_WIN_READABLE | MODE_WIN_WRITEABLE)
@@ -240,6 +242,8 @@
 /* is called for yuv only */
 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
 {
+    if(verbose > 2)
+	printf("vo_vesa: draw_slice was called: w=%u h=%u x=%u y=%u\n",w,h,x,y);
     if(vesa_zoom)
     {
 	 SwScale_YV12slice_brg24(image,stride,y,h,
@@ -282,24 +286,41 @@
 
 static void draw_osd(void)
 {
+ if(verbose > 2)
+	printf("vo_vesa: draw_osd was called\n");
  if(yuv_buffer) vo_draw_text(image_width,image_height,draw_alpha_fnc);
 }
 
 static void flip_page(void)
 {
+  if(verbose > 2)
+	printf("vo_vesa: flip_page was called\n");
   if(flip_trigger) { __vbeCopyData(yuv_buffer); flip_trigger = 0; }
 }
 
 /* is called for rgb only */
 static uint32_t draw_frame(uint8_t *src[])
 {
-	__vbeCopyData(src[0]);
-	return 0;
+  uint8_t *data;
+    if(verbose > 2)
+        printf("vo_vesa: draw_frame was called\n");
+    if(rgb2rgb_fnc)
+    {
+      (*rgb2rgb_fnc)(src[0],yuv_buffer,image_width*image_height*image_bpp);
+      data = yuv_buffer;
+      if(verbose > 2)
+          printf("vo_vesa: rgb2rgb_fnc was called\n");
+    } 
+    else data = src[0];
+    __vbeCopyData(data);
+    return 0;
 }
 
 static uint32_t query_format(uint32_t format)
 {
   uint32_t retval;
+    if(verbose > 2)
+        printf("vo_vesa: query_format was called: %x (%s)\n",format,vo_format_name(format));
 	switch(format)
 	{
 		case IMGFMT_YV12:
@@ -380,6 +401,7 @@
 	image_width = width;
 	image_height = height;
 	fs_mode = 0;
+	rgb2rgb_fnc = NULL;
 	if(flags & 0x8)
 	{
 	  printf("vo_vesa: switch -flip is not supported\n");
@@ -424,23 +446,16 @@
 	mode_ptr = vib.VideoModePtr;
 	while(*mode_ptr++ != 0xffff) num_modes++;
 	yuv_fmt = format == IMGFMT_YV12 || format == IMGFMT_I420 || format == IMGFMT_IYUV;
-	if(vo_dbpp)
-	{
-	  bpp = vo_dbpp;
-	  if(yuv_fmt)	yuv2rgb_init(bpp, MODE_RGB);
-	}
-	else
 	switch(format)
 	{
 		case IMGFMT_BGR8:
 		case IMGFMT_RGB8:  bpp = 8; break;
 		case IMGFMT_BGR15:
                 case IMGFMT_RGB15: bpp = 15; break;
+		default:
 		case IMGFMT_YV12:
 		case IMGFMT_I420:
-		case IMGFMT_IYUV: bpp=16;
-			yuv2rgb_init(bpp, MODE_RGB);
-		default:
+		case IMGFMT_IYUV:
 		case IMGFMT_BGR16:
 		case IMGFMT_RGB16: bpp = 16; break;
 		case IMGFMT_BGR24:
@@ -448,6 +463,9 @@
 		case IMGFMT_BGR32:
 		case IMGFMT_RGB32: bpp = 32; break;
 	}
+	image_bpp = bpp;
+	if(vo_dbpp) bpp = vo_dbpp;
+	if(yuv_fmt) yuv2rgb_init(bpp, MODE_RGB);
 	switch(bpp)
 	{
 	  case 15: draw_alpha_fnc = draw_alpha_15; break;
@@ -560,6 +578,16 @@
 		      return -1;
 		  }
 		}
+		if(format != IMGFMT_YV12 && image_bpp != video_mode_info.BitsPerPixel)
+		{
+		  if(image_bpp == 24 && video_mode_info.BitsPerPixel == 32) rgb2rgb_fnc = rgb24to32;
+		  else 
+		  {
+		    printf("vo_vesa: Can't convert %u to %u\n",image_bpp,video_mode_info.BitsPerPixel);
+		    return -1;
+		  }
+		  if(verbose) printf("vo_vesa: using %u to %u sw convertor\n",image_bpp,video_mode_info.BitsPerPixel);
+		}		
 		if((video_mode_info.WinAAttributes & FRAME_MODE) == FRAME_MODE)
 		   win.idx = 0; /* frame A */
 		else
@@ -587,12 +615,15 @@
 			,image_width,image_height
 			,video_mode_info.XResolution,video_mode_info.YResolution
 			,x_offset,y_offset);
-		if(yuv_fmt)
-		  if(!(yuv_buffer = malloc(image_width*image_height*bpp)))
+		if(yuv_fmt || rgb2rgb_fnc)
+		{
+		  if(!(yuv_buffer = malloc(video_mode_info.XResolution*video_mode_info.YResolution*video_mode_info.BitsPerPixel)))
 		  {
 		    printf("vo_vesa: Can't allocate temporary buffer\n");
 		    return -1;
 		  }
+		  if(verbose) printf("vo_vesa: yuv_buffer was allocated = %p\n",yuv_buffer);
+		}
 		if((err=vbeSaveState(&init_state)) != VBE_OK)
 		{
 			PRINT_VBE_ERR("vbeSaveState",err);
@@ -656,17 +687,23 @@
 static const vo_info_t*
 get_info(void)
 {
+    if(verbose > 2)
+        printf("vo_vesa: get_info was called\n");
 	return &vo_info;
 }
 
 static void
 uninit(void)
 {
+    if(verbose > 2)
+        printf("vo_vesa: uninit was called\n");
 	vesa_term();
 }
 
 
 static void check_events(void)
 {
+    if(verbose > 2)
+        printf("vo_vesa: check_events was called\n");
 /* Nothing to do */
 }
--- a/postproc/Makefile	Sun Oct 28 03:03:49 2001 +0000
+++ b/postproc/Makefile	Sun Oct 28 10:17:57 2001 +0000
@@ -3,7 +3,7 @@
 
 LIBNAME = libpostproc.a
 
-SRCS=postprocess.c swscale.c
+SRCS=postprocess.c swscale.c rgb2rgb.c
 OBJS=$(SRCS:.c=.o)
 
 CFLAGS  = $(OPTFLAGS) -I. -I.. -Wall
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/postproc/rgb2rgb.c	Sun Oct 28 10:17:57 2001 +0000
@@ -0,0 +1,18 @@
+#include <inttypes.h>
+#include "../config.h"
+#include "rgb2rgb.h"
+
+void rgb24to32(uint8_t *src,uint8_t *dst,uint32_t src_size)
+{
+  uint32_t *dest = (uint32_t *)dst;
+  uint8_t *s = src;
+  uint8_t *end;
+  end = s + src_size;
+  while(s < end)
+  {
+    uint32_t rgb0;
+    rgb0 = *(uint32_t *)s;
+    *dest++ = rgb0 & 0xFFFFFFUL;
+    s += 3;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/postproc/rgb2rgb.h	Sun Oct 28 10:17:57 2001 +0000
@@ -0,0 +1,12 @@
+/* 
+ *
+ *  rgb2rgb.h, Software RGB to RGB coverter
+ *
+ */
+
+#ifndef RGB2RGB_INCLUDED
+#define RGB2RGB_INCLUDED
+
+extern void rgb24to32(uint8_t *src,uint8_t *dst,uint32_t src_size);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/postproc/rgb2rgb_template.c	Sun Oct 28 10:17:57 2001 +0000
@@ -0,0 +1,18 @@
+#include <inttypes.h>
+#include "../config.h"
+#include "rgb2rgb.h"
+
+void rgb24to32(uint8_t *src,uint8_t *dst,uint32_t src_size)
+{
+  uint32_t *dest = (uint32_t *)dst;
+  uint8_t *s = src;
+  uint8_t *end;
+  end = s + src_size;
+  while(s < end)
+  {
+    uint32_t rgb0;
+    rgb0 = *(uint32_t *)s;
+    *dest++ = rgb0 & 0xFFFFFFUL;
+    s += 3;
+  }
+}