]> granicus.if.org Git - libvpx/commitdiff
Extend diff MV limit from +/-256 to +/-1024
authorJingning Han <jingning@google.com>
Wed, 6 Mar 2013 20:02:15 +0000 (12:02 -0800)
committerJingning Han <jingning@google.com>
Fri, 8 Mar 2013 18:04:36 +0000 (10:04 -0800)
Increase the motion search range by 4x. Change MV_CLASS tree of the
entropy coding to allow two additional mv classes to cover the
extended motion vector limit. The codec determines the effective
motion search range conditioned on the actual frame dimension.

It provides coding gains:

stdhd 0.39%
yt    0.56%
hd    0.47%

Major coding performance gains are packed in several sequences with
intense motion activities, e.g., ped_1080p gains 7% at high bit-rates,
and on average 3%.

TODO: Need to further tune the rate control and motion search units.

Change-Id: Ib842540a6796fbee5a797809433ef6a477c6d78d

vp9/common/vp9_entropymv.c
vp9/common/vp9_entropymv.h
vp9/encoder/vp9_encodeframe.c
vp9/encoder/vp9_firstpass.c
vp9/encoder/vp9_mbgraph.c
vp9/encoder/vp9_mcomp.c
vp9/encoder/vp9_mcomp.h
vp9/encoder/vp9_rdopt.c

index 99e3c2e8c2424658fa8432d70bccff2bec43e540..185cc9a09cf9ea22a2dda6511bbb932fdc8b5cef 100644 (file)
@@ -42,7 +42,9 @@ const vp9_tree_index vp9_mv_class_tree[2 * MV_CLASSES - 2] = {
   -MV_CLASS_2, -MV_CLASS_3,
   10, 12,
   -MV_CLASS_4, -MV_CLASS_5,
+  14, 16,
   -MV_CLASS_6, -MV_CLASS_7,
+  -MV_CLASS_8, -MV_CLASS_9,
 };
 struct vp9_token_struct vp9_mv_class_encodings[MV_CLASSES];
 
