Commit 9b4528b5 authored by Vincent Seguin's avatar Vincent Seguin

Gestion des touches en GGI (ouf !)

parent 22c1b3b1
......@@ -14,10 +14,10 @@
#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
......@@ -173,7 +173,8 @@ audio_output_obj = audio_output/audio_output.o \
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
......
......@@ -33,8 +33,8 @@ typedef struct
/* 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 */
......
......@@ -65,12 +65,11 @@ typedef struct vout_thread_s
* 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;
/*******************************************************************************
......
......@@ -128,8 +128,8 @@ p_intf_msg_t intf_MsgCreate( void )
* 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 );
......
......@@ -204,6 +204,18 @@ void vout_SysPrint( vout_thread_t *p_vout, int i_x, int i_y, int i_halign,
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 */
/*******************************************************************************
......
......@@ -134,7 +134,7 @@ const int MATRIX_COEFFICIENTS_TABLE[8][4] =
* 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)
......@@ -152,6 +152,16 @@ void vout_YUV420_16_MMX( u8* p_y, u8* p_u, u8 *p_v,
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
*******************************************************************************/
......@@ -413,9 +423,19 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
/* 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);
......@@ -556,16 +576,17 @@ static int InitThread( vout_thread_t *p_vout )
}
/* 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 );
......@@ -832,6 +853,7 @@ static void BuildTables( vout_thread_t *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 );
}
......@@ -874,6 +896,15 @@ static void BuildTables( vout_thread_t *p_vout )
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;
}
}
/*******************************************************************************
......@@ -1033,6 +1064,7 @@ static void RenderYUV16Picture( vout_thread_t *p_vout, picture_t *p_pic )
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 */
......
......@@ -7,7 +7,7 @@
#include <stdlib.h> /* malloc */
#include "convert.h"
//#include "convert.h"
static int binaryLog (int i)
{
......@@ -68,7 +68,7 @@ static int colorMaskToShift (int * right, int * left, int mask)
* 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])
{
......@@ -184,7 +184,7 @@ static int rgbTable32 (int table [1935],
#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)
{
......@@ -733,105 +733,3 @@ static void yuvToRgb32 (unsigned char * Y,
/* 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;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment