178e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar/* 278e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * Copyright (C) 2007-2008 ARM Limited 378e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * 478e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * Licensed under the Apache License, Version 2.0 (the "License"); 578e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * you may not use this file except in compliance with the License. 678e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * You may obtain a copy of the License at 778e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * 878e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * http://www.apache.org/licenses/LICENSE-2.0 978e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * 1078e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * Unless required by applicable law or agreed to in writing, software 1178e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * distributed under the License is distributed on an "AS IS" BASIS, 1278e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1378e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * See the License for the specific language governing permissions and 1478e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * limitations under the License. 1578e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * 1678e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar */ 170c1bc742181ded4930842b46e9507372f0b1b963James Dong/* ---------------------------------------------------------------- 180c1bc742181ded4930842b46e9507372f0b1b963James Dong * 190c1bc742181ded4930842b46e9507372f0b1b963James Dong * 200c1bc742181ded4930842b46e9507372f0b1b963James Dong * File Name: omxVCM4P10_TransformDequantChromaDCFromPair.c 210c1bc742181ded4930842b46e9507372f0b1b963James Dong * OpenMAX DL: v1.0.2 220c1bc742181ded4930842b46e9507372f0b1b963James Dong * Revision: 9641 230c1bc742181ded4930842b46e9507372f0b1b963James Dong * Date: Thursday, February 7, 2008 240c1bc742181ded4930842b46e9507372f0b1b963James Dong * 250c1bc742181ded4930842b46e9507372f0b1b963James Dong * 260c1bc742181ded4930842b46e9507372f0b1b963James Dong * 270c1bc742181ded4930842b46e9507372f0b1b963James Dong * 280c1bc742181ded4930842b46e9507372f0b1b963James Dong * H.264 inverse quantize and transform module 290c1bc742181ded4930842b46e9507372f0b1b963James Dong * 300c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 310c1bc742181ded4930842b46e9507372f0b1b963James Dong 320c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxtypes.h" 330c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armOMX.h" 340c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxVC.h" 350c1bc742181ded4930842b46e9507372f0b1b963James Dong 360c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armCOMM.h" 370c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armVC.h" 380c1bc742181ded4930842b46e9507372f0b1b963James Dong 390c1bc742181ded4930842b46e9507372f0b1b963James Dong/* 400c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 410c1bc742181ded4930842b46e9507372f0b1b963James Dong * Dequantize Chroma 2x2 DC block 420c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 430c1bc742181ded4930842b46e9507372f0b1b963James Dong 440c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic void DequantChromaDC2x2( 450c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_S16* pDst, 460c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT QP 470c1bc742181ded4930842b46e9507372f0b1b963James Dong) 480c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 490c1bc742181ded4930842b46e9507372f0b1b963James Dong int Shift = (QP/6)-1 ; 500c1bc742181ded4930842b46e9507372f0b1b963James Dong int Scale = armVCM4P10_VMatrix[QP%6][0]; 510c1bc742181ded4930842b46e9507372f0b1b963James Dong int i, Value; 520c1bc742181ded4930842b46e9507372f0b1b963James Dong 530c1bc742181ded4930842b46e9507372f0b1b963James Dong if (Shift >= 0) 540c1bc742181ded4930842b46e9507372f0b1b963James Dong { 550c1bc742181ded4930842b46e9507372f0b1b963James Dong for (i=0; i<4; i++) 560c1bc742181ded4930842b46e9507372f0b1b963James Dong { 570c1bc742181ded4930842b46e9507372f0b1b963James Dong Value = (pDst[i] * Scale) << Shift; 580c1bc742181ded4930842b46e9507372f0b1b963James Dong pDst[i] = (OMX_S16)Value; 590c1bc742181ded4930842b46e9507372f0b1b963James Dong } 600c1bc742181ded4930842b46e9507372f0b1b963James Dong } 610c1bc742181ded4930842b46e9507372f0b1b963James Dong else 620c1bc742181ded4930842b46e9507372f0b1b963James Dong { 630c1bc742181ded4930842b46e9507372f0b1b963James Dong for (i=0; i<4; i++) 640c1bc742181ded4930842b46e9507372f0b1b963James Dong { 650c1bc742181ded4930842b46e9507372f0b1b963James Dong Value = (pDst[i] * Scale) >> 1; 660c1bc742181ded4930842b46e9507372f0b1b963James Dong pDst[i] = (OMX_S16)Value; 670c1bc742181ded4930842b46e9507372f0b1b963James Dong } 680c1bc742181ded4930842b46e9507372f0b1b963James Dong } 690c1bc742181ded4930842b46e9507372f0b1b963James Dong} 700c1bc742181ded4930842b46e9507372f0b1b963James Dong 710c1bc742181ded4930842b46e9507372f0b1b963James Dong 720c1bc742181ded4930842b46e9507372f0b1b963James Dong/* 730c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 740c1bc742181ded4930842b46e9507372f0b1b963James Dong * Inverse Transform DC 2x2 Coefficients 750c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 760c1bc742181ded4930842b46e9507372f0b1b963James Dong 770c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic void InvTransformDC2x2(OMX_S16* pData) 780c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 790c1bc742181ded4930842b46e9507372f0b1b963James Dong int c00 = pData[0]; 800c1bc742181ded4930842b46e9507372f0b1b963James Dong int c01 = pData[1]; 810c1bc742181ded4930842b46e9507372f0b1b963James Dong int c10 = pData[2]; 820c1bc742181ded4930842b46e9507372f0b1b963James Dong int c11 = pData[3]; 830c1bc742181ded4930842b46e9507372f0b1b963James Dong 840c1bc742181ded4930842b46e9507372f0b1b963James Dong int d00 = c00 + c01; 850c1bc742181ded4930842b46e9507372f0b1b963James Dong int d01 = c00 - c01; 860c1bc742181ded4930842b46e9507372f0b1b963James Dong int d10 = c10 + c11; 870c1bc742181ded4930842b46e9507372f0b1b963James Dong int d11 = c10 - c11; 880c1bc742181ded4930842b46e9507372f0b1b963James Dong 890c1bc742181ded4930842b46e9507372f0b1b963James Dong pData[0] = (OMX_S16)(d00 + d10); 900c1bc742181ded4930842b46e9507372f0b1b963James Dong pData[1] = (OMX_S16)(d01 + d11); 910c1bc742181ded4930842b46e9507372f0b1b963James Dong pData[2] = (OMX_S16)(d00 - d10); 920c1bc742181ded4930842b46e9507372f0b1b963James Dong pData[3] = (OMX_S16)(d01 - d11); 930c1bc742181ded4930842b46e9507372f0b1b963James Dong} 940c1bc742181ded4930842b46e9507372f0b1b963James Dong 950c1bc742181ded4930842b46e9507372f0b1b963James Dong 960c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 970c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: omxVCM4P10_TransformDequantChromaDCFromPair (6.3.4.2.2) 980c1bc742181ded4930842b46e9507372f0b1b963James Dong * 990c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 1000c1bc742181ded4930842b46e9507372f0b1b963James Dong * Reconstruct the 2x2 ChromaDC block from coefficient-position pair buffer, 1010c1bc742181ded4930842b46e9507372f0b1b963James Dong * perform integer inverse transformation, and dequantization for 2x2 chroma 1020c1bc742181ded4930842b46e9507372f0b1b963James Dong * DC coefficients, and update the pair buffer pointer to next non-empty 1030c1bc742181ded4930842b46e9507372f0b1b963James Dong * block. 1040c1bc742181ded4930842b46e9507372f0b1b963James Dong * 1050c1bc742181ded4930842b46e9507372f0b1b963James Dong * Input Arguments: 1060c1bc742181ded4930842b46e9507372f0b1b963James Dong * 1070c1bc742181ded4930842b46e9507372f0b1b963James Dong * ppSrc - Double pointer to residual coefficient-position pair buffer 1080c1bc742181ded4930842b46e9507372f0b1b963James Dong * output by CALVC decoding 1090c1bc742181ded4930842b46e9507372f0b1b963James Dong * QP - Quantization parameter QpC 1100c1bc742181ded4930842b46e9507372f0b1b963James Dong * 1110c1bc742181ded4930842b46e9507372f0b1b963James Dong * Output Arguments: 1120c1bc742181ded4930842b46e9507372f0b1b963James Dong * 1130c1bc742181ded4930842b46e9507372f0b1b963James Dong * ppSrc - *ppSrc is updated to the start of next non empty block 1140c1bc742181ded4930842b46e9507372f0b1b963James Dong * pDst - Pointer to the reconstructed 2x2 ChromaDC coefficients buffer; 1150c1bc742181ded4930842b46e9507372f0b1b963James Dong * must be aligned on a 4-byte boundary. 1160c1bc742181ded4930842b46e9507372f0b1b963James Dong * 1170c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value: 1180c1bc742181ded4930842b46e9507372f0b1b963James Dong * OMX_Sts_NoErr, if the function runs without error. 1190c1bc742181ded4930842b46e9507372f0b1b963James Dong * OMX_Sts_BadArgErr - bad arguments: if one of the following cases occurs: 1200c1bc742181ded4930842b46e9507372f0b1b963James Dong * - ppSrc or pDst is NULL. 1210c1bc742181ded4930842b46e9507372f0b1b963James Dong * - pDst is not 4-byte aligned. 1220c1bc742181ded4930842b46e9507372f0b1b963James Dong * - QP is not in the range of [0-51]. 1230c1bc742181ded4930842b46e9507372f0b1b963James Dong * 1240c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 1250c1bc742181ded4930842b46e9507372f0b1b963James Dong 1260c1bc742181ded4930842b46e9507372f0b1b963James DongOMXResult omxVCM4P10_TransformDequantChromaDCFromPair( 1270c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 **ppSrc, 1280c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_S16* pDst, 1290c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT QP 1300c1bc742181ded4930842b46e9507372f0b1b963James Dong ) 1310c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 1320c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(ppSrc == NULL, OMX_Sts_BadArgErr); 1330c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(*ppSrc == NULL, OMX_Sts_BadArgErr); 1340c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr); 1350c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(armNot4ByteAligned(pDst), OMX_Sts_BadArgErr); 1360c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(QP<0, OMX_Sts_BadArgErr); 1370c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(QP>51, OMX_Sts_BadArgErr); 1380c1bc742181ded4930842b46e9507372f0b1b963James Dong 1390c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P10_UnpackBlock2x2(ppSrc, pDst); 1400c1bc742181ded4930842b46e9507372f0b1b963James Dong InvTransformDC2x2(pDst); 1410c1bc742181ded4930842b46e9507372f0b1b963James Dong DequantChromaDC2x2(pDst, QP); 1420c1bc742181ded4930842b46e9507372f0b1b963James Dong 1430c1bc742181ded4930842b46e9507372f0b1b963James Dong return OMX_Sts_NoErr; 1440c1bc742181ded4930842b46e9507372f0b1b963James Dong} 1450c1bc742181ded4930842b46e9507372f0b1b963James Dong 1460c1bc742181ded4930842b46e9507372f0b1b963James Dong/* End of file */ 147