summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorYaowu Xu <yaowu@google.com>2014-02-22 12:30:18 -0800
committerYaowu Xu <yaowu@google.com>2014-02-22 12:30:18 -0800
commite22b12e3040dca09d212da3bc3e92595449549be (patch)
treec168d0107c3027d2bcf0378a156dde043708dba9 /vp9
parent4b3e44f91d2742319556a247647fb95d52b3c24c (diff)
downloadlibvpx-e22b12e3040dca09d212da3bc3e92595449549be.tar
libvpx-e22b12e3040dca09d212da3bc3e92595449549be.tar.gz
libvpx-e22b12e3040dca09d212da3bc3e92595449549be.tar.bz2
libvpx-e22b12e3040dca09d212da3bc3e92595449549be.zip
Added clamp of qindex to valid range
The qindex for a segment was not clamped in ABSDATA mode, which may cause invalid memory access if an ill-formed stream has a negative value in ABSDATA mode. This commit added clamp to make sure qindex for a segment always fall into valid range. Change-Id: I0a74d00f4ef40aec7edaeca1d03c8645e23ab08c
Diffstat (limited to 'vp9')
-rw-r--r--vp9/common/vp9_quant_common.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/vp9/common/vp9_quant_common.c b/vp9/common/vp9_quant_common.c
index 9fef8b1ef..def12554d 100644
--- a/vp9/common/vp9_quant_common.c
+++ b/vp9/common/vp9_quant_common.c
@@ -134,9 +134,9 @@ int vp9_get_qindex(const struct segmentation *seg, int segment_id,
int base_qindex) {
if (vp9_segfeature_active(seg, segment_id, SEG_LVL_ALT_Q)) {
const int data = vp9_get_segdata(seg, segment_id, SEG_LVL_ALT_Q);
- return seg->abs_delta == SEGMENT_ABSDATA ?
- data : // Abs value
- clamp(base_qindex + data, 0, MAXQ); // Delta value
+ const int seg_qindex = seg->abs_delta == SEGMENT_ABSDATA ?
+ data : base_qindex + data;
+ return clamp(seg_qindex, 0, MAXQ);
} else {
return base_qindex;
}