1aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/******************************************************************************
2aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
3aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * Copyright (C) 2015 The Android Open Source Project
4aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
5aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * Licensed under the Apache License, Version 2.0 (the "License");
6aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * you may not use this file except in compliance with the License.
7aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * You may obtain a copy of the License at:
8aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
9aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * http://www.apache.org/licenses/LICENSE-2.0
10aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
11aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * Unless required by applicable law or agreed to in writing, software
12aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * distributed under the License is distributed on an "AS IS" BASIS,
13aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * See the License for the specific language governing permissions and
15aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * limitations under the License.
16aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
17aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *****************************************************************************
18aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani*/
20aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*****************************************************************************/
21aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*                                                                           */
22aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*  File Name         : impeg2_idct.c                                        */
23aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*                                                                           */
24aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*  Description       : Contains 2d idct and invese quantization functions   */
25aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*                                                                           */
26aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*  List of Functions : impeg2_idct_recon_dc()                               */
27aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*                      impeg2_idct_recon_dc_mismatch()                      */
28aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*                      impeg2_idct_recon()                                  */
29aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*                                                                           */
30aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*  Issues / Problems : None                                                 */
31aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*                                                                           */
32aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*  Revision History  :                                                      */
33aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*                                                                           */
34aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*         DD MM YYYY   Author(s)       Changes                              */
35aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*         10 09 2005   Hairsh M        First Version                        */
36aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*                                                                           */
37aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*****************************************************************************/
38aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/*
39aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani  IEEE - 1180 results for this IDCT
40aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani  L                           256         256         5           5           300         300         384         384         Thresholds
41aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani  H                           255         255         5           5           300         300         383         383
42aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani  sign                        1           -1          1           -1          1           -1          1           -1
43aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani  Peak Error                  1           1           1           1           1           1           1           1           1
44aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani  Peak Mean Square Error      0.0191      0.0188      0.0108      0.0111      0.0176      0.0188      0.0165      0.0177      0.06
45aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani  Overall Mean Square Error   0.01566406  0.01597656  0.0091875   0.00908906  0.01499063  0.01533281  0.01432344  0.01412344  0.02
46aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani  Peak Mean Error             0.0027      0.0026      0.0028      0.002       0.0017      0.0033      0.0031      0.0025      0.015
47aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani  Overall Mean Error          0.00002656  -0.00031406 0.00016875  0.00005469  -0.00003125 0.00011406  0.00009219  0.00004219  0.0015
48aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani  */
49aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani#include <stdio.h>
50aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani#include <string.h>
51aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
52aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani#include "iv_datatypedef.h"
53aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani#include "iv.h"
54aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani#include "impeg2_defs.h"
55aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani#include "impeg2_platform_macros.h"
56aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
57aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani#include "impeg2_macros.h"
58aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani#include "impeg2_globals.h"
59aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani#include "impeg2_idct.h"
60aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
61aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
62aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhanivoid impeg2_idct_recon_dc(WORD16 *pi2_src,
63aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                            WORD16 *pi2_tmp,
64aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                            UWORD8 *pu1_pred,
65aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                            UWORD8 *pu1_dst,
66aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                            WORD32 i4_src_strd,
67aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                            WORD32 i4_pred_strd,
68aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                            WORD32 i4_dst_strd,
69aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                            WORD32 i4_zero_cols,
70aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                            WORD32 i4_zero_rows)
71aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani{
72aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    WORD32 i4_val, i, j;
73aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
74aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    UNUSED(pi2_tmp);
75aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    UNUSED(i4_src_strd);
76aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    UNUSED(i4_zero_cols);
77aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    UNUSED(i4_zero_rows);
78aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
79aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    i4_val = pi2_src[0] * gai2_impeg2_idct_q15[0];
80aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    i4_val = ((i4_val + IDCT_STG1_ROUND) >> IDCT_STG1_SHIFT);
81aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    i4_val = i4_val * gai2_impeg2_idct_q11[0];
82aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    i4_val = ((i4_val + IDCT_STG2_ROUND) >> IDCT_STG2_SHIFT);
83aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
84aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    for(i = 0; i < TRANS_SIZE_8; i++)
85aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    {
86aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        for(j = 0; j < TRANS_SIZE_8; j++)
87aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        {
88aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            pu1_dst[j] = CLIP_U8(i4_val + pu1_pred[j]);
89aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        }
90aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        pu1_dst  += i4_dst_strd;
91aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        pu1_pred += i4_pred_strd;
92aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    }
93aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani}
94aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhanivoid impeg2_idct_recon_dc_mismatch(WORD16 *pi2_src,
95aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                            WORD16 *pi2_tmp,
96aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                            UWORD8 *pu1_pred,
97aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                            UWORD8 *pu1_dst,
98aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                            WORD32 i4_src_strd,
99aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                            WORD32 i4_pred_strd,
100aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                            WORD32 i4_dst_strd,
101aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                            WORD32 i4_zero_cols,
102aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                            WORD32 i4_zero_rows)
103aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
104aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani{
105aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    WORD32 i4_val, i, j;
106aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    WORD32 i4_count = 0;
107aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    WORD32 i4_sum;
108aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
109aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    UNUSED(pi2_tmp);
110aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    UNUSED(i4_src_strd);
111aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    UNUSED(i4_zero_cols);
112aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    UNUSED(i4_zero_rows);
113aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
114aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    i4_val = pi2_src[0] * gai2_impeg2_idct_q15[0];
115aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    i4_val = ((i4_val + IDCT_STG1_ROUND) >> IDCT_STG1_SHIFT);
116aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
117aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    i4_val *= gai2_impeg2_idct_q11[0];
118aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    for(i = 0; i < TRANS_SIZE_8; i++)
119aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    {
120aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        for (j = 0; j < TRANS_SIZE_8; j++)
121aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        {
122aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            i4_sum = i4_val;
123aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            i4_sum += gai2_impeg2_mismatch_stg2_additive[i4_count];
124aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            i4_sum = ((i4_sum + IDCT_STG2_ROUND) >> IDCT_STG2_SHIFT);
125aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            i4_sum += pu1_pred[j];
126aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            pu1_dst[j] = CLIP_U8(i4_sum);
127aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            i4_count++;
128aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        }
129aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
130aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        pu1_dst  += i4_dst_strd;
131aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        pu1_pred += i4_pred_strd;
132aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    }
133aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
134aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani}
135aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani/**
136aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *******************************************************************************
137aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
138aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * @brief
139aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *  This function performs Inverse transform  and reconstruction for 8x8
140aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * input block
141aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
142aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * @par Description:
143aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *  Performs inverse transform and adds the prediction  data and clips output
144aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * to 8 bit
145aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
146aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * @param[in] pi2_src
147aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *  Input 8x8 coefficients
148aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
149aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * @param[in] pi2_tmp
150aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *  Temporary 8x8 buffer for storing inverse
151aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
152aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *  transform
153aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *  1st stage output
154aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
155aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * @param[in] pu1_pred
156aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *  Prediction 8x8 block
157aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
158aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * @param[out] pu1_dst
159aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *  Output 8x8 block
160aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
161aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * @param[in] src_strd
162aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *  Input stride
163aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
164aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * @param[in] pred_strd
165aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *  Prediction stride
166aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
167aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * @param[in] dst_strd
168aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *  Output Stride
169aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
170aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * @param[in] shift
171aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *  Output shift
172aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
173aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * @param[in] zero_cols
174aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *  Zero columns in pi2_src
175aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
176aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * @returns  Void
177aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
178aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani * @remarks
179aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *  None
180aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *
181aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani *******************************************************************************
182aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani */
183aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
184aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhanivoid impeg2_idct_recon(WORD16 *pi2_src,
185aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                        WORD16 *pi2_tmp,
186aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                        UWORD8 *pu1_pred,
187aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                        UWORD8 *pu1_dst,
188aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                        WORD32 i4_src_strd,
189aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                        WORD32 i4_pred_strd,
190aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                        WORD32 i4_dst_strd,
191aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                        WORD32 i4_zero_cols,
192aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                        WORD32 i4_zero_rows)
193aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani{
194aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    WORD32 j, k;
195aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    WORD32 ai4_e[4], ai4_o[4];
196aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    WORD32 ai4_ee[2], ai4_eo[2];
197aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    WORD32 i4_add;
198aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    WORD32 i4_shift;
199aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    WORD16 *pi2_tmp_orig;
200aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    WORD32 i4_trans_size;
201aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    WORD32 i4_zero_rows_2nd_stage = i4_zero_cols;
202aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    WORD32 i4_row_limit_2nd_stage;
203aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
204aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    i4_trans_size = TRANS_SIZE_8;
205aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
206aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    pi2_tmp_orig = pi2_tmp;
207aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
208aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    if((i4_zero_cols & 0xF0) == 0xF0)
209aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        i4_row_limit_2nd_stage = 4;
210aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    else
211aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        i4_row_limit_2nd_stage = TRANS_SIZE_8;
212aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
213aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
214aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    if((i4_zero_rows & 0xF0) == 0xF0) /* First 4 rows of input are non-zero */
215aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    {
216aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        /************************************************************************************************/
217aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        /**********************************START - IT_RECON_8x8******************************************/
218aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        /************************************************************************************************/
219aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
220aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        /* Inverse Transform 1st stage */
221aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        i4_shift = IDCT_STG1_SHIFT;
222aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        i4_add = 1 << (i4_shift - 1);
223aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
224aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        for(j = 0; j < i4_row_limit_2nd_stage; j++)
225aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        {
226aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            /* Checking for Zero Cols */
227aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            if((i4_zero_cols & 1) == 1)
228aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            {
229aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                memset(pi2_tmp, 0, i4_trans_size * sizeof(WORD16));
230aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            }
231aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            else
232aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            {
233aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
234aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                for(k = 0; k < 4; k++)
235aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                {
236aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    ai4_o[k] = gai2_impeg2_idct_q15[1 * 8 + k] * pi2_src[i4_src_strd]
237aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    + gai2_impeg2_idct_q15[3 * 8 + k]
238aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                                    * pi2_src[3 * i4_src_strd];
239aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                }
240aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_eo[0] = gai2_impeg2_idct_q15[2 * 8 + 0] * pi2_src[2 * i4_src_strd];
241aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_eo[1] = gai2_impeg2_idct_q15[2 * 8 + 1] * pi2_src[2 * i4_src_strd];
242aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_ee[0] = gai2_impeg2_idct_q15[0 * 8 + 0] * pi2_src[0];
243aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_ee[1] = gai2_impeg2_idct_q15[0 * 8 + 1] * pi2_src[0];
244aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
245aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                /* Combining e and o terms at each hierarchy levels to calculate the final spatial domain vector */
246aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[0] = ai4_ee[0] + ai4_eo[0];
247aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[3] = ai4_ee[0] - ai4_eo[0];
248aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[1] = ai4_ee[1] + ai4_eo[1];
249aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[2] = ai4_ee[1] - ai4_eo[1];
250aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                for(k = 0; k < 4; k++)
251aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                {
252aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    pi2_tmp[k] =
253aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    CLIP_S16(((ai4_e[k] + ai4_o[k] + i4_add) >> i4_shift));
254aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    pi2_tmp[k + 4] =
255aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    CLIP_S16(((ai4_e[3 - k] - ai4_o[3 - k] + i4_add) >> i4_shift));
256aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                }
257aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            }
258aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            pi2_src++;
259aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            pi2_tmp += i4_trans_size;
260aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            i4_zero_cols = i4_zero_cols >> 1;
261aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        }
262aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
263aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        pi2_tmp = pi2_tmp_orig;
264aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
265aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        /* Inverse Transform 2nd stage */
266aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        i4_shift = IDCT_STG2_SHIFT;
267aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        i4_add = 1 << (i4_shift - 1);
268aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        if((i4_zero_rows_2nd_stage & 0xF0) == 0xF0) /* First 4 rows of output of 1st stage are non-zero */
269aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        {
270aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            for(j = 0; j < i4_trans_size; j++)
271aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            {
272aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
273aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                for(k = 0; k < 4; k++)
274aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                {
275aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    ai4_o[k] = gai2_impeg2_idct_q11[1 * 8 + k] * pi2_tmp[i4_trans_size]
276aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    + gai2_impeg2_idct_q11[3 * 8 + k] * pi2_tmp[3 * i4_trans_size];
277aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                }
278aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_eo[0] = gai2_impeg2_idct_q11[2 * 8 + 0] * pi2_tmp[2 * i4_trans_size];
279aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_eo[1] = gai2_impeg2_idct_q11[2 * 8 + 1] * pi2_tmp[2 * i4_trans_size];
280aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_ee[0] = gai2_impeg2_idct_q11[0 * 8 + 0] * pi2_tmp[0];
281aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_ee[1] = gai2_impeg2_idct_q11[0 * 8 + 1] * pi2_tmp[0];
282aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
283aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                /* Combining e and o terms at each hierarchy levels to calculate the final spatial domain vector */
284aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[0] = ai4_ee[0] + ai4_eo[0];
285aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[3] = ai4_ee[0] - ai4_eo[0];
286aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[1] = ai4_ee[1] + ai4_eo[1];
287aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[2] = ai4_ee[1] - ai4_eo[1];
288aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                for(k = 0; k < 4; k++)
289aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                {
290aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    WORD32 itrans_out;
291aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    itrans_out =
292aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    CLIP_S16(((ai4_e[k] + ai4_o[k] + i4_add) >> i4_shift));
293aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    pu1_dst[k] = CLIP_U8((itrans_out + pu1_pred[k]));
294aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    itrans_out =
295aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    CLIP_S16(((ai4_e[3 - k] - ai4_o[3 - k] + i4_add) >> i4_shift));
296aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    pu1_dst[k + 4] = CLIP_U8((itrans_out + pu1_pred[k + 4]));
297aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                }
298aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                pi2_tmp++;
299aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                pu1_pred += i4_pred_strd;
300aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                pu1_dst += i4_dst_strd;
301aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            }
302aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        }
303aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        else /* All rows of output of 1st stage are non-zero */
304aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        {
305aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            for(j = 0; j < i4_trans_size; j++)
306aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            {
307aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
308aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                for(k = 0; k < 4; k++)
309aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                {
310aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    ai4_o[k] = gai2_impeg2_idct_q11[1 * 8 + k] * pi2_tmp[i4_trans_size]
311aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    + gai2_impeg2_idct_q11[3 * 8 + k]
312aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                                    * pi2_tmp[3 * i4_trans_size]
313aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    + gai2_impeg2_idct_q11[5 * 8 + k]
314aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                                    * pi2_tmp[5 * i4_trans_size]
315aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    + gai2_impeg2_idct_q11[7 * 8 + k]
316aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                                    * pi2_tmp[7 * i4_trans_size];
317aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                }
318aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
319aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_eo[0] = gai2_impeg2_idct_q11[2 * 8 + 0] * pi2_tmp[2 * i4_trans_size]
320aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                + gai2_impeg2_idct_q11[6 * 8 + 0] * pi2_tmp[6 * i4_trans_size];
321aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_eo[1] = gai2_impeg2_idct_q11[2 * 8 + 1] * pi2_tmp[2 * i4_trans_size]
322aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                + gai2_impeg2_idct_q11[6 * 8 + 1] * pi2_tmp[6 * i4_trans_size];
323aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_ee[0] = gai2_impeg2_idct_q11[0 * 8 + 0] * pi2_tmp[0]
324aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                + gai2_impeg2_idct_q11[4 * 8 + 0] * pi2_tmp[4 * i4_trans_size];
325aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_ee[1] = gai2_impeg2_idct_q11[0 * 8 + 1] * pi2_tmp[0]
326aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                + gai2_impeg2_idct_q11[4 * 8 + 1] * pi2_tmp[4 * i4_trans_size];
327aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
328aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                /* Combining e and o terms at each hierarchy levels to calculate the final spatial domain vector */
329aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[0] = ai4_ee[0] + ai4_eo[0];
330aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[3] = ai4_ee[0] - ai4_eo[0];
331aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[1] = ai4_ee[1] + ai4_eo[1];
332aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[2] = ai4_ee[1] - ai4_eo[1];
333aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                for(k = 0; k < 4; k++)
334aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                {
335aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    WORD32 itrans_out;
336aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    itrans_out =
337aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    CLIP_S16(((ai4_e[k] + ai4_o[k] + i4_add) >> i4_shift));
338aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    pu1_dst[k] = CLIP_U8((itrans_out + pu1_pred[k]));
339aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    itrans_out =
340aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    CLIP_S16(((ai4_e[3 - k] - ai4_o[3 - k] + i4_add) >> i4_shift));
341aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    pu1_dst[k + 4] = CLIP_U8((itrans_out + pu1_pred[k + 4]));
342aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                }
343aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                pi2_tmp++;
344aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                pu1_pred += i4_pred_strd;
345aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                pu1_dst += i4_dst_strd;
346aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            }
347aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        }
348aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        /************************************************************************************************/
349aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        /************************************END - IT_RECON_8x8******************************************/
350aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        /************************************************************************************************/
351aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    }
352aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    else /* All rows of input are non-zero */
353aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    {
354aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        /************************************************************************************************/
355aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        /**********************************START - IT_RECON_8x8******************************************/
356aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        /************************************************************************************************/
357aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
358aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        /* Inverse Transform 1st stage */
359aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        i4_shift = IDCT_STG1_SHIFT;
360aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        i4_add = 1 << (i4_shift - 1);
361aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
362aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        for(j = 0; j < i4_row_limit_2nd_stage; j++)
363aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        {
364aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            /* Checking for Zero Cols */
365aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            if((i4_zero_cols & 1) == 1)
366aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            {
367aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                memset(pi2_tmp, 0, i4_trans_size * sizeof(WORD16));
368aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            }
369aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            else
370aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            {
371aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
372aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                for(k = 0; k < 4; k++)
373aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                {
374aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    ai4_o[k] = gai2_impeg2_idct_q15[1 * 8 + k] * pi2_src[i4_src_strd]
375aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    + gai2_impeg2_idct_q15[3 * 8 + k]
376aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                                    * pi2_src[3 * i4_src_strd]
377aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    + gai2_impeg2_idct_q15[5 * 8 + k]
378aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                                    * pi2_src[5 * i4_src_strd]
379aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    + gai2_impeg2_idct_q15[7 * 8 + k]
380aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                                    * pi2_src[7 * i4_src_strd];
381aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                }
382aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
383aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_eo[0] = gai2_impeg2_idct_q15[2 * 8 + 0] * pi2_src[2 * i4_src_strd]
384aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                + gai2_impeg2_idct_q15[6 * 8 + 0] * pi2_src[6 * i4_src_strd];
385aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_eo[1] = gai2_impeg2_idct_q15[2 * 8 + 1] * pi2_src[2 * i4_src_strd]
386aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                + gai2_impeg2_idct_q15[6 * 8 + 1] * pi2_src[6 * i4_src_strd];
387aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_ee[0] = gai2_impeg2_idct_q15[0 * 8 + 0] * pi2_src[0]
388aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                + gai2_impeg2_idct_q15[4 * 8 + 0] * pi2_src[4 * i4_src_strd];
389aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_ee[1] = gai2_impeg2_idct_q15[0 * 8 + 1] * pi2_src[0]
390aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                + gai2_impeg2_idct_q15[4 * 8 + 1] * pi2_src[4 * i4_src_strd];
391aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
392aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                /* Combining e and o terms at each hierarchy levels to calculate the final spatial domain vector */
393aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[0] = ai4_ee[0] + ai4_eo[0];
394aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[3] = ai4_ee[0] - ai4_eo[0];
395aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[1] = ai4_ee[1] + ai4_eo[1];
396aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[2] = ai4_ee[1] - ai4_eo[1];
397aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                for(k = 0; k < 4; k++)
398aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                {
399aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    pi2_tmp[k] =
400aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    CLIP_S16(((ai4_e[k] + ai4_o[k] + i4_add) >> i4_shift));
401aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    pi2_tmp[k + 4] =
402aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    CLIP_S16(((ai4_e[3 - k] - ai4_o[3 - k] + i4_add) >> i4_shift));
403aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                }
404aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            }
405aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            pi2_src++;
406aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            pi2_tmp += i4_trans_size;
407aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            i4_zero_cols = i4_zero_cols >> 1;
408aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        }
409aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
410aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        pi2_tmp = pi2_tmp_orig;
411aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
412aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        /* Inverse Transform 2nd stage */
413aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        i4_shift = IDCT_STG2_SHIFT;
414aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        i4_add = 1 << (i4_shift - 1);
415aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        if((i4_zero_rows_2nd_stage & 0xF0) == 0xF0) /* First 4 rows of output of 1st stage are non-zero */
416aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        {
417aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            for(j = 0; j < i4_trans_size; j++)
418aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            {
419aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
420aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                for(k = 0; k < 4; k++)
421aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                {
422aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    ai4_o[k] = gai2_impeg2_idct_q11[1 * 8 + k] * pi2_tmp[i4_trans_size]
423aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    + gai2_impeg2_idct_q11[3 * 8 + k] * pi2_tmp[3 * i4_trans_size];
424aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                }
425aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_eo[0] = gai2_impeg2_idct_q11[2 * 8 + 0] * pi2_tmp[2 * i4_trans_size];
426aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_eo[1] = gai2_impeg2_idct_q11[2 * 8 + 1] * pi2_tmp[2 * i4_trans_size];
427aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_ee[0] = gai2_impeg2_idct_q11[0 * 8 + 0] * pi2_tmp[0];
428aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_ee[1] = gai2_impeg2_idct_q11[0 * 8 + 1] * pi2_tmp[0];
429aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
430aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                /* Combining e and o terms at each hierarchy levels to calculate the final spatial domain vector */
431aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[0] = ai4_ee[0] + ai4_eo[0];
432aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[3] = ai4_ee[0] - ai4_eo[0];
433aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[1] = ai4_ee[1] + ai4_eo[1];
434aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[2] = ai4_ee[1] - ai4_eo[1];
435aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                for(k = 0; k < 4; k++)
436aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                {
437aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    WORD32 itrans_out;
438aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    itrans_out =
439aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    CLIP_S16(((ai4_e[k] + ai4_o[k] + i4_add) >> i4_shift));
440aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    pu1_dst[k] = CLIP_U8((itrans_out + pu1_pred[k]));
441aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    itrans_out =
442aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    CLIP_S16(((ai4_e[3 - k] - ai4_o[3 - k] + i4_add) >> i4_shift));
443aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    pu1_dst[k + 4] = CLIP_U8((itrans_out + pu1_pred[k + 4]));
444aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                }
445aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                pi2_tmp++;
446aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                pu1_pred += i4_pred_strd;
447aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                pu1_dst += i4_dst_strd;
448aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            }
449aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        }
450aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        else /* All rows of output of 1st stage are non-zero */
451aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        {
452aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            for(j = 0; j < i4_trans_size; j++)
453aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            {
454aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
455aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                for(k = 0; k < 4; k++)
456aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                {
457aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    ai4_o[k] = gai2_impeg2_idct_q11[1 * 8 + k] * pi2_tmp[i4_trans_size]
458aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    + gai2_impeg2_idct_q11[3 * 8 + k]
459aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                                    * pi2_tmp[3 * i4_trans_size]
460aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    + gai2_impeg2_idct_q11[5 * 8 + k]
461aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                                    * pi2_tmp[5 * i4_trans_size]
462aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    + gai2_impeg2_idct_q11[7 * 8 + k]
463aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                                    * pi2_tmp[7 * i4_trans_size];
464aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                }
465aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
466aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_eo[0] = gai2_impeg2_idct_q11[2 * 8 + 0] * pi2_tmp[2 * i4_trans_size]
467aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                + gai2_impeg2_idct_q11[6 * 8 + 0] * pi2_tmp[6 * i4_trans_size];
468aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_eo[1] = gai2_impeg2_idct_q11[2 * 8 + 1] * pi2_tmp[2 * i4_trans_size]
469aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                + gai2_impeg2_idct_q11[6 * 8 + 1] * pi2_tmp[6 * i4_trans_size];
470aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_ee[0] = gai2_impeg2_idct_q11[0 * 8 + 0] * pi2_tmp[0]
471aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                + gai2_impeg2_idct_q11[4 * 8 + 0] * pi2_tmp[4 * i4_trans_size];
472aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_ee[1] = gai2_impeg2_idct_q11[0 * 8 + 1] * pi2_tmp[0]
473aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                + gai2_impeg2_idct_q11[4 * 8 + 1] * pi2_tmp[4 * i4_trans_size];
474aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
475aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                /* Combining e and o terms at each hierarchy levels to calculate the final spatial domain vector */
476aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[0] = ai4_ee[0] + ai4_eo[0];
477aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[3] = ai4_ee[0] - ai4_eo[0];
478aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[1] = ai4_ee[1] + ai4_eo[1];
479aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                ai4_e[2] = ai4_ee[1] - ai4_eo[1];
480aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                for(k = 0; k < 4; k++)
481aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                {
482aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    WORD32 itrans_out;
483aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    itrans_out =
484aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    CLIP_S16(((ai4_e[k] + ai4_o[k] + i4_add) >> i4_shift));
485aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    pu1_dst[k] = CLIP_U8((itrans_out + pu1_pred[k]));
486aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    itrans_out =
487aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                                    CLIP_S16(((ai4_e[3 - k] - ai4_o[3 - k] + i4_add) >> i4_shift));
488aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                    pu1_dst[k + 4] = CLIP_U8((itrans_out + pu1_pred[k + 4]));
489aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                }
490aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                pi2_tmp++;
491aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                pu1_pred += i4_pred_strd;
492aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani                pu1_dst += i4_dst_strd;
493aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani            }
494aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        }
495aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        /************************************************************************************************/
496aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        /************************************END - IT_RECON_8x8******************************************/
497aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani        /************************************************************************************************/
498aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani    }
499aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani}
500aed24eee7ddfc93f1436b0c1679431bd286879b4Venkatarama Avadhani
501