Skip to content

Commit

Permalink
[dep-quant] Fix read out of bounds and left shift of negative
Browse files Browse the repository at this point in the history
  • Loading branch information
Jovasa committed Jul 1, 2024
1 parent 634cf72 commit d008a00
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/dep_quant.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,8 @@ static INLINE void update_common_context(
uint8_t* sbbFlags = cc->m_allSbbCtx[cc->m_curr_sbb_ctx_offset].sbbFlags;
uint8_t* levels = cc->m_allSbbCtx[cc->m_curr_sbb_ctx_offset].levels;
size_t setCpSize = cc->m_nbInfo[scan_pos - 1].maxDist * sizeof(uint8_t);
int8_t prev_sbb_state = ctxs->m_allStates.m_refSbbCtxId[prev_state];
if (prev_state != -1 && prev_sbb_state >= 0) {
if (prev_state != -1) {
const int8_t prev_sbb_state = ctxs->m_allStates.m_refSbbCtxId[prev_state];
for (int i = 0; i < numSbb; ++i) {
sbbFlags[i * 4 + curr_state_without_offset] = cc->m_allSbbCtx[cc->m_prev_sbb_ctx_offset].sbbFlags[i * 4 + prev_sbb_state];
}
Expand Down Expand Up @@ -1130,7 +1130,7 @@ void uvg_dep_quant_dequant(
{
invQScale <<= -shift;
}
int qIdx = (level << 1) + (level > 0 ? -(state >> 1) : (state >> 1));
int qIdx = (level * 2) + (level > 0 ? -(state >> 1) : (state >> 1));
int64_t nomTCoeff = ((int64_t)qIdx * (int64_t)invQScale + add) >> ((shift < 0) ? 0 : shift);
coeff[rasterPos] = (coeff_t)CLIP(minTCoeff, maxTCoeff, nomTCoeff);
}
Expand Down

0 comments on commit d008a00

Please sign in to comment.