Added error detection code in the middleware. All code is wrapped into ifdef SW_ERROR_CONCEALMENT flag, and this flag is not enabled for now to avoid disturbing the normal operation.
upgrade to 3.3.4 (replace patch #8613)
BZ:2528
Change-Id: I787dd6981ab6a3f19b2c4bffccb18b750bfc0f92
Signed-off-by: Weian Chen <weian.chen@intel.com>
diff --git a/mix_vbp/viddec_fw/fw/codecs/h264/include/h264.h b/mix_vbp/viddec_fw/fw/codecs/h264/include/h264.h
old mode 100644
new mode 100755
index a3490b4..1033948
--- a/mix_vbp/viddec_fw/fw/codecs/h264/include/h264.h
+++ b/mix_vbp/viddec_fw/fw/codecs/h264/include/h264.h
@@ -26,6 +26,9 @@
#include "viddec_fw_workload.h"
#include "h264parse_sei.h"
+#ifdef VBP
+//#define SW_ERROR_CONCEALEMNT
+#endif
#ifdef WIN32
#define mfd_printf OS_INFO
@@ -1022,7 +1025,11 @@
uint32_t wl_err_curr;
uint32_t wl_err_next;
-
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ uint32_t sw_bail;
+#endif
+#endif
} h264_Info;
diff --git a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_dpb.c b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_dpb.c
old mode 100644
new mode 100755
index 6d52307..7d26bce
--- a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_dpb.c
+++ b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_dpb.c
@@ -2487,7 +2487,11 @@
// only invoke following process for a conforming bitstream
// when gaps_in_frame_num_value_allowed_flag is equal to 1
pInfo->img.gaps_in_frame_num = 0;
-
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 1;
+#endif
+#endif
//mfd_printf("ERROR STREAM??\n");
////// Error handling here----
}
@@ -4003,6 +4007,14 @@
if (pInfo->SliceHeader.idr_flag)
{
pInfo->img.FrameNumOffset = 0;
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if (pInfo->img.frame_num)
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
}
else
{
@@ -4103,6 +4115,14 @@
pInfo->img.toppoc = 0;
pInfo->img.bottompoc = 0;
pInfo->img.ThisPOC = 0;
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if (pInfo->img.frame_num)
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
}
else
{
diff --git a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_pps.c b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_pps.c
old mode 100644
new mode 100755
index 1719a04..17f0930
--- a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_pps.c
+++ b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_pps.c
@@ -21,6 +21,14 @@
}
PictureParameterSet->pic_parameter_set_id = (uint8_t)code;
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if (code > 255)
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
code = h264_GetVLCElement(parent, pInfo, false);
if (code > MAX_NUM_SPS-1) {
@@ -28,6 +36,14 @@
}
PictureParameterSet->seq_parameter_set_id = (uint8_t)code;
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if (code > 31)
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
///// entropy_coding_mode_flag
viddec_pm_get_bits(parent, &code, 1);
PictureParameterSet->entropy_coding_mode_flag = (uint8_t)code;
@@ -37,6 +53,14 @@
PictureParameterSet->num_slice_groups_minus1 = h264_GetVLCElement(parent, pInfo, false);
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if (PictureParameterSet->num_slice_groups_minus1 > 8)
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
//
// In main profile, FMO is excluded and num_slice_groups_minus1 should be 0
//
@@ -49,6 +73,11 @@
//// PPS->num_ref_idx_l0_active --- [0,32]
if (((PictureParameterSet->num_ref_idx_l0_active) > MAX_NUM_REF_FRAMES) || ((PictureParameterSet->num_ref_idx_l1_active) > MAX_NUM_REF_FRAMES))
{
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 1;
+#endif
+#endif
break;
}
@@ -56,6 +85,14 @@
viddec_pm_get_bits(parent, &code, 1);
PictureParameterSet->weighted_pred_flag = (uint8_t)code;
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if (code > 2)
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
viddec_pm_get_bits(parent, &code, 2);
PictureParameterSet->weighted_bipred_idc = (uint8_t)code;
@@ -63,9 +100,24 @@
PictureParameterSet->pic_init_qp_minus26 = h264_GetVLCElement(parent, pInfo, true);
PictureParameterSet->pic_init_qs_minus26 = h264_GetVLCElement(parent, pInfo, true);
if (((PictureParameterSet->pic_init_qp_minus26+26) > MAX_QP) || ((PictureParameterSet->pic_init_qs_minus26+26) > MAX_QP))
+ {
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 1;
+#endif
+#endif
break;
+ }
PictureParameterSet->chroma_qp_index_offset = h264_GetVLCElement(parent, pInfo, true);
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if ((12 < PictureParameterSet->chroma_qp_index_offset) || (-12 > PictureParameterSet->chroma_qp_index_offset) )
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
//// Deblocking ctl parameters
viddec_pm_get_bits(parent, &code, 1);
PictureParameterSet->deblocking_filter_control_present_flag = (uint8_t)code;
@@ -77,6 +129,14 @@
break;
PictureParameterSet->redundant_pic_cnt_present_flag = (uint8_t)code;
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if (code && (pInfo->active_SPS.profile_idc != h264_ProfileBaseline))
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
//// Check if have more RBSP Data for additional parameters
if (h264_More_RBSP_Data(parent, pInfo))
{
@@ -107,8 +167,14 @@
}
PictureParameterSet->second_chroma_qp_index_offset = h264_GetVLCElement(parent, pInfo, true); //fix
- //if((PictureParameterSet->second_chroma_qp_index_offset>12) || (PictureParameterSet->second_chroma_qp_index_offset < -12))
- // break;
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if((PictureParameterSet->second_chroma_qp_index_offset>12) || (PictureParameterSet->second_chroma_qp_index_offset < -12))
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
}
else
{
diff --git a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_sh.c b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_sh.c
old mode 100644
new mode 100755
index de34811..189e57b
--- a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_sh.c
+++ b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_sh.c
@@ -25,6 +25,14 @@
///// slice_type
slice_type = h264_GetVLCElement(parent, pInfo, false);
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if (slice_type > 9)
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
SliceHeader->slice_type = (slice_type%5);
if (SliceHeader->slice_type > h264_PtypeI) {
@@ -36,6 +44,11 @@
////// pic_parameter_id
data = h264_GetVLCElement(parent, pInfo, false);
if (data > MAX_PIC_PARAMS) {
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 1;
+#endif
+#endif
ret = H264_PPS_INVALID_PIC_ID;
break;
}
@@ -109,6 +122,14 @@
if (pInfo->nal_unit_type == h264_NAL_UNIT_TYPE_IDR)
{
SliceHeader->idr_pic_id = h264_GetVLCElement(parent, pInfo, false);
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if (SliceHeader->idr_pic_id > 65535)
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
}
if (pInfo->active_SPS.pic_order_cnt_type == 0)
@@ -276,13 +297,24 @@
if (SliceHeader->cabac_init_idc > 2)
{
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 1;
+#endif
+#endif
break;
}
SliceHeader->slice_qp_delta = h264_GetVLCElement(parent, pInfo, true);
if ( (SliceHeader->slice_qp_delta > (25-pInfo->active_PPS.pic_init_qp_minus26)) || (SliceHeader->slice_qp_delta < -(26+pInfo->active_PPS.pic_init_qp_minus26)))
+ {
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 1;
+#endif
+#endif
break;
-
+ }
if ((SliceHeader->slice_type == h264_PtypeSP)|| (SliceHeader->slice_type == h264_PtypeSI) )
{
@@ -295,9 +327,15 @@
SliceHeader->slice_qs_delta = h264_GetVLCElement(parent, pInfo, true);
if ( (SliceHeader->slice_qs_delta > (25-pInfo->active_PPS.pic_init_qs_minus26)) || (SliceHeader->slice_qs_delta < -(26+pInfo->active_PPS.pic_init_qs_minus26)) )
+ {
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 1;
+#endif
+#endif
break;
+ }
}
-
if (pInfo->active_PPS.deblocking_filter_control_present_flag)
{
SliceHeader->disable_deblocking_filter_idc = h264_GetVLCElement(parent, pInfo, false);
@@ -305,13 +343,25 @@
{
SliceHeader->slice_alpha_c0_offset_div2 = h264_GetVLCElement(parent, pInfo, true);
slice_alpha_c0_offset = SliceHeader->slice_alpha_c0_offset_div2 << 1;
- if (slice_alpha_c0_offset < -12 || slice_alpha_c0_offset > 12) {
+ if (slice_alpha_c0_offset < -12 || slice_alpha_c0_offset > 12)
+ {
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 1;
+#endif
+#endif
break;
}
SliceHeader->slice_beta_offset_div2 = h264_GetVLCElement(parent, pInfo, true);
slice_beta_offset = SliceHeader->slice_beta_offset_div2 << 1;
- if (slice_beta_offset < -12 || slice_beta_offset > 12) {
+ if (slice_beta_offset < -12 || slice_beta_offset > 12)
+ {
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 1;
+#endif
+#endif
break;
}
}
@@ -430,16 +480,38 @@
SliceHeader->sh_predwttbl.luma_log2_weight_denom = h264_GetVLCElement(parent, pInfo, false);
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if (SliceHeader->sh_predwttbl.luma_log2_weight_denom > 7)
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
if (pInfo->active_SPS.sps_disp.chroma_format_idc != 0)
{
SliceHeader->sh_predwttbl.chroma_log2_weight_denom = h264_GetVLCElement(parent,pInfo, false);
}
-
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if (SliceHeader->sh_predwttbl.chroma_log2_weight_denom > 7)
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
for (i=0; i< SliceHeader->num_ref_idx_l0_active; i++)
{
viddec_pm_get_bits(parent, (uint32_t *)&flag, 1);
SliceHeader->sh_predwttbl.luma_weight_l0_flag = flag;
-
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if ((-128 > flag) || (127 < flag))
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
if (SliceHeader->sh_predwttbl.luma_weight_l0_flag)
{
SliceHeader->sh_predwttbl.luma_weight_l0[i] = h264_GetVLCElement(parent, pInfo, true);
@@ -455,7 +527,14 @@
{
viddec_pm_get_bits(parent, (uint32_t *)&flag, 1);
SliceHeader->sh_predwttbl.chroma_weight_l0_flag = flag;
-
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if ((-128 > flag) || (127 < flag))
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
if (SliceHeader->sh_predwttbl.chroma_weight_l0_flag)
{
for (j=0; j <2; j++)
@@ -482,7 +561,14 @@
{
viddec_pm_get_bits(parent, (uint32_t *)&flag, 1);
SliceHeader->sh_predwttbl.luma_weight_l1_flag = flag;
-
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if ((-128 > flag) || (127 < flag))
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
if (SliceHeader->sh_predwttbl.luma_weight_l1_flag)
{
SliceHeader->sh_predwttbl.luma_weight_l1[i] = h264_GetVLCElement(parent, pInfo, true);
@@ -498,7 +584,14 @@
{
viddec_pm_get_bits(parent, (uint32_t *)&flag, 1);
SliceHeader->sh_predwttbl.chroma_weight_l1_flag = flag;
-
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if ((-128 > flag) || (127 < flag))
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
if (SliceHeader->sh_predwttbl.chroma_weight_l1_flag)
{
for (j=0; j <2; j++)
diff --git a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_sps.c b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_sps.c
old mode 100644
new mode 100755
index 4a329b0..431892b
--- a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_sps.c
+++ b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_sps.c
@@ -294,6 +294,11 @@
case h264_ProfileHigh:
break;
default:
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 1;
+#endif
+#endif
return H264_SPS_INVALID_PROFILE;
break;
}
@@ -317,7 +322,14 @@
//// reserved_zero_4bits
viddec_pm_get_bits(parent, (uint32_t *)&code, 4);
#endif
-
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if (code != 0)
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
viddec_pm_get_bits(parent, &code, 8);
SPS->level_idc = (uint8_t)code;
@@ -341,6 +353,11 @@
case h264_Level51:
break;
default:
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 1;
+#endif
+#endif
return H264_SPS_INVALID_LEVEL;
}
@@ -349,7 +366,14 @@
//// seq_parameter_set_id ---[0,31]
if (SPS->seq_parameter_set_id > MAX_NUM_SPS -1)
+ {
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 1;
+#endif
+#endif
break;
+ }
#ifdef VBP
SPS->sps_disp.separate_colour_plane_flag = 0;
#endif
@@ -422,13 +446,27 @@
//// log2_max_frame_num_minus4 ---[0,12]
data = (h264_GetVLCElement(parent, pInfo, false));
if ( data > 12)
+ {
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 1;
+#endif
+#endif
break;
+ }
SPS->log2_max_frame_num_minus4 = (uint8_t)data;
//// pic_order_cnt_type ---- [0,2]
data = h264_GetVLCElement(parent, pInfo, false);
if ( data > 2)
+ {
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 1;
+#endif
+#endif
break;
+ }
SPS->pic_order_cnt_type = (uint8_t)data;
@@ -445,7 +483,14 @@
//// num_ref_frames_in_pic_order_cnt_cycle ---- [0,255]
data = h264_GetVLCElement(parent, pInfo, false);
if ( data > 255)
+ {
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 1;
+#endif
+#endif
break;
+ }
SPS->num_ref_frames_in_pic_order_cnt_cycle = (uint8_t)data;
@@ -468,7 +513,14 @@
//// num_ref_frames ---[0,16]
data = h264_GetVLCElement(parent, pInfo, false);
if ( data > 16)
+ {
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 1;
+#endif
+#endif
break;
+ }
SPS->num_ref_frames = (uint8_t)data;
viddec_pm_get_bits(parent, &code, 1);
diff --git a/mix_vbp/viddec_fw/fw/codecs/h264/parser/viddec_h264_parse.c b/mix_vbp/viddec_fw/fw/codecs/h264/parser/viddec_h264_parse.c
old mode 100644
new mode 100755
index b5b6c87..5936014
--- a/mix_vbp/viddec_fw/fw/codecs/h264/parser/viddec_h264_parse.c
+++ b/mix_vbp/viddec_fw/fw/codecs/h264/parser/viddec_h264_parse.c
@@ -28,6 +28,11 @@
}
/* picture level info which will always be initialized */
h264_init_Info_under_sps_pps_level(pInfo);
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ pInfo->sw_bail = 0;
+#endif
+#endif
return;
}
@@ -252,6 +257,14 @@
h264_dpb_update_ref_lists( pInfo);
+#ifdef VBP
+#ifdef SW_ERROR_CONCEALEMNT
+ if ((pInfo->dpb.ltref_frames_in_buffer + pInfo->dpb.ref_frames_in_buffer ) > pInfo->active_SPS.num_ref_frames)
+ {
+ pInfo->sw_bail = 1;
+ }
+#endif
+#endif
#ifdef DUMP_HEADER_INFO
dump_ref_list(pInfo);
#endif