+ /* first_mb_in_slice */
+ i_first_mb = bs_read_ue( &s );
+
+ /* slice_type */
+ switch( (i_slice_type = bs_read_ue( &s )) )
+ {
+ case 0: case 5:
+ slice.i_frame_type = BLOCK_FLAG_TYPE_P;
+ break;
+ case 1: case 6:
+ slice.i_frame_type = BLOCK_FLAG_TYPE_B;
+ break;
+ case 2: case 7:
+ slice.i_frame_type = BLOCK_FLAG_TYPE_I;
+ break;
+ case 3: case 8: /* SP */
+ slice.i_frame_type = BLOCK_FLAG_TYPE_P;
+ break;
+ case 4: case 9:
+ slice.i_frame_type = BLOCK_FLAG_TYPE_I;
+ break;
+ default:
+ slice.i_frame_type = 0;
+ break;
+ }
+
+ /* */
+ slice.i_nal_type = i_nal_type;
+ slice.i_nal_ref_idc = i_nal_ref_idc;
+
+ slice.i_pic_parameter_set_id = bs_read_ue( &s );
+ slice.i_frame_num = bs_read( &s, p_sys->i_log2_max_frame_num + 4 );
+
+ slice.i_field_pic_flag = 0;
+ slice.i_bottom_field_flag = -1;
+ if( !p_sys->b_frame_mbs_only )
+ {
+ /* field_pic_flag */
+ slice.i_field_pic_flag = bs_read( &s, 1 );
+ if( slice.i_field_pic_flag )
+ slice.i_bottom_field_flag = bs_read( &s, 1 );
+ }
+
+ slice.i_idr_pic_id = p_sys->slice.i_idr_pic_id;
+ if( slice.i_nal_type == NAL_SLICE_IDR )
+ slice.i_idr_pic_id = bs_read_ue( &s );
+
+ slice.i_pic_order_cnt_lsb = -1;
+ slice.i_delta_pic_order_cnt_bottom = -1;
+ slice.i_delta_pic_order_cnt0 = 0;
+ slice.i_delta_pic_order_cnt1 = 0;
+ if( p_sys->i_pic_order_cnt_type == 0 )
+ {
+ slice.i_pic_order_cnt_lsb = bs_read( &s, p_sys->i_log2_max_pic_order_cnt_lsb + 4 );
+ if( p_sys->i_pic_order_present_flag && !slice.i_field_pic_flag )
+ slice.i_delta_pic_order_cnt_bottom = bs_read_se( &s );
+ }
+ else if( p_sys->i_pic_order_cnt_type == 1 && !p_sys->i_delta_pic_order_always_zero_flag )