@@ -149,6 +149,7 @@ decoder_resize(DECODER * dec)
149149int
150150decoder_create (xvid_dec_create_t * create )
151151{
152+ int ret = 0 ;
152153 DECODER * dec ;
153154
154155 if (XVID_VERSION_MAJOR (create -> version ) != 1 ) /* v1.x.x */
@@ -169,8 +170,8 @@ decoder_create(xvid_dec_create_t * create)
169170
170171 create -> handle = dec ;
171172
172- dec -> width = create -> width ;
173- dec -> height = create -> height ;
173+ dec -> width = MAX ( 0 , create -> width ) ;
174+ dec -> height = MAX ( 0 , create -> height ) ;
174175
175176 dec -> num_threads = MAX (0 , create -> num_threads );
176177
@@ -209,13 +210,10 @@ decoder_create(xvid_dec_create_t * create)
209210
210211 dec -> fixed_dimensions = (dec -> width > 0 && dec -> height > 0 );
211212
212- if (dec -> fixed_dimensions ) {
213- int ret = decoder_resize (dec );
214- if (ret == XVID_ERR_MEMORY ) create -> handle = NULL ;
215- return ret ;
216- }
217- else
218- return 0 ;
213+ ret = decoder_resize (dec );
214+ if (ret == XVID_ERR_MEMORY ) create -> handle = NULL ;
215+
216+ return ret ;
219217}
220218
221219
@@ -266,7 +264,7 @@ decoder_mbintra(DECODER * dec,
266264 uint32_t stride2 = stride / 2 ;
267265 uint32_t next_block = stride * 8 ;
268266 uint32_t i ;
269- uint32_t iQuant = pMB -> quant ;
267+ uint32_t iQuant = MAX ( 1 , pMB -> quant ) ;
270268 uint8_t * pY_Cur , * pU_Cur , * pV_Cur ;
271269
272270 pY_Cur = dec -> cur .y + (y_pos << 4 ) * stride + (x_pos << 4 );
@@ -363,7 +361,7 @@ decoder_mb_decode(DECODER * dec,
363361
364362 int stride = dec -> edged_width ;
365363 int i ;
366- const uint32_t iQuant = pMB -> quant ;
364+ const uint32_t iQuant = MAX ( 1 , pMB -> quant ) ;
367365 const int direction = dec -> alternate_vertical_scan ? 2 : 0 ;
368366 typedef void (* get_inter_block_function_t )(
369367 Bitstream * bs ,
@@ -1540,9 +1538,11 @@ static void decoder_output(DECODER * dec, IMAGE * img, MACROBLOCK * mbs,
15401538 img = & dec -> tmp ;
15411539 }
15421540
1543- image_output (img , dec -> width , dec -> height ,
1544- dec -> edged_width , (uint8_t * * )frame -> output .plane , frame -> output .stride ,
1545- frame -> output .csp , dec -> interlacing );
1541+ if ((frame -> output .plane [0 ] != NULL ) && (frame -> output .stride [0 ] >= dec -> width )) {
1542+ image_output (img , dec -> width , dec -> height ,
1543+ dec -> edged_width , (uint8_t * * )frame -> output .plane , frame -> output .stride ,
1544+ frame -> output .csp , dec -> interlacing );
1545+ }
15461546
15471547 if (stats ) {
15481548 stats -> type = coding2type (coding_type );
@@ -1565,19 +1565,20 @@ decoder_decode(DECODER * dec,
15651565{
15661566
15671567 Bitstream bs ;
1568- uint32_t rounding ;
1568+ uint32_t rounding = 0 ;
15691569 uint32_t quant = 2 ;
1570- uint32_t fcode_forward ;
1571- uint32_t fcode_backward ;
1572- uint32_t intra_dc_threshold ;
1570+ uint32_t fcode_forward = 0 ;
1571+ uint32_t fcode_backward = 0 ;
1572+ uint32_t intra_dc_threshold = 0 ;
15731573 WARPPOINTS gmc_warp ;
1574- int coding_type ;
1574+ int coding_type = -1 ;
15751575 int success , output , seen_something ;
15761576
15771577 if (XVID_VERSION_MAJOR (frame -> version ) != 1 || (stats && XVID_VERSION_MAJOR (stats -> version ) != 1 )) /* v1.x.x */
15781578 return XVID_ERR_VERSION ;
15791579
15801580 start_global_timer ();
1581+ memset ((void * )& gmc_warp , 0 , sizeof (WARPPOINTS ));
15811582
15821583 dec -> low_delay_default = (frame -> general & XVID_LOWDELAY );
15831584 if ((frame -> general & XVID_DISCONTINUITY ))
@@ -1664,7 +1665,7 @@ decoder_decode(DECODER * dec,
16641665 goto repeat ;
16651666 }
16661667
1667- if (dec -> frames == 0 && coding_type != I_VOP ) {
1668+ if (( dec -> frames == 0 && coding_type != I_VOP ) || (! dec -> width || ! dec -> height ) ) {
16681669 /* 1st frame is not an i-vop */
16691670 goto repeat ;
16701671 }
0 commit comments