[client] nal: corrections to parsing logic

This commit is contained in:
Geoffrey McRae 2018-01-06 13:40:31 +11:00
parent 859e984827
commit 8ccce5666c
2 changed files with 31 additions and 24 deletions

View File

@ -664,29 +664,31 @@ static bool parse_pred_weight_table(NAL this, const uint8_t * src, size_t size,
NAL_PW_TABLE * tbl = &this->slice.pred_weight_table;
tbl->luma_log2_weight_denom = decode_u_golomb(src, offset);
if (this->sps.chroma_format_idc != 0)
tbl->chroma_log2_weight_denom = decode_u_golomb(src, offset);
tbl->l0 = this->slice_pred_weight_table_l0;
tbl->l1 = this->slice_pred_weight_table_l1;
for(uint32_t i = 0; i <= this->pps.num_ref_idx_l0_active_minus1; ++i)
{
NAL_PW_TABLE_L * l = &tbl->l0[i];
l->luma_weight_flag = get_bit(src, offset);
if (l->luma_weight_flag)
tbl->luma_weight_flag[0] = get_bit(src, offset);
if (tbl->luma_weight_flag[0])
{
l->luma_weight = decode_s_golomb(src, offset);
l->luma_offset = decode_s_golomb(src, offset);
}
l->chroma_weight_flag = get_bit(src, offset);
if (l->chroma_weight_flag)
if (this->sps.chroma_format_idc != 0)
{
tbl->chroma_weight_flag[0] = get_bit(src, offset);
if (tbl->chroma_weight_flag[0])
for(int j = 0; j < 2; ++j)
{
l->chroma_weight[j] = decode_s_golomb(src, offset);
l->chroma_offset[j] = decode_s_golomb(src, offset);
}
}
}
if (slice->slice_type == NAL_SLICE_TYPE_B)
{
@ -694,15 +696,17 @@ static bool parse_pred_weight_table(NAL this, const uint8_t * src, size_t size,
{
NAL_PW_TABLE_L * l = &tbl->l1[i];
l->luma_weight_flag = get_bit(src, offset);
if (l->luma_weight_flag)
tbl->luma_weight_flag[1] = get_bit(src, offset);
if (tbl->luma_weight_flag[1])
{
l->luma_weight = decode_s_golomb(src, offset);
l->luma_offset = decode_s_golomb(src, offset);
}
l->chroma_weight_flag = get_bit(src, offset);
if (l->chroma_weight_flag)
if (this->sps.chroma_format_idc != 0)
{
tbl->chroma_weight_flag[1] = get_bit(src, offset);
if (tbl->chroma_weight_flag[1])
for(int j = 0; j < 2; ++j)
{
l->chroma_weight[j] = decode_s_golomb(src, offset);
@ -710,6 +714,7 @@ static bool parse_pred_weight_table(NAL this, const uint8_t * src, size_t size,
}
}
}
}
return true;
}
@ -776,6 +781,8 @@ static bool parse_nal_coded_slice(
slice->slice_type = decode_u_golomb(src, offset);
slice->pic_parameter_set_id = decode_u_golomb(src, offset);
slice->frame_num = get_bits(src, offset, this->sps.log2_max_frame_num_minus4 + 4);
slice->pred_weight_table.l0 = this->slice_pred_weight_table_l0;
slice->pred_weight_table.l1 = this->slice_pred_weight_table_l1;
if (!this->sps.frame_mbs_only_flag)
{

View File

@ -230,10 +230,8 @@ NAL_RPL_REORDER;
typedef struct NAL_PW_TABLE_L
{
uint8_t luma_weight_flag;
int32_t luma_weight;
int32_t luma_offset;
uint8_t chroma_weight_flag;
int32_t chroma_weight[2];
int32_t chroma_offset[2];
}
@ -243,6 +241,8 @@ typedef struct NAL_PW_TABLE
{
uint32_t luma_log2_weight_denom;
uint32_t chroma_log2_weight_denom;
uint8_t luma_weight_flag[2];
uint8_t chroma_weight_flag[2];
NAL_PW_TABLE_L * l0;
NAL_PW_TABLE_L * l1;
}