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_Inter.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 inter reconstruction 29 * 30 */ 31 32 33#include "omxtypes.h" 34#include "armOMX.h" 35#include "omxVC.h" 36 37#include "armCOMM.h" 38 39 40/** 41 * Function: omxVCM4P2_DecodeBlockCoef_Inter (6.2.5.4.2) 42 * 43 * Description: 44 * Decodes the INTER block coefficients. This function performs inverse 45 * quantization, inverse zigzag positioning, and IDCT (with appropriate 46 * clipping on each step) on the coefficients. The results (residuals) are 47 * placed in a contiguous array of 64 elements. For INTER block, the output 48 * buffer holds the residuals for further reconstruction. 49 * 50 * Input Arguments: 51 * 52 * ppBitStream - pointer to the pointer to the current byte in the bit 53 * stream buffer. There is no boundary check for the bit stream 54 * buffer. 55 * pBitOffset - pointer to the bit position in the byte pointed to by 56 * *ppBitStream. *pBitOffset is valid within [0-7] 57 * QP - quantization parameter 58 * shortVideoHeader - binary flag indicating presence of 59 * short_video_header; shortVideoHeader==1 selects linear intra DC 60 * mode, and shortVideoHeader==0 selects non linear intra DC mode. 61 * 62 * Output Arguments: 63 * 64 * ppBitStream - *ppBitStream is updated after the block is decoded, so 65 * that it points to the current byte in the bit stream buffer 66 * pBitOffset - *pBitOffset is updated so that it points to the current bit 67 * position in the byte pointed by *ppBitStream 68 * pDst - pointer to the decoded residual buffer (a contiguous array of 64 69 * elements of OMX_S16 data type); must be aligned on a 16-byte 70 * boundary. 71 * 72 * Return Value: 73 * 74 * OMX_Sts_NoErr - no error 75 * OMX_Sts_BadArgErr - bad arguments, if: 76 * - At least one of the following pointers is Null: 77 * ppBitStream, *ppBitStream, pBitOffset , pDst 78 * - *pBitOffset exceeds [0,7] 79 * - QP <= 0. 80 * - pDst is not 16-byte aligned 81 * OMX_Sts_Err - status error. Refer to OMX_Sts_Err of DecodeVLCZigzag_Inter . 82 * 83 */ 84OMXResult omxVCM4P2_DecodeBlockCoef_Inter( 85 const OMX_U8 ** ppBitStream, 86 OMX_INT * pBitOffset, 87 OMX_S16 * pDst, 88 OMX_INT QP, 89 OMX_INT shortVideoHeader 90) 91{ 92 /* 64 elements are needed but to align it to 16 bytes need 93 15 more elements of padding */ 94 OMX_S16 tempBuf[79]; 95 OMX_S16 *pTempBuf1; 96 OMXResult errorCode; 97 /* Aligning the local buffers */ 98 pTempBuf1 = armAlignTo16Bytes(tempBuf); 99 100 /* Argument error checks */ 101 armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr); 102 armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr); 103 armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr); 104 armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr); 105 armRetArgErrIf(!armIs16ByteAligned(pDst), OMX_Sts_BadArgErr); 106 armRetArgErrIf(((QP <= 0) || (QP >= 32)), OMX_Sts_BadArgErr); 107 armRetArgErrIf(((*pBitOffset < 0) || (*pBitOffset > 7)), OMX_Sts_BadArgErr); 108 109 110 /* VLD and zigzag */ 111 errorCode = omxVCM4P2_DecodeVLCZigzag_Inter(ppBitStream, pBitOffset, 112 pTempBuf1,shortVideoHeader); 113 armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode); 114 115 /* Dequantization */ 116 errorCode = omxVCM4P2_QuantInvInter_I( 117 pTempBuf1, 118 QP); 119 armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode); 120 121 /* Inverse transform */ 122 errorCode = omxVCM4P2_IDCT8x8blk(pTempBuf1, pDst); 123 armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode); 124 125 return OMX_Sts_NoErr; 126} 127 128/* End of file */ 129 130 131