summaryrefslogtreecommitdiff
path: root/vp9/common
diff options
context:
space:
mode:
authorJohn Koleszar <jkoleszar@google.com>2013-03-26 08:30:46 -0700
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2013-03-26 08:30:46 -0700
commitf0923f3b0160d191afdafd4df339e272bd269a5b (patch)
treee448339c0864b66fad6c0ab0000547d329d16afd /vp9/common
parent49c5841b2b142084b20abdf4c9ccaf3707ddca80 (diff)
parent7cc14e598ec2386e4175612bf63c7a250b67672c (diff)
downloadlibvpx-f0923f3b0160d191afdafd4df339e272bd269a5b.tar
libvpx-f0923f3b0160d191afdafd4df339e272bd269a5b.tar.gz
libvpx-f0923f3b0160d191afdafd4df339e272bd269a5b.tar.bz2
libvpx-f0923f3b0160d191afdafd4df339e272bd269a5b.zip
Merge "Code cleanup." into experimental
Diffstat (limited to 'vp9/common')
-rw-r--r--vp9/common/vp9_loopfilter.c24
-rw-r--r--vp9/common/vp9_quant_common.c59
-rw-r--r--vp9/common/vp9_quant_common.h15
3 files changed, 26 insertions, 72 deletions
diff --git a/vp9/common/vp9_loopfilter.c b/vp9/common/vp9_loopfilter.c
index 9ce5a6378..5c846129a 100644
--- a/vp9/common/vp9_loopfilter.c
+++ b/vp9/common/vp9_loopfilter.c
@@ -129,7 +129,7 @@ void vp9_loop_filter_frame_init(VP9_COMMON *cm,
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 @@ void vp9_loop_filter_frame_init(VP9_COMMON *cm,
/* 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 @@ void vp9_loop_filter_frame_init(VP9_COMMON *cm,
/* 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 @@ void vp9_loop_filter_partial_frame(VP9_COMMON *cm, MACROBLOCKD *xd,
*/
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);
}
}
}
diff --git a/vp9/common/vp9_quant_common.c b/vp9/common/vp9_quant_common.c
index 90eb88ed3..a94c772be 100644
--- 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 @@ void vp9_init_quant_tables() {
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 @@ void vp9_init_quant_tables() {
}
}
-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)];
}
diff --git a/vp9/common/vp9_quant_common.h b/vp9/common/vp9_quant_common.h
index 871c2b035..1520c3797 100644
--- 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_