+
+/* Parse WMV3 packet and extract frame type informations */
+static void ParseWMV3( decoder_t *p_dec, block_t *p_block )
+{
+ bs_t s;
+
+ /* Parse Sequence header */
+ bs_init( &s, p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra );
+ if( bs_read( &s, 2 ) == 3 )
+ return;
+ bs_skip( &s, 22 );
+ const bool b_range_reduction = bs_read( &s, 1 );
+ const bool b_has_frames = bs_read( &s, 3 ) > 0;
+ bs_skip( &s, 2 );
+ const bool b_frame_interpolation = bs_read( &s, 1 );
+ if( bs_eof( &s ) )
+ return;
+
+ /* Parse frame type */
+ bs_init( &s, p_block->p_buffer, p_block->i_buffer );
+ bs_skip( &s, b_frame_interpolation +
+ 2 +
+ b_range_reduction );
+
+ p_block->i_flags &= ~BLOCK_FLAG_TYPE_MASK;
+ if( bs_read( &s, 1 ) )
+ p_block->i_flags |= BLOCK_FLAG_TYPE_P;
+ else if( !b_has_frames || bs_read( &s, 1 ) )
+ p_block->i_flags |= BLOCK_FLAG_TYPE_I;
+ else
+ p_block->i_flags |= BLOCK_FLAG_TYPE_B;
+}
+