Commit 57429088 authored by Vincent Seguin's avatar Vincent Seguin

Integration de display.c � vout.

Mise au point du driver X11 (plus de XShm error).
Incrustation de texte en X11, calcul des FPS, etc...
Int�gration de la conversion MMX.
Mode 'niveaux de gris' pour les machines lentes non MMX (les pauvres !)
Attention: les drivers GGI et FB ne sont pas � jour...
parent cf9e7c61
......@@ -5,3 +5,4 @@ gmon.out
vlc
vlc.init
vlc-debug.log
vlc-debug.ct
......@@ -215,7 +215,7 @@ endif
ifeq ($(ARCH),MMX)
ASM_OBJ = video_decoder_ref/idctmmx.o \
video_decoder_ref/yuv12-rgb16.o
video_output/yuv-mmx.o
endif
C_OBJ = $(interface_obj) \
......
......@@ -60,7 +60,7 @@
//#define MPEG2_COMPLIANT
/* Define for profiling support */
//#define STATS
#define STATS
/* Define for unthreaded version of the program - ?? not yet implemented */
//#define NO_THREAD
......@@ -230,6 +230,13 @@
* (~1 Mbyte) before using huge values */
#define VOUT_MAX_PICTURES 10
/* Environment variable for grayscale output mode, and default value */
#define VOUT_GRAYSCALE_VAR "vlc_grayscale"
#define VOUT_GRAYSCALE_DEFAULT 0
/* Number of pictures required to computes the FPS rate */
#define VOUT_FPS_SAMPLES 5
/*
* Time settings
*/
......@@ -237,7 +244,7 @@
/* Time during which the thread will sleep if it has nothing to
* display (in micro-seconds) */
/* ?? this constant will probably evolve to a calculated value */
#define VOUT_IDLE_SLEEP 50000
#define VOUT_IDLE_SLEEP 20000
/* Maximum lap of time allowed between the beginning of rendering and
* display. If, compared to the current date, the next image is too
......@@ -245,7 +252,7 @@
* at least VOUT_IDLE_SLEEP plus the time required to render a few
* images, to avoid trashing of decoded images */
/* ?? this constant will probably evolve to a calculated value */
#define VOUT_DISPLAY_DELAY 150000
#define VOUT_DISPLAY_DELAY 100000
/*
* Framebuffer settings
......@@ -262,6 +269,11 @@
/* Allow use of X11 XShm (shared memory) extension if possible */
#define VOUT_XSHM 1
/* Font maximum and minimum characters - characters outside this range are not
* printed - maximum range is 0-256 */
#define VOUT_MIN_CHAR 1
#define VOUT_MAX_CHAR 128
/*******************************************************************************
* Video parser configuration
*******************************************************************************/
......@@ -363,12 +375,12 @@
/* Maximal size of the message queue - in case of overflow, all messages in the
* queue are printed by the calling thread */
#define INTF_MSG_QSIZE 32
#define INTF_MSG_QSIZE 64
/* Define to enable messages queues - disabling messages queue can be usefull
* when debugging, since it allows messages which would not otherwise be printed,
* due to a crash, to be printed anyway */
//#define INTF_MSG_QUEUE
#define INTF_MSG_QUEUE
/* Format of the header for debug messages. The arguments following this header
* are the file (char *), the function (char *) and the line (int) in which the
......
......@@ -45,4 +45,5 @@ extern main_t *p_main;
*******************************************************************************/
int main_GetIntVariable( char *psz_name, int i_default );
char * main_GetPszVariable( char *psz_name, char *psz_default );
void main_PutIntVariable( char *psz_name, int i_value );
void main_PutPszVariable( char *psz_name, char *psz_value );
......@@ -14,7 +14,7 @@
/*******************************************************************************
* yuv_data_t: type for storing one Y, U or V sample.
*******************************************************************************/
typedef s16 yuv_data_t;
typedef u8 yuv_data_t;
/*******************************************************************************
* picture_t: video picture
......
......@@ -25,8 +25,11 @@ typedef struct vout_thread_s
int * pi_status; /* temporary status flag */
/* Common display properties */
boolean_t b_info; /* print additionnal informations */
boolean_t b_grayscale; /* color or grayscale display */
int i_width; /* current output method width */
int i_height; /* current output method height */
int i_bytes_per_line;/* bytes per line (including virtual) */
int i_screen_depth; /* bits per pixel */
int i_bytes_per_pixel; /* real screen depth */
float f_x_ratio; /* horizontal display ratio */
......@@ -34,9 +37,18 @@ typedef struct vout_thread_s
#ifdef STATS
/* Statistics */
count_t c_loops; /* number of loops */
count_t c_idle_loops; /* number of idle loops */
count_t c_pictures; /* number of pictures added to heap */
count_t c_loops; /* number of loops */
count_t c_idle_loops; /* number of idle loops */
count_t c_pictures; /* number of pictures added to heap */
/* FPS */
mtime_t fps_sample[ VOUT_FPS_SAMPLES ]; /* samples dates */
int i_fps_index; /* index in samples */
#endif
#ifdef DEBUG_VIDEO
/* Video debugging informations */
mtime_t picture_render_time; /* last picture rendering time */
#endif
/* Output method */
......@@ -49,12 +61,12 @@ typedef struct vout_thread_s
/* YUV translation tables, for 15,16 and 24/32 bpp displays. 16 bits and 32
* bits pointers points on the same data.
* CAUTION: these tables are translated: their origin is -384 */
u16 * pi_trans16_red;
u16 * pi_trans16_green;
u16 * pi_trans16_blue;
u32 * pi_trans32_red;
u32 * pi_trans32_green;
u32 * pi_trans32_blue;
u16 * pi_trans16_red;
u16 * pi_trans16_green;
u16 * pi_trans16_blue;
u32 * pi_trans32_red;
u32 * pi_trans32_green;
u32 * pi_trans32_blue;
} vout_thread_t;
/*******************************************************************************
......
......@@ -16,6 +16,10 @@ void vout_SysEnd ( p_vout_thread_t p_vout );
void vout_SysDestroy ( p_vout_thread_t p_vout );
int vout_SysManage ( p_vout_thread_t p_vout );
void vout_SysDisplay ( p_vout_thread_t p_vout );
byte_t * vout_SysGetPicture ( p_vout_thread_t p_vout, int *pi_eol_offset );
byte_t * vout_SysGetPicture ( p_vout_thread_t p_vout );
void vout_SysPrint ( p_vout_thread_t p_vout, int i_x, int i_y,
int i_halign, int i_valign,
unsigned char *psz_text );
......@@ -68,15 +68,12 @@
/* Video */
#include "video.h"
#include "video_sys.h"
#include "video_output.h"
#include "video_decoder.h"
/* Interface */
#include "intf_cmd.h"
#include "intf_ctrl.h"
#include "intf_sys.h"
#include "intf_console.h"
#include "interface.h"
#include "main.h"
......
......@@ -119,8 +119,8 @@ p_intf_msg_t intf_MsgCreate( void )
{
#ifdef INTF_MSG_QUEUE
/* Message queue initialization */
vlc_mutex_init( &p_intf_msg->lock ); /* intialize lock */
p_intf_msg->i_count = 0; /* queue is empty */
vlc_mutex_init( &p_msg->lock ); /* intialize lock */
p_msg->i_count = 0; /* queue is empty */
#endif
#ifdef DEBUG_LOG
......@@ -293,9 +293,9 @@ void _intf_DbgMsgImm( char *psz_file, char *psz_function, int i_line,
#ifdef INTF_MSG_QUEUE
void intf_FlushMsg( void )
{
vlc_mutex_lock( &p_program_data->intf_msg.lock ); /* get lock */
FlushLockedMsg( &p_program_data->intf_msg ); /* flush messages */
vlc_mutex_unlock( &p_program_data->intf_msg.lock ); /* give lock back */
vlc_mutex_lock( &p_main->p_msg->lock ); /* get lock */
FlushLockedMsg( p_main->p_msg ); /* flush messages */
vlc_mutex_unlock( &p_main->p_msg->lock ); /* give lock back */
}
#endif
......@@ -325,7 +325,7 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a
vasprintf( &psz_str, psz_format, ap );
if( psz_str == NULL )
{
fprintf(stderr, "Warning: can't store following message (%s): ",
fprintf(stderr, "warning: can't store following message (%s): ",
strerror(errno) );
vfprintf(stderr, psz_format, ap );
exit( errno );
......@@ -336,7 +336,7 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a
if( p_msg->i_count == INTF_MSG_QSIZE ) /* flush queue if needed */
{
#ifdef DEBUG /* in debug mode, queue overflow causes a warning */
fprintf(stderr, "Warning: message queue overflow\n" );
fprintf(stderr, "warning: message queue overflow\n" );
#endif
FlushLockedMsg( p_msg );
}
......@@ -381,7 +381,7 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function,
vasprintf( &psz_str, psz_format, ap );
if( psz_str == NULL )
{
fprintf(stderr, "Warning: can't store following message (%s): ",
fprintf(stderr, "warning: can't store following message (%s): ",
strerror(errno) );
fprintf(stderr, INTF_MSG_DBG_FORMAT, psz_file, psz_function, i_line );
vfprintf(stderr, psz_format, ap );
......@@ -393,7 +393,7 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function,
if( p_msg->i_count == INTF_MSG_QSIZE ) /* flush queue if needed */
{
#ifdef DEBUG /* in debug mode, queue overflow causes a warning */
fprintf(stderr, "Warning: message queue overflow\n" );
fprintf(stderr, "warning: message queue overflow\n" );
#endif
FlushLockedMsg( p_msg );
}
......@@ -481,7 +481,7 @@ static void PrintMsg( intf_msg_item_t *p_msg )
/* Check if formatting function suceeded */
if( psz_msg == NULL )
{
fprintf( stderr, "intf error: *** can not format message (%s): %s ***\n",
fprintf( stderr, "error: can not format message (%s): %s\n",
strerror( errno ), p_msg->psz_msg );
return;
}
......@@ -519,7 +519,7 @@ static void PrintMsg( intf_msg_item_t *p_msg )
#else
static void PrintMsg( interface_msg_message_t *p_msg )
static void PrintMsg( intf_msg_item_t *p_msg )
{
/*
* Print messages on screen
......@@ -534,8 +534,7 @@ static void PrintMsg( interface_msg_message_t *p_msg )
fprintf( stderr, p_msg->psz_msg );
break;
case INTF_MSG_INTF: /* interface messages */
intf_PrintXConsole( &p_main->intf_thread.xconsole,
p_msg->psz_msg );
intf_ConsolePrint( p_main->p_intf->p_console, p_msg->psz_msg );
break;
}
}
......
......@@ -38,16 +38,11 @@
#define OPT_NOAUDIO 150
#define OPT_STEREO 151
#define OPT_MONO 152
#define OPT_RATE 153
#define OPT_NOVIDEO 160
#define OPT_XDGA 161
#define OPT_XSHM 162
#define OPT_XNOSHM 163
#define OPT_XNODGA 164
#define OPT_COLOR 161
#define OPT_NOVLANS 170
#define OPT_VLAN_SERVER 171
/* Long options */
static const struct option longopts[] =
......@@ -64,6 +59,8 @@ static const struct option longopts[] =
/* Video options */
{ "novideo", 0, 0, OPT_NOVIDEO },
{ "grayscale", 0, 0, 'g' },
{ "color", 0, 0, OPT_COLOR },
/* VLAN management options */
{ "novlans", 0, 0, OPT_NOVLANS },
......@@ -72,7 +69,7 @@ static const struct option longopts[] =
};
/* Short options */
static const char *psz_shortopts = "h";
static const char *psz_shortopts = "hg";
/*******************************************************************************
* Global variable program_data - this is the one and only, see main.h
......@@ -187,18 +184,19 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
*******************************************************************************/
int main_GetIntVariable( char *psz_name, int i_default )
{
char *psz_env;
char * psz_env; /* environment value */
char * psz_end; /* end of parsing index */
long int i_value; /* value */
psz_env = getenv( psz_name );
if( psz_env )
{
psz_env = strchr( psz_env, '=' );
if( psz_env )
{
return( atoi( psz_env + 1) );
}
{
i_value = strtol( psz_env, &psz_end, 0 );
if( (*psz_env != '\0') && (*psz_end == '\0') )
{
return( i_value );
}
}
return( i_default );
}
......@@ -214,16 +212,52 @@ char * main_GetPszVariable( char *psz_name, char *psz_default )
psz_env = getenv( psz_name );
if( psz_env )
{
psz_env = strchr( psz_env, '=' );
if( psz_env )
{
return( psz_env + 1 );
}
return( psz_env );
}
return( psz_default );
}
/*******************************************************************************
* main_PutPszVariable: set the string value of an environment variable
*******************************************************************************
* This function is used to set some default parameters in modules. The use of
* this function will cause some memory leak: since some systems use the pointer
* passed to putenv to store the environment string, it can't be freed.
*******************************************************************************/
void main_PutPszVariable( char *psz_name, char *psz_value )
{
char *psz_env;
psz_env = malloc( strlen(psz_name) + strlen(psz_value) + 2 );
if( psz_env == NULL )
{
intf_ErrMsg("error: %s\n", strerror(ENOMEM));
}
else
{
sprintf( psz_env, "%s=%s", psz_name, psz_value );
if( putenv( psz_env ) )
{
intf_ErrMsg("error: %s\n", strerror(errno));
}
}
}
/*******************************************************************************
* main_PutIntVariable: set the integer value of an environment variable
*******************************************************************************
* This function is used to set some default parameters in modules. The use of
* this function will cause some memory leak: since some systems use the pointer
* passed to putenv to store the environment string, it can't be freed.
*******************************************************************************/
void main_PutIntVariable( char *psz_name, int i_value )
{
char psz_value[ 256 ]; /* buffer for value */
sprintf(psz_value, "%d", i_value );
main_PutPszVariable( psz_name, psz_value );
}
/* following functions are local */
/*******************************************************************************
......@@ -299,19 +333,23 @@ static int GetConfiguration( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
case OPT_NOAUDIO: /* --noaudio */
p_main->b_audio = 0;
break;
case OPT_STEREO: /* --stereo */
// ?? should be replaced by a putenv
//p_main->p_aout->dsp.b_stereo = 1;
case OPT_STEREO: /* --stereo */
main_PutIntVariable( AOUT_STEREO_VAR, 1 );
break;
case OPT_MONO: /* --mono */
// ?? should be replaced by a putenv
//p_main->p_aout->dsp.b_stereo = 0;
main_PutIntVariable( AOUT_STEREO_VAR, 0 );
break;
/* Video options */
case OPT_NOVIDEO: /* --novideo */
p_main->b_video = 0;
break;
case 'g': /* -g, --grayscale */
main_PutIntVariable( VOUT_GRAYSCALE_VAR, 1 );
break;
case OPT_COLOR: /* --color */
main_PutIntVariable( VOUT_GRAYSCALE_VAR, 0 );
break;
/* VLAN management options */
case OPT_NOVLANS: /* --novlans */
......@@ -352,10 +390,12 @@ static void Usage( void )
/* Options */
intf_Msg("Options:" \
" -h, --help print usage\n" \
" -g, --grayscale grayscale video\n" \
" --noaudio disable audio\n" \
" --stereo enable stereo\n" \
" --mono disable stereo\n"
" --novideo disable video\n" \
" --color color video\n" \
" --novlans disable vlans\n" \
);
......@@ -374,6 +414,7 @@ static void Usage( void )
/* Video parameters */
intf_Msg("Video parameters:\n" \
" " VOUT_FB_DEV_VAR "=<filename> framebuffer device path\n" \
" " VOUT_GRAYSCALE_VAR "={1|0} grayscale or color output\n" \
);
/* Vlan parameters */
......
......@@ -12,6 +12,7 @@
* Preamble
******************************************************************************/
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include "common.h"
......@@ -82,24 +83,25 @@ void mwait( mtime_t date )
{
return;
}
#ifndef usleep
tv_delay.tv_sec = delay / 1000000;
tv_delay.tv_usec = delay % 1000000;
/* see msleep() about select() errors */
select( 0, NULL, NULL, NULL, &tv_delay );
#else
usleep( delay );
#endif
}
/******************************************************************************
* msleep: more precise sleep() (inline function) (ok ?)
******************************************************************************
* This function uses select() in a classical way to implement a sleep() call
* with a microsecond precision.
* For synchronization purposes, mwait() should be prefered.
******************************************************************************
* ?? decalre as inline
* Portable usleep() function.
******************************************************************************/
void msleep( mtime_t delay )
{
#ifndef usleep
struct timeval tv_delay;
tv_delay.tv_sec = delay / 1000000;
......@@ -109,4 +111,7 @@ void msleep( mtime_t delay )
* (i.e. when a signal is sent to the thread, or when memory is full), and
* can be ingnored. */
select( 0, NULL, NULL, NULL, &tv_delay );
#else
usleep( delay );
#endif
}
......@@ -137,13 +137,10 @@ void vout_SysDisplay( vout_thread_t *p_vout )
/*******************************************************************************
* vout_SysGetPicture: get current display buffer informations
*******************************************************************************
* This function returns the address of the current display buffer, and the
* number of samples per line. For 15, 16 and 32 bits displays, this value is
* the number of pixels in a line.
* This function returns the address of the current display buffer.
*******************************************************************************/
byte_t * vout_SysGetPicture( vout_thread_t *p_vout, int *pi_eol_offset )
byte_t * vout_SysGetPicture( vout_thread_t *p_vout )
{
*pi_eol_offset = p_vout->i_width;
//????
// return( p_vout->p_sys->p_ximage[ p_vout->p_sys->i_buffer_index ].data );
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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