@@ -63,9 +65,9 @@ const nmv_context vp9_default_nmv_context = {
   {
     { /* vert component */
       128,                                             /* sign */
-      {224, 144, 192, 168, 192, 176, 192},             /* class */
+      {224, 144, 192, 168, 192, 176, 192, 198, 198},   /* class */
       {216},                                           /* class0 */
-      {136, 140, 148, 160, 176, 192, 224},             /* bits */
+      {136, 140, 148, 160, 176, 192, 224, 234, 234},   /* bits */
       {{128, 128, 64}, {96, 112, 64}},                 /* class0_fp */
       {64, 96, 64},                                    /* fp */
       160,                                             /* class0_hp bit */
@@ -73,9 +75,9 @@ const nmv_context vp9_default_nmv_context = {
     },
     { /* hor component */
       128,                                             /* sign */
-      {216, 128, 176, 160, 176, 176, 192},             /* class */
+      {216, 128, 176, 160, 176, 176, 192, 198, 198},   /* class */
       {208},                                           /* class0 */
-      {136, 140, 148, 160, 176, 192, 224},             /* bits */
+      {136, 140, 148, 160, 176, 192, 224, 234, 234},   /* bits */
       {{128, 128, 64}, {96, 112, 64}},                 /* class0_fp */
       {64, 96, 64},                                    /* fp */
       160,                                             /* class0_hp bit */
@@ -103,6 +105,8 @@ MV_CLASS_TYPE vp9_get_mv_class(int z, int *offset) {
   else if (z < CLASS0_SIZE * 256)  c = MV_CLASS_5;
   else if (z < CLASS0_SIZE * 512)  c = MV_CLASS_6;
   else if (z < CLASS0_SIZE * 1024) c = MV_CLASS_7;
+  else if (z < CLASS0_SIZE * 2048) c = MV_CLASS_8;
+  else if (z < CLASS0_SIZE * 4096) c = MV_CLASS_9;
   else assert(0);
   if (offset)
     *offset = z - mv_class_base(c);
index f5cfee9379e0affd7f1d337865eaa230ce839055..33500069e7afc48c76d3234ee6c9dbd6fde1d56e 100644 (file)
@@ -49,7 +49,7 @@ extern const vp9_tree_index vp9_mv_joint_tree[2 * MV_JOINTS - 2];
 extern struct vp9_token_struct vp9_mv_joint_encodings [MV_JOINTS];
 
 /* Symbols for coding magnitude class of nonzero components */
-#define MV_CLASSES     8
+#define MV_CLASSES     10
 typedef enum {
   MV_CLASS_0 = 0,      /* (0, 2]     integer pel */
   MV_CLASS_1 = 1,      /* (2, 4]     integer pel */
@@ -59,6 +59,8 @@ typedef enum {
   MV_CLASS_5 = 5,      /* (32, 64]   integer pel */
   MV_CLASS_6 = 6,      /* (64, 128]  integer pel */
   MV_CLASS_7 = 7,      /* (128, 256] integer pel */
+  MV_CLASS_8 = 8,      /* (256, 512] integer pel */
+  MV_CLASS_9 = 9,      /* (512, 1024] integer pel */
 } MV_CLASS_TYPE;
 
 extern const vp9_tree_index vp9_mv_class_tree[2 * MV_CLASSES - 2];
index f2be96dd77598b5cc4b7edc70ec00eab1a120a53..9ca7677a3c1ebf85a7cabf27977aa5c89958aa6d 100644 (file)
@@ -1241,8 +1241,9 @@ static void encode_frame_internal(VP9_COMP *cpi) {
   MACROBLOCKD *const xd = &x->e_mbd;
   int totalrate;
 
-//   fprintf(stderr, "encode_frame_internal frame %d (%d)\n",
-//          cpi->common.current_video_frame, cpi->common.show_frame);
+//   fprintf(stderr, "encode_frame_internal frame %d (%d) type %d\n",
+//            cpi->common.current_video_frame, cpi->common.show_frame,
+//            cm->frame_type);
 
   // Compute a modified set of reference frame probabilities to use when
   // prediction fails. These are based on the current general estimates for
index 337276d5919b81b29e3d28ae633a9c65d71d5ffd..5e2f323a213cdd9cb73f4be0c3741073377be94c 100644 (file)
@@ -378,6 +378,19 @@ static void first_pass_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
   vp9_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[BLOCK_16X16];
   int new_mv_mode_penalty = 256;
 
+  int sr = 0;
+  int quart_frm = MIN(cpi->common.Width, cpi->common.Height);
+
+  // refine the motion search range accroding to the frame dimension
+  // for first pass test
+  while ((quart_frm << sr) < MAX_FULL_PEL_VAL)
+    sr++;
+  if (sr)
+    sr--;
+
+  step_param    += sr;
+  further_steps -= sr;
+
   // override the default variance function to use MSE
   v_fn_ptr.vf = vp9_mse16x16;
 
index 121de653f8919cf6cdc650032046a83a971bc8f8..715d683778a3dfc596c6ddfb8961b8020e6d8e62 100644 (file)
@@ -420,7 +420,7 @@ static void separate_arf_mbs(VP9_COMP *cpi) {
       cpi->static_mb_pct = (ncnt[1] * 100) / cm->MBs;
 
     // This error case should not be reachable as this function should
-    // never be called with the common data structure unititialized.
+    // never be called with the common data structure uninitialized.
     else
       cpi->static_mb_pct = 0;
 
index 300d9f85c6b2aebf5d5adf7afd4887ddf8e01bfb..5fd1e83cdd9c6058e6667ccd51cc04e0bcecdde0 100644 (file)
@@ -21,9 +21,9 @@
 
 void vp9_clamp_mv_min_max(MACROBLOCK *x, int_mv *ref_mv) {
   int col_min = (ref_mv->as_mv.col >> 3) - MAX_FULL_PEL_VAL +
-      ((ref_mv->as_mv.col & 7) ? 1 : 0);
+                                 ((ref_mv->as_mv.col & 7) ? 1 : 0);
   int row_min = (ref_mv->as_mv.row >> 3) - MAX_FULL_PEL_VAL +
-      ((ref_mv->as_mv.row & 7) ? 1 : 0);
+                                 ((ref_mv->as_mv.row & 7) ? 1 : 0);
   int col_max = (ref_mv->as_mv.col >> 3) + MAX_FULL_PEL_VAL;
   int row_max = (ref_mv->as_mv.row >> 3) + MAX_FULL_PEL_VAL;
 
@@ -38,6 +38,19 @@ void vp9_clamp_mv_min_max(MACROBLOCK *x, int_mv *ref_mv) {
     x->mv_row_max = row_max;
 }
 
+int vp9_init_search_range(int width, int height) {
+  int sr = 0;
+  int frm = MIN(width, height);
+
+  while ((frm << sr) < MAX_FULL_PEL_VAL)
+    sr++;
+
+  if (sr)
+    sr--;
+
+  return sr;
+}
+
 int vp9_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvjcost, int *mvcost[2],
                     int weight, int ishp) {
   MV v;
index 2479d7235017493391e1ea2480a9572a2b616f3d..d5c7032a91ded0d8e45174fa810402835f277dea 100644 (file)
 void print_mode_context(VP9_COMMON *pc);
 #endif
 
-
-#define MAX_MVSEARCH_STEPS 8                                    // The maximum number of steps in a step search given the largest allowed initial step
-#define MAX_FULL_PEL_VAL ((1 << (MAX_MVSEARCH_STEPS)) - 1)      // Max full pel mv specified in 1 pel units
-#define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS-1))            // Maximum size of the first step in full pel units
+// The maximum number of steps in a step search given the largest
+// allowed initial step
+#define MAX_MVSEARCH_STEPS 10
+// Max full pel mv specified in 1 pel units
+#define MAX_FULL_PEL_VAL ((1 << (MAX_MVSEARCH_STEPS)) - 1)
+// Maximum size of the first step in full pel units
+#define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS-1))
 
 void vp9_clamp_mv_min_max(MACROBLOCK *x, int_mv *ref_mv);
+int vp9_init_search_range(int width, int height);
+
 int vp9_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvjcost,
                            int *mvcost[2], int weight, int ishp);
 void vp9_init_dsmotion_compensation(MACROBLOCK *x, int stride);
index 8778f7028b58a9223dc794370113990296f125dd..cdc8edd0316cdc097f7f53146ac66b03b798bf1c 100644 (file)
@@ -3505,6 +3505,8 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
 
         vp9_clamp_mv_min_max(x, &ref_mv[0]);
 
+        sr = vp9_init_search_range(cpi->common.Width, cpi->common.Height);
+
         // mvp_full.as_int = ref_mv[0].as_int;
         mvp_full.as_int =
          mbmi->ref_mvs[refs[0]][x->mv_best_ref_index[refs[0]]].as_int;