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_InvTransformDequant_LumaDC.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 calculate 4x4 hadamard transform of luma DC coefficients 28 * and quantization 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 * Function: omxVCM4P10_InvTransformDequant_LumaDC (6.3.5.6.3) 41 * 42 * Description: 43 * This function performs inverse 4x4 Hadamard transform and then dequantizes 44 * the coefficients. 45 * 46 * Input Arguments: 47 * 48 * pSrc - Pointer to the 4x4 array of the 4x4 Hadamard-transformed and 49 * quantized coefficients. 16 byte alignment required. 50 * iQP - Quantization parameter; must be in the range [0,51]. 51 * 52 * Output Arguments: 53 * 54 * pDst - Pointer to inverse-transformed and dequantized coefficients. 55 * 16-byte alignment required. 56 * 57 * Return Value: 58 * 59 * OMX_Sts_NoErr - no error 60 * OMX_Sts_BadArgErr - bad arguments; returned if any of the following 61 * conditions are true: 62 * - at least one of the following pointers is NULL: pSrc 63 * - pSrc or pDst is not aligned on a 16-byte boundary 64 * 65 */ 66OMXResult omxVCM4P10_InvTransformDequant_LumaDC( 67 const OMX_S16* pSrc, 68 OMX_S16* pDst, 69 OMX_U32 iQP 70) 71{ 72 OMX_INT i, j; 73 OMX_S32 m1[4][4], m2[4][4], Value; 74 OMX_S32 QPer, V; 75 76 /* check for argument error */ 77 armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr) 78 armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr) 79 armRetArgErrIf(iQP > 51, OMX_Sts_BadArgErr) 80 armRetArgErrIf(armNot16ByteAligned(pSrc), OMX_Sts_BadArgErr) 81 armRetArgErrIf(armNot16ByteAligned(pDst), OMX_Sts_BadArgErr) 82 83 /* Inv Hadamard Transform for DC Luma 4x4 block */ 84 /* Horizontal */ 85 for (i = 0; i < 4; i++) 86 { 87 j = i * 4; 88 89 m1[i][0] = pSrc[j + 0] + pSrc[j + 2]; /* a+c */ 90 m1[i][1] = pSrc[j + 1] + pSrc[j + 3]; /* b+d */ 91 m1[i][2] = pSrc[j + 0] - pSrc[j + 2]; /* a-c */ 92 m1[i][3] = pSrc[j + 1] - pSrc[j + 3]; /* b-d */ 93 94 m2[i][0] = m1[i][0] + m1[i][1]; /* a+b+c+d */ 95 m2[i][1] = m1[i][2] + m1[i][3]; /* a+b-c-d */ 96 m2[i][2] = m1[i][2] - m1[i][3]; /* a-b-c+d */ 97 m2[i][3] = m1[i][0] - m1[i][1]; /* a-b+c-d */ 98 99 } 100 101 /* Vertical */ 102 for (i = 0; i < 4; i++) 103 { 104 m1[0][i] = m2[0][i] + m2[2][i]; 105 m1[1][i] = m2[1][i] + m2[3][i]; 106 m1[2][i] = m2[0][i] - m2[2][i]; 107 m1[3][i] = m2[1][i] - m2[3][i]; 108 109 m2[0][i] = m1[0][i] + m1[1][i]; 110 m2[1][i] = m1[2][i] + m1[3][i]; 111 m2[2][i] = m1[2][i] - m1[3][i]; 112 m2[3][i] = m1[0][i] - m1[1][i]; 113 } 114 115 116 /* Scaling */ 117 QPer = iQP / 6; 118 V = armVCM4P10_VMatrix [iQP % 6][0]; 119 120 for (j = 0; j < 4; j++) 121 { 122 for (i = 0; i < 4; i++) 123 { 124 if (QPer < 2) 125 { 126 Value = (m2[j][i] * V + (1 << (1 - QPer))) >> (2 - QPer); 127 } 128 else 129 { 130 Value = m2[j][i] * V * (1 << (QPer - 2)); 131 } 132 133 pDst[j * 4 + i] = (OMX_S16) Value; 134 135 } 136 } 137 return OMX_Sts_NoErr; 138} 139 140/***************************************************************************** 141 * END OF FILE 142 *****************************************************************************/ 143 144