Merge "Moving mv entropy encodings calculation to the encoder side."

This commit is contained in:
Dmitry Kovalev 2013-11-25 19:15:21 -08:00 committed by Gerrit Code Review
commit 5488da280d
6 changed files with 27 additions and 30 deletions

View File

@ -213,7 +213,6 @@ void vp9_initialize_common() {
vp9_init_neighbors(); vp9_init_neighbors();
vp9_coef_tree_initialize(); vp9_coef_tree_initialize();
vp9_entropy_mode_init(); vp9_entropy_mode_init();
vp9_entropy_mv_init();
} }
void vp9_update_frame_size(VP9_COMMON *cm) { void vp9_update_frame_size(VP9_COMMON *cm) {

View File

@ -23,7 +23,6 @@ const vp9_tree_index vp9_mv_joint_tree[TREE_SIZE(MV_JOINTS)] = {
-MV_JOINT_HNZVZ, 4, -MV_JOINT_HNZVZ, 4,
-MV_JOINT_HZVNZ, -MV_JOINT_HNZVNZ -MV_JOINT_HZVNZ, -MV_JOINT_HNZVNZ
}; };
struct vp9_token vp9_mv_joint_encodings[MV_JOINTS];
const vp9_tree_index vp9_mv_class_tree[TREE_SIZE(MV_CLASSES)] = { const vp9_tree_index vp9_mv_class_tree[TREE_SIZE(MV_CLASSES)] = {
-MV_CLASS_0, 2, -MV_CLASS_0, 2,
@ -37,19 +36,16 @@ const vp9_tree_index vp9_mv_class_tree[TREE_SIZE(MV_CLASSES)] = {
-MV_CLASS_7, -MV_CLASS_8, -MV_CLASS_7, -MV_CLASS_8,
-MV_CLASS_9, -MV_CLASS_10, -MV_CLASS_9, -MV_CLASS_10,
}; };
struct vp9_token vp9_mv_class_encodings[MV_CLASSES];
const vp9_tree_index vp9_mv_class0_tree[TREE_SIZE(CLASS0_SIZE)] = { const vp9_tree_index vp9_mv_class0_tree[TREE_SIZE(CLASS0_SIZE)] = {
-0, -1, -0, -1,
}; };
struct vp9_token vp9_mv_class0_encodings[CLASS0_SIZE];
const vp9_tree_index vp9_mv_fp_tree[TREE_SIZE(4)] = { const vp9_tree_index vp9_mv_fp_tree[TREE_SIZE(MV_FP_SIZE)] = {
-0, 2, -0, 2,
-1, 4, -1, 4,
-2, -3 -2, -3
}; };
struct vp9_token vp9_mv_fp_encodings[4];
static const nmv_context default_nmv_context = { static const nmv_context default_nmv_context = {
{32, 64, 96}, {32, 64, 96},
@ -235,13 +231,6 @@ void vp9_adapt_mv_probs(VP9_COMMON *cm, int allow_hp) {
} }
} }
void vp9_entropy_mv_init() {
vp9_tokens_from_tree(vp9_mv_joint_encodings, vp9_mv_joint_tree);
vp9_tokens_from_tree(vp9_mv_class_encodings, vp9_mv_class_tree);
vp9_tokens_from_tree(vp9_mv_class0_encodings, vp9_mv_class0_tree);
vp9_tokens_from_tree(vp9_mv_fp_encodings, vp9_mv_fp_tree);
}
void vp9_init_mv_probs(VP9_COMMON *cm) { void vp9_init_mv_probs(VP9_COMMON *cm) {
cm->fc.nmvc = default_nmv_context; cm->fc.nmvc = default_nmv_context;
} }

View File

@ -18,7 +18,6 @@
struct VP9Common; struct VP9Common;
void vp9_entropy_mv_init();
void vp9_init_mv_probs(struct VP9Common *cm); void vp9_init_mv_probs(struct VP9Common *cm);
void vp9_adapt_mv_probs(struct VP9Common *cm, int usehp); void vp9_adapt_mv_probs(struct VP9Common *cm, int usehp);
@ -72,17 +71,10 @@ typedef enum {
#define MV_UPP ((1 << MV_IN_USE_BITS) - 1) #define MV_UPP ((1 << MV_IN_USE_BITS) - 1)
#define MV_LOW (-(1 << MV_IN_USE_BITS)) #define MV_LOW (-(1 << MV_IN_USE_BITS))
extern const vp9_tree_index vp9_mv_joint_tree[TREE_SIZE(MV_JOINTS)]; extern const vp9_tree_index vp9_mv_joint_tree[];
extern struct vp9_token vp9_mv_joint_encodings[MV_JOINTS]; extern const vp9_tree_index vp9_mv_class_tree[];
extern const vp9_tree_index vp9_mv_class0_tree[];
extern const vp9_tree_index vp9_mv_class_tree[TREE_SIZE(MV_CLASSES)]; extern const vp9_tree_index vp9_mv_fp_tree[];
extern struct vp9_token vp9_mv_class_encodings[MV_CLASSES];
extern const vp9_tree_index vp9_mv_class0_tree[TREE_SIZE(CLASS0_SIZE)];
extern struct vp9_token vp9_mv_class0_encodings[CLASS0_SIZE];
extern const vp9_tree_index vp9_mv_fp_tree[TREE_SIZE(MV_FP_SIZE)];
extern struct vp9_token vp9_mv_fp_encodings[4];
typedef struct { typedef struct {
vp9_prob sign; vp9_prob sign;

View File

@ -15,11 +15,22 @@
#include "vp9/common/vp9_systemdependent.h" #include "vp9/common/vp9_systemdependent.h"
#include "vp9/encoder/vp9_encodemv.h" #include "vp9/encoder/vp9_encodemv.h"
#ifdef ENTROPY_STATS #ifdef ENTROPY_STATS
extern unsigned int active_section; extern unsigned int active_section;
#endif #endif
static struct vp9_token mv_joint_encodings[MV_JOINTS];
static struct vp9_token mv_class_encodings[MV_CLASSES];
static struct vp9_token mv_fp_encodings[MV_FP_SIZE];
static struct vp9_token mv_class0_encodings[CLASS0_SIZE];
void vp9_entropy_mv_init() {
vp9_tokens_from_tree(mv_joint_encodings, vp9_mv_joint_tree);
vp9_tokens_from_tree(mv_class_encodings, vp9_mv_class_tree);
vp9_tokens_from_tree(mv_class0_encodings, vp9_mv_class0_tree);
vp9_tokens_from_tree(mv_fp_encodings, vp9_mv_fp_tree);
}
static void encode_mv_component(vp9_writer* w, int comp, static void encode_mv_component(vp9_writer* w, int comp,
const nmv_component* mvcomp, int usehp) { const nmv_component* mvcomp, int usehp) {
int offset; int offset;
@ -37,12 +48,12 @@ static void encode_mv_component(vp9_writer* w, int comp,
// Class // Class
write_token(w, vp9_mv_class_tree, mvcomp->classes, write_token(w, vp9_mv_class_tree, mvcomp->classes,
&vp9_mv_class_encodings[mv_class]); &mv_class_encodings[mv_class]);
// Integer bits // Integer bits
if (mv_class == MV_CLASS_0) { if (mv_class == MV_CLASS_0) {
write_token(w, vp9_mv_class0_tree, mvcomp->class0, write_token(w, vp9_mv_class0_tree, mvcomp->class0,
&vp9_mv_class0_encodings[d]); &mv_class0_encodings[d]);
} else { } else {
int i; int i;
const int n = mv_class + CLASS0_BITS - 1; // number of bits const int n = mv_class + CLASS0_BITS - 1; // number of bits
@ -53,7 +64,7 @@ static void encode_mv_component(vp9_writer* w, int comp,
// Fractional bits // Fractional bits
write_token(w, vp9_mv_fp_tree, write_token(w, vp9_mv_fp_tree,
mv_class == MV_CLASS_0 ? mvcomp->class0_fp[d] : mvcomp->fp, mv_class == MV_CLASS_0 ? mvcomp->class0_fp[d] : mvcomp->fp,
&vp9_mv_fp_encodings[fr]); &mv_fp_encodings[fr]);
// High precision bit // High precision bit
if (usehp) if (usehp)
@ -198,7 +209,7 @@ void vp9_encode_mv(VP9_COMP* cpi, vp9_writer* w,
const MV_JOINT_TYPE j = vp9_get_mv_joint(&diff); const MV_JOINT_TYPE j = vp9_get_mv_joint(&diff);
usehp = usehp && vp9_use_mv_hp(ref); usehp = usehp && vp9_use_mv_hp(ref);
write_token(w, vp9_mv_joint_tree, mvctx->joints, &vp9_mv_joint_encodings[j]); write_token(w, vp9_mv_joint_tree, mvctx->joints, &mv_joint_encodings[j]);
if (mv_joint_vertical(j)) if (mv_joint_vertical(j))
encode_mv_component(w, diff.row, &mvctx->comps[0], usehp); encode_mv_component(w, diff.row, &mvctx->comps[0], usehp);
@ -258,3 +269,4 @@ void vp9_update_mv_count(VP9_COMP *cpi, MACROBLOCK *x, int_mv best_ref_mv[2]) {
inc_mvs(mbmi->mv, best_ref_mv, is_compound, &cpi->NMVcount); inc_mvs(mbmi->mv, best_ref_mv, is_compound, &cpi->NMVcount);
} }
} }

View File

@ -14,6 +14,8 @@
#include "vp9/encoder/vp9_onyx_int.h" #include "vp9/encoder/vp9_onyx_int.h"
void vp9_entropy_mv_init();
void vp9_write_nmv_probs(VP9_COMP* const, int usehp, vp9_writer* const); void vp9_write_nmv_probs(VP9_COMP* const, int usehp, vp9_writer* const);
void vp9_encode_mv(VP9_COMP *cpi, vp9_writer* w, const MV* mv, const MV* ref, void vp9_encode_mv(VP9_COMP *cpi, vp9_writer* w, const MV* mv, const MV* ref,

View File

@ -24,6 +24,8 @@
#include "vp9/common/vp9_reconinter.h" #include "vp9/common/vp9_reconinter.h"
#include "vp9/common/vp9_systemdependent.h" #include "vp9/common/vp9_systemdependent.h"
#include "vp9/common/vp9_tile_common.h" #include "vp9/common/vp9_tile_common.h"
#include "vp9/encoder/vp9_encodemv.h"
#include "vp9/encoder/vp9_firstpass.h" #include "vp9/encoder/vp9_firstpass.h"
#include "vp9/encoder/vp9_mbgraph.h" #include "vp9/encoder/vp9_mbgraph.h"
#include "vp9/encoder/vp9_onyx_int.h" #include "vp9/encoder/vp9_onyx_int.h"
@ -159,6 +161,7 @@ void vp9_initialize_enc() {
vp9_init_me_luts(); vp9_init_me_luts();
vp9_init_minq_luts(); vp9_init_minq_luts();
// init_base_skip_probs(); // init_base_skip_probs();
vp9_entropy_mv_init();
init_done = 1; init_done = 1;
} }
} }