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 * 20 * File Name: omxVCM4P10_TransformDequantLumaDCFromPair.c 21 * OpenMAX DL: v1.0.2 22 * Revision: 9641 23 * Date: Thursday, February 7, 2008 24 * 25 * 26 * 27 * 28 * H.264 inverse quantize and transform module 29 * 30 */ 31 32 #include "omxtypes.h" 33 #include "armOMX.h" 34 #include "omxVC.h" 35 36 #include "armCOMM.h" 37 #include "armVC.h" 38 39 /* 40 * Description: 41 * Dequantize Luma DC block 42 */ 43 44 static void DequantLumaDC4x4( 45 OMX_S16* pDst, 46 OMX_INT QP 47 ) 48 { 49 int Shift = (QP/6)-2 ; 50 int Scale = armVCM4P10_VMatrix[QP%6][0]; 51 int i, Round, Value; 52 53 if (Shift >= 0) 54 { 55 for (i=0; i<16; i++) 56 { 57 Value = (pDst[i] * Scale) << Shift; 58 pDst[i] = (OMX_S16)Value; 59 } 60 } 61 else 62 { 63 Shift = -Shift;; 64 Round = 1<<(Shift-1); 65 66 for (i=0; i<16; i++) 67 { 68 Value = (pDst[i] * Scale + Round) >> Shift; 69 pDst[i] = (OMX_S16)Value; 70 } 71 } 72 } 73 74 75 76 /* 77 * Description: 78 * Inverse Transform DC 4x4 Coefficients 79 */ 80 static void InvTransformDC4x4(OMX_S16* pData) 81 { 82 int i; 83 84 /* Transform rows */ 85 for (i=0; i<16; i+=4) 86 { 87 int c0 = pData[i+0]; 88 int c1 = pData[i+1]; 89 int c2 = pData[i+2]; 90 int c3 = pData[i+3]; 91 pData[i+0] = (OMX_S16)(c0+c1+c2+c3); 92 pData[i+1] = (OMX_S16)(c0+c1-c2-c3); 93 pData[i+2] = (OMX_S16)(c0-c1-c2+c3); 94 pData[i+3] = (OMX_S16)(c0-c1+c2-c3); 95 } 96 97 /* Transform columns */ 98 for (i=0; i<4; i++) 99 { 100 int c0 = pData[i+0]; 101 int c1 = pData[i+4]; 102 int c2 = pData[i+8]; 103 int c3 = pData[i+12]; 104 pData[i+0] = (OMX_S16)(c0+c1+c2+c3); 105 pData[i+4] = (OMX_S16)(c0+c1-c2-c3); 106 pData[i+8] = (OMX_S16)(c0-c1-c2+c3); 107 pData[i+12] = (OMX_S16)(c0-c1+c2-c3); 108 } 109 } 110 111 112 /** 113 * Function: omxVCM4P10_TransformDequantLumaDCFromPair (6.3.4.2.1) 114 * 115 * Description: 116 * Reconstructs the 4x4 LumaDC block from the coefficient-position pair 117 * buffer, performs integer inverse, and dequantization for 4x4 LumaDC 118 * coefficients, and updates the pair buffer pointer to the next non-empty 119 * block. 120 * 121 * Input Arguments: 122 * 123 * ppSrc - Double pointer to residual coefficient-position pair buffer 124 * output by CALVC decoding 125 * QP - Quantization parameter QpY 126 * 127 * Output Arguments: 128 * 129 * ppSrc - *ppSrc is updated to the start of next non empty block 130 * pDst - Pointer to the reconstructed 4x4 LumaDC coefficients buffer; must 131 * be aligned on a 8-byte boundary. 132 * 133 * Return Value: 134 * OMX_Sts_NoErr, if the function runs without error. 135 * OMX_Sts_BadArgErr - bad arguments: if one of the following cases occurs: 136 * - ppSrc or pDst is NULL. 137 * - pDst is not 8 byte aligned. 138 * - QP is not in the range of [0-51]. 139 * 140 */ 141 142 OMXResult omxVCM4P10_TransformDequantLumaDCFromPair( 143 const OMX_U8 **ppSrc, 144 OMX_S16* pDst, 145 OMX_INT QP 146 ) 147 { 148 armRetArgErrIf(ppSrc == NULL, OMX_Sts_BadArgErr); 149 armRetArgErrIf(*ppSrc == NULL, OMX_Sts_BadArgErr); 150 armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr); 151 armRetArgErrIf(armNot8ByteAligned(pDst), OMX_Sts_BadArgErr); 152 armRetArgErrIf(QP<0, OMX_Sts_BadArgErr); 153 armRetArgErrIf(QP>51, OMX_Sts_BadArgErr); 154 155 armVCM4P10_UnpackBlock4x4(ppSrc, pDst); 156 /*InvTransformDequantLumaDC4x4(pDst, QP);*/ 157 InvTransformDC4x4(pDst); 158 DequantLumaDC4x4(pDst, QP); 159 160 return OMX_Sts_NoErr; 161 } 162 163 /* End of file */ 164