10c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
20c1bc742181ded4930842b46e9507372f0b1b963James Dong *
30c1bc742181ded4930842b46e9507372f0b1b963James Dong * File Name:  omxVCM4P2_DecodeBlockCoef_Inter.c
40c1bc742181ded4930842b46e9507372f0b1b963James Dong * OpenMAX DL: v1.0.2
50c1bc742181ded4930842b46e9507372f0b1b963James Dong * Revision:   9641
60c1bc742181ded4930842b46e9507372f0b1b963James Dong * Date:       Thursday, February 7, 2008
70c1bc742181ded4930842b46e9507372f0b1b963James Dong *
80c1bc742181ded4930842b46e9507372f0b1b963James Dong * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
90c1bc742181ded4930842b46e9507372f0b1b963James Dong *
100c1bc742181ded4930842b46e9507372f0b1b963James Dong *
110c1bc742181ded4930842b46e9507372f0b1b963James Dong *
120c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
130c1bc742181ded4930842b46e9507372f0b1b963James Dong * Contains modules for inter reconstruction
140c1bc742181ded4930842b46e9507372f0b1b963James Dong *
150c1bc742181ded4930842b46e9507372f0b1b963James Dong */
160c1bc742181ded4930842b46e9507372f0b1b963James Dong
170c1bc742181ded4930842b46e9507372f0b1b963James Dong
180c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxtypes.h"
190c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armOMX.h"
200c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxVC.h"
210c1bc742181ded4930842b46e9507372f0b1b963James Dong
220c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armCOMM.h"
230c1bc742181ded4930842b46e9507372f0b1b963James Dong
240c1bc742181ded4930842b46e9507372f0b1b963James Dong
250c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
260c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function:  omxVCM4P2_DecodeBlockCoef_Inter   (6.2.5.4.2)
270c1bc742181ded4930842b46e9507372f0b1b963James Dong *
280c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
290c1bc742181ded4930842b46e9507372f0b1b963James Dong * Decodes the INTER block coefficients. This function performs inverse
300c1bc742181ded4930842b46e9507372f0b1b963James Dong * quantization, inverse zigzag positioning, and IDCT (with appropriate
310c1bc742181ded4930842b46e9507372f0b1b963James Dong * clipping on each step) on the coefficients. The results (residuals) are
320c1bc742181ded4930842b46e9507372f0b1b963James Dong * placed in a contiguous array of 64 elements. For INTER block, the output
330c1bc742181ded4930842b46e9507372f0b1b963James Dong * buffer holds the residuals for further reconstruction.
340c1bc742181ded4930842b46e9507372f0b1b963James Dong *
350c1bc742181ded4930842b46e9507372f0b1b963James Dong * Input Arguments:
360c1bc742181ded4930842b46e9507372f0b1b963James Dong *
370c1bc742181ded4930842b46e9507372f0b1b963James Dong *   ppBitStream - pointer to the pointer to the current byte in the bit
380c1bc742181ded4930842b46e9507372f0b1b963James Dong *            stream buffer. There is no boundary check for the bit stream
390c1bc742181ded4930842b46e9507372f0b1b963James Dong *            buffer.
400c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pBitOffset - pointer to the bit position in the byte pointed to by
410c1bc742181ded4930842b46e9507372f0b1b963James Dong *            *ppBitStream. *pBitOffset is valid within [0-7]
420c1bc742181ded4930842b46e9507372f0b1b963James Dong *   QP - quantization parameter
430c1bc742181ded4930842b46e9507372f0b1b963James Dong *   shortVideoHeader - binary flag indicating presence of
440c1bc742181ded4930842b46e9507372f0b1b963James Dong *            short_video_header; shortVideoHeader==1 selects linear intra DC
450c1bc742181ded4930842b46e9507372f0b1b963James Dong *            mode, and shortVideoHeader==0 selects non linear intra DC mode.
460c1bc742181ded4930842b46e9507372f0b1b963James Dong *
470c1bc742181ded4930842b46e9507372f0b1b963James Dong * Output Arguments:
480c1bc742181ded4930842b46e9507372f0b1b963James Dong *
490c1bc742181ded4930842b46e9507372f0b1b963James Dong *   ppBitStream - *ppBitStream is updated after the block is decoded, so
500c1bc742181ded4930842b46e9507372f0b1b963James Dong *            that it points to the current byte in the bit stream buffer
510c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pBitOffset - *pBitOffset is updated so that it points to the current bit
520c1bc742181ded4930842b46e9507372f0b1b963James Dong *            position in the byte pointed by *ppBitStream
530c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pDst - pointer to the decoded residual buffer (a contiguous array of 64
540c1bc742181ded4930842b46e9507372f0b1b963James Dong *            elements of OMX_S16 data type); must be aligned on a 16-byte
550c1bc742181ded4930842b46e9507372f0b1b963James Dong *            boundary.
560c1bc742181ded4930842b46e9507372f0b1b963James Dong *
570c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value:
580c1bc742181ded4930842b46e9507372f0b1b963James Dong *
590c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_NoErr - no error
600c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_BadArgErr - bad arguments, if:
610c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    At least one of the following pointers is Null:
620c1bc742181ded4930842b46e9507372f0b1b963James Dong *         ppBitStream, *ppBitStream, pBitOffset , pDst
630c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    *pBitOffset exceeds [0,7]
640c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    QP <= 0.
650c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    pDst is not 16-byte aligned
660c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_Err - status error. Refer to OMX_Sts_Err of DecodeVLCZigzag_Inter .
670c1bc742181ded4930842b46e9507372f0b1b963James Dong *
680c1bc742181ded4930842b46e9507372f0b1b963James Dong */
690c1bc742181ded4930842b46e9507372f0b1b963James DongOMXResult omxVCM4P2_DecodeBlockCoef_Inter(
700c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMX_U8 ** ppBitStream,
710c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT * pBitOffset,
720c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_S16 * pDst,
730c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT QP,
740c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT shortVideoHeader
750c1bc742181ded4930842b46e9507372f0b1b963James Dong)
760c1bc742181ded4930842b46e9507372f0b1b963James Dong{
770c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* 64 elements are needed but to align it to 16 bytes need
780c1bc742181ded4930842b46e9507372f0b1b963James Dong    15 more elements of padding */
790c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_S16 tempBuf[79];
800c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_S16 *pTempBuf1;
810c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMXResult errorCode;
820c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* Aligning the local buffers */
830c1bc742181ded4930842b46e9507372f0b1b963James Dong    pTempBuf1 = armAlignTo16Bytes(tempBuf);
840c1bc742181ded4930842b46e9507372f0b1b963James Dong
850c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* Argument error checks */
860c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr);
870c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr);
880c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr);
890c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
900c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(!armIs16ByteAligned(pDst), OMX_Sts_BadArgErr);
910c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(((QP <= 0) || (QP >= 32)), OMX_Sts_BadArgErr);
920c1bc742181ded4930842b46e9507372f0b1b963James Dong	armRetArgErrIf(((*pBitOffset < 0) || (*pBitOffset > 7)), OMX_Sts_BadArgErr);
930c1bc742181ded4930842b46e9507372f0b1b963James Dong
940c1bc742181ded4930842b46e9507372f0b1b963James Dong
950c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* VLD and zigzag */
960c1bc742181ded4930842b46e9507372f0b1b963James Dong    errorCode = omxVCM4P2_DecodeVLCZigzag_Inter(ppBitStream, pBitOffset,
970c1bc742181ded4930842b46e9507372f0b1b963James Dong                                        pTempBuf1,shortVideoHeader);
980c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
990c1bc742181ded4930842b46e9507372f0b1b963James Dong
1000c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* Dequantization */
1010c1bc742181ded4930842b46e9507372f0b1b963James Dong    errorCode = omxVCM4P2_QuantInvInter_I(
1020c1bc742181ded4930842b46e9507372f0b1b963James Dong     pTempBuf1,
1030c1bc742181ded4930842b46e9507372f0b1b963James Dong     QP);
1040c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
1050c1bc742181ded4930842b46e9507372f0b1b963James Dong
1060c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* Inverse transform */
1070c1bc742181ded4930842b46e9507372f0b1b963James Dong    errorCode = omxVCM4P2_IDCT8x8blk(pTempBuf1, pDst);
1080c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
1090c1bc742181ded4930842b46e9507372f0b1b963James Dong
1100c1bc742181ded4930842b46e9507372f0b1b963James Dong    return OMX_Sts_NoErr;
1110c1bc742181ded4930842b46e9507372f0b1b963James Dong}
1120c1bc742181ded4930842b46e9507372f0b1b963James Dong
1130c1bc742181ded4930842b46e9507372f0b1b963James Dong/* End of file */
1140c1bc742181ded4930842b46e9507372f0b1b963James Dong
1150c1bc742181ded4930842b46e9507372f0b1b963James Dong
116