Commit e16affa0 authored by Sam Hocevar's avatar Sam Hocevar

* fixed 8bpp YUV.

  * fixed the fscked up Bresenham algorithm in all YUV functions.
parent b7c5bd56
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
* now scaling is on by default, so that people won't tell that the vlc * now scaling is on by default, so that people won't tell that the vlc
cannot do scaling :-) cannot do scaling :-)
* fixed a few long lines. * fixed a few long lines.
* _almost_ fixed 8bpp YUV. * fixed 8bpp YUV.
* fixed the fscked up Bresenham algorithm in all YUV functions.
Tue Aug 8 11:24:01 CEST 2000 Tue Aug 8 11:24:01 CEST 2000
0.1.99f : 0.1.99f :
......
...@@ -110,7 +110,7 @@ Urgency: Important ...@@ -110,7 +110,7 @@ Urgency: Important
Description: Fix 8bpp YUV Description: Fix 8bpp YUV
The 8bpp YUV function is broken, there is some serious The 8bpp YUV function is broken, there is some serious
alpha blending, and it scales pretty badly. Fix it. alpha blending, and it scales pretty badly. Fix it.
Status: Todo Status: Done 14 Aug 2000 (sam)
Task: 0x15 Task: 0x15
Difficulty: Medium Difficulty: Medium
......
...@@ -468,53 +468,71 @@ void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height, ...@@ -468,53 +468,71 @@ void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height,
/* /*
* Prepare horizontal offset array * Prepare horizontal offset array
*/ */
if( i_pic_width - i_width > 0 ) if( i_pic_width - i_width == 0 )
{
/* No horizontal scaling: YUV conversion is done directly to picture */
*pb_h_scaling = 0;
}
else if( i_pic_width - i_width > 0 )
{ {
/* Prepare scaling array for horizontal extension */ /* Prepare scaling array for horizontal extension */
*pb_h_scaling = 1; *pb_h_scaling = 1;
i_scale_count = i_pic_width; i_scale_count = i_pic_width;
if( b_double ) if( !b_double )
{ {
int i_dummy = 0;
for( i_x = i_width; i_x--; ) for( i_x = i_width; i_x--; )
{ {
while( (i_scale_count -= i_width) > 0 ) while( (i_scale_count -= i_width) > 0 )
{ {
*p_offset++ = 0; *p_offset++ = 0;
*p_offset++ = 0;
} }
*p_offset++ = 1; *p_offset++ = 1;
*p_offset++ = i_dummy & 1;
i_dummy++;
i_scale_count += i_pic_width; i_scale_count += i_pic_width;
} }
} }
else else
{ {
int i_dummy = 0;
for( i_x = i_width; i_x--; ) for( i_x = i_width; i_x--; )
{ {
while( (i_scale_count -= i_width) > 0 ) while( (i_scale_count -= i_width) > 0 )
{ {
*p_offset++ = 0; *p_offset++ = 0;
*p_offset++ = 0;
} }
*p_offset++ = 1; *p_offset++ = 1;
*p_offset++ = i_dummy;
i_dummy = 1 - i_dummy;
i_scale_count += i_pic_width; i_scale_count += i_pic_width;
} }
} }
} }
else if( i_pic_width - i_width < 0 ) else /* if( i_pic_width - i_width < 0 ) */
{ {
/* Prepare scaling array for horizontal reduction */ /* Prepare scaling array for horizontal reduction */
*pb_h_scaling = 1; *pb_h_scaling = 1;
i_scale_count = i_pic_width; i_scale_count = i_width;
if( b_double ) if( !b_double )
{
for( i_x = i_pic_width; i_x--; )
{
*p_offset = 1;
while( (i_scale_count -= i_pic_width) > 0 )
{
*p_offset += 1;
}
p_offset++;
i_scale_count += i_width;
}
}
else
{ {
int i_remainder = 0; int i_remainder = 0;
int i_jump; int i_jump;
for( i_x = i_pic_width; i_x--; ) for( i_x = i_pic_width; i_x--; )
{ {
i_jump = 1; i_jump = 1;
while( (i_scale_count -= i_pic_width) >= 0 ) while( (i_scale_count -= i_pic_width) > 0 )
{ {
i_jump += 1; i_jump += 1;
} }
...@@ -523,41 +541,23 @@ void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height, ...@@ -523,41 +541,23 @@ void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height,
i_remainder = i_jump & 1; i_remainder = i_jump & 1;
i_scale_count += i_width; i_scale_count += i_width;
} }
}
else
{
for( i_x = i_pic_width; i_x--; )
{
*p_offset = 1;
while( (i_scale_count -= i_pic_width) >= 0 )
{
*p_offset += 1;
}
p_offset++;
i_scale_count += i_width;
}
} }
} }
else
{
/* No horizontal scaling: YUV conversion is done directly to picture */
*pb_h_scaling = 0;
}
/* /*
* Set vertical scaling indicator * Set vertical scaling indicator
*/ */
if( i_pic_height - i_height > 0 ) if( i_pic_height - i_height == 0 )
{ {
*pi_v_scaling = 1; *pi_v_scaling = 0;
} }
else if( i_pic_height - i_height < 0 ) else if( i_pic_height - i_height > 0 )
{ {
*pi_v_scaling = -1; *pi_v_scaling = 1;
} }
else else /* if( i_pic_height - i_height < 0 ) */
{ {
*pi_v_scaling = 0; *pi_v_scaling = -1;
} }
} }
...@@ -76,7 +76,7 @@ void ConvertY4Gray16( YUV_ARGS_16BPP ) ...@@ -76,7 +76,7 @@ void ConvertY4Gray16( YUV_ARGS_16BPP )
/* /*
* Perform conversion * Perform conversion
*/ */
i_scale_count = i_pic_height; i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
for( i_y = 0; i_y < i_height; i_y++ ) for( i_y = 0; i_y < i_height; i_y++ )
{ {
/* Mark beginnning of line for possible later line copy, and initialize /* Mark beginnning of line for possible later line copy, and initialize
...@@ -138,7 +138,7 @@ void ConvertYUV420RGB16( YUV_ARGS_16BPP ) ...@@ -138,7 +138,7 @@ void ConvertYUV420RGB16( YUV_ARGS_16BPP )
/* /*
* Perform conversion * Perform conversion
*/ */
i_scale_count = i_pic_height; i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
for( i_y = 0; i_y < i_height; i_y++ ) for( i_y = 0; i_y < i_height; i_y++ )
{ {
/* Mark beginnning of line for possible later line copy, and initialize /* Mark beginnning of line for possible later line copy, and initialize
...@@ -200,7 +200,7 @@ void ConvertYUV422RGB16( YUV_ARGS_16BPP ) ...@@ -200,7 +200,7 @@ void ConvertYUV422RGB16( YUV_ARGS_16BPP )
/* /*
* Perform conversion * Perform conversion
*/ */
i_scale_count = i_pic_height; i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
for( i_y = 0; i_y < i_height; i_y++ ) for( i_y = 0; i_y < i_height; i_y++ )
{ {
/* Mark beginnning of line for possible later line copy, and initialize /* Mark beginnning of line for possible later line copy, and initialize
...@@ -261,7 +261,7 @@ void ConvertYUV444RGB16( YUV_ARGS_16BPP ) ...@@ -261,7 +261,7 @@ void ConvertYUV444RGB16( YUV_ARGS_16BPP )
/* /*
* Perform conversion * Perform conversion
*/ */
i_scale_count = i_pic_height; i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
for( i_y = 0; i_y < i_height; i_y++ ) for( i_y = 0; i_y < i_height; i_y++ )
{ {
/* Mark beginnning of line for possible later line copy, and initialize /* Mark beginnning of line for possible later line copy, and initialize
......
...@@ -76,7 +76,7 @@ void ConvertY4Gray32( YUV_ARGS_32BPP ) ...@@ -76,7 +76,7 @@ void ConvertY4Gray32( YUV_ARGS_32BPP )
/* /*
* Perform conversion * Perform conversion
*/ */
i_scale_count = i_pic_height; i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
for( i_y = 0; i_y < i_height; i_y++ ) for( i_y = 0; i_y < i_height; i_y++ )
{ {
/* Mark beginnning of line for possible later line copy, and initialize /* Mark beginnning of line for possible later line copy, and initialize
...@@ -138,7 +138,7 @@ void ConvertYUV420RGB32( YUV_ARGS_32BPP ) ...@@ -138,7 +138,7 @@ void ConvertYUV420RGB32( YUV_ARGS_32BPP )
/* /*
* Perform conversion * Perform conversion
*/ */
i_scale_count = i_pic_height; i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
for( i_y = 0; i_y < i_height; i_y++ ) for( i_y = 0; i_y < i_height; i_y++ )
{ {
/* Mark beginnning of line for possible later line copy, and initialize /* Mark beginnning of line for possible later line copy, and initialize
...@@ -200,7 +200,7 @@ void ConvertYUV422RGB32( YUV_ARGS_32BPP ) ...@@ -200,7 +200,7 @@ void ConvertYUV422RGB32( YUV_ARGS_32BPP )
/* /*
* Perform conversion * Perform conversion
*/ */
i_scale_count = i_pic_height; i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
for( i_y = 0; i_y < i_height; i_y++ ) for( i_y = 0; i_y < i_height; i_y++ )
{ {
/* Mark beginnning of line for possible later line copy, and initialize /* Mark beginnning of line for possible later line copy, and initialize
...@@ -261,7 +261,7 @@ void ConvertYUV444RGB32( YUV_ARGS_32BPP ) ...@@ -261,7 +261,7 @@ void ConvertYUV444RGB32( YUV_ARGS_32BPP )
/* /*
* Perform conversion * Perform conversion
*/ */
i_scale_count = i_pic_height; i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
for( i_y = 0; i_y < i_height; i_y++ ) for( i_y = 0; i_y < i_height; i_y++ )
{ {
/* Mark beginnning of line for possible later line copy, and initialize /* Mark beginnning of line for possible later line copy, and initialize
......
...@@ -77,7 +77,7 @@ void ConvertY4Gray8( YUV_ARGS_8BPP ) ...@@ -77,7 +77,7 @@ void ConvertY4Gray8( YUV_ARGS_8BPP )
/* /*
* Perform conversion * Perform conversion
*/ */
i_scale_count = i_pic_height; i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
for( i_y = 0; i_y < i_height; i_y++ ) for( i_y = 0; i_y < i_height; i_y++ )
{ {
/* Mark beginnning of line for possible later line copy, and initialize /* Mark beginnning of line for possible later line copy, and initialize
...@@ -146,7 +146,7 @@ void ConvertYUV420RGB8( YUV_ARGS_8BPP ) ...@@ -146,7 +146,7 @@ void ConvertYUV420RGB8( YUV_ARGS_8BPP )
/* /*
* Perform conversion * Perform conversion
*/ */
i_scale_count = i_pic_height; i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
i_real_y = 0; i_real_y = 0;
for( i_y = 0; i_y < i_height; i_y++ ) for( i_y = 0; i_y < i_height; i_y++ )
{ {
......
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
switch( i_vertical_scaling ) \ switch( i_vertical_scaling ) \
{ \ { \
case -1: /* vertical scaling factor is < 1 */ \ case -1: /* vertical scaling factor is < 1 */ \
while( (i_scale_count -= i_pic_height) >= 0 ) \ while( (i_scale_count -= i_pic_height) > 0 ) \
{ \ { \
/* Height reduction: skip next source line */ \ /* Height reduction: skip next source line */ \
p_y += i_width; \ p_y += i_width; \
......
...@@ -136,7 +136,7 @@ ...@@ -136,7 +136,7 @@
switch( i_vertical_scaling ) \ switch( i_vertical_scaling ) \
{ \ { \
case -1: /* vertical scaling factor is < 1 */ \ case -1: /* vertical scaling factor is < 1 */ \
while( (i_scale_count -= i_pic_height) >= 0 ) \ while( (i_scale_count -= i_pic_height) > 0 ) \
{ \ { \
/* Height reduction: skip next source line */ \ /* Height reduction: skip next source line */ \
p_y += i_width; \ p_y += i_width; \
...@@ -160,11 +160,10 @@ ...@@ -160,11 +160,10 @@
case 1: /* vertical scaling factor is > 1 */ \ case 1: /* vertical scaling factor is > 1 */ \
while( (i_scale_count -= i_height) > 0 ) \ while( (i_scale_count -= i_height) > 0 ) \
{ \ { \
SCALE_WIDTH_DITHER( CHROMA ); \
p_y -= i_width; \ p_y -= i_width; \
p_u -= i_chroma_width; \ p_u -= i_chroma_width; \
p_v -= i_chroma_width; \ p_v -= i_chroma_width; \
p_pic += i_pic_line_width; \ SCALE_WIDTH_DITHER( CHROMA ); \
} \ } \
i_scale_count += i_pic_height; \ i_scale_count += i_pic_height; \
break; \ break; \
......
...@@ -352,11 +352,16 @@ void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height, ...@@ -352,11 +352,16 @@ void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height,
/* /*
* Prepare horizontal offset array * Prepare horizontal offset array
*/ */
if( i_pic_width - i_width > 0 ) if( i_pic_width - i_width == 0 )
{
/* No horizontal scaling: YUV conversion is done directly to picture */
*pb_h_scaling = 0;
}
else if( i_pic_width - i_width > 0 )
{ {
/* Prepare scaling array for horizontal extension */ /* Prepare scaling array for horizontal extension */
*pb_h_scaling = 1; *pb_h_scaling = 1;
i_scale_count = i_pic_width; i_scale_count = i_pic_width;
for( i_x = i_width; i_x--; ) for( i_x = i_width; i_x--; )
{ {
while( (i_scale_count -= i_width) > 0 ) while( (i_scale_count -= i_width) > 0 )
...@@ -367,15 +372,15 @@ void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height, ...@@ -367,15 +372,15 @@ void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height,
i_scale_count += i_pic_width; i_scale_count += i_pic_width;
} }
} }
else if( i_pic_width - i_width < 0 ) else /* if( i_pic_width - i_width < 0 ) */
{ {
/* Prepare scaling array for horizontal reduction */ /* Prepare scaling array for horizontal reduction */
*pb_h_scaling = 1; *pb_h_scaling = 1;
i_scale_count = i_pic_width; i_scale_count = i_width;
for( i_x = i_pic_width; i_x--; ) for( i_x = i_pic_width; i_x--; )
{ {
*p_offset = 1; *p_offset = 1;
while( (i_scale_count -= i_pic_width) >= 0 ) while( (i_scale_count -= i_pic_width) > 0 )
{ {
*p_offset += 1; *p_offset += 1;
} }
...@@ -383,26 +388,21 @@ void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height, ...@@ -383,26 +388,21 @@ void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height,
i_scale_count += i_width; i_scale_count += i_width;
} }
} }
else
{
/* No horizontal scaling: YUV conversion is done directly to picture */
*pb_h_scaling = 0;
}
/* /*
* Set vertical scaling indicator * Set vertical scaling indicator
*/ */
if( i_pic_height - i_height > 0 ) if( i_pic_height - i_height == 0 )
{ {
*pi_v_scaling = 1; *pi_v_scaling = 0;
} }
else if( i_pic_height - i_height < 0 ) else if( i_pic_height - i_height > 0 )
{ {
*pi_v_scaling = -1; *pi_v_scaling = 1;
} }
else else /* if( i_pic_height - i_height < 0 ) */
{ {
*pi_v_scaling = 0; *pi_v_scaling = -1;
} }
} }
...@@ -84,7 +84,7 @@ void ConvertYUV420RGB16( YUV_ARGS_16BPP ) ...@@ -84,7 +84,7 @@ void ConvertYUV420RGB16( YUV_ARGS_16BPP )
/* /*
* Perform conversion * Perform conversion
*/ */
i_scale_count = i_pic_height; i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
for( i_y = 0; i_y < i_height; i_y++ ) for( i_y = 0; i_y < i_height; i_y++ )
{ {
/* Mark beginnning of line for possible later line copy, and initialize /* Mark beginnning of line for possible later line copy, and initialize
......
...@@ -84,7 +84,7 @@ void ConvertYUV420RGB32( YUV_ARGS_32BPP ) ...@@ -84,7 +84,7 @@ void ConvertYUV420RGB32( YUV_ARGS_32BPP )
/* /*
* Perform conversion * Perform conversion
*/ */
i_scale_count = i_pic_height; i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
for( i_y = 0; i_y < i_height; i_y++ ) for( i_y = 0; i_y < i_height; i_y++ )
{ {
/* Mark beginnning of line for possible later line copy, and initialize /* Mark beginnning of line for possible later line copy, and initialize
......
...@@ -160,21 +160,28 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar, ...@@ -160,21 +160,28 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
#if 1 #if 1
if( p_vpar->synchro.b_all_I ) if( p_vpar->synchro.b_all_I )
intf_ErrMsg( " I: 1024/1024 " ); intf_ErrMsg( " I: 1024/1024 " );
if( p_vpar->synchro.b_all_P ) if( p_vpar->synchro.b_all_P )
intf_ErrMsg( "P: %i/%i ", p_vpar->synchro.i_P_seen, intf_ErrMsg( "P: %i/%i ", p_vpar->synchro.i_P_seen,
p_vpar->synchro.i_P_seen ); p_vpar->synchro.i_P_seen );
else if( p_vpar->synchro.displayable_p > 0 ) else if( p_vpar->synchro.displayable_p > 0 )
intf_ErrMsg( "P: %i/%i ", p_vpar->synchro.displayable_p, intf_ErrMsg( "P: %i/%i ", p_vpar->synchro.displayable_p,
p_vpar->synchro.i_P_seen ); p_vpar->synchro.i_P_seen );
else
intf_ErrMsg( " " );
if( p_vpar->synchro.b_all_B ) if( p_vpar->synchro.b_all_B )
intf_ErrMsg( "B: %i/%i", p_vpar->synchro.i_B_seen, intf_ErrMsg( "B: %i/%i", p_vpar->synchro.i_B_seen,
p_vpar->synchro.i_B_seen ); p_vpar->synchro.i_B_seen );
else if( p_vpar->synchro.displayable_b > 0 ) else if( p_vpar->synchro.displayable_b > 0 )
intf_ErrMsg( "B: %i/%i", p_vpar->synchro.displayable_b, intf_ErrMsg( "B: %i/%i", p_vpar->synchro.displayable_b,
p_vpar->synchro.i_B_seen ); p_vpar->synchro.i_B_seen );
// intf_ErrMsg( " " ); else
intf_ErrMsg( "\n" ); intf_ErrMsg( " " );
intf_ErrMsg( " Decoding: " );
/*intf_ErrMsg( "\n" );*/
#endif #endif
p_vpar->synchro.i_P_seen = 0; p_vpar->synchro.i_P_seen = 0;
p_vpar->synchro.i_B_seen = 0; p_vpar->synchro.i_B_seen = 0;
......
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