Commit b7c5bd56 authored by Sam Hocevar's avatar Sam Hocevar

* now scaling is on by default, so that people won't tell that the vlc

    cannot do scaling :-)
  * fixed a few long lines.
  * _almost_ fixed 8bpp YUV.
parent 0615d6b6
......@@ -4,6 +4,10 @@
* new --synchro flag which lets you force which images are decoded.
* removed an unused variable in the MMX YUVs.
* fixed 32bpp MMX YUV, made the comments clearer, removed an emms.
* now scaling is on by default, so that people won't tell that the vlc
cannot do scaling :-)
* fixed a few long lines.
* _almost_ fixed 8bpp YUV.
Tue Aug 8 11:24:01 CEST 2000
0.1.99f :
......
......@@ -90,7 +90,11 @@ int yuv_CInit( vout_thread_t *p_vout )
free( p_vout->yuv.p_base );
return( 1 );
}
p_vout->yuv.p_offset = malloc( p_vout->i_width * sizeof( int ) );
/* In 8bpp we have a twice as big offset table because we also
* need the offsets for U and V (not only Y) */
p_vout->yuv.p_offset = malloc( p_vout->i_width * sizeof( int ) *
( ( p_vout->i_bytes_per_pixel == 1 ) ? 2 : 1 ) );
if( p_vout->yuv.p_offset == NULL )
{
intf_ErrMsg("error: %s\n", strerror(ENOMEM));
......@@ -451,10 +455,12 @@ void SetYUV( vout_thread_t *p_vout )
* SetOffset: build offset array for conversion functions
*****************************************************************************
* This function will build an offset array used in later conversion functions.
* It will also set horizontal and vertical scaling indicators.
* It will also set horizontal and vertical scaling indicators. If b_double
* is set, the p_offset structure has interleaved Y and U/V offsets.
*****************************************************************************/
void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height,
boolean_t *pb_h_scaling, int *pi_v_scaling, int *p_offset )
boolean_t *pb_h_scaling, int *pi_v_scaling, int *p_offset,
boolean_t b_double )
{
int i_x; /* x position in destination */
int i_scale_count; /* modulo counter */
......@@ -467,6 +473,24 @@ void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height,
/* Prepare scaling array for horizontal extension */
*pb_h_scaling = 1;
i_scale_count = i_pic_width;
if( b_double )
{
int i_dummy = 0;
for( i_x = i_width; i_x--; )
{
while( (i_scale_count -= i_width) > 0 )
{
*p_offset++ = 0;
*p_offset++ = 0;
}
*p_offset++ = 1;
*p_offset++ = i_dummy & 1;
i_dummy++;
i_scale_count += i_pic_width;
}
}
else
{
for( i_x = i_width; i_x--; )
{
while( (i_scale_count -= i_width) > 0 )
......@@ -477,11 +501,31 @@ void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height,
i_scale_count += i_pic_width;
}
}
}
else if( i_pic_width - i_width < 0 )
{
/* Prepare scaling array for horizontal reduction */
*pb_h_scaling = 1;
i_scale_count = i_pic_width;
if( b_double )
{
int i_remainder = 0;
int i_jump;
for( i_x = i_pic_width; i_x--; )
{
i_jump = 1;
while( (i_scale_count -= i_pic_width) >= 0 )
{
i_jump += 1;
}
*p_offset++ = i_jump;
*p_offset++ = ( i_jump += i_remainder ) >> 1;
i_remainder = i_jump & 1;
i_scale_count += i_width;
}
}
else
{
for( i_x = i_pic_width; i_x--; )
{
*p_offset = 1;
......@@ -493,6 +537,7 @@ void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height,
i_scale_count += i_width;
}
}
}
else
{
/* No horizontal scaling: YUV conversion is done directly to picture */
......
......@@ -53,21 +53,15 @@
#define V_GREEN_COEF ((int)(-0.813 * (1<<SHIFT) / 1.164))
/* argument lists for YUV functions */
#define YUV_ARGS_8BPP p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_y, \
yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, int i_pic_width, \
int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
#define YUV_ARGS( word_size ) p_vout_thread_t p_vout, word_size *p_pic, \
yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, \
int i_pic_width, int i_pic_height, int i_pic_line_width, \
int i_matrix_coefficients
#define YUV_ARGS_16BPP p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y, \
yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, int i_pic_width, \
int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
#define YUV_ARGS_24BPP p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, \
yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, int i_pic_width, \
int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
#define YUV_ARGS_32BPP p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, \
yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, int i_pic_width, \
int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
#define YUV_ARGS_8BPP YUV_ARGS( u8 )
#define YUV_ARGS_16BPP YUV_ARGS( u16 )
#define YUV_ARGS_24BPP YUV_ARGS( u32 )
#define YUV_ARGS_32BPP YUV_ARGS( u32 )
/*****************************************************************************
* Local prototypes
......@@ -76,7 +70,8 @@ void SetGammaTable ( int *pi_table, double f_gamma );
void SetYUV ( vout_thread_t *p_vout );
void SetOffset ( int i_width, int i_height, int i_pic_width,
int i_pic_height, boolean_t *pb_h_scaling,
int *pi_v_scaling, int *p_offset );
int *pi_v_scaling, int *p_offset,
boolean_t b_double );
void ConvertY4Gray8 ( YUV_ARGS_8BPP );
void ConvertYUV420RGB8 ( YUV_ARGS_8BPP );
......
......@@ -71,10 +71,8 @@ void ConvertY4Gray16( YUV_ARGS_16BPP )
p_buffer_start = p_vout->yuv.p_buffer;
p_offset_start = p_vout->yuv.p_offset;
SetOffset( i_width, i_height, i_pic_width, i_pic_height,
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
p_y = p_v;
i_height /= 4;
/*
* Perform conversion
*/
......@@ -135,7 +133,7 @@ void ConvertYUV420RGB16( YUV_ARGS_16BPP )
p_buffer_start = p_vout->yuv.p_buffer;
p_offset_start = p_vout->yuv.p_offset;
SetOffset( i_width, i_height, i_pic_width, i_pic_height,
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
/*
* Perform conversion
......@@ -197,7 +195,7 @@ void ConvertYUV422RGB16( YUV_ARGS_16BPP )
p_buffer_start = p_vout->yuv.p_buffer;
p_offset_start = p_vout->yuv.p_offset;
SetOffset( i_width, i_height, i_pic_width, i_pic_height,
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
/*
* Perform conversion
......@@ -258,7 +256,7 @@ void ConvertYUV444RGB16( YUV_ARGS_16BPP )
p_buffer_start = p_vout->yuv.p_buffer;
p_offset_start = p_vout->yuv.p_offset;
SetOffset( i_width, i_height, i_pic_width, i_pic_height,
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
/*
* Perform conversion
......
......@@ -71,7 +71,7 @@ void ConvertY4Gray32( YUV_ARGS_32BPP )
p_buffer_start = p_vout->yuv.p_buffer;
p_offset_start = p_vout->yuv.p_offset;
SetOffset( i_width, i_height, i_pic_width, i_pic_height,
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
/*
* Perform conversion
......@@ -133,7 +133,7 @@ void ConvertYUV420RGB32( YUV_ARGS_32BPP )
p_buffer_start = p_vout->yuv.p_buffer;
p_offset_start = p_vout->yuv.p_offset;
SetOffset( i_width, i_height, i_pic_width, i_pic_height,
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
/*
* Perform conversion
......@@ -195,7 +195,7 @@ void ConvertYUV422RGB32( YUV_ARGS_32BPP )
p_buffer_start = p_vout->yuv.p_buffer;
p_offset_start = p_vout->yuv.p_offset;
SetOffset( i_width, i_height, i_pic_width, i_pic_height,
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
/*
* Perform conversion
......@@ -256,7 +256,7 @@ void ConvertYUV444RGB32( YUV_ARGS_32BPP )
p_buffer_start = p_vout->yuv.p_buffer;
p_offset_start = p_vout->yuv.p_offset;
SetOffset( i_width, i_height, i_pic_width, i_pic_height,
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
/*
* Perform conversion
......
......@@ -72,7 +72,7 @@ void ConvertY4Gray8( YUV_ARGS_8BPP )
p_buffer_start = p_vout->yuv.p_buffer;
p_offset_start = p_vout->yuv.p_offset;
SetOffset( i_width, i_height, i_pic_width, i_pic_height,
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
/*
* Perform conversion
......@@ -114,7 +114,6 @@ void ConvertYUV420RGB8( YUV_ARGS_8BPP )
int i_vertical_scaling; /* vertical scaling type */
int i_x, i_y; /* horizontal and vertical indexes */
int i_scale_count; /* scale modulo counter */
int b_jump_uv; /* should we jump u and v ? */
int i_real_y; /* y % 4 */
u8 * p_lookup; /* lookup table */
int i_chroma_width; /* chroma width */
......@@ -122,17 +121,17 @@ void ConvertYUV420RGB8( YUV_ARGS_8BPP )
int * p_offset; /* offset array pointer */
/*
* The dither matrices
* The dithering matrices
*/
int dither10[4] = { 0x0, 0x8, 0x2, 0xa };
int dither11[4] = { 0xc, 0x4, 0xe, 0x6 };
int dither12[4] = { 0x3, 0xb, 0x1, 0x9 };
int dither13[4] = { 0xf, 0x7, 0xd, 0x5 };
static int dither10[4] = { 0x0, 0x8, 0x2, 0xa };
static int dither11[4] = { 0xc, 0x4, 0xe, 0x6 };
static int dither12[4] = { 0x3, 0xb, 0x1, 0x9 };
static int dither13[4] = { 0xf, 0x7, 0xd, 0x5 };
int dither20[4] = { 0x0, 0x10, 0x4, 0x14 };
int dither21[4] = { 0x18, 0x8, 0x1c, 0xc };
int dither22[4] = { 0x6, 0x16, 0x2, 0x12 };
int dither23[4] = { 0x1e, 0xe, 0x1a, 0xa };
static int dither20[4] = { 0x0, 0x10, 0x4, 0x14 };
static int dither21[4] = { 0x18, 0x8, 0x1c, 0xc };
static int dither22[4] = { 0x6, 0x16, 0x2, 0x12 };
static int dither23[4] = { 0x1e, 0xe, 0x1a, 0xa };
/*
* Initialize some values - i_pic_line_width will store the line skip
......@@ -142,7 +141,7 @@ void ConvertYUV420RGB8( YUV_ARGS_8BPP )
p_offset_start = p_vout->yuv.p_offset;
p_lookup = p_vout->yuv.p_base;
SetOffset( i_width, i_height, i_pic_width, i_pic_height,
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
&b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 1 );
/*
* Perform conversion
......
......@@ -54,34 +54,30 @@
( ((*p_y + dither10[i_real_y]) >> 4) << 7) \
+ ((*p_u + dither20[i_real_y]) >> 5) * 9 \
+ ((*p_v + dither20[i_real_y]) >> 5) ]; \
b_jump_uv += *p_offset; \
p_y += *p_offset; \
p_u += *p_offset & b_jump_uv; \
p_v += *p_offset++ & b_jump_uv; \
p_y += *p_offset++; \
p_u += *p_offset; \
p_v += *p_offset++; \
*p_pic++ = p_lookup[ \
( ((*p_y + dither11[i_real_y]) >> 4) << 7) \
+ ((*p_u + dither21[i_real_y]) >> 5) * 9 \
+ ((*p_v + dither21[i_real_y]) >> 5) ]; \
b_jump_uv += *p_offset; \
p_y += *p_offset; \
p_u += *p_offset & b_jump_uv; \
p_v += *p_offset++ & b_jump_uv; \
p_y += *p_offset++; \
p_u += *p_offset; \
p_v += *p_offset++; \
*p_pic++ = p_lookup[ \
( ((*p_y + dither12[i_real_y]) >> 4) << 7) \
+ ((*p_u + dither22[i_real_y]) >> 5) * 9 \
+ ((*p_v + dither22[i_real_y]) >> 5) ]; \
b_jump_uv += *p_offset; \
p_y += *p_offset; \
p_u += *p_offset & b_jump_uv; \
p_v += *p_offset++ & b_jump_uv; \
p_y += *p_offset++; \
p_u += *p_offset; \
p_v += *p_offset++; \
*p_pic++ = p_lookup[ \
( ((*p_y + dither13[i_real_y]) >> 4) << 7) \
+ ((*p_u + dither23[i_real_y]) >> 5) * 9 \
+ ((*p_v + dither23[i_real_y]) >> 5) ]; \
b_jump_uv += *p_offset; \
p_y += *p_offset; \
p_u += *p_offset & b_jump_uv; \
p_v += *p_offset++ & b_jump_uv; \
p_y += *p_offset++; \
p_u += *p_offset; \
p_v += *p_offset++; \
/*****************************************************************************
* SCALE_WIDTH_DITHER: scale a line horizontally for dithered 8 bpp
......@@ -91,9 +87,8 @@
#define SCALE_WIDTH_DITHER( CHROMA ) \
if( b_horizontal_scaling ) \
{ \
/* Horizontal scaling, but we can't use a buffer due to dither */ \
/* Horizontal scaling - we can't use a buffer due to dithering */ \
p_offset = p_offset_start; \
b_jump_uv = 0; \
for( i_x = i_pic_width / 16; i_x--; ) \
{ \
CONVERT_4YUV_PIXELS_SCALE( CHROMA ) \
......@@ -114,13 +109,15 @@
} \
/* Increment of picture pointer to end of line is still needed */ \
p_pic += i_pic_line_width; \
\
/* Increment the Y coordinate in the matrix, modulo 4 */ \
i_real_y = (i_real_y + 1) & 0x3; \
/*****************************************************************************
* SCALE_HEIGHT_DITHER: handle vertical scaling for dithered 8 bpp
*****************************************************************************
* This macro handles vertical scaling for a picture. CHROMA may be 420, 422 or
* 444 for RGB conversion, or 400 for gray conversion.
* This macro handles vertical scaling for a picture. CHROMA may be 420,
* 422 or 444 for RGB conversion, or 400 for gray conversion.
*****************************************************************************/
#define SCALE_HEIGHT_DITHER( CHROMA ) \
\
......
......@@ -312,8 +312,8 @@ void _intf_DbgMsgImm( char *psz_file, char *psz_function, int i_line,
*****************************************************************************
* Print all messages remaining in queue: get lock and call FlushLockedMsg.
* This function does nothing if the message queue isn't used.
* This function is only implemented if message queue is used. If not, it is an
* empty macro.
* This function is only implemented if message queue is used. If not, it is
* an empty macro.
*****************************************************************************/
#ifdef INTF_MSG_QUEUE
void intf_FlushMsg( void )
......@@ -339,10 +339,10 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a
char * psz_str; /* formatted message string */
intf_msg_item_t * p_msg_item; /* pointer to message */
#ifndef INTF_MSG_QUEUE /*..................................... instant mode ...*/
#ifndef INTF_MSG_QUEUE /*................................... instant mode ...*/
intf_msg_item_t msg_item; /* message */
p_msg_item = &msg_item;
#endif /*......................................................................*/
#endif /*....................................................................*/
/*
* Convert message to string
......@@ -361,7 +361,7 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a
exit( errno );
}
#ifdef INTF_MSG_QUEUE /*........................................ queue mode ...*/
#ifdef INTF_MSG_QUEUE /*...................................... queue mode ...*/
vlc_mutex_lock( &p_msg->lock ); /* get lock */
if( p_msg->i_count == INTF_MSG_QSIZE ) /* flush queue if needed */
{
......@@ -371,7 +371,7 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a
FlushLockedMsg( p_msg );
}
p_msg_item = p_msg->msg + p_msg->i_count++; /* select message */
#endif /*................................................ end of queue mode ...*/
#endif /*.............................................. end of queue mode ...*/
/*
* Fill message information fields
......@@ -379,12 +379,12 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a
p_msg_item->i_type = i_type;
p_msg_item->psz_msg = psz_str;
#ifdef INTF_MSG_QUEUE /*........................................... queue mode */
#ifdef INTF_MSG_QUEUE /*......................................... queue mode */
vlc_mutex_unlock( &p_msg->lock ); /* give lock back */
#else /*......................................................... instant mode */
#else /*....................................................... instant mode */
PrintMsg( p_msg_item ); /* print message */
free( psz_str ); /* free message data */
#endif /*......................................................................*/
#endif /*....................................................................*/
}
/*****************************************************************************
......@@ -400,10 +400,10 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function,
char * psz_str; /* formatted message string */
intf_msg_item_t * p_msg_item; /* pointer to message */
#ifndef INTF_MSG_QUEUE /*..................................... instant mode ...*/
#ifndef INTF_MSG_QUEUE /*................................... instant mode ...*/
intf_msg_item_t msg_item; /* message */
p_msg_item = &msg_item;
#endif /*......................................................................*/
#endif /*....................................................................*/
/*
* Convert message to string
......@@ -423,7 +423,7 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function,
exit( errno );
}
#ifdef INTF_MSG_QUEUE /*........................................ queue mode ...*/
#ifdef INTF_MSG_QUEUE /*...................................... queue mode ...*/
vlc_mutex_lock( &p_msg->lock ); /* get lock */
if( p_msg->i_count == INTF_MSG_QSIZE ) /* flush queue if needed */
{
......@@ -433,7 +433,7 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function,
FlushLockedMsg( p_msg );
}
p_msg_item = p_msg->msg + p_msg->i_count++; /* select message */
#endif /*................................................ end of queue mode ...*/
#endif /*.............................................. end of queue mode ...*/
/*
* Fill message information fields
......@@ -445,12 +445,12 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function,
p_msg_item->i_line = i_line;
p_msg_item->date = mdate();
#ifdef INTF_MSG_QUEUE /*........................................... queue mode */
#ifdef INTF_MSG_QUEUE /*......................................... queue mode */
vlc_mutex_unlock( &p_msg->lock ); /* give lock back */
#else /*......................................................... instant mode */
#else /*....................................................... instant mode */
PrintMsg( p_msg_item ); /* print message */
free( psz_str ); /* free message data */
#endif /*......................................................................*/
#endif /*....................................................................*/
}
#endif
......
......@@ -160,7 +160,7 @@ vout_thread_t * vout_CreateThread ( char *psz_display, int i_root_window,
VOUT_GRAYSCALE_DEFAULT );
p_vout->b_info = 0;
p_vout->b_interface = 0;
p_vout->b_scale = 0;
p_vout->b_scale = 1;
intf_DbgMsg( "wished configuration: %dx%d, %d/%d bpp (%d Bpl)\n",
p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
......@@ -1691,7 +1691,7 @@ static void RenderPictureInfo( vout_thread_t *p_vout, picture_t *p_pic )
*/
if( p_vout->c_fps_samples > VOUT_FPS_SAMPLES )
{
sprintf( psz_buffer, "%lli fps/10", VOUT_FPS_SAMPLES * 1000000 * 10 /
sprintf( psz_buffer, "%lli/10 fps", VOUT_FPS_SAMPLES * 1000000 * 10 /
( p_vout->p_fps_sample[ (p_vout->c_fps_samples - 1) % VOUT_FPS_SAMPLES ] -
p_vout->p_fps_sample[ p_vout->c_fps_samples % VOUT_FPS_SAMPLES ] ) );
Print( p_vout, 0, 0, RIGHT_RALIGN, TOP_RALIGN, psz_buffer );
......@@ -1700,7 +1700,7 @@ static void RenderPictureInfo( vout_thread_t *p_vout, picture_t *p_pic )
/*
* Print frames count and loop time in upper left corner
*/
sprintf( psz_buffer, "%ld frames rendering: %ld us",
sprintf( psz_buffer, "%ld frames, render: %ldus",
(long) p_vout->c_fps_samples, (long) p_vout->render_time );
Print( p_vout, 0, 0, LEFT_RALIGN, TOP_RALIGN, psz_buffer );
#endif
......
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