+ 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) )
+ {
+ slice.i_delta_pic_order_cnt0 = bs_read_se( &s );
+ if( p_sys->i_pic_order_present_flag && !slice.i_field_pic_flag )
+ slice.i_delta_pic_order_cnt1 = bs_read_se( &s );
+ }
+ free( pb_dec );
+
+ /* Detection of the first VCL NAL unit of a primary coded picture
+ * (cf. 7.4.1.2.4) */
+ bool b_pic = false;
+ if( slice.i_frame_num != p_sys->slice.i_frame_num ||
+ slice.i_pic_parameter_set_id != p_sys->slice.i_pic_parameter_set_id ||
+ slice.i_field_pic_flag != p_sys->slice.i_field_pic_flag ||
+ slice.i_nal_ref_idc != p_sys->slice.i_nal_ref_idc )
+ b_pic = true;
+ if( (slice.i_bottom_field_flag != -1) &&
+ (p_sys->slice.i_bottom_field_flag != -1) &&
+ (slice.i_bottom_field_flag != p_sys->slice.i_bottom_field_flag) )
+ b_pic = true;
+ if( p_sys->i_pic_order_cnt_type == 0 &&
+ ( slice.i_pic_order_cnt_lsb != p_sys->slice.i_pic_order_cnt_lsb ||
+ slice.i_delta_pic_order_cnt_bottom != p_sys->slice.i_delta_pic_order_cnt_bottom ) )
+ b_pic = true;
+ else if( p_sys->i_pic_order_cnt_type == 1 &&
+ ( slice.i_delta_pic_order_cnt0 != p_sys->slice.i_delta_pic_order_cnt0 ||
+ slice.i_delta_pic_order_cnt1 != p_sys->slice.i_delta_pic_order_cnt1 ) )
+ b_pic = true;
+ if( ( slice.i_nal_type == NAL_SLICE_IDR || p_sys->slice.i_nal_type == NAL_SLICE_IDR ) &&
+ ( slice.i_nal_type != p_sys->slice.i_nal_type || slice.i_idr_pic_id != p_sys->slice.i_idr_pic_id ) )
+ b_pic = true;
+
+ /* */
+ *pb_new_picture = b_pic;
+ *p_slice = slice;
+}