#SHELL = /bin/sh
# Video output settings
-VIDEO=X11
+#VIDEO=X11
#VIDEO=DGA (not yet supported)
#VIDEO=FB
-#VIDEO=GGI
+VIDEO=GGI
#VIDEO=BEOS (not yet supported)
# Target architecture and optimization
audio_output/audio_dsp.o
video_output_obj = video_output/video_output.o \
- video_output/video_$(video).o
+ video_output/video_$(video).o \
+ video_output/video_yuv_c.o
ac3_decoder_obj = ac3_decoder/ac3_decoder.o
/* Picture properties - those properties are fixed at initialization and
* should NOT be modified. Note that for YUV pictures, i_bytes_per_line is
- * the number of bytes for ONE of the Y, U or V pictures, and therefore the
- * number of bytes in the picture is 3 * i_height * i_bytes_per_line */
+ * the number of bytes for Y samples - the total size allocated will depend
+ * of the picture format */
int i_width; /* picture width */
int i_height; /* picture height */
int i_bytes_per_line; /* total number of bytes per line */
* on use. All tables are allocated in the same memory block, based at
* p_trans_base, and shifted depending of the output thread configuration */
byte_t * p_trans_base; /* base for all translation tables */
- void * p_trans_red;
- void * p_trans_green;
- void * p_trans_blue;
- void * p_trans_gray;
-
- /* YUV translation tables, for optimized C YUV transform ?? */
+ void * p_trans_red; /* regular red */
+ void * p_trans_green; /* regular green */
+ void * p_trans_blue; /* regular blue */
+ void * p_trans_gray; /* regular gray */
+ void * p_trans_optimized; /* optimized (all colors) */
} vout_thread_t;
/*******************************************************************************
* and no log will be issued, but this is not considered as an
* error */
p_msg->i_log_file = open( DEBUG_LOG,
- O_CREAT | O_APPEND | O_SYNC | O_WRONLY,
- 0777 );
+ O_CREAT | O_TRUNC | O_SYNC | O_WRONLY,
+ 0666 );
#endif
}
return( p_msg );
ggiPuts( p_vout->p_sys->p_display, i_x, i_y, psz_text );
}
+/*******************************************************************************
+ * vout_SysGetVisual: send visual to interface driver
+ *******************************************************************************
+ * This function is not part of the regular vout_Sys* API, but is used by GGI
+ * interface to get back visual display pointer once the output thread has
+ * been spawned. This visual is used to keep track of keyboard events.
+ *******************************************************************************/
+ggi_visual_t vout_SysGetVisual( vout_thread_t *p_vout )
+{
+ return( p_vout->p_sys->p_display );
+}
+
/* following functions are local */
/*******************************************************************************
* External prototypes
*******************************************************************************/
#ifdef HAVE_MMX
-/* YUV transformations for MMX - in yuv-mmx.S
+/* YUV transformations for MMX - in video_yuv_mmx.S
* p_y, p_u, p_v: Y U and V planes
* i_width, i_height: frames dimensions (pixels)
* i_ypitch, i_vpitch: Y and V lines sizes (bytes)
int CCOPitch, int i_colortype );
#endif
+/* Optimized YUV functions: translations and tables building - in video_yuv_c.c
+ * ??? looks efficient, but does not work well - ask walken */
+void yuvToRgb16 ( unsigned char * Y,
+ unsigned char * U, unsigned char * V,
+ short * dest, short table[1935], int width);
+int rgbTable16 (short table [1935],
+ int redMask, int greenMask, int blueMask,
+ unsigned char gamma[256]);
+
+
/*******************************************************************************
* Local prototypes
*******************************************************************************/
/* Allocate memory */
switch( i_type )
{
- case YUV_420_PICTURE: /* YUV picture: bits per pixel */
- case YUV_422_PICTURE:
- case YUV_444_PICTURE:
+ case YUV_420_PICTURE: /* YUV 420: 1,1/4,1/4 samples per pixel */
+ p_free_picture->p_data = malloc( i_height * i_bytes_per_line * 3 / 2 );
+ p_free_picture->p_y = (yuv_data_t *) p_free_picture->p_data;
+ p_free_picture->p_u = (yuv_data_t *)(p_free_picture->p_data + i_height * i_bytes_per_line);
+ p_free_picture->p_v = (yuv_data_t *)(p_free_picture->p_data + i_height * i_bytes_per_line * 5 / 4);
+ break;
+ case YUV_422_PICTURE: /* YUV 422: 1,1/2,1/2 samples per pixel */
+ p_free_picture->p_data = malloc( 2 * i_height * i_bytes_per_line );
+ p_free_picture->p_y = (yuv_data_t *) p_free_picture->p_data;
+ p_free_picture->p_u = (yuv_data_t *)(p_free_picture->p_data + i_height * i_bytes_per_line);
+ p_free_picture->p_v = (yuv_data_t *)(p_free_picture->p_data + i_height * i_bytes_per_line * 3 / 2);
+ break;
+ case YUV_444_PICTURE: /* YUV 444: 1,1,1 samples per pixel */
p_free_picture->p_data = malloc( 3 * i_height * i_bytes_per_line );
p_free_picture->p_y = (yuv_data_t *) p_free_picture->p_data;
p_free_picture->p_u = (yuv_data_t *)(p_free_picture->p_data + i_height * i_bytes_per_line);
}
/* Allocate translation tables */
- p_vout->p_trans_base = malloc( 4 * 1024 * p_vout->i_bytes_per_pixel );
+ p_vout->p_trans_base = malloc( ( 4 * 1024 + 1935 ) * p_vout->i_bytes_per_pixel );
if( p_vout->p_trans_base == NULL )
{
intf_ErrMsg("error: %s\n", strerror(ENOMEM));
return( 1 );
}
- p_vout->p_trans_red = p_vout->p_trans_base + 384 *p_vout->i_bytes_per_pixel;
- p_vout->p_trans_green = p_vout->p_trans_base + ( 1024 + 384)*p_vout->i_bytes_per_pixel;
- p_vout->p_trans_blue = p_vout->p_trans_base + (2*1024 + 384)*p_vout->i_bytes_per_pixel;
- p_vout->p_trans_gray = p_vout->p_trans_base + (3*1024 + 384)*p_vout->i_bytes_per_pixel;
+ p_vout->p_trans_red = p_vout->p_trans_base + 384 *p_vout->i_bytes_per_pixel;
+ p_vout->p_trans_green = p_vout->p_trans_base + ( 1024 + 384)*p_vout->i_bytes_per_pixel;
+ p_vout->p_trans_blue = p_vout->p_trans_base + (2*1024 + 384)*p_vout->i_bytes_per_pixel;
+ p_vout->p_trans_gray = p_vout->p_trans_base + (3*1024 + 384)*p_vout->i_bytes_per_pixel;
+ p_vout->p_trans_optimized = p_vout->p_trans_base + (4*1024 )*p_vout->i_bytes_per_pixel;
/* Build translation tables */
BuildTables( p_vout );
/* Build gamma table */
for( i_index = 0; i_index < 256; i_index++ )
{
+ //?? add contrast and brightness
i_gamma[i_index] = 255. * pow( (double)i_index / 255., p_vout->f_gamma );
}
break;
#endif
}
+
+ /* Build red, green and blue tables for optimized transformation */
+ //????
+ switch( p_vout->i_screen_depth )
+ {
+ case 16:
+ rgbTable16( (short *) p_vout->p_trans_optimized, 0xf800, 0x07e0, 0x01f, i_gamma );
+ break;
+ }
}
/*******************************************************************************
p_trans_green,
p_trans_blue,
p_data );
+ //??? yuvToRgb16( p_y, p_u, p_v, p_data, p_vout->p_trans_optimized, i_width*i_height );
#endif
break;
case YUV_422_PICTURE: /* 15 or 16 bpp 422 transformation */
#include <stdlib.h> /* malloc */
-#include "convert.h"
+//#include "convert.h"
static int binaryLog (int i)
{
* calculated to minimize the cache interactions of the 3 tables.
*/
-static int rgbTable16 (short table [1935],
+int rgbTable16 (short table [1935],
int redMask, int greenMask, int blueMask,
unsigned char gamma[256])
{
#define V_RED_COEF ((int)(1.596 * (1<<SHIFT) / 1.164))
#define V_GREEN_COEF ((int)(-0.813 * (1<<SHIFT) / 1.164))
-static void yuvToRgb16 (unsigned char * Y,
+ void yuvToRgb16 (unsigned char * Y,
unsigned char * U, unsigned char * V,
short * dest, short table[1935], int width)
{
/* API routines */
-int convertGrey (CONVERTER * convert, DISPLAY * disp)
-{
- if ((convert == NULL) || (disp == NULL))
- return 1;
-
- if (greyRgbTable (disp))
- return 1;
-
- switch (disp->bytesPerPixel) {
- case 2:
- convert->convert = &greyToRgb16;
- break;
- case 3:
- convert->convert = &greyToRgb24;
- break;
- case 4:
- convert->convert = &greyToRgb32;
- break;
- default:
- return 1;
- }
- convert->table = disp->greyRgbTable;
- return 0;
-}
-
-static void * greyRgbTable (DISP_COLORS * colors, unsigned char gamma[256])
-{
- /* FIXME could avoid recalculating the same table */
- void * table;
-
- for (i = 0; i < 16; i++)
- gamma[i] = 0;
-#define Y_COEF ((int)(1.164 * 65536))
- for (; i <= 235; i++)
- gamma[i] = (Y_COEF * i - Y_COEF * 16) >> 16;
-#undef Y_COEF
- for (; i < 256; i++)
- gamma[i] = 255;
- }
-
- switch (colors->bytesPerPixel) {
- case 2:
- table = malloc (256 * sizeof (short));
- if (table == NULL)
- break;
- if (greyRgb16Table (table,
- colors->redMask,
- colors->greenMask,
- colors->blueMask,
- gamma))
- goto error;
- return table;
- case 3:
- case 4:
- table = malloc (256 * sizeof (int));
- if (table == NULL)
- break;
- if (greyRgb32Table (table,
- colors->redMask,
- colors->greenMask,
- colors->blueMask,
- gamma))
- goto error;
- return table;
- error:
- free (table);
- }
-
- return NULL;
-}
-
-static void * rgbTable (DISP_COLORS * colors, unsigned char gamma[256])
-{
- /* FIXME could avoid recalculating the same table */
- void * table;
-
- switch (colors->bytesPerPixel) {
- case 2:
- table = malloc (1935 * sizeof (short));
- if (table == NULL)
- break;
- if (rgbTable16 (table,
- colors->redMask, colors->greenMask, colors->blueMask,
- gamma))
- goto error;
- return table;
- case 3:
- case 4:
- table = malloc (1935 * sizeof (int));
- if (table == NULL)
- break;
- if (rgbTable32 (table,
- colors->redMask, colors->greenMask, colors->blueMask,
- gamma))
- goto error;
- return table;
- error:
- free (table);
- }
-
- return NULL;
-}