• Deb Mukherjee's avatar
    Adds feature for companded MV encoding · 2b26cf17
    Deb Mukherjee authored
    The high-precision (1/8) pel bit is turned off if the reference
    MV is larger than a threshold. The motivation for this patch is
    the intuition that if motion is likely large (as indicated by
    the reference), there is likley to be more motion blur, and as
    a result 1/8 pel precision would be wasteful both in rd sense
    as well as computationally.
    
    The feature is incorporated as part of the newmventropy experiment.
    There is a modest RD improvement with the patch. Overall the
    results with the newmventropy experiment with the threshold being
    16 integer pels are:
    
    derf: +0.279%
    std-hd: +0.617%
    hd: +1.299%
    yt: +0.822%
    
    With threshold 8 integer pels are:
    
    derf: +0.295%
    std-hd: +0.623%
    hd: +1.365%
    yt: +0.847%
    
    Patch: rebased
    Patch: rebase fixes
    
    Change-Id: I4ed14600df3c457944e6541ed407cb6e91fe428b
    2b26cf17
encodemv.c 31.62 KiB
/*
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */
#include "vp8/common/common.h"
#include "encodemv.h"
#include "vp8/common/entropymode.h"
#include "vp8/common/systemdependent.h"
#include <math.h>
#ifdef ENTROPY_STATS
extern unsigned int active_section;
#endif
//extern int final_packing;
#if CONFIG_NEWMVENTROPY
#ifdef NMV_STATS
nmv_context_counts tnmvcounts;
#endif
static void encode_nmv_component(vp8_writer *w,
                                 int v,
                                 int r,
                                 const nmv_component *mvcomp) {
  int s, z, c, o, d;
  assert (v != 0);            /* should not be zero */
  s = v < 0;
  vp8_write(w, s, mvcomp->sign);
  z = (s ? -v : v) - 1;       /* magnitude - 1 */
  c = vp8_get_mv_class(z, &o);
  vp8_write_token(w, vp8_mv_class_tree, mvcomp->classes,
                  vp8_mv_class_encodings + c);
  d = (o >> 3);               /* int mv data */
  if (c == MV_CLASS_0) {
    vp8_write_token(w, vp8_mv_class0_tree, mvcomp->class0,
                    vp8_mv_class0_encodings + d);
  } else {
    int i, b;
    b = c + CLASS0_BITS - 1;  /* number of bits */
    for (i = 0; i < b; ++i)
      vp8_write(w, ((d >> i) & 1), mvcomp->bits[i]);
static void encode_nmv_component_fp(vp8_writer *w,
                                    int v,
                                    int r,
                                    const nmv_component *mvcomp,
                                    int usehp) {
  int s, z, c, o, d, f, e;
  assert (v != 0);            /* should not be zero */
  s = v < 0;
  z = (s ? -v : v) - 1;       /* magnitude - 1 */
  c = vp8_get_mv_class(z, &o);