omxVCM4P2_DecodeBlockCoef_Intra.c revision 78e52bfac041d71ce53b5b13c2abf78af742b09d
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: omxVCM4P2_DecodeBlockCoef_Intra.c 20 * OpenMAX DL: v1.0.2 21 * Revision: 9641 22 * Date: Thursday, February 7, 2008 23 * 24 * 25 * 26 * 27 * Description: 28 * Contains modules for intra reconstruction 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: omxVCM4P2_DecodeBlockCoef_Intra 41 * 42 * Description: 43 * Decodes the INTRA block coefficients. Inverse quantization, inversely zigzag 44 * positioning, and IDCT, with appropriate clipping on each step, are performed 45 * on the coefficients. The results are then placed in the output frame/plane on 46 * a pixel basis. For INTRA block, the output values are clipped to [0, 255] and 47 * written to corresponding block buffer within the destination plane. 48 * 49 * Remarks: 50 * 51 * Parameters: 52 * [in] ppBitStream pointer to the pointer to the current byte in 53 * the bit stream buffer. There is no boundary 54 * check for the bit stream buffer. 55 * [in] pBitOffset pointer to the bit position in the byte pointed 56 * to by *ppBitStream. *pBitOffset is valid within 57 * [0-7]. 58 * [in] step width of the destination plane 59 * [in/out] pCoefBufRow [in] pointer to the coefficient row buffer 60 * [out] updated coefficient rwo buffer 61 * [in/out] pCoefBufCol [in] pointer to the coefficient column buffer 62 * [out] updated coefficient column buffer 63 * [in] curQP quantization parameter of the macroblock which 64 * the current block belongs to 65 * [in] pQpBuf Pointer to a 2-element QP array. pQpBuf[0] holds the QP of the 8x8 block left to 66 * the current block(QPa). pQpBuf[1] holds the QP of the 8x8 block just above the 67 * current block(QPc). 68 * Note, in case the corresponding block is out of VOP bound, the QP value will have 69 * no effect to the intra-prediction process. Refer to subclause "7.4.3.3 Adaptive 70 * ac coefficient prediction" of ISO/IEC 14496-2(MPEG4 Part2) for accurate description. 71 * [in] blockIndex block index indicating the component type and 72 * position as defined in subclause 6.1.3.8, 73 * Figure 6-5 of ISO/IEC 14496-2. 74 * [in] intraDCVLC a code determined by intra_dc_vlc_thr and QP. 75 * This allows a mechanism to switch between two VLC 76 * for coding of Intra DC coefficients as per Table 77 * 6-21 of ISO/IEC 14496-2. 78 * [in] ACPredFlag a flag equal to ac_pred_flag (of luminance) indicating 79 * if the ac coefficients of the first row or first 80 * column are differentially coded for intra coded 81 * macroblock. 82 * [in] shortVideoHeader a flag indicating presence of short_video_header; 83 * shortVideoHeader==1 selects linear intra DC mode, 84 * and shortVideoHeader==0 selects nonlinear intra DC mode. 85 * [out] ppBitStream *ppBitStream is updated after the block is 86 * decoded, so that it points to the current byte 87 * in the bit stream buffer 88 * [out] pBitOffset *pBitOffset is updated so that it points to the 89 * current bit position in the byte pointed by 90 * *ppBitStream 91 * [out] pDst pointer to the block in the destination plane. 92 * pDst should be 16-byte aligned. 93 * [out] pCoefBufRow pointer to the updated coefficient row buffer. 94 * 95 * Return Value: 96 * OMX_Sts_NoErr - no error 97 * OMX_Sts_BadArgErr - bad arguments 98 * - At least one of the following pointers is NULL: ppBitStream, *ppBitStream, pBitOffset, 99 * pCoefBufRow, pCoefBufCol, pQPBuf, pDst. 100 * or 101 * - At least one of the below case: *pBitOffset exceeds [0,7], curQP exceeds (1, 31), 102 * blockIndex exceeds [0,9], step is not the multiple of 8, intraDCVLC is zero while 103 * blockIndex greater than 5. 104 * or 105 * - pDst is not 16-byte aligned 106 * OMX_Sts_Err - status error 107 * 108 */ 109 110OMXResult omxVCM4P2_DecodeBlockCoef_Intra( 111 const OMX_U8 ** ppBitStream, 112 OMX_INT *pBitOffset, 113 OMX_U8 *pDst, 114 OMX_INT step, 115 OMX_S16 *pCoefBufRow, 116 OMX_S16 *pCoefBufCol, 117 OMX_U8 curQP, 118 const OMX_U8 *pQPBuf, 119 OMX_INT blockIndex, 120 OMX_INT intraDCVLC, 121 OMX_INT ACPredFlag, 122 OMX_INT shortVideoHeader 123 ) 124{ 125 OMX_S16 tempBuf1[79], tempBuf2[79]; 126 OMX_S16 *pTempBuf1, *pTempBuf2; 127 OMX_INT predDir, predACDir; 128 OMX_INT predQP; 129 OMXVCM4P2VideoComponent videoComp; 130 OMXResult errorCode; 131 132 133 /* Aligning the local buffers */ 134 pTempBuf1 = armAlignTo16Bytes(tempBuf1); 135 pTempBuf2 = armAlignTo16Bytes(tempBuf2); 136 137 /* Setting the AC prediction direction and prediction direction */ 138 armVCM4P2_SetPredDir( 139 blockIndex, 140 pCoefBufRow, 141 pCoefBufCol, 142 &predDir, 143 &predQP, 144 pQPBuf); 145 146 predACDir = predDir; 147 148 149 if (ACPredFlag == 0) 150 { 151 predACDir = OMX_VC_NONE; 152 } 153 154 /* Setting the videoComp */ 155 if (blockIndex <= 3) 156 { 157 videoComp = OMX_VC_LUMINANCE; 158 } 159 else 160 { 161 videoComp = OMX_VC_CHROMINANCE; 162 } 163 164 165 /* VLD and zigzag */ 166 if (intraDCVLC == 1) 167 { 168 errorCode = omxVCM4P2_DecodeVLCZigzag_IntraDCVLC( 169 ppBitStream, 170 pBitOffset, 171 pTempBuf1, 172 predACDir, 173 shortVideoHeader, 174 videoComp); 175 armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode); 176 } 177 else 178 { 179 errorCode = omxVCM4P2_DecodeVLCZigzag_IntraACVLC( 180 ppBitStream, 181 pBitOffset, 182 pTempBuf1, 183 predACDir, 184 shortVideoHeader); 185 armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode); 186 } 187 188 /* AC DC prediction */ 189 errorCode = omxVCM4P2_PredictReconCoefIntra( 190 pTempBuf1, 191 pCoefBufRow, 192 pCoefBufCol, 193 curQP, 194 predQP, 195 predDir, 196 ACPredFlag, 197 videoComp); 198 armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode); 199 200 /* Dequantization */ 201 errorCode = omxVCM4P2_QuantInvIntra_I( 202 pTempBuf1, 203 curQP, 204 videoComp, 205 shortVideoHeader); 206 armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode); 207 208 /* Inverse transform */ 209 errorCode = omxVCM4P2_IDCT8x8blk (pTempBuf1, pTempBuf2); 210 armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode); 211 212 /* Placing the linear array into the destination plane and clipping 213 it to 0 to 255 */ 214 215 armVCM4P2_Clip8(pTempBuf2,pDst,step); 216 217 218 return OMX_Sts_NoErr; 219} 220 221/* End of file */ 222 223 224