From 044909dc7ba89966d6bec1dcbafd78ea73d814da Mon Sep 17 00:00:00 2001 From: rwillenbacher Date: Mon, 15 Aug 2022 17:11:52 +0200 Subject: [PATCH] too bad, odd mb row count mpeg-2 streams were broken. --- src/y262/aboveslicelevel.c | 20 +++++++++++++++++--- src/y262/y262api.c | 4 ++-- src/y262/y262api.h | 2 +- src/y262app/main.c | 9 ++++++++- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/y262/aboveslicelevel.c b/src/y262/aboveslicelevel.c index 3bc314a..c8255cd 100644 --- a/src/y262/aboveslicelevel.c +++ b/src/y262/aboveslicelevel.c @@ -47,13 +47,27 @@ void y262_write_sequence_header( y262_t *ps_context ) { s_sequence_header.i_horizontal_size = ps_context->i_sequence_width; } - if( ( ps_context->i_sequence_height >> 4 ) == ( ( ps_context->i_sequence_display_height + 15 ) >> 4 ) ) + if( ps_context->b_progressive_sequence ) { - s_sequence_header.i_vertical_size = ps_context->i_sequence_display_height; + if( ( ps_context->i_sequence_height >> 4 ) == ( ( ps_context->i_sequence_display_height + 15 ) >> 4 ) ) + { + s_sequence_header.i_vertical_size = ps_context->i_sequence_display_height; + } + else + { + s_sequence_header.i_vertical_size = ps_context->i_sequence_height; + } } else { - s_sequence_header.i_vertical_size = ps_context->i_sequence_height; + if( ( ps_context->i_sequence_height >> 5 ) == ( ( ps_context->i_sequence_display_height + 31 ) >> 5 ) ) + { + s_sequence_header.i_vertical_size = ps_context->i_sequence_display_height; + } + else + { + s_sequence_header.i_vertical_size = ps_context->i_sequence_height; + } } s_sequence_header.i_aspect_ratio_information = ps_context->i_sequence_aspect_ratio_information; s_sequence_header.i_frame_rate_code = ps_context->i_sequence_pulldown_frame_rate_code; diff --git a/src/y262/y262api.c b/src/y262/y262api.c index f622db8..c941b14 100644 --- a/src/y262/y262api.c +++ b/src/y262/y262api.c @@ -471,7 +471,7 @@ int32_t y262_initialize( void *p_y262, y262_configuration_t *ps_config ) { return Y262_INIT_ERROR_CODED_SIZE; } - if( ( ps_config->i_coded_height & 0xf ) != 0 ) + if( ( ( ps_config->i_coded_height & 0xf ) != 0 ) || ( ps_config->b_interlaced && ( ps_config->i_coded_height & 0x1f ) != 0 ) ) { return Y262_INIT_ERROR_CODED_SIZE; } @@ -601,7 +601,7 @@ int32_t y262_initialize( void *p_y262, y262_configuration_t *ps_config ) } else { - ps_y262->b_progressive_sequence = FALSE; + ps_y262->b_progressive_sequence = !ps_config->b_interlaced; ps_y262->i_intra_dc_precision = 1; } ps_y262->b_frame_pred_frame_dct = !ps_config->b_interlaced; /* interlaced */ diff --git a/src/y262/y262api.h b/src/y262/y262api.h index 2406221..8fae203 100644 --- a/src/y262/y262api.h +++ b/src/y262/y262api.h @@ -104,7 +104,7 @@ typedef struct { int32_t i_display_width; /* display width, for example 1920 */ int32_t i_display_height; /* display height, for example 1080 */ int32_t i_coded_width; /* coded width, has to be multiple of 16, for example 1920 */ - int32_t i_coded_height; /* coded height, has to be multiple of 16, for example 1088 */ + int32_t i_coded_height; /* coded height, has to be multiple of 16, for example 1088, or multiple of 32 if b_interlaced is set */ #define Y262_CHROMA_FORMAT_420 1 #define Y262_CHROMA_FORMAT_422 2 #define Y262_CHROMA_FORMAT_444 3 diff --git a/src/y262app/main.c b/src/y262app/main.c index eb2a5aa..61ac515 100644 --- a/src/y262app/main.c +++ b/src/y262app/main.c @@ -719,7 +719,14 @@ int32_t main( int32_t i_argc, char *rgpi8_argv[] ) s_config.i_display_width = i_width; s_config.i_display_height = i_height; i_pad_x = ( ( ( i_width + 15 ) / 16 ) * 16 ) - i_width; - i_pad_y = ( ( ( i_height + 15 ) / 16 ) * 16 ) - i_height; + if( !s_config.b_interlaced ) + { + i_pad_y = ( ( ( i_height + 15 ) / 16 ) * 16 ) - i_height; + } + else + { + i_pad_y = ( ( ( i_height + 31 ) / 32 ) * 32 ) - i_height; + } s_config.i_coded_width = i_width + i_pad_x; s_config.i_coded_height = i_height + i_pad_y;