LCOV - code coverage report
Current view: top level - third_party/aom/av1/common - av1_fwd_txfm2d.c (source / functions) Hit Total Coverage
Test: output.info Lines: 0 80 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
       3             :  *
       4             :  * This source code is subject to the terms of the BSD 2 Clause License and
       5             :  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
       6             :  * was not distributed with this source code in the LICENSE file, you can
       7             :  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
       8             :  * Media Patent License 1.0 was not distributed with this source code in the
       9             :  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
      10             :  */
      11             : 
      12             : #include <assert.h>
      13             : 
      14             : #include "./av1_rtcd.h"
      15             : #include "av1/common/enums.h"
      16             : #include "av1/common/av1_fwd_txfm1d.h"
      17             : #include "av1/common/av1_fwd_txfm1d_cfg.h"
      18             : #include "av1/common/av1_txfm.h"
      19             : 
      20           0 : static INLINE TxfmFunc fwd_txfm_type_to_func(TXFM_TYPE txfm_type) {
      21           0 :   switch (txfm_type) {
      22           0 :     case TXFM_TYPE_DCT4: return av1_fdct4_new;
      23           0 :     case TXFM_TYPE_DCT8: return av1_fdct8_new;
      24           0 :     case TXFM_TYPE_DCT16: return av1_fdct16_new;
      25           0 :     case TXFM_TYPE_DCT32: return av1_fdct32_new;
      26           0 :     case TXFM_TYPE_ADST4: return av1_fadst4_new;
      27           0 :     case TXFM_TYPE_ADST8: return av1_fadst8_new;
      28           0 :     case TXFM_TYPE_ADST16: return av1_fadst16_new;
      29           0 :     case TXFM_TYPE_ADST32: return av1_fadst32_new;
      30             : #if CONFIG_EXT_TX
      31           0 :     case TXFM_TYPE_IDENTITY4: return av1_fidentity4_c;
      32           0 :     case TXFM_TYPE_IDENTITY8: return av1_fidentity8_c;
      33           0 :     case TXFM_TYPE_IDENTITY16: return av1_fidentity16_c;
      34           0 :     case TXFM_TYPE_IDENTITY32: return av1_fidentity32_c;
      35             : #endif  // CONFIG_EXT_TX
      36           0 :     default: assert(0); return NULL;
      37             :   }
      38             : }
      39             : 
      40           0 : static INLINE void fwd_txfm2d_c(const int16_t *input, int32_t *output,
      41             :                                 const int stride, const TXFM_2D_FLIP_CFG *cfg,
      42             :                                 int32_t *buf) {
      43             :   int c, r;
      44             :   // TODO(sarahparker) must correct for rectangular transforms in follow up
      45           0 :   const int txfm_size = cfg->row_cfg->txfm_size;
      46           0 :   const int8_t *shift = cfg->row_cfg->shift;
      47           0 :   const int8_t *stage_range_col = cfg->col_cfg->stage_range;
      48           0 :   const int8_t *stage_range_row = cfg->row_cfg->stage_range;
      49           0 :   const int8_t *cos_bit_col = cfg->col_cfg->cos_bit;
      50           0 :   const int8_t *cos_bit_row = cfg->row_cfg->cos_bit;
      51           0 :   const TxfmFunc txfm_func_col = fwd_txfm_type_to_func(cfg->col_cfg->txfm_type);
      52           0 :   const TxfmFunc txfm_func_row = fwd_txfm_type_to_func(cfg->row_cfg->txfm_type);
      53             : 
      54             :   // use output buffer as temp buffer
      55           0 :   int32_t *temp_in = output;
      56           0 :   int32_t *temp_out = output + txfm_size;
      57             : 
      58             :   // Columns
      59           0 :   for (c = 0; c < txfm_size; ++c) {
      60           0 :     if (cfg->ud_flip == 0) {
      61           0 :       for (r = 0; r < txfm_size; ++r) temp_in[r] = input[r * stride + c];
      62             :     } else {
      63           0 :       for (r = 0; r < txfm_size; ++r)
      64             :         // flip upside down
      65           0 :         temp_in[r] = input[(txfm_size - r - 1) * stride + c];
      66             :     }
      67           0 :     round_shift_array(temp_in, txfm_size, -shift[0]);
      68           0 :     txfm_func_col(temp_in, temp_out, cos_bit_col, stage_range_col);
      69           0 :     round_shift_array(temp_out, txfm_size, -shift[1]);
      70           0 :     if (cfg->lr_flip == 0) {
      71           0 :       for (r = 0; r < txfm_size; ++r) buf[r * txfm_size + c] = temp_out[r];
      72             :     } else {
      73           0 :       for (r = 0; r < txfm_size; ++r)
      74             :         // flip from left to right
      75           0 :         buf[r * txfm_size + (txfm_size - c - 1)] = temp_out[r];
      76             :     }
      77             :   }
      78             : 
      79             :   // Rows
      80           0 :   for (r = 0; r < txfm_size; ++r) {
      81           0 :     txfm_func_row(buf + r * txfm_size, output + r * txfm_size, cos_bit_row,
      82             :                   stage_range_row);
      83           0 :     round_shift_array(output + r * txfm_size, txfm_size, -shift[2]);
      84             :   }
      85           0 : }
      86             : 
      87           0 : void av1_fwd_txfm2d_4x4_c(const int16_t *input, int32_t *output, int stride,
      88             :                           int tx_type, int bd) {
      89             :   int32_t txfm_buf[4 * 4];
      90           0 :   TXFM_2D_FLIP_CFG cfg = av1_get_fwd_txfm_cfg(tx_type, TX_4X4);
      91             :   (void)bd;
      92           0 :   fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf);
      93           0 : }
      94             : 
      95           0 : void av1_fwd_txfm2d_8x8_c(const int16_t *input, int32_t *output, int stride,
      96             :                           int tx_type, int bd) {
      97             :   int32_t txfm_buf[8 * 8];
      98           0 :   TXFM_2D_FLIP_CFG cfg = av1_get_fwd_txfm_cfg(tx_type, TX_8X8);
      99             :   (void)bd;
     100           0 :   fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf);
     101           0 : }
     102             : 
     103           0 : void av1_fwd_txfm2d_16x16_c(const int16_t *input, int32_t *output, int stride,
     104             :                             int tx_type, int bd) {
     105             :   int32_t txfm_buf[16 * 16];
     106           0 :   TXFM_2D_FLIP_CFG cfg = av1_get_fwd_txfm_cfg(tx_type, TX_16X16);
     107             :   (void)bd;
     108           0 :   fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf);
     109           0 : }
     110             : 
     111           0 : void av1_fwd_txfm2d_32x32_c(const int16_t *input, int32_t *output, int stride,
     112             :                             int tx_type, int bd) {
     113             :   int32_t txfm_buf[32 * 32];
     114           0 :   TXFM_2D_FLIP_CFG cfg = av1_get_fwd_txfm_cfg(tx_type, TX_32X32);
     115             :   (void)bd;
     116           0 :   fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf);
     117           0 : }
     118             : 
     119           0 : void av1_fwd_txfm2d_64x64_c(const int16_t *input, int32_t *output, int stride,
     120             :                             int tx_type, int bd) {
     121             :   int32_t txfm_buf[64 * 64];
     122           0 :   TXFM_2D_FLIP_CFG cfg = av1_get_fwd_txfm_64x64_cfg(tx_type);
     123             :   (void)bd;
     124           0 :   fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf);
     125           0 : }
     126             : 
     127             : static const TXFM_1D_CFG *fwd_txfm_col_cfg_ls[TX_TYPES_1D][TX_SIZES] = {
     128             :   // DCT
     129             :   {
     130             : #if CONFIG_CHROMA_2X2
     131             :       NULL,
     132             : #endif
     133             :       &fwd_txfm_1d_col_cfg_dct_4, &fwd_txfm_1d_col_cfg_dct_8,
     134             :       &fwd_txfm_1d_col_cfg_dct_16, &fwd_txfm_1d_col_cfg_dct_32 },
     135             :   // ADST
     136             :   {
     137             : #if CONFIG_CHROMA_2X2
     138             :       NULL,
     139             : #endif
     140             :       &fwd_txfm_1d_col_cfg_adst_4, &fwd_txfm_1d_col_cfg_adst_8,
     141             :       &fwd_txfm_1d_col_cfg_adst_16, &fwd_txfm_1d_col_cfg_adst_32 },
     142             : #if CONFIG_EXT_TX
     143             :   // FLIPADST
     144             :   {
     145             : #if CONFIG_CHROMA_2X2
     146             :       NULL,
     147             : #endif
     148             :       &fwd_txfm_1d_col_cfg_adst_4, &fwd_txfm_1d_col_cfg_adst_8,
     149             :       &fwd_txfm_1d_col_cfg_adst_16, &fwd_txfm_1d_col_cfg_adst_32 },
     150             :   // IDENTITY
     151             :   {
     152             : #if CONFIG_CHROMA_2X2
     153             :       NULL,
     154             : #endif
     155             :       &fwd_txfm_1d_cfg_identity_4, &fwd_txfm_1d_cfg_identity_8,
     156             :       &fwd_txfm_1d_cfg_identity_16, &fwd_txfm_1d_cfg_identity_32 },
     157             : #endif  // CONFIG_EXT_TX
     158             : };
     159             : 
     160             : static const TXFM_1D_CFG *fwd_txfm_row_cfg_ls[TX_TYPES_1D][TX_SIZES] = {
     161             :   // DCT
     162             :   {
     163             : #if CONFIG_CHROMA_2X2
     164             :       NULL,
     165             : #endif
     166             :       &fwd_txfm_1d_row_cfg_dct_4, &fwd_txfm_1d_row_cfg_dct_8,
     167             :       &fwd_txfm_1d_row_cfg_dct_16, &fwd_txfm_1d_row_cfg_dct_32 },
     168             :   // ADST
     169             :   {
     170             : #if CONFIG_CHROMA_2X2
     171             :       NULL,
     172             : #endif
     173             :       &fwd_txfm_1d_row_cfg_adst_4, &fwd_txfm_1d_row_cfg_adst_8,
     174             :       &fwd_txfm_1d_row_cfg_adst_16, &fwd_txfm_1d_row_cfg_adst_32 },
     175             : #if CONFIG_EXT_TX
     176             :   // FLIPADST
     177             :   {
     178             : #if CONFIG_CHROMA_2X2
     179             :       NULL,
     180             : #endif
     181             :       &fwd_txfm_1d_row_cfg_adst_4, &fwd_txfm_1d_row_cfg_adst_8,
     182             :       &fwd_txfm_1d_row_cfg_adst_16, &fwd_txfm_1d_row_cfg_adst_32 },
     183             :   // IDENTITY
     184             :   {
     185             : #if CONFIG_CHROMA_2X2
     186             :       NULL,
     187             : #endif
     188             :       &fwd_txfm_1d_cfg_identity_4, &fwd_txfm_1d_cfg_identity_8,
     189             :       &fwd_txfm_1d_cfg_identity_16, &fwd_txfm_1d_cfg_identity_32 },
     190             : #endif  // CONFIG_EXT_TX
     191             : };
     192             : 
     193           0 : TXFM_2D_FLIP_CFG av1_get_fwd_txfm_cfg(int tx_type, int tx_size) {
     194             :   TXFM_2D_FLIP_CFG cfg;
     195           0 :   set_flip_cfg(tx_type, &cfg);
     196           0 :   int tx_type_col = vtx_tab[tx_type];
     197           0 :   int tx_type_row = htx_tab[tx_type];
     198           0 :   cfg.col_cfg = fwd_txfm_col_cfg_ls[tx_type_col][tx_size];
     199           0 :   cfg.row_cfg = fwd_txfm_row_cfg_ls[tx_type_row][tx_size];
     200           0 :   return cfg;
     201             : }
     202             : 
     203           0 : TXFM_2D_FLIP_CFG av1_get_fwd_txfm_64x64_cfg(int tx_type) {
     204             :   TXFM_2D_FLIP_CFG cfg;
     205           0 :   switch (tx_type) {
     206             :     case DCT_DCT:
     207           0 :       cfg.col_cfg = &fwd_txfm_1d_col_cfg_dct_64;
     208           0 :       cfg.row_cfg = &fwd_txfm_1d_row_cfg_dct_64;
     209           0 :       cfg.ud_flip = 0;
     210           0 :       cfg.lr_flip = 0;
     211           0 :       break;
     212             :     default:
     213           0 :       cfg.ud_flip = 0;
     214           0 :       cfg.lr_flip = 0;
     215           0 :       assert(0);
     216             :   }
     217           0 :   return cfg;
     218             : }

Generated by: LCOV version 1.13