ref: f0923f3b0160d191afdafd4df339e272bd269a5b
parent: 49c5841b2b142084b20abdf4c9ccaf3707ddca80
parent: 7cc14e598ec2386e4175612bf63c7a250b67672c
author: John Koleszar <jkoleszar@google.com>
date: Tue Mar 26 04:30:46 EDT 2013
Merge "Code cleanup." into experimental
--- a/vp9/common/vp9_loopfilter.c
+++ b/vp9/common/vp9_loopfilter.c
@@ -129,7 +129,7 @@
lvl_seg = vp9_get_segdata(xd, seg, SEG_LVL_ALT_LF);
} else { /* Delta Value */
lvl_seg += vp9_get_segdata(xd, seg, SEG_LVL_ALT_LF);
- lvl_seg = (lvl_seg > 0) ? ((lvl_seg > 63) ? 63 : lvl_seg) : 0;
+ lvl_seg = clamp(lvl_seg, 0, 63);
}
}
@@ -152,13 +152,12 @@
/* Apply delta for Intra modes */
mode = 0; /* B_PRED */
/* Only the split mode BPRED has a further special case */
- lvl_mode = lvl_ref + xd->mode_lf_deltas[mode];
- lvl_mode = (lvl_mode > 0) ? (lvl_mode > 63 ? 63 : lvl_mode) : 0; /* clamp */
+ lvl_mode = clamp(lvl_ref + xd->mode_lf_deltas[mode], 0, 63);
lfi->lvl[seg][ref][mode] = lvl_mode;
mode = 1; /* all the rest of Intra modes */
- lvl_mode = (lvl_ref > 0) ? (lvl_ref > 63 ? 63 : lvl_ref) : 0; /* clamp */
+ lvl_mode = clamp(lvl_ref, 0, 63);
lfi->lvl[seg][ref][mode] = lvl_mode;
/* LAST, GOLDEN, ALT */
@@ -170,9 +169,7 @@
/* Apply delta for Inter modes */
for (mode = 1; mode < 4; mode++) {
- lvl_mode = lvl_ref + xd->mode_lf_deltas[mode];
- lvl_mode = (lvl_mode > 0) ? (lvl_mode > 63 ? 63 : lvl_mode) : 0; /* clamp */
-
+ lvl_mode = clamp(lvl_ref + xd->mode_lf_deltas[mode], 0, 63);
lfi->lvl[seg][ref][mode] = lvl_mode;
}
}
@@ -379,16 +376,13 @@
*/
if (alt_flt_enabled) {
for (i = 0; i < MAX_MB_SEGMENTS; i++) {
- /* Abs value */
if (xd->mb_segment_abs_delta == SEGMENT_ABSDATA) {
+ // Abs value
lvl_seg[i] = vp9_get_segdata(xd, i, SEG_LVL_ALT_LF);
- }
- /* Delta Value */
- else {
- lvl_seg[i] = default_filt_lvl +
- vp9_get_segdata(xd, i, SEG_LVL_ALT_LF);
- lvl_seg[i] = (lvl_seg[i] > 0) ?
- ((lvl_seg[i] > 63) ? 63 : lvl_seg[i]) : 0;
+ } else {
+ // Delta Value
+ lvl_seg[i] = default_filt_lvl + vp9_get_segdata(xd, i, SEG_LVL_ALT_LF);
+ lvl_seg[i] = clamp(lvl_seg[i], 0, 63);
}
}
}
--- a/vp9/common/vp9_quant_common.c
+++ b/vp9/common/vp9_quant_common.c
@@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-
+#include "vp9/common/vp9_common.h"
#include "vp9/common/vp9_quant_common.h"
static int dc_qlookup[QINDEX_RANGE];
@@ -24,7 +24,7 @@
for (i = 0; i < QINDEX_RANGE; i++) {
ac_qlookup[i] = current_val;
- current_val = (int)((double)current_val * 1.02);
+ current_val = (int)(current_val * 1.02);
if (current_val == last_val)
current_val++;
last_val = current_val;
@@ -38,57 +38,18 @@
}
}
-int vp9_dc_quant(int QIndex, int Delta) {
- int retval;
-
- QIndex = QIndex + Delta;
-
- if (QIndex > MAXQ)
- QIndex = MAXQ;
- else if (QIndex < 0)
- QIndex = 0;
-
- retval = dc_qlookup[ QIndex ];
- return retval;
+int vp9_dc_quant(int qindex, int delta) {
+ return dc_qlookup[clamp(qindex + delta, 0, MAXQ)];
}
-int vp9_dc_uv_quant(int QIndex, int Delta) {
- int retval;
-
- QIndex = QIndex + Delta;
-
- if (QIndex > MAXQ)
- QIndex = MAXQ;
- else if (QIndex < 0)
- QIndex = 0;
-
- retval = dc_qlookup[ QIndex ];
-
- return retval;
+int vp9_dc_uv_quant(int qindex, int delta) {
+ return dc_qlookup[clamp(qindex + delta, 0, MAXQ)];
}
-int vp9_ac_yquant(int QIndex) {
- int retval;
-
- if (QIndex > MAXQ)
- QIndex = MAXQ;
- else if (QIndex < 0)
- QIndex = 0;
-
- retval = ac_qlookup[ QIndex ];
- return retval;
+int vp9_ac_yquant(int qindex) {
+ return ac_qlookup[clamp(qindex, 0, MAXQ)];
}
-int vp9_ac_uv_quant(int QIndex, int Delta) {
- int retval;
-
- QIndex = QIndex + Delta;
-
- if (QIndex > MAXQ)
- QIndex = MAXQ;
- else if (QIndex < 0)
- QIndex = 0;
-
- retval = ac_qlookup[ QIndex ];
- return retval;
+int vp9_ac_uv_quant(int qindex, int delta) {
+ return ac_qlookup[clamp(qindex + delta, 0, MAXQ)];
}
--- a/vp9/common/vp9_quant_common.h
+++ b/vp9/common/vp9_quant_common.h
@@ -11,16 +11,15 @@
#ifndef VP9_COMMON_VP9_QUANT_COMMON_H_
#define VP9_COMMON_VP9_QUANT_COMMON_H_
-#include "string.h"
#include "vp9/common/vp9_blockd.h"
#include "vp9/common/vp9_onyxc_int.h"
-extern void vp9_init_quant_tables(void);
-extern int vp9_ac_yquant(int QIndex);
-extern int vp9_dc_quant(int QIndex, int Delta);
-extern int vp9_dc2quant(int QIndex, int Delta);
-extern int vp9_ac2quant(int QIndex, int Delta);
-extern int vp9_dc_uv_quant(int QIndex, int Delta);
-extern int vp9_ac_uv_quant(int QIndex, int Delta);
+void vp9_init_quant_tables();
+int vp9_ac_yquant(int qindex);
+int vp9_dc_quant(int qindex, int delta);
+int vp9_dc2quant(int qindex, int delta);
+int vp9_ac2quant(int qindex, int delta);
+int vp9_dc_uv_quant(int qindex, int delta);
+int vp9_ac_uv_quant(int qindex, int delta);
#endif // VP9_COMMON_VP9_QUANT_COMMON_H_
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -1291,7 +1291,7 @@
pc->version = (data[0] >> 1) & 7;
pc->show_frame = (data[0] >> 4) & 1;
scaling_active = (data[0] >> 5) & 1;
- first_partition_length_in_bytes = data[1] | (data[2] << 8);
+ first_partition_length_in_bytes = read_le16(data + 1);
if (!read_is_valid(data, first_partition_length_in_bytes, data_end))
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
--
⑨