summaryrefslogtreecommitdiff
path: root/vp8/encoder/bitstream.c
diff options
context:
space:
mode:
Diffstat (limited to 'vp8/encoder/bitstream.c')
-rw-r--r--vp8/encoder/bitstream.c67
1 files changed, 63 insertions, 4 deletions
diff --git a/vp8/encoder/bitstream.c b/vp8/encoder/bitstream.c
index 7d94bec26..712019602 100644
--- a/vp8/encoder/bitstream.c
+++ b/vp8/encoder/bitstream.c
@@ -27,6 +27,7 @@
#include "vp8/common/seg_common.h"
#include "vp8/common/pred_common.h"
#include "vp8/common/entropy.h"
+#include "vp8/encoder/encodemv.h"
#if CONFIG_NEW_MVREF
#include "vp8/common/mvref_common.h"
@@ -36,6 +37,8 @@
unsigned __int64 Sectionbits[500];
#endif
+//int final_packing = 0;
+
#ifdef ENTROPY_STATS
int intra_mode_stats [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES];
unsigned int tree_update_hist [BLOCK_TYPES]
@@ -564,6 +567,19 @@ static void write_sub_mv_ref
vp8_sub_mv_ref_encoding_array - LEFT4X4 + m);
}
+#if CONFIG_NEWMVENTROPY
+static void write_nmv (vp8_writer *w, const MV *mv, const int_mv *ref,
+ const nmv_context *nmvc, int usehp) {
+ MV e;
+ e.row = mv->row - ref->as_mv.row;
+ e.col = mv->col - ref->as_mv.col;
+
+ vp8_encode_nmv(w, &e, &ref->as_mv, nmvc);
+ vp8_encode_nmv_fp(w, &e, &ref->as_mv, nmvc, usehp);
+}
+
+#else
+
static void write_mv
(
vp8_writer *w, const MV *mv, const int_mv *ref, const MV_CONTEXT *mvc
@@ -585,6 +601,7 @@ static void write_mv_hp
vp8_encode_motion_vector_hp(w, &e, mvc);
}
+#endif /* CONFIG_NEWMVENTROPY */
// This function writes the current macro block's segnment id to the bitstream
// It should only be called if a segment map update is indicated.
@@ -737,8 +754,12 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
int i;
VP8_COMMON *const pc = & cpi->common;
vp8_writer *const w = & cpi->bc;
+#if CONFIG_NEWMVENTROPY
+ const nmv_context *nmvc = &pc->fc.nmvc;
+#else
const MV_CONTEXT *mvc = pc->fc.mvc;
const MV_CONTEXT_HP *mvc_hp = pc->fc.mvc_hp;
+#endif
MACROBLOCKD *xd = &cpi->mb.e_mbd;
MODE_INFO *m;
MODE_INFO *prev_m;
@@ -754,6 +775,8 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
int row_delta[4] = { 0, +1, 0, -1};
int col_delta[4] = { +1, -1, +1, +1};
+ //final_packing = !cpi->dummy_packing;
+
cpi->mb.partition_info = cpi->mb.pi;
// Update the probabilities used to encode reference frame data
@@ -814,10 +837,14 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
update_mbintra_mode_probs(cpi);
+#if CONFIG_NEWMVENTROPY
+ vp8_write_nmvprobs(cpi, xd->allow_high_precision_mv);
+#else
if (xd->allow_high_precision_mv)
vp8_write_mvprobs_hp(cpi);
else
vp8_write_mvprobs(cpi);
+#endif
mb_row = 0;
for (row = 0; row < pc->mb_rows; row += 2) {
@@ -1055,10 +1082,17 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
pick_best_mv_ref( mi->mv[0], mi->ref_mvs[rf], &best_mv);
#endif
- if (xd->allow_high_precision_mv)
+#if CONFIG_NEWMVENTROPY
+ write_nmv(w, &mi->mv[0].as_mv, &best_mv,
+ (const nmv_context*) nmvc,
+ xd->allow_high_precision_mv);
+#else
+ if (xd->allow_high_precision_mv) {
write_mv_hp(w, &mi->mv[0].as_mv, &best_mv, mvc_hp);
- else
+ } else {
write_mv(w, &mi->mv[0].as_mv, &best_mv, mvc);
+ }
+#endif
if (mi->second_ref_frame) {
#if 0 //CONFIG_NEW_MVREF
@@ -1071,10 +1105,17 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
mi->ref_mvs[mi->second_ref_frame],
&best_second_mv);
#endif
- if (xd->allow_high_precision_mv)
+#if CONFIG_NEWMVENTROPY
+ write_nmv(w, &mi->mv[1].as_mv, &best_second_mv,
+ (const nmv_context*) nmvc,
+ xd->allow_high_precision_mv);
+#else
+ if (xd->allow_high_precision_mv) {
write_mv_hp(w, &mi->mv[1].as_mv, &best_second_mv, mvc_hp);
- else
+ } else {
write_mv(w, &mi->mv[1].as_mv, &best_second_mv, mvc);
+ }
+#endif
}
break;
case SPLITMV: {
@@ -1116,6 +1157,11 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
#ifdef ENTROPY_STATS
active_section = 11;
#endif
+#if CONFIG_NEWMVENTROPY
+ write_nmv(w, &blockmv.as_mv, &best_mv,
+ (const nmv_context*) nmvc,
+ xd->allow_high_precision_mv);
+#else
if (xd->allow_high_precision_mv) {
write_mv_hp(w, &blockmv.as_mv, &best_mv,
(const MV_CONTEXT_HP *) mvc_hp);
@@ -1123,8 +1169,16 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
write_mv(w, &blockmv.as_mv, &best_mv,
(const MV_CONTEXT *) mvc);
}
+#endif
if (mi->second_ref_frame) {
+#if CONFIG_NEWMVENTROPY
+ write_nmv(w,
+ &cpi->mb.partition_info->bmi[j].second_mv.as_mv,
+ &best_second_mv,
+ (const nmv_context*) nmvc,
+ xd->allow_high_precision_mv);
+#else
if (xd->allow_high_precision_mv) {
write_mv_hp(w, &cpi->mb.partition_info->bmi[j].second_mv.as_mv,
&best_second_mv, (const MV_CONTEXT_HP *) mvc_hp);
@@ -1132,6 +1186,7 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
write_mv(w, &cpi->mb.partition_info->bmi[j].second_mv.as_mv,
&best_second_mv, (const MV_CONTEXT *) mvc);
}
+#endif
}
}
} while (++j < cpi->mb.partition_info->count);
@@ -2313,8 +2368,12 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size)
vp8_copy(cpi->common.fc.pre_sub_mv_ref_prob, cpi->common.fc.sub_mv_ref_prob);
vp8_copy(cpi->common.fc.pre_mbsplit_prob, cpi->common.fc.mbsplit_prob);
vp8_copy(cpi->common.fc.pre_i8x8_mode_prob, cpi->common.fc.i8x8_mode_prob);
+#if CONFIG_NEWMVENTROPY
+ cpi->common.fc.pre_nmvc = cpi->common.fc.nmvc;
+#else
vp8_copy(cpi->common.fc.pre_mvc, cpi->common.fc.mvc);
vp8_copy(cpi->common.fc.pre_mvc_hp, cpi->common.fc.mvc_hp);
+#endif
vp8_zero(cpi->sub_mv_ref_count);
vp8_zero(cpi->mbsplit_count);
vp8_zero(cpi->common.fc.mv_ref_ct)