+ if( i == PICTURE_RING_SIZE && p_dec->p_owner->p_sys->i_threads >= 1 )
+ {
+ int i_first_pic = p_dec->p_owner->p_sys->i_first_pic;
+
+ if( p_dec->p_owner->p_sys->i_first_pic !=
+ p_dec->p_owner->p_sys->i_last_pic )
+ {
+ /* Encoder still has stuff to encode, wait to clear-up the list */
+ while( p_dec->p_owner->p_sys->i_first_pic == i_first_pic )
+ msleep( 100000 );
+ }
+
+ /* Find an empty space in the picture ring buffer */
+ for( i = 0; i < PICTURE_RING_SIZE; i++ )
+ {
+ if( pp_ring[i] != 0 && pp_ring[i]->i_status == DESTROYED_PICTURE )
+ {
+ pp_ring[i]->i_status = RESERVED_PICTURE;
+ return pp_ring[i];
+ }
+ }
+ for( i = 0; i < PICTURE_RING_SIZE; i++ )
+ {
+ if( pp_ring[i] == 0 ) break;
+ }
+ }
+