1 /*
2 * Copyright (C) 2007-2008 ARM Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17 /**
18 *
19 * File Name: omxVCM4P10_InvTransformResidualAndAdd.c
20 * OpenMAX DL: v1.0.2
21 * Revision: 9641
22 * Date: Thursday, February 7, 2008
23 *
24 *
25 *
26 * Description:
27 * This function will inverse integer 4x4 transform
28 *
29 */
30
31 #include "omxtypes.h"
32 #include "armOMX.h"
33 #include "omxVC.h"
34
35 #include "armCOMM.h"
36 #include "armVC.h"
37
38 /**
39 * Function: omxVCM4P10_InvTransformResidualAndAdd (6.3.5.7.1)
40 *
41 * Description:
42 * This function performs inverse an 4x4 integer transformation to produce
43 * the difference signal and then adds the difference to the prediction to get
44 * the reconstructed signal.
45 *
46 * Input Arguments:
47 *
48 * pSrcPred - Pointer to prediction signal. 4-byte alignment required.
49 * pDequantCoeff - Pointer to the transformed coefficients. 8-byte
50 * alignment required.
51 * iSrcPredStep - Step of the prediction buffer; must be a multiple of 4.
52 * iDstReconStep - Step of the destination reconstruction buffer; must be a
53 * multiple of 4.
54 * bAC - Indicate whether there is AC coefficients in the coefficients
55 * matrix.
56 *
57 * Output Arguments:
58 *
59 * pDstRecon -Pointer to the destination reconstruction buffer. 4-byte
60 * alignment required.
61 *
62 * Return Value:
63 *
64 * OMX_Sts_NoErr - no error
65 * OMX_Sts_BadArgErr - bad arguments; returned if any of the following
66 * conditions are true:
67 * - at least one of the following pointers is NULL:
68 * pSrcPred, pDequantCoeff, pDstRecon
69 * - pSrcPred is not aligned on a 4-byte boundary
70 * - iSrcPredStep or iDstReconStep is not a multiple of 4.
71 * - pDequantCoeff is not aligned on an 8-byte boundary
72 *
73 */
omxVCM4P10_InvTransformResidualAndAdd(const OMX_U8 * pSrcPred,const OMX_S16 * pDequantCoeff,OMX_U8 * pDstRecon,OMX_U32 iSrcPredStep,OMX_U32 iDstReconStep,OMX_U8 bAC)74 OMXResult omxVCM4P10_InvTransformResidualAndAdd(
75 const OMX_U8* pSrcPred,
76 const OMX_S16* pDequantCoeff,
77 OMX_U8* pDstRecon,
78 OMX_U32 iSrcPredStep,
79 OMX_U32 iDstReconStep,
80 OMX_U8 bAC
81 )
82 {
83 OMX_INT i, j;
84 OMX_S16 In[16], Out[16];
85 OMX_S32 Value;
86
87 /* check for argument error */
88 armRetArgErrIf(pSrcPred == NULL, OMX_Sts_BadArgErr)
89 armRetArgErrIf(armNot4ByteAligned(pSrcPred), OMX_Sts_BadArgErr)
90 armRetArgErrIf(pDequantCoeff == NULL, OMX_Sts_BadArgErr)
91 armRetArgErrIf(armNot8ByteAligned(pDequantCoeff), OMX_Sts_BadArgErr)
92 armRetArgErrIf(pDstRecon == NULL, OMX_Sts_BadArgErr)
93 armRetArgErrIf(armNot4ByteAligned(pDstRecon), OMX_Sts_BadArgErr)
94 armRetArgErrIf(bAC > 1, OMX_Sts_BadArgErr)
95 armRetArgErrIf(iSrcPredStep == 0 || iSrcPredStep & 3, OMX_Sts_BadArgErr)
96 armRetArgErrIf(iDstReconStep == 0 || iDstReconStep & 3, OMX_Sts_BadArgErr)
97
98 if (bAC)
99 {
100 for (i = 0; i < 16; i++)
101 {
102 In[i] = pDequantCoeff [i];
103 }
104 }
105 else
106 {
107 /* Copy DC */
108 In[0] = pDequantCoeff [0];
109
110 for (i = 1; i < 16; i++)
111 {
112 In[i] = 0;
113 }
114 }
115
116 /* Residual Transform */
117 armVCM4P10_TransformResidual4x4 (Out, In);
118
119 for (j = 0; j < 4; j++)
120 {
121 for (i = 0; i < 4; i++)
122 {
123 /* Add predition */
124 Value = (OMX_S32) Out [j * 4 + i] + pSrcPred [j * iSrcPredStep + i];
125
126 /* Saturate Value to OMX_U8 */
127 Value = armClip (0, 255, Value);
128
129 pDstRecon[j * iDstReconStep + i] = (OMX_U8) Value;
130 }
131 }
132
133 return OMX_Sts_NoErr;
134 }
135
136 /*****************************************************************************
137 * END OF FILE
138 *****************************************************************************/
139
140