diff --git a/src/parser/hevc_parser.cpp b/src/parser/hevc_parser.cpp index f0a14b9239..868c7278b8 100644 --- a/src/parser/hevc_parser.cpp +++ b/src/parser/hevc_parser.cpp @@ -337,7 +337,7 @@ int HEVCVideoParser::SendPicForDecode() { } for (i = ref_idx; i < 15; i++) { - pic_param_ptr->ref_frames[ref_idx].PicIdx = 0xFF; + pic_param_ptr->ref_frames[i].PicIdx = 0xFF; } pic_param_ptr->picture_width_in_luma_samples = sps_ptr->pic_width_in_luma_samples; @@ -432,34 +432,34 @@ int HEVCVideoParser::SendPicForDecode() { // Ref lists memset(slice_params_ptr->RefPicList, 0xFF, sizeof(slice_params_ptr->RefPicList)); - for (i = 0; i < m_sh_->num_ref_idx_l0_active_minus1; i++) { + for (i = 0; i <= m_sh_->num_ref_idx_l0_active_minus1; i++) { int idx = ref_pic_list_0_[i]; // pic_idx of the ref pic for (j = 0; j < 15; j++) { - if (pic_param_ptr->ref_frames[ref_idx].PicIdx == idx) { + if (pic_param_ptr->ref_frames[j].PicIdx == idx) { break; } + } + if (j == 15) { + ERR("Could not find matching pic in ref_frames list."); + } + else { + slice_params_ptr->RefPicList[0][i] = j; + } + } + + if (m_sh_->slice_type == HEVC_SLICE_TYPE_B) { + for (i = 0; i <= m_sh_->num_ref_idx_l1_active_minus1; i++) { + int idx = ref_pic_list_1_[i]; // pic_idx of the ref pic + for (j = 0; j < 15; j++) { + if (pic_param_ptr->ref_frames[j].PicIdx == idx) { + break; + } + } if (j == 15) { ERR("Could not find matching pic in ref_frames list."); } else { - slice_params_ptr->RefPicList[0][i] = j; - } - } - } - - if (m_sh_->slice_type == HEVC_SLICE_TYPE_B) { - for (i = 0; i < m_sh_->num_ref_idx_l1_active_minus1; i++) { - int idx = ref_pic_list_1_[i]; // pic_idx of the ref pic - for (j = 0; j < 15; j++) { - if (pic_param_ptr->ref_frames[ref_idx].PicIdx == idx) { - break; - } - if (j == 15) { - ERR("Could not find matching pic in ref_frames list."); - } - else { - slice_params_ptr->RefPicList[1][i] = j; - } + slice_params_ptr->RefPicList[1][i] = j; } } } diff --git a/src/rocdecode/vaapi/vaapi_videodecoder.cpp b/src/rocdecode/vaapi/vaapi_videodecoder.cpp index 140bd9ded3..22f500ed8b 100644 --- a/src/rocdecode/vaapi/vaapi_videodecoder.cpp +++ b/src/rocdecode/vaapi/vaapi_videodecoder.cpp @@ -204,6 +204,11 @@ rocDecStatus VaapiVideoDecoder::SubmitDecode(RocdecPicParams *pPicParams) { switch (decoder_create_info_.CodecType) { case rocDecVideoCodec_HEVC: { pPicParams->pic_params.hevc.cur_pic.PicIdx = curr_surface_id; + for (int i = 0; i < 15; i++) { + if (pPicParams->pic_params.hevc.ref_frames[i].PicIdx != 0xFF) { + pPicParams->pic_params.hevc.ref_frames[i].PicIdx = va_surface_ids_[pPicParams->pic_params.hevc.ref_frames[i].PicIdx]; + } + } pic_params_ptr = (uint8_t*)&pPicParams->pic_params.hevc; pic_params_size = sizeof(RocdecHevcPicParams);