summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2013-04-11 11:08:00 -0700
committerDmitry Kovalev <dkovalev@google.com>2013-04-11 11:08:00 -0700
commitec299e2092c51d60d487109366b982b1eadcf7fc (patch)
treea97c0a338912a930e263c0247f928de182250832
parent38d79453457e12ddc735243a701c980c068c0d0b (diff)
downloadlibvpx-ec299e2092c51d60d487109366b982b1eadcf7fc.tar
libvpx-ec299e2092c51d60d487109366b982b1eadcf7fc.tar.gz
libvpx-ec299e2092c51d60d487109366b982b1eadcf7fc.tar.bz2
libvpx-ec299e2092c51d60d487109366b982b1eadcf7fc.zip
Encoder code cleanup.
Removing duplicated code from vp9_encodemv.c and reusing ROUND_POWER_OF_TWO macro definitions. Change-Id: I9caf0c17f761ada7905cb99a3e2a31f871fef0f9
-rw-r--r--vp9/common/vp9_treecoder.h3
-rw-r--r--vp9/encoder/vp9_encodemv.c72
-rw-r--r--vp9/encoder/vp9_mcomp.c7
3 files changed, 29 insertions, 53 deletions
diff --git a/vp9/common/vp9_treecoder.h b/vp9/common/vp9_treecoder.h
index 9297d5280..133764856 100644
--- a/vp9/common/vp9_treecoder.h
+++ b/vp9/common/vp9_treecoder.h
@@ -13,6 +13,7 @@
#include "./vpx_config.h"
#include "vpx/vpx_integer.h"
+#include "vp9/common/vp9_common.h"
typedef uint8_t vp9_prob;
@@ -76,7 +77,7 @@ static INLINE vp9_prob get_binary_prob(int n0, int n1) {
/* this function assumes prob1 and prob2 are already within [1,255] range */
static INLINE vp9_prob weighted_prob(int prob1, int prob2, int factor) {
- return (prob1 * (256 - factor) + prob2 * factor + 128) >> 8;
+ return ROUND_POWER_OF_TWO(prob1 * (256 - factor) + prob2 * factor, 8);
}
#endif // VP9_COMMON_VP9_TREECODER_H_
diff --git a/vp9/encoder/vp9_encodemv.c b/vp9/encoder/vp9_encodemv.c
index 9431f0781..918a0bd7d 100644
--- a/vp9/encoder/vp9_encodemv.c
+++ b/vp9/encoder/vp9_encodemv.c
@@ -603,59 +603,33 @@ void vp9_update_nmv_count(VP9_COMP *cpi, MACROBLOCK *x,
if (mbmi->mode == SPLITMV) {
int i;
-
- for (i = 0; i < x->partition_info->count; i++) {
- if (x->partition_info->bmi[i].mode == NEW4X4) {
- if (x->e_mbd.allow_high_precision_mv) {
- mv.row = (x->partition_info->bmi[i].mv.as_mv.row
- - best_ref_mv->as_mv.row);
- mv.col = (x->partition_info->bmi[i].mv.as_mv.col
- - best_ref_mv->as_mv.col);
- vp9_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount, 1);
- if (x->e_mbd.mode_info_context->mbmi.second_ref_frame > 0) {
- mv.row = (x->partition_info->bmi[i].second_mv.as_mv.row
- - second_best_ref_mv->as_mv.row);
- mv.col = (x->partition_info->bmi[i].second_mv.as_mv.col
- - second_best_ref_mv->as_mv.col);
- vp9_increment_nmv(&mv, &second_best_ref_mv->as_mv,
- &cpi->NMVcount, 1);
- }
- } else {
- mv.row = (x->partition_info->bmi[i].mv.as_mv.row
- - best_ref_mv->as_mv.row);
- mv.col = (x->partition_info->bmi[i].mv.as_mv.col
- - best_ref_mv->as_mv.col);
- vp9_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount, 0);
- if (x->e_mbd.mode_info_context->mbmi.second_ref_frame > 0) {
- mv.row = (x->partition_info->bmi[i].second_mv.as_mv.row
- - second_best_ref_mv->as_mv.row);
- mv.col = (x->partition_info->bmi[i].second_mv.as_mv.col
- - second_best_ref_mv->as_mv.col);
- vp9_increment_nmv(&mv, &second_best_ref_mv->as_mv,
- &cpi->NMVcount, 0);
- }
+ PARTITION_INFO *pi = x->partition_info;
+ for (i = 0; i < pi->count; i++) {
+ if (pi->bmi[i].mode == NEW4X4) {
+ mv.row = (pi->bmi[i].mv.as_mv.row - best_ref_mv->as_mv.row);
+ mv.col = (pi->bmi[i].mv.as_mv.col - best_ref_mv->as_mv.col);
+ vp9_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount,
+ x->e_mbd.allow_high_precision_mv);
+ if (x->e_mbd.mode_info_context->mbmi.second_ref_frame > 0) {
+ mv.row = pi->bmi[i].second_mv.as_mv.row -
+ second_best_ref_mv->as_mv.row;
+ mv.col = pi->bmi[i].second_mv.as_mv.col -
+ second_best_ref_mv->as_mv.col;
+ vp9_increment_nmv(&mv, &second_best_ref_mv->as_mv, &cpi->NMVcount,
+ x->e_mbd.allow_high_precision_mv);
}
}
}
} else if (mbmi->mode == NEWMV) {
- if (x->e_mbd.allow_high_precision_mv) {
- mv.row = (mbmi->mv[0].as_mv.row - best_ref_mv->as_mv.row);
- mv.col = (mbmi->mv[0].as_mv.col - best_ref_mv->as_mv.col);
- vp9_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount, 1);
- if (mbmi->second_ref_frame > 0) {
- mv.row = (mbmi->mv[1].as_mv.row - second_best_ref_mv->as_mv.row);
- mv.col = (mbmi->mv[1].as_mv.col - second_best_ref_mv->as_mv.col);
- vp9_increment_nmv(&mv, &second_best_ref_mv->as_mv, &cpi->NMVcount, 1);
- }
- } else {
- mv.row = (mbmi->mv[0].as_mv.row - best_ref_mv->as_mv.row);
- mv.col = (mbmi->mv[0].as_mv.col - best_ref_mv->as_mv.col);
- vp9_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount, 0);
- if (mbmi->second_ref_frame > 0) {
- mv.row = (mbmi->mv[1].as_mv.row - second_best_ref_mv->as_mv.row);
- mv.col = (mbmi->mv[1].as_mv.col - second_best_ref_mv->as_mv.col);
- vp9_increment_nmv(&mv, &second_best_ref_mv->as_mv, &cpi->NMVcount, 0);
- }
+ mv.row = (mbmi->mv[0].as_mv.row - best_ref_mv->as_mv.row);
+ mv.col = (mbmi->mv[0].as_mv.col - best_ref_mv->as_mv.col);
+ vp9_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount,
+ x->e_mbd.allow_high_precision_mv);
+ if (mbmi->second_ref_frame > 0) {
+ mv.row = (mbmi->mv[1].as_mv.row - second_best_ref_mv->as_mv.row);
+ mv.col = (mbmi->mv[1].as_mv.col - second_best_ref_mv->as_mv.col);
+ vp9_increment_nmv(&mv, &second_best_ref_mv->as_mv, &cpi->NMVcount,
+ x->e_mbd.allow_high_precision_mv);
}
}
}
diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c
index e642b7487..1649ccade 100644
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -79,9 +79,10 @@ static int mvsad_err_cost(int_mv *mv, int_mv *ref, int *mvjsadcost,
MV v;
v.row = mv->as_mv.row - ref->as_mv.row;
v.col = mv->as_mv.col - ref->as_mv.col;
- return ((mvjsadcost[vp9_get_mv_joint(v)] +
- mvsadcost[0][v.row] + mvsadcost[1][v.col]) *
- error_per_bit + 128) >> 8;
+
+ return ROUND_POWER_OF_TWO((mvjsadcost[vp9_get_mv_joint(v)] +
+ mvsadcost[0][v.row] + mvsadcost[1][v.col]) *
+ error_per_bit, 8);
}
return 0;
}