Code cleanup.
Lower case variable names, code simplification by using already defined clamp and read_le16 functions. Change-Id: I8fd544365bd8d1daed86d7b2ae0843e4ef80df08
This commit is contained in:
parent
f68350ca98
commit
7cc14e598e
@ -129,7 +129,7 @@ void vp9_loop_filter_frame_init(VP9_COMMON *cm,
|
|||||||
lvl_seg = vp9_get_segdata(xd, seg, SEG_LVL_ALT_LF);
|
lvl_seg = vp9_get_segdata(xd, seg, SEG_LVL_ALT_LF);
|
||||||
} else { /* Delta Value */
|
} else { /* Delta Value */
|
||||||
lvl_seg += vp9_get_segdata(xd, seg, SEG_LVL_ALT_LF);
|
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 */
|
/* Apply delta for Intra modes */
|
||||||
mode = 0; /* B_PRED */
|
mode = 0; /* B_PRED */
|
||||||
/* Only the split mode BPRED has a further special case */
|
/* Only the split mode BPRED has a further special case */
|
||||||
lvl_mode = lvl_ref + xd->mode_lf_deltas[mode];
|
lvl_mode = clamp(lvl_ref + xd->mode_lf_deltas[mode], 0, 63);
|
||||||
lvl_mode = (lvl_mode > 0) ? (lvl_mode > 63 ? 63 : lvl_mode) : 0; /* clamp */
|
|
||||||
|
|
||||||
lfi->lvl[seg][ref][mode] = lvl_mode;
|
lfi->lvl[seg][ref][mode] = lvl_mode;
|
||||||
|
|
||||||
mode = 1; /* all the rest of Intra modes */
|
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;
|
lfi->lvl[seg][ref][mode] = lvl_mode;
|
||||||
|
|
||||||
/* LAST, GOLDEN, ALT */
|
/* LAST, GOLDEN, ALT */
|
||||||
@ -170,9 +169,7 @@ void vp9_loop_filter_frame_init(VP9_COMMON *cm,
|
|||||||
|
|
||||||
/* Apply delta for Inter modes */
|
/* Apply delta for Inter modes */
|
||||||
for (mode = 1; mode < 4; mode++) {
|
for (mode = 1; mode < 4; mode++) {
|
||||||
lvl_mode = lvl_ref + xd->mode_lf_deltas[mode];
|
lvl_mode = clamp(lvl_ref + xd->mode_lf_deltas[mode], 0, 63);
|
||||||
lvl_mode = (lvl_mode > 0) ? (lvl_mode > 63 ? 63 : lvl_mode) : 0; /* clamp */
|
|
||||||
|
|
||||||
lfi->lvl[seg][ref][mode] = lvl_mode;
|
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) {
|
if (alt_flt_enabled) {
|
||||||
for (i = 0; i < MAX_MB_SEGMENTS; i++) {
|
for (i = 0; i < MAX_MB_SEGMENTS; i++) {
|
||||||
/* Abs value */
|
|
||||||
if (xd->mb_segment_abs_delta == SEGMENT_ABSDATA) {
|
if (xd->mb_segment_abs_delta == SEGMENT_ABSDATA) {
|
||||||
|
// Abs value
|
||||||
lvl_seg[i] = vp9_get_segdata(xd, i, SEG_LVL_ALT_LF);
|
lvl_seg[i] = vp9_get_segdata(xd, i, SEG_LVL_ALT_LF);
|
||||||
}
|
} else {
|
||||||
/* Delta Value */
|
// Delta Value
|
||||||
else {
|
lvl_seg[i] = default_filt_lvl + vp9_get_segdata(xd, i, SEG_LVL_ALT_LF);
|
||||||
lvl_seg[i] = default_filt_lvl +
|
lvl_seg[i] = clamp(lvl_seg[i], 0, 63);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* 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"
|
#include "vp9/common/vp9_quant_common.h"
|
||||||
|
|
||||||
static int dc_qlookup[QINDEX_RANGE];
|
static int dc_qlookup[QINDEX_RANGE];
|
||||||
@ -24,7 +24,7 @@ void vp9_init_quant_tables() {
|
|||||||
|
|
||||||
for (i = 0; i < QINDEX_RANGE; i++) {
|
for (i = 0; i < QINDEX_RANGE; i++) {
|
||||||
ac_qlookup[i] = current_val;
|
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)
|
if (current_val == last_val)
|
||||||
current_val++;
|
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 vp9_dc_quant(int qindex, int delta) {
|
||||||
int retval;
|
return dc_qlookup[clamp(qindex + delta, 0, MAXQ)];
|
||||||
|
|
||||||
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) {
|
int vp9_dc_uv_quant(int qindex, int delta) {
|
||||||
int retval;
|
return dc_qlookup[clamp(qindex + delta, 0, MAXQ)];
|
||||||
|
|
||||||
QIndex = QIndex + Delta;
|
|
||||||
|
|
||||||
if (QIndex > MAXQ)
|
|
||||||
QIndex = MAXQ;
|
|
||||||
else if (QIndex < 0)
|
|
||||||
QIndex = 0;
|
|
||||||
|
|
||||||
retval = dc_qlookup[ QIndex ];
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int vp9_ac_yquant(int QIndex) {
|
int vp9_ac_yquant(int qindex) {
|
||||||
int retval;
|
return ac_qlookup[clamp(qindex, 0, MAXQ)];
|
||||||
|
|
||||||
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) {
|
int vp9_ac_uv_quant(int qindex, int delta) {
|
||||||
int retval;
|
return ac_qlookup[clamp(qindex + delta, 0, MAXQ)];
|
||||||
|
|
||||||
QIndex = QIndex + Delta;
|
|
||||||
|
|
||||||
if (QIndex > MAXQ)
|
|
||||||
QIndex = MAXQ;
|
|
||||||
else if (QIndex < 0)
|
|
||||||
QIndex = 0;
|
|
||||||
|
|
||||||
retval = ac_qlookup[ QIndex ];
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
@ -11,16 +11,15 @@
|
|||||||
#ifndef VP9_COMMON_VP9_QUANT_COMMON_H_
|
#ifndef VP9_COMMON_VP9_QUANT_COMMON_H_
|
||||||
#define 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_blockd.h"
|
||||||
#include "vp9/common/vp9_onyxc_int.h"
|
#include "vp9/common/vp9_onyxc_int.h"
|
||||||
|
|
||||||
extern void vp9_init_quant_tables(void);
|
void vp9_init_quant_tables();
|
||||||
extern int vp9_ac_yquant(int QIndex);
|
int vp9_ac_yquant(int qindex);
|
||||||
extern int vp9_dc_quant(int QIndex, int Delta);
|
int vp9_dc_quant(int qindex, int delta);
|
||||||
extern int vp9_dc2quant(int QIndex, int Delta);
|
int vp9_dc2quant(int qindex, int delta);
|
||||||
extern int vp9_ac2quant(int QIndex, int Delta);
|
int vp9_ac2quant(int qindex, int delta);
|
||||||
extern int vp9_dc_uv_quant(int QIndex, int Delta);
|
int vp9_dc_uv_quant(int qindex, int delta);
|
||||||
extern int vp9_ac_uv_quant(int QIndex, int Delta);
|
int vp9_ac_uv_quant(int qindex, int delta);
|
||||||
|
|
||||||
#endif // VP9_COMMON_VP9_QUANT_COMMON_H_
|
#endif // VP9_COMMON_VP9_QUANT_COMMON_H_
|
||||||
|
@ -1281,7 +1281,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
|
|||||||
pc->version = (data[0] >> 1) & 7;
|
pc->version = (data[0] >> 1) & 7;
|
||||||
pc->show_frame = (data[0] >> 4) & 1;
|
pc->show_frame = (data[0] >> 4) & 1;
|
||||||
scaling_active = (data[0] >> 5) & 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))
|
if (!read_is_valid(data, first_partition_length_in_bytes, data_end))
|
||||||
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
|
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user