LCOV - code coverage report
Current view: top level - Codec - EbGlobalMotionEstimationCost.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 30 39 76.9 %
Date: 2019-11-25 17:38:06 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             : * Copyright(c) 2019 Intel Corporation
       3             : * SPDX - License - Identifier: BSD - 2 - Clause - Patent
       4             : */
       5             : 
       6             : /*
       7             : * Copyright (c) 2016, Alliance for Open Media. All rights reserved
       8             : *
       9             : * This source code is subject to the terms of the BSD 2 Clause License and
      10             : * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
      11             : * was not distributed with this source code in the LICENSE file, you can
      12             : * obtain it at www.aomedia.org/license/software. If the Alliance for Open
      13             : * Media Patent License 1.0 was not distributed with this source code in the
      14             : * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
      15             : */
      16             : 
      17             : 
      18             : #include "EbGlobalMotionEstimationCost.h"
      19             : #include "EbEntropyCoding.h"
      20             : #include "global_motion.h"
      21             : 
      22             : 
      23         452 : int aom_count_signed_primitive_refsubexpfin(uint16_t n, uint16_t k, int16_t ref,
      24             :                                             int16_t v) {
      25         452 :   ref += n - 1;
      26         452 :   v += n - 1;
      27         452 :   const uint16_t scaled_n = (n << 1) - 1;
      28         452 :   return eb_aom_count_primitive_refsubexpfin(scaled_n, k, ref, v);
      29             : }
      30             : 
      31             : #define GLOBAL_TRANS_TYPES_ENC 3  // highest motion model to search
      32         113 : int gm_get_params_cost(const EbWarpedMotionParams *gm,
      33             :                        const EbWarpedMotionParams *ref_gm, int allow_hp)
      34             : {
      35         113 :   int params_cost = 0;
      36             :   int trans_bits, trans_prec_diff;
      37         113 :   switch (gm->wmtype) {
      38         113 :     case AFFINE:
      39             :     case ROTZOOM:
      40         226 :       params_cost += aom_count_signed_primitive_refsubexpfin(
      41             :           GM_ALPHA_MAX + 1, SUBEXPFIN_K,
      42         113 :           (ref_gm->wmmat[2] >> GM_ALPHA_PREC_DIFF) - (1 << GM_ALPHA_PREC_BITS),
      43         113 :           (gm->wmmat[2] >> GM_ALPHA_PREC_DIFF) - (1 << GM_ALPHA_PREC_BITS));
      44         226 :       params_cost += aom_count_signed_primitive_refsubexpfin(
      45             :           GM_ALPHA_MAX + 1, SUBEXPFIN_K,
      46         113 :           (ref_gm->wmmat[3] >> GM_ALPHA_PREC_DIFF),
      47         113 :           (gm->wmmat[3] >> GM_ALPHA_PREC_DIFF));
      48         113 :       if (gm->wmtype >= AFFINE) {
      49           0 :         params_cost += aom_count_signed_primitive_refsubexpfin(
      50             :             GM_ALPHA_MAX + 1, SUBEXPFIN_K,
      51           0 :             (ref_gm->wmmat[4] >> GM_ALPHA_PREC_DIFF),
      52           0 :             (gm->wmmat[4] >> GM_ALPHA_PREC_DIFF));
      53           0 :         params_cost += aom_count_signed_primitive_refsubexpfin(
      54             :             GM_ALPHA_MAX + 1, SUBEXPFIN_K,
      55           0 :             (ref_gm->wmmat[5] >> GM_ALPHA_PREC_DIFF) -
      56             :                 (1 << GM_ALPHA_PREC_BITS),
      57           0 :             (gm->wmmat[5] >> GM_ALPHA_PREC_DIFF) - (1 << GM_ALPHA_PREC_BITS));
      58             :       }
      59             :       AOM_FALLTHROUGH_INTENDED;
      60             :     case TRANSLATION:
      61         226 :       trans_bits = (gm->wmtype == TRANSLATION)
      62           0 :                        ? GM_ABS_TRANS_ONLY_BITS - !allow_hp
      63         113 :                        : GM_ABS_TRANS_BITS;
      64         226 :       trans_prec_diff = (gm->wmtype == TRANSLATION)
      65           0 :                             ? GM_TRANS_ONLY_PREC_DIFF + !allow_hp
      66         113 :                             : GM_TRANS_PREC_DIFF;
      67         226 :       params_cost += aom_count_signed_primitive_refsubexpfin(
      68         113 :           (1 << trans_bits) + 1, SUBEXPFIN_K,
      69         113 :           (ref_gm->wmmat[0] >> trans_prec_diff),
      70         113 :           (gm->wmmat[0] >> trans_prec_diff));
      71         113 :       params_cost += aom_count_signed_primitive_refsubexpfin(
      72         113 :           (1 << trans_bits) + 1, SUBEXPFIN_K,
      73         113 :           (ref_gm->wmmat[1] >> trans_prec_diff),
      74         113 :           (gm->wmmat[1] >> trans_prec_diff));
      75             :       AOM_FALLTHROUGH_INTENDED;
      76         113 :     case IDENTITY: break;
      77           0 :     default: assert(0);
      78             :   }
      79         113 :   return (params_cost << AV1_PROB_COST_SHIFT);
      80             : }

Generated by: LCOV version 1.14