LCOV - code coverage report
Current view: top level - Codec - EbHmCode.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 199 0.0 %
Date: 2019-11-25 17:38:06 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /* The copyright in this software is being made available under the BSD
       2             : * License, included below. This software may be subject to other third party
       3             : * and contributor rights, including patent rights, and no such rights are
       4             : * granted under this license.
       5             : *
       6             : * Copyright  2010-2014, ITU/ISO/IEC
       7             : * All rights reserved.
       8             : *
       9             : * Redistribution and use in source and binary forms, with or without
      10             : * modification, are permitted provided that the following conditions are met:
      11             : *
      12             : *  * Redistributions of source code must retain the above copyright notice,
      13             : *    this list of conditions and the following disclaimer.
      14             : *  * Redistributions in binary form must reproduce the above copyright notice,
      15             : *    this list of conditions and the following disclaimer in the documentation
      16             : *    and/or other materials provided with the distribution.
      17             : *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
      18             : *    be used to endorse or promote products derived from this software without
      19             : *    specific prior written permission.
      20             : *
      21             : * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
      22             : * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
      23             : * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
      24             : * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
      25             : * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      26             : * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
      27             : * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
      28             : * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
      29             : * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
      30             : * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
      31             : * THE POSSIBILITY OF SUCH DAMAGE.
      32             : */
      33             : 
      34             : #include "EbHmCode.h"
      35             : #include "EbUtility.h"
      36             : 
      37             : /*******************************************
      38             : * compute4x4_satd
      39             : *   returns 4x4 Sum of Absolute Transformed Differences
      40             : *******************************************/
      41           0 : uint64_t compute4x4_satd(
      42             :     int16_t *diff)       // input parameter, diff samples Ptr
      43             : {
      44           0 :     uint64_t satdBlock4x4 = 0;
      45             :     int16_t m[16], d[16];
      46             :     uint32_t k;
      47             : 
      48             :     /*===== hadamard transform =====*/
      49           0 :     m[0] = diff[0] + diff[12];
      50           0 :     m[1] = diff[1] + diff[13];
      51           0 :     m[2] = diff[2] + diff[14];
      52           0 :     m[3] = diff[3] + diff[15];
      53           0 :     m[4] = diff[4] + diff[8];
      54           0 :     m[5] = diff[5] + diff[9];
      55           0 :     m[6] = diff[6] + diff[10];
      56           0 :     m[7] = diff[7] + diff[11];
      57           0 :     m[8] = diff[4] - diff[8];
      58           0 :     m[9] = diff[5] - diff[9];
      59           0 :     m[10] = diff[6] - diff[10];
      60           0 :     m[11] = diff[7] - diff[11];
      61           0 :     m[12] = diff[0] - diff[12];
      62           0 :     m[13] = diff[1] - diff[13];
      63           0 :     m[14] = diff[2] - diff[14];
      64           0 :     m[15] = diff[3] - diff[15];
      65             : 
      66           0 :     d[0] = m[0] + m[4];
      67           0 :     d[1] = m[1] + m[5];
      68           0 :     d[2] = m[2] + m[6];
      69           0 :     d[3] = m[3] + m[7];
      70           0 :     d[4] = m[8] + m[12];
      71           0 :     d[5] = m[9] + m[13];
      72           0 :     d[6] = m[10] + m[14];
      73           0 :     d[7] = m[11] + m[15];
      74           0 :     d[8] = m[0] - m[4];
      75           0 :     d[9] = m[1] - m[5];
      76           0 :     d[10] = m[2] - m[6];
      77           0 :     d[11] = m[3] - m[7];
      78           0 :     d[12] = m[12] - m[8];
      79           0 :     d[13] = m[13] - m[9];
      80           0 :     d[14] = m[14] - m[10];
      81           0 :     d[15] = m[15] - m[11];
      82             : 
      83           0 :     m[0] = d[0] + d[3];
      84           0 :     m[1] = d[1] + d[2];
      85           0 :     m[2] = d[1] - d[2];
      86           0 :     m[3] = d[0] - d[3];
      87           0 :     m[4] = d[4] + d[7];
      88           0 :     m[5] = d[5] + d[6];
      89           0 :     m[6] = d[5] - d[6];
      90           0 :     m[7] = d[4] - d[7];
      91           0 :     m[8] = d[8] + d[11];
      92           0 :     m[9] = d[9] + d[10];
      93           0 :     m[10] = d[9] - d[10];
      94           0 :     m[11] = d[8] - d[11];
      95           0 :     m[12] = d[12] + d[15];
      96           0 :     m[13] = d[13] + d[14];
      97           0 :     m[14] = d[13] - d[14];
      98           0 :     m[15] = d[12] - d[15];
      99             : 
     100           0 :     d[0] = m[0] + m[1];
     101           0 :     d[1] = m[0] - m[1];
     102           0 :     d[2] = m[2] + m[3];
     103           0 :     d[3] = m[3] - m[2];
     104           0 :     d[4] = m[4] + m[5];
     105           0 :     d[5] = m[4] - m[5];
     106           0 :     d[6] = m[6] + m[7];
     107           0 :     d[7] = m[7] - m[6];
     108           0 :     d[8] = m[8] + m[9];
     109           0 :     d[9] = m[8] - m[9];
     110           0 :     d[10] = m[10] + m[11];
     111           0 :     d[11] = m[11] - m[10];
     112           0 :     d[12] = m[12] + m[13];
     113           0 :     d[13] = m[12] - m[13];
     114           0 :     d[14] = m[14] + m[15];
     115           0 :     d[15] = m[15] - m[14];
     116             : 
     117           0 :     for (k = 0; k < 16; ++k)
     118           0 :         satdBlock4x4 += ABS(d[k]);
     119           0 :     satdBlock4x4 = ((satdBlock4x4 + 1) >> 1);
     120             : 
     121           0 :     return satdBlock4x4;
     122             : }
     123             : 
     124           0 : uint64_t compute4x4_satd_u8(
     125             :     uint8_t *src,       // input parameter, diff samples Ptr
     126             :     uint64_t *dc_value,
     127             :     uint32_t  src_stride)
     128             : {
     129           0 :     uint64_t satdBlock4x4 = 0;
     130             :     int16_t m[16], d[16];
     131             :     uint32_t k;
     132             : 
     133             :     /*===== hadamard transform =====*/
     134           0 :     m[0] = src[0] + src[3 * src_stride];
     135           0 :     m[1] = src[1] + src[1 + (3 * src_stride)];
     136           0 :     m[2] = src[2] + src[2 + (3 * src_stride)];
     137           0 :     m[3] = src[3] + src[3 + (3 * src_stride)];
     138           0 :     m[4] = src[src_stride] + src[2 * src_stride];
     139           0 :     m[5] = src[1 + src_stride] + src[1 + (2 * src_stride)];
     140           0 :     m[6] = src[2 + src_stride] + src[2 + (2 * src_stride)];
     141           0 :     m[7] = src[3 + src_stride] + src[3 + (2 * src_stride)];
     142           0 :     m[8] = src[src_stride] - src[2 * src_stride];
     143           0 :     m[9] = src[1 + src_stride] - src[1 + (2 * src_stride)];
     144           0 :     m[10] = src[2 + src_stride] - src[2 + (2 * src_stride)];
     145           0 :     m[11] = src[3 + src_stride] - src[3 + (2 * src_stride)];
     146           0 :     m[12] = src[0] - src[3 * src_stride];
     147           0 :     m[13] = src[1] - src[1 + (3 * src_stride)];
     148           0 :     m[14] = src[2] - src[2 + (3 * src_stride)];
     149           0 :     m[15] = src[3] - src[3 + (3 * src_stride)];
     150             : 
     151           0 :     d[0] = m[0] + m[4];
     152           0 :     d[1] = m[1] + m[5];
     153           0 :     d[2] = m[2] + m[6];
     154           0 :     d[3] = m[3] + m[7];
     155           0 :     d[4] = m[8] + m[12];
     156           0 :     d[5] = m[9] + m[13];
     157           0 :     d[6] = m[10] + m[14];
     158           0 :     d[7] = m[11] + m[15];
     159           0 :     d[8] = m[0] - m[4];
     160           0 :     d[9] = m[1] - m[5];
     161           0 :     d[10] = m[2] - m[6];
     162           0 :     d[11] = m[3] - m[7];
     163           0 :     d[12] = m[12] - m[8];
     164           0 :     d[13] = m[13] - m[9];
     165           0 :     d[14] = m[14] - m[10];
     166           0 :     d[15] = m[15] - m[11];
     167             : 
     168           0 :     m[0] = d[0] + d[3];
     169           0 :     m[1] = d[1] + d[2];
     170           0 :     m[2] = d[1] - d[2];
     171           0 :     m[3] = d[0] - d[3];
     172           0 :     m[4] = d[4] + d[7];
     173           0 :     m[5] = d[5] + d[6];
     174           0 :     m[6] = d[5] - d[6];
     175           0 :     m[7] = d[4] - d[7];
     176           0 :     m[8] = d[8] + d[11];
     177           0 :     m[9] = d[9] + d[10];
     178           0 :     m[10] = d[9] - d[10];
     179           0 :     m[11] = d[8] - d[11];
     180           0 :     m[12] = d[12] + d[15];
     181           0 :     m[13] = d[13] + d[14];
     182           0 :     m[14] = d[13] - d[14];
     183           0 :     m[15] = d[12] - d[15];
     184             : 
     185           0 :     d[0] = m[0] + m[1];
     186           0 :     d[1] = m[0] - m[1];
     187           0 :     d[2] = m[2] + m[3];
     188           0 :     d[3] = m[3] - m[2];
     189           0 :     d[4] = m[4] + m[5];
     190           0 :     d[5] = m[4] - m[5];
     191           0 :     d[6] = m[6] + m[7];
     192           0 :     d[7] = m[7] - m[6];
     193           0 :     d[8] = m[8] + m[9];
     194           0 :     d[9] = m[8] - m[9];
     195           0 :     d[10] = m[10] + m[11];
     196           0 :     d[11] = m[11] - m[10];
     197           0 :     d[12] = m[12] + m[13];
     198           0 :     d[13] = m[12] - m[13];
     199           0 :     d[14] = m[14] + m[15];
     200           0 :     d[15] = m[15] - m[14];
     201             : 
     202           0 :     for (k = 0; k < 16; ++k)
     203           0 :         satdBlock4x4 += ABS(d[k]);
     204           0 :     satdBlock4x4 = ((satdBlock4x4 + 1) >> 1);
     205           0 :     *dc_value += d[0];
     206           0 :     return satdBlock4x4;
     207             : }
     208             : 
     209           0 : uint64_t compute8x8_satd_u8_c(
     210             :     uint8_t* src,       // input parameter, diff samples Ptr
     211             :     uint64_t* dcValue,
     212             :     uint32_t  srcStride)
     213             : {
     214           0 :     uint64_t satdBlock8x8 = 0;
     215             :     int16_t m1[8][8], m2[8][8], m3[8][8];
     216             :     uint32_t i, j;
     217             : 
     218             :     // Horizontal
     219           0 :     for (j = 0; j < 8; j++) {
     220           0 :         m2[j][0] = src[j * srcStride] + src[j * srcStride + 4];
     221           0 :         m2[j][1] = src[j * srcStride + 1] + src[j * srcStride + 5];
     222           0 :         m2[j][2] = src[j * srcStride + 2] + src[j * srcStride + 6];
     223           0 :         m2[j][3] = src[j * srcStride + 3] + src[j * srcStride + 7];
     224           0 :         m2[j][4] = src[j * srcStride] - src[j * srcStride + 4];
     225           0 :         m2[j][5] = src[j * srcStride + 1] - src[j * srcStride + 5];
     226           0 :         m2[j][6] = src[j * srcStride + 2] - src[j * srcStride + 6];
     227           0 :         m2[j][7] = src[j * srcStride + 3] - src[j * srcStride + 7];
     228             : 
     229           0 :         m1[j][0] = m2[j][0] + m2[j][2];
     230           0 :         m1[j][1] = m2[j][1] + m2[j][3];
     231           0 :         m1[j][2] = m2[j][0] - m2[j][2];
     232           0 :         m1[j][3] = m2[j][1] - m2[j][3];
     233           0 :         m1[j][4] = m2[j][4] + m2[j][6];
     234           0 :         m1[j][5] = m2[j][5] + m2[j][7];
     235           0 :         m1[j][6] = m2[j][4] - m2[j][6];
     236           0 :         m1[j][7] = m2[j][5] - m2[j][7];
     237             : 
     238           0 :         m2[j][0] = m1[j][0] + m1[j][1];
     239           0 :         m2[j][1] = m1[j][0] - m1[j][1];
     240           0 :         m2[j][2] = m1[j][2] + m1[j][3];
     241           0 :         m2[j][3] = m1[j][2] - m1[j][3];
     242           0 :         m2[j][4] = m1[j][4] + m1[j][5];
     243           0 :         m2[j][5] = m1[j][4] - m1[j][5];
     244           0 :         m2[j][6] = m1[j][6] + m1[j][7];
     245           0 :         m2[j][7] = m1[j][6] - m1[j][7];
     246             :     }
     247             : 
     248             :     // Vertical
     249           0 :     for (i = 0; i < 8; i++) {
     250           0 :         m3[0][i] = m2[0][i] + m2[4][i];
     251           0 :         m3[1][i] = m2[1][i] + m2[5][i];
     252           0 :         m3[2][i] = m2[2][i] + m2[6][i];
     253           0 :         m3[3][i] = m2[3][i] + m2[7][i];
     254           0 :         m3[4][i] = m2[0][i] - m2[4][i];
     255           0 :         m3[5][i] = m2[1][i] - m2[5][i];
     256           0 :         m3[6][i] = m2[2][i] - m2[6][i];
     257           0 :         m3[7][i] = m2[3][i] - m2[7][i];
     258             : 
     259           0 :         m1[0][i] = m3[0][i] + m3[2][i];
     260           0 :         m1[1][i] = m3[1][i] + m3[3][i];
     261           0 :         m1[2][i] = m3[0][i] - m3[2][i];
     262           0 :         m1[3][i] = m3[1][i] - m3[3][i];
     263           0 :         m1[4][i] = m3[4][i] + m3[6][i];
     264           0 :         m1[5][i] = m3[5][i] + m3[7][i];
     265           0 :         m1[6][i] = m3[4][i] - m3[6][i];
     266           0 :         m1[7][i] = m3[5][i] - m3[7][i];
     267             : 
     268           0 :         m2[0][i] = m1[0][i] + m1[1][i];
     269           0 :         m2[1][i] = m1[0][i] - m1[1][i];
     270           0 :         m2[2][i] = m1[2][i] + m1[3][i];
     271           0 :         m2[3][i] = m1[2][i] - m1[3][i];
     272           0 :         m2[4][i] = m1[4][i] + m1[5][i];
     273           0 :         m2[5][i] = m1[4][i] - m1[5][i];
     274           0 :         m2[6][i] = m1[6][i] + m1[7][i];
     275           0 :         m2[7][i] = m1[6][i] - m1[7][i];
     276             :     }
     277             : 
     278           0 :     for (i = 0; i < 8; i++) {
     279           0 :         for (j = 0; j < 8; j++) {
     280           0 :             satdBlock8x8 += (uint64_t)ABS(m2[i][j]);
     281             :         }
     282             :     }
     283             : 
     284           0 :     satdBlock8x8 = ((satdBlock8x8 + 2) >> 2);
     285           0 :     *dcValue += m2[0][0];
     286           0 :     return satdBlock8x8;
     287             : }

Generated by: LCOV version 1.14