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 );
}
......
/*******************************************************************************
* video_output.c : video output thread
* (c)1999 VideoLAN
* (c)2000 VideoLAN
*******************************************************************************
* This module describes the programming interface for video output threads.
* It includes functions allowing to open a new thread, send pictures to a
......@@ -27,6 +27,7 @@
#include "video_output.h"
#include "video_sys.h"
#include "intf_msg.h"
#include "main.h"
/*******************************************************************************
* Macros
......@@ -36,6 +37,25 @@
* (0 or 255) */
#define CLIP_BYTE( i_val ) ( (i_val < 0) ? 0 : ((i_val > 255) ? 255 : i_val) )
/* YUV_GRAYSCALE: parametric macro for YUV grayscale transformation.
* Due to the high performance need of this loop, all possible conditions
* evaluations are made outside the transformation loop. However, the code does
* not change much for two different loops. This macro allows to change slightly
* the content of the loop without having to copy and paste code. It is used in
* RenderYUVPicture function. */
#define YUV_GRAYSCALE( TRANS_RED, TRANS_GREEN, TRANS_BLUE, P_PIC ) \
/* Main loop */ \
for (i_pic_y=0; i_pic_y < p_pic->i_height ; i_pic_y++) \
{ \
for (i_pic_x=0; i_pic_x< p_pic->i_width; i_pic_x++) \
{ \
i_y = *p_y++; \
*P_PIC++ = TRANS_RED[i_y] | TRANS_GREEN[i_y] | TRANS_BLUE[i_y]; \
} \
/* Skip until beginning of next line */ \
P_PIC += i_eol_offset; \
}
/* YUV_TRANSFORM: parametric macro for YUV transformation.
* Due to the high performance need of this loop, all possible conditions
* evaluations are made outside the transformation loop. However, the code does
......@@ -70,11 +90,11 @@ for (i_pic_y=0; i_pic_y < p_pic->i_height ; i_pic_y++) \
} \
if( (CHROMA == 420) && !(i_pic_y & 0x1) ) \
{ \
p_u -= p_pic->i_width; \
p_v -= p_pic->i_width; \
p_u -= i_chroma_width; \
p_v -= i_chroma_width; \
} \
/* Skip until beginning of next line */ \
P_PIC += i_pic_eol_offset - p_pic->i_width; \
P_PIC += i_eol_offset; \
}
/*******************************************************************************
......@@ -82,7 +102,7 @@ for (i_pic_y=0; i_pic_y < p_pic->i_height ; i_pic_y++) \
*******************************************************************************/
/* RGB/YUV inversion matrix (ISO/IEC 13818-2 section 6.3.6, table 6.9) */
int matrix_coefficients_table[8][4] =
const int MATRIX_COEFFICIENTS_TABLE[8][4] =
{
{117504, 138453, 13954, 34903}, /* no sequence_display_extension */
{117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */
......@@ -94,15 +114,40 @@ int matrix_coefficients_table[8][4] =
{117579, 136230, 16907, 35559} /* SMPTE 240M (1987) */
};
/*******************************************************************************
* External prototypes
*******************************************************************************/
#ifdef HAVE_MMX
/* YUV transformations for MMX - in 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)
* i_aspect: vertical aspect factor
* pi_pic: RGB frame
* i_dci_offset: ?? x offset for left image border
* i_offset_to_line_0: ?? x offset for left image border
* i_pitch: RGB line size (bytes)
* i_colortype: 0 for 565, 1 for 555 */
void vout_YUV420_16_MMX( u8* p_y, u8* p_u, u8 *p_v,
unsigned int i_width, unsigned int i_height,
unsigned int i_ypitch, unsigned int i_vpitch,
unsigned int i_aspect, u8 *pi_pic,
u32 i_dci_offset, u32 i_offset_to_line_0,
int CCOPitch, int i_colortype );
#endif
/*******************************************************************************
* Local prototypes
*******************************************************************************/
static int InitThread ( vout_thread_t *p_vout );
static void RunThread ( vout_thread_t *p_vout );
static void ErrorThread ( vout_thread_t *p_vout );
static void EndThread ( vout_thread_t *p_vout );
static void RenderPicture ( vout_thread_t *p_vout, picture_t *p_pic );
static void RenderYUVPicture( vout_thread_t *p_vout, picture_t *p_pic );
static int InitThread ( vout_thread_t *p_vout );
static void RunThread ( vout_thread_t *p_vout );
static void ErrorThread ( vout_thread_t *p_vout );
static void EndThread ( vout_thread_t *p_vout );
static void RenderPicture ( vout_thread_t *p_vout, picture_t *p_pic );
static void RenderYUVGrayPicture ( vout_thread_t *p_vout, picture_t *p_pic );
static void RenderYUV16Picture ( vout_thread_t *p_vout, picture_t *p_pic );
static void RenderYUV32Picture ( vout_thread_t *p_vout, picture_t *p_pic );
static void RenderInfo ( vout_thread_t *p_vout );
/*******************************************************************************
* vout_CreateThread: creates a new video output thread
......@@ -132,15 +177,20 @@ vout_thread_t * vout_CreateThread (
/* Initialize some fields used by the system-dependant method - these fields will
* probably be modified by the method */
p_vout->b_info = 0;
p_vout->b_grayscale = main_GetIntVariable( VOUT_GRAYSCALE_VAR,
VOUT_GRAYSCALE_DEFAULT );
p_vout->i_width = i_width;
p_vout->i_height = i_height;
p_vout->i_bytes_per_line = i_width * 2;
p_vout->i_screen_depth = 15;
p_vout->i_bytes_per_pixel = 2;
p_vout->f_x_ratio = 1;
p_vout->f_y_ratio = 1;
intf_DbgMsg("wished configuration: %dx%dx%d (%d bytes per pixel), ratio %f:%f\n",
intf_DbgMsg("wished configuration: %dx%d,%d (%d bytes/pixel, %d bytes/line), ratio %.2f:%.2f, gray=%d\n",
p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
p_vout->i_bytes_per_pixel, p_vout->f_x_ratio, p_vout->f_y_ratio );
p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
p_vout->f_x_ratio, p_vout->f_y_ratio, p_vout->b_grayscale );
/* Create and initialize system-dependant method - this function issues its
* own error messages */
......@@ -153,9 +203,10 @@ vout_thread_t * vout_CreateThread (
free( p_vout );
return( NULL );
}
intf_DbgMsg("actual configuration: %dx%dx%d (%d bytes per pixel), ratio %f:%f\n",
intf_DbgMsg("actual configuration: %dx%d,%d (%d bytes/pixel, %d bytes/line), ratio %.2f:%.2f, gray=%d\n",
p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
p_vout->i_bytes_per_pixel, p_vout->f_x_ratio, p_vout->f_y_ratio );
p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
p_vout->f_x_ratio, p_vout->f_y_ratio, p_vout->b_grayscale );
/* Terminate the initialization */
p_vout->b_die = 0;
......@@ -166,7 +217,7 @@ vout_thread_t * vout_CreateThread (
#ifdef STATS
p_vout->c_loops = 0;
p_vout->c_idle_loops = 0;
p_vout->c_pictures = 0;
p_vout->c_pictures = 0;
#endif
/* Create thread and set locks */
......@@ -237,7 +288,20 @@ void vout_DestroyThread( vout_thread_t *p_vout, int *pi_status )
*******************************************************************************/
void vout_DisplayPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
vlc_mutex_lock( &p_vout->lock );
#ifdef DEBUG_VIDEO
char psz_date[MSTRTIME_MAX_SIZE]; /* buffer for date string */
#endif
vlc_mutex_lock( &p_vout->lock );
#ifdef DEBUG_VIDEO
/* Check if picture status is valid */
if( p_pic->i_status != RESERVED_PICTURE )
{
intf_DbgMsg("error: picture %d has invalid status %d\n",
p_pic, p_pic->i_status );
}
#endif
/* Remove reservation flag */
p_pic->i_status = READY_PICTURE;
......@@ -247,6 +311,12 @@ void vout_DisplayPicture( vout_thread_t *p_vout, picture_t *p_pic )
p_vout->c_pictures++;
#endif
#ifdef DEBUG_VIDEO
/* Send picture informations */
intf_DbgMsg("picture %p: type=%d, %dx%d, date=%s\n", p_pic, p_pic->i_type,
p_pic->i_width,p_pic->i_height, mstrtime( psz_date, p_pic->date ) );
#endif
vlc_mutex_unlock( &p_vout->lock );
}
......@@ -286,6 +356,10 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
* memory allocation needs to be done */
p_vout->p_picture[i_picture].i_width = i_width;
p_vout->p_picture[i_picture].i_status = RESERVED_PICTURE;
#ifdef DEBUG_VIDEO
intf_DbgMsg("picture %p (in destroyed picture slot)\n",
&p_vout->p_picture[i_picture] );
#endif
vlc_mutex_unlock( &p_vout->lock );
return( &p_vout->p_picture[i_picture] );
}
......@@ -331,7 +405,7 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
break;
#ifdef DEBUG
default:
intf_DbgMsg("unknown picture type %d\n", i_type );
intf_DbgMsg("error: unknown picture type %d\n", i_type );
p_free_picture->p_data = NULL;
break;
#endif
......@@ -340,13 +414,13 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
if( p_free_picture->p_data != NULL )
{
/* Copy picture informations */
p_free_picture->i_type = i_type;
p_free_picture->i_status = RESERVED_PICTURE;
p_free_picture->i_width = i_width;
p_free_picture->i_height = i_height;
p_free_picture->i_bytes_per_line = i_bytes_per_line;
p_free_picture->i_refcount = 0;
p_free_picture->i_matrix_coefficients = 1; // ?? default value
p_free_picture->i_type = i_type;
p_free_picture->i_status = RESERVED_PICTURE;
p_free_picture->i_width = i_width;
p_free_picture->i_height = i_height;
p_free_picture->i_bytes_per_line = i_bytes_per_line;
p_free_picture->i_refcount = 0;
p_free_picture->i_matrix_coefficients = 1;
}
else
{
......@@ -357,18 +431,21 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
intf_ErrMsg("warning: %s\n", strerror( ENOMEM ) );
}
#ifdef DEBUG_VIDEO
intf_DbgMsg("picture %p (in free picture slot)\n", p_free_picture );
#endif
vlc_mutex_unlock( &p_vout->lock );
return( p_free_picture );
}
// No free or destroyed picture could be found
intf_DbgMsg( "heap is full\n" );
intf_DbgMsg( "warning: heap is full\n" );
vlc_mutex_unlock( &p_vout->lock );
return( NULL );
}
/*******************************************************************************
* vout_RemovePicture: remove a permanent or reserved picture from the heap
* vout_DestroyPicture: remove a permanent or reserved picture from the heap
*******************************************************************************
* This function frees a previously reserved picture or a permanent
* picture. It is meant to be used when the construction of a picture aborted.
......@@ -377,7 +454,22 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
void vout_DestroyPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
vlc_mutex_lock( &p_vout->lock );