From 6b56c84c9b69b9ca4c2cd2534f0c850e56f5e06e Mon Sep 17 00:00:00 2001 From: Wind Yuan Date: Wed, 29 Feb 2012 03:08:46 -0500 Subject: h264: fix modification process of reference picture lists. Construction of RefPicList0/1 could be off by one element. Signed-off-by: Gwenole Beauchesne --- gst-libs/gst/vaapi/gstvaapidecoder_h264.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'gst-libs/gst') diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c index 0746c28e..a8a4bc0d 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c @@ -1396,14 +1396,18 @@ exec_picture_refs_modification_1( if (picNum > CurrPicNum) picNum -= MaxPicNum; + // (8-37) for (j = num_refs; j > ref_list_idx; j--) ref_list[j] = ref_list[j - 1]; found_ref_idx = find_short_term_reference(decoder, picNum); ref_list[ref_list_idx++] = found_ref_idx >= 0 ? priv->short_ref[found_ref_idx] : NULL; n = ref_list_idx; - for (j = ref_list_idx; j < num_refs; j++) { - const gint32 PicNumF = ref_list[j]->is_long_term ? + for (j = ref_list_idx; j <= num_refs; j++) { + gint32 PicNumF; + if (!ref_list[j]) + continue; + PicNumF = ref_list[j]->is_long_term ? MaxPicNum : ref_list[j]->pic_num; if (PicNumF != picNum) ref_list[n++] = ref_list[j]; @@ -1420,8 +1424,11 @@ exec_picture_refs_modification_1( ref_list[ref_list_idx++] = found_ref_idx >= 0 ? priv->long_ref[found_ref_idx] : NULL; n = ref_list_idx; - for (j = ref_list_idx; j < num_refs; j++) { - const gint32 LongTermPicNumF = ref_list[j]->is_long_term ? + for (j = ref_list_idx; j <= num_refs; j++) { + gint32 LongTermPicNumF; + if (!ref_list[j]) + continue; + LongTermPicNumF = ref_list[j]->is_long_term ? ref_list[j]->long_term_pic_num : INT_MAX; if (LongTermPicNumF != l->value.long_term_pic_num) ref_list[n++] = ref_list[j]; -- cgit v1.2.3