From e16affa0e0a6cd6797d4411a03debd19cc4d26b0 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 14 Aug 2000 01:13:25 +0000 Subject: [PATCH] * fixed 8bpp YUV. * fixed the fscked up Bresenham algorithm in all YUV functions. --- ChangeLog | 3 +- TODO | 2 +- plugins/yuv/video_yuv.c | 72 ++++++++++++++--------------- plugins/yuv/video_yuv16.c | 8 ++-- plugins/yuv/video_yuv32.c | 8 ++-- plugins/yuv/video_yuv8.c | 4 +- plugins/yuv/video_yuv_macros.h | 2 +- plugins/yuv/video_yuv_macros_8bpp.h | 5 +- plugins/yuvmmx/video_yuv.c | 32 ++++++------- plugins/yuvmmx/video_yuv16.c | 2 +- plugins/yuvmmx/video_yuv32.c | 2 +- src/video_parser/vpar_synchro.c | 13 ++++-- 12 files changed, 80 insertions(+), 73 deletions(-) diff --git a/ChangeLog b/ChangeLog index 820f727714..e4e6f5633f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,8 @@ * 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. + * fixed 8bpp YUV. + * fixed the fscked up Bresenham algorithm in all YUV functions. Tue Aug 8 11:24:01 CEST 2000 0.1.99f : diff --git a/TODO b/TODO index 7bfedaed83..d0d660d1f8 100644 --- a/TODO +++ b/TODO @@ -110,7 +110,7 @@ Urgency: Important Description: Fix 8bpp YUV The 8bpp YUV function is broken, there is some serious alpha blending, and it scales pretty badly. Fix it. -Status: Todo +Status: Done 14 Aug 2000 (sam) Task: 0x15 Difficulty: Medium diff --git a/plugins/yuv/video_yuv.c b/plugins/yuv/video_yuv.c index 1826a11ea5..6a73bed6b4 100644 --- a/plugins/yuv/video_yuv.c +++ b/plugins/yuv/video_yuv.c @@ -468,53 +468,71 @@ void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height, /* * 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 */ *pb_h_scaling = 1; i_scale_count = i_pic_width; - if( b_double ) + 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 { + 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; + i_dummy = 1 - i_dummy; 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 */ - *pb_h_scaling = 1; - i_scale_count = i_pic_width; - if( b_double ) + *pb_h_scaling = 1; + i_scale_count = i_width; + 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_jump; for( i_x = i_pic_width; i_x--; ) { i_jump = 1; - while( (i_scale_count -= i_pic_width) >= 0 ) + while( (i_scale_count -= i_pic_width) > 0 ) { i_jump += 1; } @@ -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_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 */ - 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; } } diff --git a/plugins/yuv/video_yuv16.c b/plugins/yuv/video_yuv16.c index 747415a8fa..eafb631b89 100644 --- a/plugins/yuv/video_yuv16.c +++ b/plugins/yuv/video_yuv16.c @@ -76,7 +76,7 @@ void ConvertY4Gray16( YUV_ARGS_16BPP ) /* * 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++ ) { /* Mark beginnning of line for possible later line copy, and initialize @@ -138,7 +138,7 @@ void ConvertYUV420RGB16( YUV_ARGS_16BPP ) /* * 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++ ) { /* Mark beginnning of line for possible later line copy, and initialize @@ -200,7 +200,7 @@ void ConvertYUV422RGB16( YUV_ARGS_16BPP ) /* * 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++ ) { /* Mark beginnning of line for possible later line copy, and initialize @@ -261,7 +261,7 @@ void ConvertYUV444RGB16( YUV_ARGS_16BPP ) /* * 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++ ) { /* Mark beginnning of line for possible later line copy, and initialize diff --git a/plugins/yuv/video_yuv32.c b/plugins/yuv/video_yuv32.c index 827b6ee359..02c717f396 100644 --- a/plugins/yuv/video_yuv32.c +++ b/plugins/yuv/video_yuv32.c @@ -76,7 +76,7 @@ void ConvertY4Gray32( YUV_ARGS_32BPP ) /* * 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++ ) { /* Mark beginnning of line for possible later line copy, and initialize @@ -138,7 +138,7 @@ void ConvertYUV420RGB32( YUV_ARGS_32BPP ) /* * 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++ ) { /* Mark beginnning of line for possible later line copy, and initialize @@ -200,7 +200,7 @@ void ConvertYUV422RGB32( YUV_ARGS_32BPP ) /* * 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++ ) { /* Mark beginnning of line for possible later line copy, and initialize @@ -261,7 +261,7 @@ void ConvertYUV444RGB32( YUV_ARGS_32BPP ) /* * 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++ ) { /* Mark beginnning of line for possible later line copy, and initialize diff --git a/plugins/yuv/video_yuv8.c b/plugins/yuv/video_yuv8.c index 5650dd2947..c386148676 100644 --- a/plugins/yuv/video_yuv8.c +++ b/plugins/yuv/video_yuv8.c @@ -77,7 +77,7 @@ void ConvertY4Gray8( YUV_ARGS_8BPP ) /* * 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++ ) { /* Mark beginnning of line for possible later line copy, and initialize @@ -146,7 +146,7 @@ void ConvertYUV420RGB8( YUV_ARGS_8BPP ) /* * Perform conversion */ - i_scale_count = i_pic_height; + i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height; i_real_y = 0; for( i_y = 0; i_y < i_height; i_y++ ) { diff --git a/plugins/yuv/video_yuv_macros.h b/plugins/yuv/video_yuv_macros.h index d054adbf32..0aab9dde0c 100644 --- a/plugins/yuv/video_yuv_macros.h +++ b/plugins/yuv/video_yuv_macros.h @@ -107,7 +107,7 @@ switch( i_vertical_scaling ) \ { \ 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 */ \ p_y += i_width; \ diff --git a/plugins/yuv/video_yuv_macros_8bpp.h b/plugins/yuv/video_yuv_macros_8bpp.h index 2209d075ae..76ce3fd77f 100644 --- a/plugins/yuv/video_yuv_macros_8bpp.h +++ b/plugins/yuv/video_yuv_macros_8bpp.h @@ -136,7 +136,7 @@ switch( i_vertical_scaling ) \ { \ 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 */ \ p_y += i_width; \ @@ -160,11 +160,10 @@ case 1: /* vertical scaling factor is > 1 */ \ while( (i_scale_count -= i_height) > 0 ) \ { \ - SCALE_WIDTH_DITHER( CHROMA ); \ p_y -= i_width; \ p_u -= i_chroma_width; \ p_v -= i_chroma_width; \ - p_pic += i_pic_line_width; \ + SCALE_WIDTH_DITHER( CHROMA ); \ } \ i_scale_count += i_pic_height; \ break; \ diff --git a/plugins/yuvmmx/video_yuv.c b/plugins/yuvmmx/video_yuv.c index b59f6a047a..13125032c6 100644 --- a/plugins/yuvmmx/video_yuv.c +++ b/plugins/yuvmmx/video_yuv.c @@ -352,11 +352,16 @@ void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height, /* * 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 */ *pb_h_scaling = 1; - i_scale_count = i_pic_width; + i_scale_count = i_pic_width; for( i_x = i_width; i_x--; ) { 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, 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 */ *pb_h_scaling = 1; - i_scale_count = i_pic_width; + i_scale_count = i_width; for( i_x = i_pic_width; i_x--; ) { *p_offset = 1; - while( (i_scale_count -= i_pic_width) >= 0 ) + while( (i_scale_count -= i_pic_width) > 0 ) { *p_offset += 1; } @@ -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; } } - else - { - /* No horizontal scaling: YUV conversion is done directly to picture */ - *pb_h_scaling = 0; - } /* * 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; } } diff --git a/plugins/yuvmmx/video_yuv16.c b/plugins/yuvmmx/video_yuv16.c index 1864532004..b13e636b90 100644 --- a/plugins/yuvmmx/video_yuv16.c +++ b/plugins/yuvmmx/video_yuv16.c @@ -84,7 +84,7 @@ void ConvertYUV420RGB16( YUV_ARGS_16BPP ) /* * 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++ ) { /* Mark beginnning of line for possible later line copy, and initialize diff --git a/plugins/yuvmmx/video_yuv32.c b/plugins/yuvmmx/video_yuv32.c index 796733787c..adb3ace1cd 100644 --- a/plugins/yuvmmx/video_yuv32.c +++ b/plugins/yuvmmx/video_yuv32.c @@ -84,7 +84,7 @@ void ConvertYUV420RGB32( YUV_ARGS_32BPP ) /* * 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++ ) { /* Mark beginnning of line for possible later line copy, and initialize diff --git a/src/video_parser/vpar_synchro.c b/src/video_parser/vpar_synchro.c index 998ee3f51c..81113e5c40 100644 --- a/src/video_parser/vpar_synchro.c +++ b/src/video_parser/vpar_synchro.c @@ -160,21 +160,28 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar, #if 1 if( p_vpar->synchro.b_all_I ) - intf_ErrMsg( " I: 1024/1024 " ); + intf_ErrMsg( " I: 1024/1024 " ); + if( p_vpar->synchro.b_all_P ) intf_ErrMsg( "P: %i/%i ", p_vpar->synchro.i_P_seen, p_vpar->synchro.i_P_seen ); else if( p_vpar->synchro.displayable_p > 0 ) intf_ErrMsg( "P: %i/%i ", p_vpar->synchro.displayable_p, p_vpar->synchro.i_P_seen ); + else + intf_ErrMsg( " " ); + if( p_vpar->synchro.b_all_B ) intf_ErrMsg( "B: %i/%i", p_vpar->synchro.i_B_seen, p_vpar->synchro.i_B_seen ); else if( p_vpar->synchro.displayable_b > 0 ) intf_ErrMsg( "B: %i/%i", p_vpar->synchro.displayable_b, p_vpar->synchro.i_B_seen ); -// intf_ErrMsg( " " ); - intf_ErrMsg( "\n" ); + else + intf_ErrMsg( " " ); + + intf_ErrMsg( " Decoding: " ); + /*intf_ErrMsg( "\n" );*/ #endif p_vpar->synchro.i_P_seen = 0; p_vpar->synchro.i_B_seen = 0; -- 2.39.5