summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src
diff options
context:
space:
mode:
Diffstat (limited to 'media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src')
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_ACDCPredict.c253
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_BlockMatch_Half.c187
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_BlockMatch_Integer.c167
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_CheckVLCEscapeMode.c156
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_CompareMV.c71
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_DCT_Table.c112
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_DecodeVLCZigzag_intra.c144
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_EncodeVLCZigzag_intra.c145
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_FillVLCBuffer.c153
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_FillVLDBuffer.c84
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_GetVLCBits.c278
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_Huff_Tables_VLC.c495
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_PutVLCBits.c200
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_SetPredDir.c89
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_Zigzag_Tables.c58
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_BlockMatch_Half_16x16.c111
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_BlockMatch_Half_8x8.c109
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_BlockMatch_Integer_16x16.c114
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_BlockMatch_Integer_8x8.c110
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DCT8x8blk.c87
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeBlockCoef_Inter.c115
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeBlockCoef_Intra.c225
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodePadMV_PVOP.c243
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeVLCZigzag_Inter.c120
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeVLCZigzag_IntraACVLC.c103
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeVLCZigzag_IntraDCVLC.c170
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_EncodeMV.c212
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_EncodeVLCZigzag_Inter.c112
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_EncodeVLCZigzag_IntraACVLC.c97
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_EncodeVLCZigzag_IntraDCVLC.c160
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_FindMVpred.c188
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_IDCT8x8blk.c92
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_MCReconBlock.c357
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_MEGetBufSize.c70
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_MEInit.c84
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_MotionEstimationMB.c630
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_PredictReconCoefIntra.c121
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_QuantInter_I.c117
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_QuantIntra_I.c153
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_QuantInvInter_I.c96
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_QuantInvIntra_I.c153
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_TransRecBlockCoef_inter.c108
-rw-r--r--media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_TransRecBlockCoef_intra.c260
43 files changed, 7109 insertions, 0 deletions
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_ACDCPredict.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_ACDCPredict.c
new file mode 100644
index 0000000..b6a396a
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_ACDCPredict.c
@@ -0,0 +1,253 @@
+/**
+ *
+ * File Name: armVCM4P2_ACDCPredict.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains module for DC/AC coefficient prediction
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+
+/**
+ * Function: armVCM4P2_ACDCPredict
+ *
+ * Description:
+ * Performs adaptive DC/AC coefficient prediction for an intra block. Prior
+ * to the function call, prediction direction (predDir) should be selected
+ * as specified in subclause 7.4.3.1 of ISO/IEC 14496-2.
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] pSrcDst pointer to the coefficient buffer which contains
+ * the quantized coefficient residuals (PQF) of the
+ * current block
+ * [in] pPredBufRow pointer to the coefficient row buffer
+ * [in] pPredBufCol pointer to the coefficient column buffer
+ * [in] curQP quantization parameter of the current block. curQP
+ * may equal to predQP especially when the current
+ * block and the predictor block are in the same
+ * macroblock.
+ * [in] predQP quantization parameter of the predictor block
+ * [in] predDir indicates the prediction direction which takes one
+ * of the following values:
+ * OMX_VC_HORIZONTAL predict horizontally
+ * OMX_VC_VERTICAL predict vertically
+ * [in] ACPredFlag a flag indicating if AC prediction should be
+ * performed. It is equal to ac_pred_flag in the bit
+ * stream syntax of MPEG-4
+ * [in] videoComp video component type (luminance, chrominance or
+ * alpha) of the current block
+ * [in] flag This flag defines the if one wants to use this functions to
+ * calculate PQF (set 1, prediction) or QF (set 0, reconstruction)
+ * [out] pPreACPredict pointer to the predicted coefficients buffer.
+ * Filled ONLY if it is not NULL
+ * [out] pSrcDst pointer to the coefficient buffer which contains
+ * the quantized coefficients (QF) of the current
+ * block
+ * [out] pPredBufRow pointer to the updated coefficient row buffer
+ * [out] pPredBufCol pointer to the updated coefficient column buffer
+ * [out] pSumErr pointer to the updated sum of the difference
+ * between predicted and unpredicted coefficients
+ * If this is NULL, do not update
+ *
+ * Return Value:
+ * Standard OMXResult result. See enumeration for possible result codes.
+ *
+ */
+
+OMXResult armVCM4P2_ACDCPredict(
+ OMX_S16 * pSrcDst,
+ OMX_S16 * pPreACPredict,
+ OMX_S16 * pPredBufRow,
+ OMX_S16 * pPredBufCol,
+ OMX_INT curQP,
+ OMX_INT predQP,
+ OMX_INT predDir,
+ OMX_INT ACPredFlag,
+ OMXVCM4P2VideoComponent videoComp,
+ OMX_U8 flag,
+ OMX_INT *pSumErr
+)
+{
+ OMX_INT dcScaler, i;
+ OMX_S16 tempPred;
+
+ /* Argument error checks */
+ armRetArgErrIf(pSrcDst == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pPredBufRow == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pPredBufCol == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(curQP <= 0, OMX_Sts_BadArgErr);
+ armRetArgErrIf(predQP <= 0, OMX_Sts_BadArgErr);
+ armRetArgErrIf((predDir != 1) && (predDir != 2), OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs4ByteAligned(pSrcDst), OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs4ByteAligned(pPredBufRow), OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs4ByteAligned(pPredBufCol), OMX_Sts_BadArgErr);
+
+
+ /* Set DC scaler value to avoid some compilers giving a warning. */
+ dcScaler=0;
+
+ /* Calculate the DC scaler value */
+ if (videoComp == OMX_VC_LUMINANCE)
+ {
+ if (curQP >= 1 && curQP <= 4)
+ {
+ dcScaler = 8;
+ }
+ else if (curQP >= 5 && curQP <= 8)
+ {
+ dcScaler = 2 * curQP;
+ }
+ else if (curQP >= 9 && curQP <= 24)
+ {
+ dcScaler = curQP + 8;
+ }
+ else
+ {
+ dcScaler = (2 * curQP) - 16;
+ }
+ }
+ else if (videoComp == OMX_VC_CHROMINANCE)
+ {
+ if (curQP >= 1 && curQP <= 4)
+ {
+ dcScaler = 8;
+ }
+ else if (curQP >= 5 && curQP <= 24)
+ {
+ dcScaler = (curQP + 13)/2;
+ }
+ else
+ {
+ dcScaler = curQP - 6;
+ }
+ }
+
+ if (pPreACPredict != NULL)
+ {
+ pPreACPredict[0] = predDir;
+ }
+
+ if (predDir == OMX_VC_VERTICAL)
+ {
+ /* F[0][0]//dc_scaler */
+ tempPred = armIntDivAwayFromZero(pPredBufRow[0], dcScaler);
+ }
+ else
+ {
+ /* F[0][0]//dc_scaler */
+ tempPred = armIntDivAwayFromZero(pPredBufCol[0], dcScaler);
+ }
+
+ /* Updating the DC value to the row and col buffer */
+ *(pPredBufRow - 8) = *pPredBufCol;
+
+ if (flag)
+ {
+ /* Cal and store F[0][0] into the col buffer */
+ *pPredBufCol = pSrcDst[0] * dcScaler;
+
+ /* PQF = QF - F[0][0]//dc_scaler */
+ pSrcDst[0] -= tempPred;
+ }
+ else
+ {
+ /* QF = PQF + F[0][0]//dc_scaler */
+ pSrcDst[0] += tempPred;
+
+ /* Saturate */
+ pSrcDst[0] = armClip (-2048, 2047, pSrcDst[0]);
+
+ /* Cal and store F[0][0] into the col buffer */
+ *pPredBufCol = pSrcDst[0] * dcScaler;
+ }
+
+
+ if (ACPredFlag == 1)
+ {
+ if (predDir == OMX_VC_VERTICAL)
+ {
+ for (i = 1; i < 8; i++)
+ {
+ tempPred = armIntDivAwayFromZero \
+ (pPredBufRow[i] * predQP, curQP);
+ if (flag)
+ {
+ /* Updating QF to the row buff */
+ pPredBufRow[i] = pSrcDst[i];
+ /*PQFX[v][0] = QFX[v][0] - (QFA[v][0] * QPA) // QPX */
+ pSrcDst[i] -= tempPred;
+ /* Sum of absolute values of AC prediction error, this can
+ be used as a reference to choose whether to use
+ AC prediction */
+ *pSumErr += armAbs(pSrcDst[i]);
+ /* pPreACPredict[1~7] store the error signal
+ after AC prediction */
+ pPreACPredict[i] = pSrcDst[i];
+ }
+ else
+ {
+ /*QFX[v][0] = PQFX[v][0] + (QFA[v][0] * QPA) // QPX */
+ pSrcDst[i] += tempPred;
+
+ /* Saturate */
+ pSrcDst[i] = armClip (-2048, 2047, pSrcDst[i]);
+
+ /* Updating QF to the row buff */
+ pPredBufRow[i] = pSrcDst[i];
+ }
+ }
+ }
+ else
+ {
+ for (i = 8; i < 64; i += 8)
+ {
+ tempPred = armIntDivAwayFromZero \
+ (pPredBufCol[i>>3] * predQP, curQP);
+ if (flag)
+ {
+ /* Updating QF to col buff */
+ pPredBufCol[i>>3] = pSrcDst[i];
+ /*PQFX[0][u] = QFX[0][u] - (QFA[0][u] * QPA) // QPX */
+ pSrcDst[i] -= tempPred;
+ /* Sum of absolute values of AC prediction error, this can
+ be used as a reference to choose whether to use AC
+ prediction */
+ *pSumErr += armAbs(pSrcDst[i]);
+ /* pPreACPredict[1~7] store the error signal
+ after AC prediction */
+ pPreACPredict[i>>3] = pSrcDst[i];
+ }
+ else
+ {
+ /*QFX[0][u] = PQFX[0][u] + (QFA[0][u] * QPA) // QPX */
+ pSrcDst[i] += tempPred;
+
+ /* Saturate */
+ pSrcDst[i] = armClip (-2048, 2047, pSrcDst[i]);
+
+ /* Updating QF to col buff */
+ pPredBufCol[i>>3] = pSrcDst[i];
+ }
+ }
+ }
+ }
+
+ return OMX_Sts_NoErr;
+}
+
+/*End of File*/
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_BlockMatch_Half.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_BlockMatch_Half.c
new file mode 100644
index 0000000..1b69a33
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_BlockMatch_Half.c
@@ -0,0 +1,187 @@
+/**
+ *
+ * File Name: armVCM4P2_BlockMatch_Half.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for Block matching, a full search algorithm
+ * is implemented
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+
+/**
+ * Function: armVCM4P2_BlockMatch_Half
+ *
+ * Description:
+ * Performs a 16x16 block match with half-pixel resolution. Returns the estimated
+ * motion vector and associated minimum SAD. This function estimates the half-pixel
+ * motion vector by interpolating the integer resolution motion vector referenced
+ * by the input parameter pSrcDstMV, i.e., the initial integer MV is generated
+ * externally. The input parameters pSrcRefBuf and pSearchPointRefPos should be
+ * shifted by the winning MV of 16x16 integer search prior to calling BlockMatch_Half_16x16.
+ * The function BlockMatch_Integer_16x16 may be used for integer motion estimation.
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] pSrcRefBuf pointer to the reference Y plane; points to the reference MB
+ * that corresponds to the location of the current macroblock in
+ * the current plane.
+ * [in] refWidth width of the reference plane
+ * [in] pRefRect reference plane valid region rectangle
+ * [in] pSrcCurrBuf pointer to the current macroblock extracted from original plane
+ * (linear array, 256 entries); must be aligned on an 8-byte boundary.
+ * [in] pSearchPointRefPos position of the starting point for half pixel search (specified
+ * in terms of integer pixel units) in the reference plane.
+ * [in] rndVal rounding control bit for half pixel motion estimation;
+ * 0=rounding control disabled; 1=rounding control enabled
+ * [in] pSrcDstMV pointer to the initial MV estimate; typically generated during a prior
+ * 16X16 integer search and its unit is half pixel.
+ * [in] BlockSize MacroBlock Size i.e either 16x16 or 8x8.
+ * [out]pSrcDstMV pointer to estimated MV
+ * [out]pDstSAD pointer to minimum SAD
+ *
+ * Return Value:
+ * OMX_Sts_NoErr ¨C no error
+ * OMX_Sts_BadArgErr ¨C bad arguments
+ *
+ */
+
+OMXResult armVCM4P2_BlockMatch_Half(
+ const OMX_U8 *pSrcRefBuf,
+ OMX_INT refWidth,
+ const OMXRect *pRefRect,
+ const OMX_U8 *pSrcCurrBuf,
+ const OMXVCM4P2Coordinate *pSearchPointRefPos,
+ OMX_INT rndVal,
+ OMXVCMotionVector *pSrcDstMV,
+ OMX_INT *pDstSAD,
+ OMX_U8 BlockSize
+)
+{
+ OMX_INT outer, inner, count, index;
+ OMX_S16 halfPelX = 0, halfPelY = 0, x, y;
+ OMX_INT candSAD, refSAD = 0;
+ OMX_INT minSAD, fromX, toX, fromY, toY;
+ /* Offset to the reference at the begining of the bounding box */
+ const OMX_U8 *pTempSrcRefBuf;
+ OMX_U8 tempPel;
+
+ /* Argument error checks */
+ armRetArgErrIf(pSrcRefBuf == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pRefRect == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pSrcCurrBuf == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pSearchPointRefPos == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pSrcDstMV == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pDstSAD == NULL, OMX_Sts_BadArgErr);
+
+ /* Positioning the pointer */
+ pTempSrcRefBuf = pSrcRefBuf + (refWidth * (pSrcDstMV->dy/2)) + (pSrcDstMV->dx/2);
+
+ /* Copy the candidate to the temporary linear array */
+ for (outer = 0, count = 0,index = 0;
+ outer < BlockSize;
+ outer++, index += refWidth - BlockSize)
+ {
+ for (inner = 0; inner < BlockSize; inner++, count++, index++)
+ {
+ refSAD += armAbs (pTempSrcRefBuf[index] - pSrcCurrBuf[count]);
+ }
+ }
+
+ /* Set the minSad as reference SAD */
+ minSAD = refSAD;
+ *pDstSAD = refSAD;
+
+ /* Check for valid region */
+ fromX = 1;
+ toX = 1;
+ fromY = 1;
+ toY = 1;
+ if ((pSearchPointRefPos->x - 1) < pRefRect->x)
+ {
+ fromX = 0;
+ }
+
+ if ((pSearchPointRefPos->x + BlockSize + 1) > (pRefRect->x + pRefRect->width))
+ {
+ toX = 0;
+ }
+
+ if ((pSearchPointRefPos->y - 1) < pRefRect->y)
+ {
+ fromY = 0;
+ }
+
+ if ((pSearchPointRefPos->y + BlockSize + 1) > (pRefRect->y + pRefRect->height))
+ {
+ toY = 0;
+ }
+
+ /* Looping on y- axis */
+ for (y = -fromY; y <= toY; y++)
+ {
+ /* Looping on x- axis */
+ for (x = -fromX; x <= toX; x++)
+ {
+ /* check for integer position */
+ if ( x == 0 && y == 0)
+ {
+ continue;
+ }
+ /* Positioning the pointer */
+ pTempSrcRefBuf = pSrcRefBuf + (refWidth * (pSrcDstMV->dy/2))
+ + (pSrcDstMV->dx/2);
+
+ /* Interpolate the pixel and calculate the SAD*/
+ for (outer = 0, count = 0, candSAD = 0,index = 0;
+ outer < BlockSize;
+ outer++, index += refWidth - BlockSize)
+ {
+ for (inner = 0; inner < BlockSize; inner++, count++,index++)
+ {
+ tempPel = (
+ pTempSrcRefBuf[index]
+ + pTempSrcRefBuf[index + x] * armAbs(x)
+ + pTempSrcRefBuf[index + refWidth * y] * armAbs(y)
+ + pTempSrcRefBuf[index + refWidth * y + x]
+ * armAbs(x*y)
+ + armAbs (x) + armAbs (y) - rndVal
+ ) / (2 * (armAbs (x) + armAbs (y)));
+ candSAD += armAbs (tempPel - pSrcCurrBuf[count]);
+ }
+ }
+
+ /* Result calculations */
+ if (armVCM4P2_CompareMV (x, y, candSAD, halfPelX, halfPelY, minSAD))
+ {
+ *pDstSAD = candSAD;
+ minSAD = candSAD;
+ halfPelX = x;
+ halfPelY = y;
+ }
+
+ } /* End of x- axis */
+ } /* End of y-axis */
+
+ pSrcDstMV->dx += halfPelX;
+ pSrcDstMV->dy += halfPelY;
+
+ return OMX_Sts_NoErr;
+
+}
+
+/* End of file */
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_BlockMatch_Integer.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_BlockMatch_Integer.c
new file mode 100644
index 0000000..77fe358
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_BlockMatch_Integer.c
@@ -0,0 +1,167 @@
+/**
+ *
+ * File Name: armVCM4P2_BlockMatch_Integer.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for Block matching, a full search algorithm
+ * is implemented
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+
+/**
+ * Function: armVCM4P2_BlockMatch_Integer
+ *
+ * Description:
+ * Performs a 16x16 block search; estimates motion vector and associated minimum SAD.
+ * Both the input and output motion vectors are represented using half-pixel units, and
+ * therefore a shift left or right by 1 bit may be required, respectively, to match the
+ * input or output MVs with other functions that either generate output MVs or expect
+ * input MVs represented using integer pixel units.
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] pSrcRefBuf pointer to the reference Y plane; points to the reference MB that
+ * corresponds to the location of the current macroblock in the current
+ * plane.
+ * [in] refWidth width of the reference plane
+ * [in] pRefRect pointer to the valid rectangular in reference plane. Relative to image origin.
+ * It's not limited to the image boundary, but depended on the padding. For example,
+ * if you pad 4 pixels outside the image border, then the value for left border
+ * can be -4
+ * [in] pSrcCurrBuf pointer to the current macroblock extracted from original plane (linear array,
+ * 256 entries); must be aligned on an 8-byte boundary.
+ * [in] pCurrPointPos position of the current macroblock in the current plane
+ * [in] pSrcPreMV pointer to predicted motion vector; NULL indicates no predicted MV
+ * [in] pSrcPreSAD pointer to SAD associated with the predicted MV (referenced by pSrcPreMV)
+ * [in] searchRange search range for 16X16 integer block,the units of it is full pixel,the search range
+ * is the same in all directions.It is in inclusive of the boundary and specified in
+ * terms of integer pixel units.
+ * [in] pMESpec vendor-specific motion estimation specification structure; must have been allocated
+ * and then initialized using omxVCM4P2_MEInit prior to calling the block matching
+ * function.
+ * [out] pDstMV pointer to estimated MV
+ * [out] pDstSAD pointer to minimum SAD
+ *
+ * Return Value:
+ * OMX_Sts_NoErr ¨C no error.
+ * OMX_Sts_BadArgErr ¨C bad arguments
+ *
+ */
+
+OMXResult armVCM4P2_BlockMatch_Integer(
+ const OMX_U8 *pSrcRefBuf,
+ OMX_INT refWidth,
+ const OMXRect *pRefRect,
+ const OMX_U8 *pSrcCurrBuf,
+ const OMXVCM4P2Coordinate *pCurrPointPos,
+ const OMXVCMotionVector *pSrcPreMV,
+ const OMX_INT *pSrcPreSAD,
+ void *pMESpec,
+ OMXVCMotionVector *pDstMV,
+ OMX_INT *pDstSAD,
+ OMX_U8 BlockSize
+)
+{
+
+ /* Definitions and Initializations*/
+
+ OMX_INT outer, inner, count,index;
+ OMX_INT candSAD;
+ /*(256*256 +1) this is to make the SAD max initially*/
+ OMX_INT minSAD = 0x10001, fromX, toX, fromY, toY;
+ /* Offset to the reference at the begining of the bounding box */
+ const OMX_U8 *pTempSrcRefBuf;
+ OMX_S16 x, y;
+ OMX_INT searchRange;
+
+ /* Argument error checks */
+ armRetArgErrIf(pSrcRefBuf == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pRefRect == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pSrcCurrBuf == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pCurrPointPos == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pMESpec == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pDstMV == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pDstSAD == NULL, OMX_Sts_BadArgErr);
+
+ searchRange = ((OMXVCM4P2MEParams *)pMESpec)->searchRange;
+ /* Check for valid region */
+ fromX = searchRange;
+ toX = searchRange;
+ fromY = searchRange;
+ toY = searchRange;
+
+ if ((pCurrPointPos->x - searchRange) < pRefRect->x)
+ {
+ fromX = pCurrPointPos->x - pRefRect->x;
+ }
+
+ if ((pCurrPointPos->x + BlockSize + searchRange) > (pRefRect->x + pRefRect->width))
+ {
+ toX = pRefRect->width - (pCurrPointPos->x - pRefRect->x) - BlockSize;
+ }
+
+ if ((pCurrPointPos->y - searchRange) < pRefRect->y)
+ {
+ fromY = pCurrPointPos->y - pRefRect->y;
+ }
+
+ if ((pCurrPointPos->y + BlockSize + searchRange) > (pRefRect->y + pRefRect->height))
+ {
+ toY = pRefRect->width - (pCurrPointPos->y - pRefRect->y) - BlockSize;
+ }
+
+ pDstMV->dx = -fromX;
+ pDstMV->dy = -fromY;
+ /* Looping on y- axis */
+ for (y = -fromY; y <= toY; y++)
+ {
+
+ /* Looping on x- axis */
+ for (x = -fromX; x <= toX; x++)
+ {
+ /* Positioning the pointer */
+ pTempSrcRefBuf = pSrcRefBuf + (refWidth * y) + x;
+
+ /* Calculate the SAD */
+ for (outer = 0, count = 0, index = 0, candSAD = 0;
+ outer < BlockSize;
+ outer++, index += refWidth - BlockSize)
+ {
+ for (inner = 0; inner < BlockSize; inner++, count++, index++)
+ {
+ candSAD += armAbs (pTempSrcRefBuf[index] - pSrcCurrBuf[count]);
+ }
+ }
+
+ /* Result calculations */
+ if (armVCM4P2_CompareMV (x, y, candSAD, pDstMV->dx/2, pDstMV->dy/2, minSAD))
+ {
+ *pDstSAD = candSAD;
+ minSAD = candSAD;
+ pDstMV->dx = x*2;
+ pDstMV->dy = y*2;
+ }
+
+ } /* End of x- axis */
+ } /* End of y-axis */
+
+ return OMX_Sts_NoErr;
+
+}
+
+/* End of file */
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_CheckVLCEscapeMode.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_CheckVLCEscapeMode.c
new file mode 100644
index 0000000..94e8639
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_CheckVLCEscapeMode.c
@@ -0,0 +1,156 @@
+/**
+ *
+ * File Name: armVCM4P2_CheckVLCEscapeMode.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains module for VLC escape mode check
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+
+/**
+ * Function: armVCM4P2_CheckVLCEscapeMode
+ *
+ * Description:
+ * Performs escape mode decision based on the run, run+, level, level+ and
+ * last combinations.
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] run Run value (count of zeros) to be encoded
+ * [in] level Level value (non-zero value) to be encoded
+ * [in] runPlus Calculated as runPlus = run - (RMAX + 1)
+ * [in] levelPlus Calculated as
+ * levelPlus = sign(level)*[abs(level) - LMAX]
+ * [in] maxStoreRun Max store possible (considering last and inter/intra)
+ * [in] maxRunForMultipleEntries
+ * The run value after which level
+ * will be equal to 1:
+ * (considering last and inter/intra status)
+ * [in] pRunIndexTable Run Index table defined in
+ * armVCM4P2_Huff_Tables_VLC.c
+ * (considering last and inter/intra status)
+ *
+ *
+ * Return Value:
+ * Returns an Escape mode which can take values from 0 to 3
+ * 0 --> no escape mode, 1 --> escape type 1,
+ * 1 --> escape type 2, 3 --> escape type 3, check section 7.4.1.3
+ * in the MPEG ISO standard.
+ *
+ */
+
+OMX_U8 armVCM4P2_CheckVLCEscapeMode(
+ OMX_U32 run,
+ OMX_U32 runPlus,
+ OMX_S16 level,
+ OMX_S16 levelPlus,
+ OMX_U8 maxStoreRun,
+ OMX_U8 maxRunForMultipleEntries,
+ OMX_INT shortVideoHeader,
+ const OMX_U8 *pRunIndexTable
+)
+{
+ OMX_U8 escape = 0, fMode = 0, entries;
+
+ level = armAbs (level);
+ levelPlus = armAbs (levelPlus);
+
+ /* Check for a valid entry with run, level and Last combination
+ Mode 0 check */
+ if (run <= maxStoreRun)
+ {
+ entries = pRunIndexTable[run + 1]
+ - pRunIndexTable[run];
+ if (run > maxRunForMultipleEntries)
+ {
+ entries = 1;
+ }
+ if (level > entries)
+ {
+ escape = 1;
+ }
+ }
+ else
+ {
+ escape = 1;
+ }
+ if(escape && shortVideoHeader)
+ {
+ escape = 0;
+ fMode = 4;
+ }
+ /* Check for a valid entry with run, levelPlus and Last combination
+ Mode 1 check */
+ if (escape)
+ {
+ escape = 0;
+ fMode = 1;
+ if (run <= maxStoreRun)
+ {
+ entries = pRunIndexTable[run + 1]
+ - pRunIndexTable[run];
+ if (run > maxRunForMultipleEntries)
+ {
+ entries = 1;
+ }
+ if (levelPlus > entries)
+ {
+ escape = 1;
+ }
+ }
+ else
+ {
+ escape = 1;
+ }
+ }
+
+ /* Check for a valid entry with runPlus, level and Last combination
+ Mode 2 check */
+ if (escape)
+ {
+ escape = 0;
+ fMode = 2;
+ if (runPlus <= maxStoreRun)
+ {
+ entries = pRunIndexTable[runPlus + 1]
+ - pRunIndexTable[runPlus];
+ if (runPlus > maxRunForMultipleEntries)
+ {
+ entries = 1;
+ }
+ if (level > entries)
+ {
+ escape = 1;
+ }
+ }
+ else
+ {
+ escape = 1;
+ }
+ }
+
+ /* select mode 3 --> FLC */
+ if (escape)
+ {
+ fMode = 3;
+ }
+
+ return fMode;
+}
+
+/*End of File*/
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_CompareMV.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_CompareMV.c
new file mode 100644
index 0000000..3b8845e
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_CompareMV.c
@@ -0,0 +1,71 @@
+/**
+ *
+ * File Name: armVCM4P2_CompareMV.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains module for comparing motion vectors and SAD's to decide
+ * the best MV and SAD
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+
+/**
+ * Function: armVCM4P2_CompareMV
+ *
+ * Description:
+ * Performs comparision of motion vectors and SAD's to decide the
+ * best MV and SAD
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] mvX x coordinate of the candidate motion vector
+ * [in] mvY y coordinate of the candidate motion vector
+ * [in] candSAD Candidate SAD
+ * [in] bestMVX x coordinate of the best motion vector
+ * [in] bestMVY y coordinate of the best motion vector
+ * [in] bestSAD best SAD
+ *
+ * Return Value:
+ * OMX_INT -- 1 to indicate that the current sad is the best
+ * 0 to indicate that it is NOT the best SAD
+ */
+
+OMX_INT armVCM4P2_CompareMV (
+ OMX_S16 mvX,
+ OMX_S16 mvY,
+ OMX_INT candSAD,
+ OMX_S16 bestMVX,
+ OMX_S16 bestMVY,
+ OMX_INT bestSAD
+)
+{
+ if (candSAD < bestSAD)
+ {
+ return 1;
+ }
+ if (candSAD > bestSAD)
+ {
+ return 0;
+ }
+ /* shorter motion vector */
+ if ( (mvX * mvX + mvY * mvY) < (bestMVX*bestMVX+bestMVY*bestMVY) )
+ {
+ return 1;
+ }
+ return 0;
+}
+
+/*End of File*/
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_DCT_Table.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_DCT_Table.c
new file mode 100644
index 0000000..a6f713e
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_DCT_Table.c
@@ -0,0 +1,112 @@
+ /**
+ *
+ * File Name: armVCM4P2_DCT_Table.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * File: armVCM4P2_DCT_Table.c
+ * Description: Contains the DCT/IDCT coefficent matrix
+ *
+ */
+
+#ifndef _OMXDCTCOSTAB_C_
+#define _OMXDCTCOSTAB_C_
+
+#include "omxtypes.h"
+#include "armOMX.h"
+
+const OMX_F64 armVCM4P2_preCalcDCTCos[8][8] =
+{
+ {
+ 0.353553390593273730,
+ 0.490392640201615220,
+ 0.461939766255643370,
+ 0.415734806151272620,
+ 0.353553390593273790,
+ 0.277785116509801140,
+ 0.191341716182544920,
+ 0.097545161008064152
+ },
+ {
+ 0.353553390593273730,
+ 0.415734806151272620,
+ 0.191341716182544920,
+ -0.097545161008064096,
+ -0.353553390593273730,
+ -0.490392640201615220,
+ -0.461939766255643420,
+ -0.277785116509801090
+ },
+ {
+ 0.353553390593273730,
+ 0.277785116509801140,
+ -0.191341716182544860,
+ -0.490392640201615220,
+ -0.353553390593273840,
+ 0.097545161008064138,
+ 0.461939766255643260,
+ 0.415734806151272730
+ },
+ {
+ 0.353553390593273730,
+ 0.097545161008064152,
+ -0.461939766255643370,
+ -0.277785116509801090,
+ 0.353553390593273680,
+ 0.415734806151272730,
+ -0.191341716182544920,
+ -0.490392640201615330
+ },
+ {
+ 0.353553390593273730,
+ -0.097545161008064096,
+ -0.461939766255643420,
+ 0.277785116509800920,
+ 0.353553390593273840,
+ -0.415734806151272620,
+ -0.191341716182545280,
+ 0.490392640201615220
+ },
+ {
+ 0.353553390593273730,
+ -0.277785116509800980,
+ -0.191341716182545170,
+ 0.490392640201615220,
+ -0.353553390593273340,
+ -0.097545161008064013,
+ 0.461939766255643370,
+ -0.415734806151272510
+ },
+ {
+ 0.353553390593273730,
+ -0.415734806151272670,
+ 0.191341716182545000,
+ 0.097545161008064388,
+ -0.353553390593273620,
+ 0.490392640201615330,
+ -0.461939766255643200,
+ 0.277785116509800760
+ },
+ {
+ 0.353553390593273730,
+ -0.490392640201615220,
+ 0.461939766255643260,
+ -0.415734806151272620,
+ 0.353553390593273290,
+ -0.277785116509800760,
+ 0.191341716182544780,
+ -0.097545161008064277
+ }
+};
+
+#endif /*_OMXDCTCOSTAB_C_*/
+
+
+/* End of file */
+
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_DecodeVLCZigzag_intra.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_DecodeVLCZigzag_intra.c
new file mode 100644
index 0000000..a2572e0
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_DecodeVLCZigzag_intra.c
@@ -0,0 +1,144 @@
+/**
+ *
+ * File Name: armVCM4P2_DecodeVLCZigzag_intra.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for filling of the coefficient buffer
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+#include "armCOMM_Bitstream.h"
+#include "armCOMM.h"
+#include "armVCM4P2_Huff_Tables_VLC.h"
+#include "armVCM4P2_ZigZag_Tables.h"
+
+
+
+/**
+ * Function: armVCM4P2_DecodeVLCZigzag_Intra
+ *
+ * Description:
+ * Performs VLC decoding and inverse zigzag scan for one intra coded block.
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] ppBitStream pointer to the pointer to the current byte in
+ * the bitstream buffer
+ * [in] pBitOffset pointer to the bit position in the byte pointed
+ * to by *ppBitStream. *pBitOffset is valid within
+ * [0-7].
+ * [in] predDir AC prediction direction which is used to decide
+ * the zigzag scan pattern. It takes one of the
+ * following values:
+ * OMX_VC_NONE AC prediction not used;
+ * perform classical zigzag scan;
+ * OMX_VC_HORIZONTAL Horizontal prediction;
+ * perform alternate-vertical
+ * zigzag scan;
+ * OMX_VC_VERTICAL Vertical prediction;
+ * thus perform
+ * alternate-horizontal
+ * zigzag scan.
+ * [in] start start indicates whether the encoding begins with 0th element
+ * or 1st.
+ * [out] ppBitStream *ppBitStream is updated after the block is
+ * decoded, so that it points to the current byte
+ * in the bit stream buffer
+ * [out] pBitOffset *pBitOffset is updated so that it points to the
+ * current bit position in the byte pointed by
+ * *ppBitStream
+ * [out] pDst pointer to the coefficient buffer of current
+ * block. Should be 32-bit aligned
+ *
+ * Return Value:
+ * Standard OMXResult result. See enumeration for possible result codes.
+ *
+ */
+
+OMXResult armVCM4P2_DecodeVLCZigzag_Intra(
+ const OMX_U8 ** ppBitStream,
+ OMX_INT * pBitOffset,
+ OMX_S16 * pDst,
+ OMX_U8 predDir,
+ OMX_INT shortVideoHeader,
+ OMX_U8 start
+)
+{
+ OMX_U8 last = 0;
+ const OMX_U8 *pZigzagTable = armVCM4P2_aClassicalZigzagScan;
+ OMXResult errorCode;
+
+ /* Argument error checks */
+ armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs4ByteAligned(pDst), OMX_Sts_BadArgErr);
+ armRetArgErrIf((*pBitOffset < 0) || (*pBitOffset >7), OMX_Sts_BadArgErr);
+ armRetArgErrIf((predDir > 2), OMX_Sts_BadArgErr);
+
+ switch (predDir)
+ {
+ case OMX_VC_NONE:
+ {
+ pZigzagTable = armVCM4P2_aClassicalZigzagScan;
+ break;
+ }
+
+ case OMX_VC_HORIZONTAL:
+ {
+ pZigzagTable = armVCM4P2_aVerticalZigzagScan;
+ break;
+ }
+
+ case OMX_VC_VERTICAL:
+ {
+ pZigzagTable = armVCM4P2_aHorizontalZigzagScan;
+ break;
+ }
+ }
+
+ errorCode = armVCM4P2_GetVLCBits (
+ ppBitStream,
+ pBitOffset,
+ pDst,
+ shortVideoHeader,
+ start,
+ &last,
+ 10,
+ 62,
+ 7,
+ 21,
+ armVCM4P2_IntraL0RunIdx,
+ armVCM4P2_IntraVlcL0,
+ armVCM4P2_IntraL1RunIdx,
+ armVCM4P2_IntraVlcL1,
+ armVCM4P2_IntraL0LMAX,
+ armVCM4P2_IntraL1LMAX,
+ armVCM4P2_IntraL0RMAX,
+ armVCM4P2_IntraL1RMAX,
+ pZigzagTable );
+ armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
+
+ if (last == 0)
+ {
+ return OMX_Sts_Err;
+ }
+ return OMX_Sts_NoErr;
+}
+
+/* End of file */
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_EncodeVLCZigzag_intra.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_EncodeVLCZigzag_intra.c
new file mode 100644
index 0000000..cd6b56d
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_EncodeVLCZigzag_intra.c
@@ -0,0 +1,145 @@
+/**
+ *
+ * File Name: armVCM4P2_EncodeVLCZigzag_intra.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for zigzag scanning and VLC encoding
+ * for intra block.
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+#include "armCOMM_Bitstream.h"
+#include "armCOMM.h"
+#include "armVCM4P2_Huff_Tables_VLC.h"
+#include "armVCM4P2_ZigZag_Tables.h"
+
+
+
+/**
+ * Function: armVCM4P2_EncodeVLCZigzag_Intra
+ *
+ * Description:
+ * Performs zigzag scanning and VLC encoding for one intra block.
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] ppBitStream pointer to the pointer to the current byte in
+ * the bit stream
+ * [in] pBitOffset pointer to the bit position in the byte pointed
+ * by *ppBitStream. Valid within 0 to 7.
+ * [in] pQDctBlkCoef pointer to the quantized DCT coefficient
+ * [in] predDir AC prediction direction, which is used to decide
+ * the zigzag scan pattern. This takes one of the
+ * following values:
+ * OMX_VC_NONE AC prediction not used.
+ * Performs classical zigzag
+ * scan.
+ * OMX_VC_HORIZONTAL Horizontal prediction.
+ * Performs alternate-vertical
+ * zigzag scan.
+ * OMX_VC_VERTICAL Vertical prediction.
+ * Performs alternate-horizontal
+ * zigzag scan.
+ * [in] pattern block pattern which is used to decide whether
+ * this block is encoded
+ * [in] start start indicates whether the encoding begins with 0th element
+ * or 1st.
+ * [out] ppBitStream *ppBitStream is updated after the block is encoded,
+ * so that it points to the current byte in the bit
+ * stream buffer.
+ * [out] pBitOffset *pBitOffset is updated so that it points to the
+ * current bit position in the byte pointed by
+ * *ppBitStream.
+ *
+ * Return Value:
+ * Standard OMXResult result. See enumeration for possible result codes.
+ *
+ */
+
+OMXResult armVCM4P2_EncodeVLCZigzag_Intra(
+ OMX_U8 **ppBitStream,
+ OMX_INT *pBitOffset,
+ const OMX_S16 *pQDctBlkCoef,
+ OMX_U8 predDir,
+ OMX_U8 pattern,
+ OMX_INT shortVideoHeader,
+ OMX_U8 start
+)
+{
+ const OMX_U8 *pZigzagTable = armVCM4P2_aClassicalZigzagScan;
+ OMXResult errorCode;
+
+ /* Argument error checks */
+ armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pQDctBlkCoef == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf((*pBitOffset < 0) || (*pBitOffset >7), OMX_Sts_BadArgErr);
+ armRetArgErrIf(start > 1, OMX_Sts_BadArgErr);
+ armRetArgErrIf(predDir > 2, OMX_Sts_BadArgErr);
+
+ if (pattern)
+ {
+ switch (predDir)
+ {
+ case OMX_VC_NONE:
+ {
+ pZigzagTable = armVCM4P2_aClassicalZigzagScan;
+ break;
+ }
+
+ case OMX_VC_HORIZONTAL:
+ {
+ pZigzagTable = armVCM4P2_aVerticalZigzagScan;
+ break;
+ }
+
+ case OMX_VC_VERTICAL:
+ {
+ pZigzagTable = armVCM4P2_aHorizontalZigzagScan;
+ break;
+ }
+ }
+
+ errorCode = armVCM4P2_PutVLCBits (
+ ppBitStream,
+ pBitOffset,
+ pQDctBlkCoef,
+ shortVideoHeader,
+ start,
+ 14,
+ 20,
+ 9,
+ 6,
+ armVCM4P2_IntraL0RunIdx,
+ armVCM4P2_IntraVlcL0,
+ armVCM4P2_IntraL1RunIdx,
+ armVCM4P2_IntraVlcL1,
+ armVCM4P2_IntraL0LMAX,
+ armVCM4P2_IntraL1LMAX,
+ armVCM4P2_IntraL0RMAX,
+ armVCM4P2_IntraL1RMAX,
+ pZigzagTable
+ );
+ armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
+
+ } /* Pattern check ends*/
+
+ return (OMX_Sts_NoErr);
+
+}
+
+/* End of file */
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_FillVLCBuffer.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_FillVLCBuffer.c
new file mode 100644
index 0000000..93c9504
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_FillVLCBuffer.c
@@ -0,0 +1,153 @@
+/**
+ *
+ * File Name: armVCM4P2_FillVLCBuffer.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains module for putting VLC bits
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+#include "armCOMM_Bitstream.h"
+
+/**
+ * Function: armVCM4P2_FillVLCBuffer
+ *
+ * Description:
+ * Performs calculating the VLC bits depending on the escape type and insert
+ * the same in the bitstream
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] ppBitStream pointer to the pointer to the current byte in
+ * the bit stream
+ * [in] pBitOffset pointer to the bit position in the byte pointed
+ * by *ppBitStream. Valid within 0 to 7
+ * [in] run Run value (count of zeros) to be encoded
+ * [in] level Level value (non-zero value) to be encoded
+ * [in] runPlus Calculated as runPlus = run - (RMAX + 1)
+ * [in] levelPlus Calculated as
+ * levelPlus = sign(level)*[abs(level) - LMAX]
+ * [in] fMode Flag indicating the escape modes
+ * [in] last status of the last flag
+ * [in] maxRunForMultipleEntries
+ * The run value after which level will be equal to 1:
+ * (considering last and inter/intra status)
+ * [in] pRunIndexTable Run Index table defined in
+ * armVCM4P2_Huff_Tables_VLC.h
+ * [in] pVlcTable VLC table defined in armVCM4P2_Huff_Tables_VLC.h
+ * [out] ppBitStream *ppBitStream is updated after the block is encoded
+ * so that it points to the current byte in the bit
+ * stream buffer.
+ * [out] pBitOffset *pBitOffset is updated so that it points to the
+ * current bit position in the byte pointed by
+ * *ppBitStream.
+ *
+ * Return Value:
+ * Standard OMXResult result. See enumeration for possible result codes.
+ *
+ */
+
+OMXResult armVCM4P2_FillVLCBuffer (
+ OMX_U8 **ppBitStream,
+ OMX_INT * pBitOffset,
+ OMX_U32 run,
+ OMX_S16 level,
+ OMX_U32 runPlus,
+ OMX_S16 levelPlus,
+ OMX_U8 fMode,
+ OMX_U8 last,
+ OMX_U8 maxRunForMultipleEntries,
+ const OMX_U8 *pRunIndexTable,
+ const ARM_VLC32 *pVlcTable
+)
+{
+ OMX_INT tempIndex;
+ OMX_U32 tempRun = run, sign = 0;
+ OMX_S16 tempLevel = level;
+
+ /* Escape sequence addition */
+ if (fMode == 1)
+ {
+ armPackBits(ppBitStream, pBitOffset, 3, 7);
+ armPackBits(ppBitStream, pBitOffset, 0, 1);
+ tempLevel = levelPlus;
+
+ }
+ else if(fMode == 2)
+ {
+ armPackBits(ppBitStream, pBitOffset, 3, 7);
+ armPackBits(ppBitStream, pBitOffset, 2, 2);
+ tempRun = runPlus;
+ }
+ else if (fMode == 3)
+ {
+ armPackBits(ppBitStream, pBitOffset, 3, 7);
+ armPackBits(ppBitStream, pBitOffset, 3, 2);
+ }
+ else if (fMode == 4)
+ {
+ armPackBits(ppBitStream, pBitOffset, 3, 7);
+ armPackBits(ppBitStream, pBitOffset, (OMX_U32)last, 1);
+ armPackBits(ppBitStream, pBitOffset, tempRun, 6);
+ if((tempLevel != 0) && (tempLevel != -128))
+ {
+ armPackBits(ppBitStream, pBitOffset,
+ (OMX_U32) tempLevel, 8);
+ }
+ return OMX_Sts_NoErr;
+ }
+
+ if (tempLevel < 0)
+ {
+ sign = 1;
+ tempLevel = armAbs(tempLevel);
+ }
+ /* Putting VLC bits in the stream */
+ if (fMode < 3)
+ {
+ if (tempRun > maxRunForMultipleEntries)
+ {
+ tempIndex = pRunIndexTable [maxRunForMultipleEntries + 1] +
+ (tempRun - maxRunForMultipleEntries - 1);
+ }
+ else
+ {
+ tempIndex = pRunIndexTable [tempRun] + (tempLevel -1);
+ }
+
+ armPackVLC32 (ppBitStream, pBitOffset,
+ pVlcTable [tempIndex]);
+ armPackBits(ppBitStream, pBitOffset, (OMX_U32)sign, 1);
+ }
+ else
+ {
+ if (sign)
+ {
+ tempLevel = -tempLevel;
+ }
+ tempRun = run;
+ armPackBits(ppBitStream, pBitOffset, (OMX_U32)last, 1);
+ armPackBits(ppBitStream, pBitOffset, tempRun, 6);
+ armPackBits(ppBitStream, pBitOffset, 1, 1);
+ armPackBits(ppBitStream, pBitOffset,
+ (OMX_U32) tempLevel, 12);
+ armPackBits(ppBitStream, pBitOffset, 1, 1);
+ }
+ return OMX_Sts_NoErr;
+}
+
+/*End of File*/
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_FillVLDBuffer.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_FillVLDBuffer.c
new file mode 100644
index 0000000..1712c3a
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_FillVLDBuffer.c
@@ -0,0 +1,84 @@
+/**
+ *
+ * File Name: armVCM4P2_FillVLDBuffer.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains module for VLC get bits from the stream
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+
+#include "armVCM4P2_ZigZag_Tables.h"
+
+
+/**
+ * Function: armVCM4P2_FillVLDBuffer
+ *
+ * Description:
+ * Performs filling of the coefficient buffer according to the run, level
+ * and sign, also updates the index
+ *
+ * Parameters:
+ * [in] storeRun Stored Run value (count of zeros)
+ * [in] storeLevel Stored Level value (non-zero value)
+ * [in] sign Flag indicating the sign of level
+ * [in] last status of the last flag
+ * [in] pIndex pointer to coefficient index in 8x8 matrix
+ * [out] pIndex pointer to updated coefficient index in 8x8
+ * matrix
+ * [in] pZigzagTable pointer to the zigzag tables
+ * [out] pDst pointer to the coefficient buffer of current
+ * block. Should be 32-bit aligned
+ * Return Value:
+ * Standard OMXResult result. See enumeration for possible result codes.
+ *
+ */
+
+OMXResult armVCM4P2_FillVLDBuffer(
+ OMX_U32 storeRun,
+ OMX_S16 * pDst,
+ OMX_S16 storeLevel,
+ OMX_U8 sign,
+ OMX_U8 last,
+ OMX_U8 * pIndex,
+ const OMX_U8 * pZigzagTable
+)
+{
+ /* Store the zero's as per the run length count */
+ for (;storeRun > 0; storeRun--, (*pIndex)++)
+ {
+ pDst[pZigzagTable[*pIndex]] = 0;
+ }
+ /* Store the level depending on the sign*/
+ if (sign == 1)
+ {
+ pDst[pZigzagTable[*pIndex]] = -storeLevel;
+ }
+ else
+ {
+ pDst[pZigzagTable[*pIndex]] = storeLevel;
+ }
+ (*pIndex)++;
+
+ /* If last is 1, fill the remaining elments of the buffer with zeros */
+ if (last == 1)
+ {
+ while (*pIndex < 64)
+ {
+ pDst[pZigzagTable[*pIndex]] = 0;
+ (*pIndex)++;
+ }
+ }
+
+ return OMX_Sts_NoErr;
+}
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_GetVLCBits.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_GetVLCBits.c
new file mode 100644
index 0000000..953f597
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_GetVLCBits.c
@@ -0,0 +1,278 @@
+/**
+ *
+ * File Name: armVCM4P2_GetVLCBits.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains module for VLC get bits from the stream
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+#include "armCOMM_Bitstream.h"
+#include "armVCM4P2_ZigZag_Tables.h"
+#include "armVCM4P2_Huff_Tables_VLC.h"
+
+
+/**
+ * Function: armVCM4P2_GetVLCBits
+ *
+ * Description:
+ * Performs escape mode decision based on the run, run+, level, level+ and
+ * last combinations.
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] ppBitStream pointer to the pointer to the current byte in
+ * the bit stream
+ * [in] pBitOffset pointer to the bit position in the byte pointed
+ * by *ppBitStream. Valid within 0 to 7
+ * [in] start start indicates whether the encoding begins with
+ * 0th element or 1st.
+ * [in/out] pLast pointer to last status flag
+ * [in] runBeginSingleLevelEntriesL0 The run value from which level
+ * will be equal to 1: last == 0
+ * [in] IndexBeginSingleLevelEntriesL0 Array index in the VLC table
+ * pointing to the
+ * runBeginSingleLevelEntriesL0
+ * [in] runBeginSingleLevelEntriesL1 The run value from which level
+ * will be equal to 1: last == 1
+ * [in] IndexBeginSingleLevelEntriesL1 Array index in the VLC table
+ * pointing to the
+ * runBeginSingleLevelEntriesL0
+ * [in] pRunIndexTableL0 Run Index table defined in
+ * armVCM4P2_Huff_Tables_VLC.c for last == 0
+ * [in] pVlcTableL0 VLC table for last == 0
+ * [in] pRunIndexTableL1 Run Index table defined in
+ * armVCM4P2_Huff_Tables_VLC.c for last == 1
+ * [in] pVlcTableL1 VLC table for last == 1
+ * [in] pLMAXTableL0 Level MAX table defined in
+ * armVCM4P2_Huff_Tables_VLC.c for last == 0
+ * [in] pLMAXTableL1 Level MAX table defined in
+ * armVCM4P2_Huff_Tables_VLC.c for last == 1
+ * [in] pRMAXTableL0 Run MAX table defined in
+ * armVCM4P2_Huff_Tables_VLC.c for last == 0
+ * [in] pRMAXTableL1 Run MAX table defined in
+ * armVCM4P2_Huff_Tables_VLC.c for last == 1
+ * [out]pDst pointer to the coefficient buffer of current
+ * block. Should be 32-bit aligned
+ *
+ * Return Value:
+ * Standard OMXResult result. See enumeration for possible result codes.
+ *
+ */
+
+OMXResult armVCM4P2_GetVLCBits (
+ const OMX_U8 **ppBitStream,
+ OMX_INT * pBitOffset,
+ OMX_S16 * pDst,
+ OMX_INT shortVideoHeader,
+ OMX_U8 start,
+ OMX_U8 * pLast,
+ OMX_U8 runBeginSingleLevelEntriesL0,
+ OMX_U8 maxIndexForMultipleEntriesL0,
+ OMX_U8 maxRunForMultipleEntriesL1,
+ OMX_U8 maxIndexForMultipleEntriesL1,
+ const OMX_U8 * pRunIndexTableL0,
+ const ARM_VLC32 *pVlcTableL0,
+ const OMX_U8 * pRunIndexTableL1,
+ const ARM_VLC32 *pVlcTableL1,
+ const OMX_U8 * pLMAXTableL0,
+ const OMX_U8 * pLMAXTableL1,
+ const OMX_U8 * pRMAXTableL0,
+ const OMX_U8 * pRMAXTableL1,
+ const OMX_U8 * pZigzagTable
+)
+{
+ OMX_U32 storeRun;
+ OMX_U8 tabIndex, markerBit;
+ OMX_S16 storeLevel;
+ OMX_U16 unpackRetIndex;
+ OMX_U8 i, fType, escape;
+ OMX_U8 sign = 0;
+
+ /* Unpacking the bitstream and RLD */
+ for (i = start; i < 64;)
+ {
+ escape = armLookAheadBits(ppBitStream, pBitOffset, 7);
+ if (escape != 3)
+ {
+ fType = 0; /* Not in escape mode */
+ }
+ else
+ {
+ armSkipBits (ppBitStream, pBitOffset, 7);
+ if(shortVideoHeader)
+ {
+ *pLast = armGetBits(ppBitStream, pBitOffset, 1);
+ storeRun = armGetBits(ppBitStream, pBitOffset, 6);
+ storeLevel = armGetBits(ppBitStream, pBitOffset, 8);
+
+ /* Ref to Table B-18 (c) in MPEG4 Standard- FLC code for */
+ /* LEVEL when short_video_header is 1, the storeLevel is */
+ /* a signed value and the sign and the unsigned value for */
+ /* storeLevel need to be extracted and passed to arm */
+ /* FillVLDBuffer function */
+
+ sign = (storeLevel & 0x80);
+ if(sign==0x80)
+ {
+ storeLevel=(storeLevel^0xff)+1;
+ sign=1;
+
+ }
+
+ armRetDataErrIf( storeLevel == 0 || sign*storeLevel == 128 , OMX_Sts_Err); /* Invalid FLC */
+ armRetDataErrIf((i + storeRun) >= 64, OMX_Sts_Err);
+ armVCM4P2_FillVLDBuffer(
+ storeRun,
+ pDst,
+ storeLevel,
+ sign,
+ *pLast,
+ &i,
+ pZigzagTable);
+ return OMX_Sts_NoErr;
+
+ }
+ if (armGetBits(ppBitStream, pBitOffset, 1))
+ {
+ if (armGetBits(ppBitStream, pBitOffset, 1))
+ {
+ fType = 3;
+ }
+ else
+ {
+ fType = 2;
+ }
+ }
+ else
+ {
+ fType = 1;
+ }
+ }
+
+ if (fType < 3)
+ {
+ unpackRetIndex = armUnPackVLC32(ppBitStream, pBitOffset,
+ pVlcTableL0);
+ if (unpackRetIndex != ARM_NO_CODEBOOK_INDEX)
+ {
+ /* Decode run and level from the index */
+ /* last = 0 */
+ *pLast = 0;
+ if (unpackRetIndex > maxIndexForMultipleEntriesL0)
+ {
+ storeLevel = 1;
+ storeRun = (unpackRetIndex - maxIndexForMultipleEntriesL0)
+ + runBeginSingleLevelEntriesL0;
+ }
+ else
+ {
+ tabIndex = 1;
+ while (pRunIndexTableL0[tabIndex] <= unpackRetIndex)
+ {
+ tabIndex++;
+ }
+ storeRun = tabIndex - 1;
+ storeLevel = unpackRetIndex - pRunIndexTableL0[tabIndex - 1] + 1;
+ }
+ sign = (OMX_U8) armGetBits(ppBitStream, pBitOffset, 1);
+
+ if (fType == 1)
+ {
+ storeLevel = (armAbs(storeLevel) + pLMAXTableL0[storeRun]);
+ }
+ else if (fType == 2)
+ {
+ storeRun = storeRun + pRMAXTableL0[storeLevel-1] + 1;
+ }
+ }
+ else
+ {
+ unpackRetIndex = armUnPackVLC32(ppBitStream, pBitOffset,
+ pVlcTableL1);
+
+ armRetDataErrIf(unpackRetIndex == ARM_NO_CODEBOOK_INDEX, OMX_Sts_Err);
+
+ /* Decode run and level from the index */
+ /* last = 1 */
+ *pLast = 1;
+ if (unpackRetIndex > maxIndexForMultipleEntriesL1)
+ {
+ storeLevel = 1;
+ storeRun = (unpackRetIndex - maxIndexForMultipleEntriesL1)
+ + maxRunForMultipleEntriesL1;
+ }
+ else
+ {
+ tabIndex = 1;
+ while (pRunIndexTableL1[tabIndex] <= unpackRetIndex)
+ {
+ tabIndex++;
+ }
+ storeRun = tabIndex - 1;
+ storeLevel = unpackRetIndex - pRunIndexTableL1[tabIndex - 1] + 1;
+ }
+ sign = (OMX_U8) armGetBits(ppBitStream, pBitOffset, 1);
+
+ if (fType == 1)
+ {
+ storeLevel = (armAbs(storeLevel) + pLMAXTableL1[storeRun]);
+ }
+ else if (fType == 2)
+ {
+ storeRun = storeRun + pRMAXTableL1[storeLevel-1] + 1;
+ }
+ }
+ armRetDataErrIf((i + storeRun) >= 64, OMX_Sts_Err);
+ armVCM4P2_FillVLDBuffer(
+ storeRun,
+ pDst,
+ storeLevel,
+ sign,
+ *pLast,
+ &i,
+ pZigzagTable);
+ }
+ else
+ {
+ *pLast = armGetBits(ppBitStream, pBitOffset, 1);
+ storeRun = armGetBits(ppBitStream, pBitOffset, 6);
+ armRetDataErrIf((i + storeRun) >= 64, OMX_Sts_Err);
+ markerBit = armGetBits(ppBitStream, pBitOffset, 1);
+ armRetDataErrIf( markerBit == 0, OMX_Sts_Err);
+ storeLevel = armGetBits(ppBitStream, pBitOffset, 12);
+ if (storeLevel & 0x800)
+ {
+ storeLevel -= 4096;
+ }
+ armRetDataErrIf( storeLevel == 0 || storeLevel == -2048 , OMX_Sts_Err); /* Invalid FLC */
+ armGetBits(ppBitStream, pBitOffset, 1);
+ armVCM4P2_FillVLDBuffer(
+ storeRun,
+ pDst,
+ storeLevel,
+ 0, /* Sign is not used, preprocessing done */
+ *pLast,
+ &i,
+ pZigzagTable);
+
+ }
+ } /* End of forloop for i */
+ return OMX_Sts_NoErr;
+}
+
+/* End of File */
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_Huff_Tables_VLC.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_Huff_Tables_VLC.c
new file mode 100644
index 0000000..cd7e9e4
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_Huff_Tables_VLC.c
@@ -0,0 +1,495 @@
+ /**
+ *
+ * File Name: armVCM4P2_Huff_Tables_VLC.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * File: armVCM4P2_Huff_Tables_VLC.c
+ * Description: Contains all the Huffman tables used in MPEG4 codec
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+
+#include "armCOMM_Bitstream.h"
+
+/*
+* For Intra
+* last = 0
+*/
+const OMX_U8 armVCM4P2_IntraL0RunIdx[11] =
+{
+ 0, 27, 37, 42, 46, 49, 52,
+ 55, 58, 60, 62
+};
+
+/* Entry defined for all values
+* for run = 0 to 14
+* Note: the last entry is to terminate while decoding
+*/
+const ARM_VLC32 armVCM4P2_IntraVlcL0[68] =
+{
+ {2, 2},
+ {3, 6},
+ {4, 15},
+ {5, 13},
+ {5, 12},
+ {6, 21},
+ {6, 19},
+ {6, 18},
+ {7, 23},
+ {8, 31},
+ {8, 30},
+ {8, 29},
+ {9, 37},
+ {9, 36},
+ {9, 35},
+ {9, 33},
+ {10, 33},
+ {10, 32},
+ {10, 15},
+ {10, 14},
+ {11, 7},
+ {11, 6},
+ {11, 32},
+ {11, 33},
+ {12, 80},
+ {12, 81},
+ {12, 82},
+ {4, 14},
+ {6, 20},
+ {7, 22},
+ {8, 28},
+ {9, 32},
+ {9, 31},
+ {10, 13},
+ {11, 34},
+ {12, 83},
+ {12, 85},
+ {5, 11},
+ {7, 21},
+ {9, 30},
+ {10, 12},
+ {12, 86},
+ {6, 17},
+ {8, 27},
+ {9, 29},
+ {10, 11},
+ {6, 16},
+ {9, 34},
+ {10, 10},
+ {6, 13},
+ {9, 28},
+ {10, 8},
+ {7, 18},
+ {9, 27},
+ {12, 84},
+ {7, 20},
+ {9, 26},
+ {12, 87},
+ {8, 25},
+ {10, 9},
+ {8, 24},
+ {11, 35},
+ {8, 23},
+ {9, 25},
+ {9, 24},
+ {10, 7},
+ {12, 88},
+ {0, 0}
+};
+
+/*
+* For Intra
+* last = 1
+*/
+
+const OMX_U8 armVCM4P2_IntraL1RunIdx[8] =
+{
+ 0, 8, 11, 13, 15, 17, 19, 21
+};
+
+/* Entry defined for all values
+* for run = 0 to 20
+* * Note: the last entry is to terminate while decoding
+*/
+const ARM_VLC32 armVCM4P2_IntraVlcL1[36] =
+{
+ {4, 7},
+ {6, 12},
+ {8, 22},
+ {9, 23},
+ {10, 6},
+ {11, 5},
+ {11, 4},
+ {12, 89},
+ {6, 15},
+ {9, 22},
+ {10, 5},
+ {6, 14},
+ {10, 4},
+ {7, 17},
+ {11, 36},
+ {7, 16},
+ {11, 37},
+ {7, 19},
+ {12, 90},
+ {8, 21},
+ {12, 91},
+ {8, 20},
+ {8, 19},
+ {8, 26},
+ {9, 21},
+ {9, 20},
+ {9, 19},
+ {9, 18},
+ {9, 17},
+ {11, 38},
+ {11, 39},
+ {12, 92},
+ {12, 93},
+ {12, 94},
+ {12, 95},
+ {0, 0}
+};
+
+/* LMAX table for Intra (Last == 0)*/
+const OMX_U8 armVCM4P2_IntraL0LMAX[15] =
+{
+ 27, 10, 5, 4, 3, 3, 3,
+ 3, 2, 2, 1, 1, 1, 1, 1
+};
+
+/* LMAX table for Intra (Last == 1)*/
+const OMX_U8 armVCM4P2_IntraL1LMAX[21] =
+{
+ 8, 3, 2, 2, 2, 2, 2, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1
+};
+
+/* RMAX table for Intra (Last == 0)
+ Level - 1 Indexed
+*/
+const OMX_U8 armVCM4P2_IntraL0RMAX[27] =
+{
+ 14, 9, 7, 3, 2, 1, 1,
+ 1, 1, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0
+};
+
+/* RMAX table for Intra (Last == 1)
+ Level - 1 Indexed
+*/
+const OMX_U8 armVCM4P2_IntraL1RMAX[8] =
+{
+ 20, 6, 1, 0, 0, 0, 0, 0
+};
+
+/*
+* For Inter
+* last = 0
+*/
+const OMX_U8 armVCM4P2_InterL0RunIdx[12] =
+{
+ 0, 12, 18, 22, 25, 28,
+ 31, 34, 36, 38, 40, 42
+};
+
+/* Entry defined for all values
+* for run = 0 to 26
+* Note: the last entry is to terminate while decoding
+*/
+const ARM_VLC32 armVCM4P2_InterVlcL0[59] =
+{
+ {2, 2},
+ {4, 15},
+ {6, 21},
+ {7, 23},
+ {8, 31},
+ {9, 37},
+ {9, 36},
+ {10, 33},
+ {10, 32},
+ {11, 7},
+ {11, 6},
+ {11, 32},
+ {3, 6},
+ {6, 20},
+ {8, 30},
+ {10, 15},
+ {11, 33},
+ {12, 80},
+ {4, 14},
+ {8, 29},
+ {10, 14},
+ {12, 81},
+ {5, 13},
+ {9, 35},
+ {10, 13},
+ {5, 12},
+ {9, 34},
+ {12, 82},
+ {5, 11},
+ {10, 12},
+ {12, 83},
+ {6, 19},
+ {10, 11},
+ {12, 84},
+ {6, 18},
+ {10, 10},
+ {6, 17},
+ {10, 9},
+ {6, 16},
+ {10, 8},
+ {7, 22},
+ {12, 85},
+ {7, 21},
+ {7, 20},
+ {8, 28},
+ {8, 27},
+ {9, 33},
+ {9, 32},
+ {9, 31},
+ {9, 30},
+ {9, 29},
+ {9, 28},
+ {9, 27},
+ {9, 26},
+ {11, 34},
+ {11, 35},
+ {12, 86},
+ {12, 87},
+ {0, 0}
+};
+
+
+/*
+* For Intra
+* last = 1
+*/
+
+const OMX_U8 armVCM4P2_InterL1RunIdx[3] =
+{
+ 0, 3, 5
+};
+
+/* Entry defined for all values
+* for run = 0 to 40
+* Note: the last entry is to terminate while decoding
+*/
+const ARM_VLC32 armVCM4P2_InterVlcL1[45] =
+{
+ {4, 7},
+ {9, 25},
+ {11, 5},
+ {6, 15},
+ {11, 4},
+ {6, 14},
+ {6, 13},
+ {6, 12},
+ {7, 19},
+ {7, 18},
+ {7, 17},
+ {7, 16},
+ {8, 26},
+ {8, 25},
+ {8, 24},
+ {8, 23},
+ {8, 22},
+ {8, 21},
+ {8, 20},
+ {8, 19},
+ {9, 24},
+ {9, 23},
+ {9, 22},
+ {9, 21},
+ {9, 20},
+ {9, 19},
+ {9, 18},
+ {9, 17},
+ {10, 7},
+ {10, 6},
+ {10, 5},
+ {10, 4},
+ {11, 36},
+ {11, 37},
+ {11, 38},
+ {11, 39},
+ {12, 88},
+ {12, 89},
+ {12, 90},
+ {12, 91},
+ {12, 92},
+ {12, 93},
+ {12, 94},
+ {12, 95},
+ { 0, 0}
+};
+
+/* LMAX table for Intra (Last == 0)*/
+const OMX_U8 armVCM4P2_InterL0LMAX[27] =
+{
+ 12, 6, 4, 3, 3, 3, 3, 2,
+ 2, 2, 2, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1,
+};
+
+/* LMAX table for Intra (Last == 1)*/
+const OMX_U8 armVCM4P2_InterL1LMAX[41] =
+{
+ 3, 2, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1,
+};
+
+/* RMAX table for Intra (Last == 0)
+ Level - 1 Indexed
+*/
+const OMX_U8 armVCM4P2_InterL0RMAX[12] =
+{
+ 26, 10, 6, 2, 1, 1,
+ 0, 0, 0, 0, 0, 0
+};
+
+/* RMAX table for Intra (Last == 1)
+ Level - 1 Indexed
+*/
+const OMX_U8 armVCM4P2_InterL1RMAX[3] =
+{
+ 40, 1, 0
+};
+
+/*
+* For Intra - Luminance
+*/
+
+const ARM_VLC32 armVCM4P2_aIntraDCLumaIndex[14] =
+{
+ {3, 3},
+ {2, 3},
+ {2, 2},
+ {3, 2},
+ {3, 1},
+ {4, 1},
+ {5, 1},
+ {6, 1},
+ {7, 1},
+ {8, 1},
+ {9, 1},
+ {10, 1},
+ {11, 1},
+ {0, 0}
+};
+
+/*
+* For Intra - Chrominance
+*/
+
+const ARM_VLC32 armVCM4P2_aIntraDCChromaIndex[14] =
+{
+ {2, 3},
+ {2, 2},
+ {2, 1},
+ {3, 1},
+ {4, 1},
+ {5, 1},
+ {6, 1},
+ {7, 1},
+ {8, 1},
+ {9, 1},
+ {10, 1},
+ {11, 1},
+ {12, 1},
+ {0, 0}
+};
+
+/*
+ * Motion vector decoding table
+ */
+
+const ARM_VLC32 armVCM4P2_aVlcMVD[66] =
+{
+ {13, 5},
+ {13, 7},
+ {12, 5},
+ {12, 7},
+ {12, 9},
+ {12, 11},
+ {12, 13},
+ {12, 15},
+ {11, 9},
+ {11, 11},
+ {11, 13},
+ {11, 15},
+ {11, 17},
+ {11, 19},
+ {11, 21},
+ {11, 23},
+ {11, 25},
+ {11, 27},
+ {11, 29},
+ {11, 31},
+ {11, 33},
+ {11, 35},
+ {10, 19},
+ {10, 21},
+ {10, 23},
+ {8, 7},
+ {8, 9},
+ {8, 11},
+ {7, 7},
+ {5, 3},
+ {4, 3},
+ {3, 3},
+ {1, 1},
+ {3, 2},
+ {4, 2},
+ {5, 2},
+ {7, 6},
+ {8, 10},
+ {8, 8},
+ {8, 6},
+ {10, 22},
+ {10, 20},
+ {10, 18},
+ {11, 34},
+ {11, 32},
+ {11, 30},
+ {11, 28},
+ {11, 26},
+ {11, 24},
+ {11, 22},
+ {11, 20},
+ {11, 18},
+ {11, 16},
+ {11, 14},
+ {11, 12},
+ {11, 10},
+ {11, 8},
+ {12, 14},
+ {12, 12},
+ {12, 10},
+ {12, 8},
+ {12, 6},
+ {12, 4},
+ {13, 6},
+ {13, 4},
+ { 0, 0}
+};
+
+/* End of file */
+
+
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_PutVLCBits.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_PutVLCBits.c
new file mode 100644
index 0000000..ca9efec
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_PutVLCBits.c
@@ -0,0 +1,200 @@
+/**
+ *
+ * File Name: armVCM4P2_PutVLCBits.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains module for VLC put bits to bitstream
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+#include "armCOMM_Bitstream.h"
+#include "armVCM4P2_ZigZag_Tables.h"
+#include "armVCM4P2_Huff_Tables_VLC.h"
+
+
+/**
+ * Function: armVCM4P2_PutVLCBits
+ *
+ * Description:
+ * Checks the type of Escape Mode and put encoded bits for
+ * quantized DCT coefficients.
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] ppBitStream pointer to the pointer to the current byte in
+ * the bit stream
+ * [in] pBitOffset pointer to the bit position in the byte pointed
+ * by *ppBitStream. Valid within 0 to 7
+ * [in] shortVideoHeader binary flag indicating presence of short_video_header; escape modes 0-3 are used if shortVideoHeader==0,
+ * and escape mode 4 is used when shortVideoHeader==1.
+ * [in] start start indicates whether the encoding begins with
+ * 0th element or 1st.
+ * [in] maxStoreRunL0 Max store possible (considering last and inter/intra)
+ * for last = 0
+ * [in] maxStoreRunL1 Max store possible (considering last and inter/intra)
+ * for last = 1
+ * [in] maxRunForMultipleEntriesL0
+ * The run value after which level
+ * will be equal to 1:
+ * (considering last and inter/intra status) for last = 0
+ * [in] maxRunForMultipleEntriesL1
+ * The run value after which level
+ * will be equal to 1:
+ * (considering last and inter/intra status) for last = 1
+ * [in] pRunIndexTableL0 Run Index table defined in
+ * armVCM4P2_Huff_Tables_VLC.c for last == 0
+ * [in] pVlcTableL0 VLC table for last == 0
+ * [in] pRunIndexTableL1 Run Index table defined in
+ * armVCM4P2_Huff_Tables_VLC.c for last == 1
+ * [in] pVlcTableL1 VLC table for last == 1
+ * [in] pLMAXTableL0 Level MAX table defined in
+ * armVCM4P2_Huff_Tables_VLC.c for last == 0
+ * [in] pLMAXTableL1 Level MAX table defined in
+ * armVCM4P2_Huff_Tables_VLC.c for last == 1
+ * [in] pRMAXTableL0 Run MAX table defined in
+ * armVCM4P2_Huff_Tables_VLC.c for last == 0
+ * [in] pRMAXTableL1 Run MAX table defined in
+ * armVCM4P2_Huff_Tables_VLC.c for last == 1
+ * [out] pQDctBlkCoef pointer to the quantized DCT coefficient
+ * [out] ppBitStream *ppBitStream is updated after the block is encoded
+ * so that it points to the current byte in the bit
+ * stream buffer.
+ * [out] pBitOffset *pBitOffset is updated so that it points to the
+ * current bit position in the byte pointed by
+ * *ppBitStream.
+ *
+ * Return Value:
+ * Standard OMXResult result. See enumeration for possible result codes.
+ *
+ */
+
+
+OMXResult armVCM4P2_PutVLCBits (
+ OMX_U8 **ppBitStream,
+ OMX_INT * pBitOffset,
+ const OMX_S16 *pQDctBlkCoef,
+ OMX_INT shortVideoHeader,
+ OMX_U8 start,
+ OMX_U8 maxStoreRunL0,
+ OMX_U8 maxStoreRunL1,
+ OMX_U8 maxRunForMultipleEntriesL0,
+ OMX_U8 maxRunForMultipleEntriesL1,
+ const OMX_U8 * pRunIndexTableL0,
+ const ARM_VLC32 *pVlcTableL0,
+ const OMX_U8 * pRunIndexTableL1,
+ const ARM_VLC32 *pVlcTableL1,
+ const OMX_U8 * pLMAXTableL0,
+ const OMX_U8 * pLMAXTableL1,
+ const OMX_U8 * pRMAXTableL0,
+ const OMX_U8 * pRMAXTableL1,
+ const OMX_U8 * pZigzagTable
+)
+{
+
+ OMX_U32 storeRun = 0, run, storeRunPlus;
+ OMX_U8 last = 0, first = 1, fMode;
+ OMX_S16 level, storeLevel = 0, storeLevelPlus;
+ OMX_INT i;
+
+ /* RLE encoding and packing the bits into the streams */
+ for (i = start, run=0; i < 64; i++)
+ {
+ level = pQDctBlkCoef[pZigzagTable[i]];
+
+ /* Counting the run */
+ if (level == 0)
+ {
+ run++;
+ }
+
+ /* Found a non-zero coeff */
+ else
+ {
+ if (first == 0)
+ {
+ last = 0;
+
+ /* Check for a valid entry in the VLC table */
+ storeLevelPlus = armSignCheck(storeLevel) *
+ (armAbs(storeLevel) - pLMAXTableL0[storeRun]);
+ storeRunPlus = storeRun -
+ (pRMAXTableL0[armAbs(storeLevel) - 1] + 1);
+
+ fMode = armVCM4P2_CheckVLCEscapeMode(
+ storeRun,
+ storeRunPlus,
+ storeLevel,
+ storeLevelPlus,
+ maxStoreRunL0,
+ maxRunForMultipleEntriesL0,
+ shortVideoHeader,
+ pRunIndexTableL0);
+
+ armVCM4P2_FillVLCBuffer (
+ ppBitStream,
+ pBitOffset,
+ storeRun,
+ storeLevel,
+ storeRunPlus,
+ storeLevelPlus,
+ fMode,
+ last,
+ maxRunForMultipleEntriesL0,
+ pRunIndexTableL0,
+ pVlcTableL0);
+ }
+ storeLevel = level;
+ storeRun = run;
+ first = 0;
+ run = 0;
+ }
+
+ } /* end of for loop for 64 elements */
+
+ /* writing the last element */
+ last = 1;
+
+ /* Check for a valid entry in the VLC table */
+ storeLevelPlus = armSignCheck(storeLevel) *
+ (armAbs(storeLevel) - pLMAXTableL1[run]);
+ storeRunPlus = storeRun -
+ (pRMAXTableL1[armAbs(storeLevel) - 1] + 1);
+ fMode = armVCM4P2_CheckVLCEscapeMode(
+ storeRun,
+ storeRunPlus,
+ storeLevel,
+ storeLevelPlus,
+ maxStoreRunL1,
+ maxRunForMultipleEntriesL1,
+ shortVideoHeader,
+ pRunIndexTableL1);
+
+ armVCM4P2_FillVLCBuffer (
+ ppBitStream,
+ pBitOffset,
+ storeRun,
+ storeLevel,
+ storeRunPlus,
+ storeLevelPlus,
+ fMode,
+ last,
+ maxRunForMultipleEntriesL1,
+ pRunIndexTableL1,
+ pVlcTableL1);
+ return OMX_Sts_NoErr;
+}
+
+/* End of File */
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_SetPredDir.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_SetPredDir.c
new file mode 100644
index 0000000..a9cd008
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_SetPredDir.c
@@ -0,0 +1,89 @@
+/**
+ *
+ * File Name: armVCM4P2_SetPredDir.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains module for detecting the prediction direction
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+
+/**
+ * Function: armVCM4P2_SetPredDir
+ *
+ * Description:
+ * Performs detecting the prediction direction
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] blockIndex block index indicating the component type and
+ * position as defined in subclause 6.1.3.8, of ISO/IEC
+ * 14496-2. Furthermore, indexes 6 to 9 indicate the
+ * alpha blocks spatially corresponding to luminance
+ * blocks 0 to 3 in the same macroblock.
+ * [in] pCoefBufRow pointer to the coefficient row buffer
+ * [in] pQpBuf pointer to the quantization parameter buffer
+ * [out] predQP quantization parameter of the predictor block
+ * [out] predDir indicates the prediction direction which takes one
+ * of the following values:
+ * OMX_VC_HORIZONTAL predict horizontally
+ * OMX_VC_VERTICAL predict vertically
+ *
+ * Return Value:
+ * Standard OMXResult result. See enumeration for possible result codes.
+ *
+ */
+
+OMXResult armVCM4P2_SetPredDir(
+ OMX_INT blockIndex,
+ OMX_S16 *pCoefBufRow,
+ OMX_S16 *pCoefBufCol,
+ OMX_INT *predDir,
+ OMX_INT *predQP,
+ const OMX_U8 *pQpBuf
+)
+{
+ OMX_U8 blockDCLeft;
+ OMX_U8 blockDCTop;
+ OMX_U8 blockDCTopLeft;
+
+ if (blockIndex == 3)
+ {
+ blockDCTop = *(pCoefBufCol - 8);
+ }
+ else
+ {
+ blockDCTop = *pCoefBufRow;
+ }
+ blockDCLeft = *pCoefBufCol;
+ blockDCTopLeft = *(pCoefBufRow - 8);
+
+ if (armAbs(blockDCLeft - blockDCTopLeft) < armAbs(blockDCTopLeft \
+ - blockDCTop))
+ {
+ *predDir = OMX_VC_VERTICAL;
+ *predQP = pQpBuf[1];
+ }
+ else
+ {
+ *predDir = OMX_VC_HORIZONTAL;
+ *predQP = pQpBuf[0];
+ }
+ return OMX_Sts_NoErr;
+}
+
+
+/*End of File*/
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_Zigzag_Tables.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_Zigzag_Tables.c
new file mode 100644
index 0000000..a247c69
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/armVCM4P2_Zigzag_Tables.c
@@ -0,0 +1,58 @@
+ /**
+ *
+ * File Name: armVCM4P2_Zigzag_Tables.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * File: armVCM4P2_ZigZag_Tables.c
+ * Description: Contains the zigzag tables
+ *
+ */
+
+#include "omxtypes.h"
+
+const OMX_U8 armVCM4P2_aClassicalZigzagScan [64] =
+{
+ 0, 1, 8, 16, 9, 2, 3, 10,
+ 17, 24, 32, 25, 18, 11, 4, 5,
+ 12, 19, 26, 33, 40, 48, 41, 34,
+ 27, 20, 13, 6, 7, 14, 21, 28,
+ 35, 42, 49, 56, 57, 50, 43, 36,
+ 29, 22, 15, 23, 30, 37, 44, 51,
+ 58, 59, 52, 45, 38, 31, 39, 46,
+ 53, 60, 61, 54, 47, 55, 62, 63
+};
+
+const OMX_U8 armVCM4P2_aHorizontalZigzagScan [64] =
+{
+ 0, 1, 2, 3, 8, 9, 16, 17,
+ 10, 11, 4, 5, 6, 7, 15, 14,
+ 13, 12, 19, 18, 24, 25, 32, 33,
+ 26, 27, 20, 21, 22, 23, 28, 29,
+ 30, 31, 34, 35, 40, 41, 48, 49,
+ 42, 43, 36, 37, 38, 39, 44, 45,
+ 46, 47, 50, 51, 56, 57, 58, 59,
+ 52, 53, 54, 55, 60, 61, 62, 63
+};
+
+const OMX_U8 armVCM4P2_aVerticalZigzagScan [64] =
+{
+ 0, 8, 16, 24, 1, 9, 2, 10,
+ 17, 25, 32, 40, 48, 56, 57, 49,
+ 41, 33, 26, 18, 3, 11, 4, 12,
+ 19, 27, 34, 42, 50, 58, 35, 43,
+ 51, 59, 20, 28, 5, 13, 6, 14,
+ 21, 29, 36, 44, 52, 60, 37, 45,
+ 53, 61, 22, 30, 7, 15, 23, 31,
+ 38, 46, 54, 62, 39, 47, 55, 63
+};
+
+
+/* End of file */
+
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_BlockMatch_Half_16x16.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_BlockMatch_Half_16x16.c
new file mode 100644
index 0000000..dcd3ce1
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_BlockMatch_Half_16x16.c
@@ -0,0 +1,111 @@
+/**
+ *
+ * File Name: omxVCM4P2_BlockMatch_Half_16x16.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for Block matching, a full search algorithm
+ * is implemented
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+
+/**
+ * Function: omxVCM4P2_BlockMatch_Half_16x16 (6.2.4.2.3)
+ *
+ * Description:
+ * Performs a 16x16 block match with half-pixel resolution. Returns the
+ * estimated motion vector and associated minimum SAD. This function
+ * estimates the half-pixel motion vector by interpolating the integer
+ * resolution motion vector referenced by the input parameter pSrcDstMV, i.e.,
+ * the initial integer MV is generated externally. The input parameters
+ * pSrcRefBuf and pSearchPointRefPos should be shifted by the winning MV of
+ * 16x16 integer search prior to calling BlockMatch_Half_16x16. The function
+ * BlockMatch_Integer_16x16 may be used for integer motion estimation.
+ *
+ * Input Arguments:
+ *
+ * pSrcRefBuf - pointer to the reference Y plane; points to the reference
+ * macroblock that corresponds to the location of the current
+ * macroblock in the current plane.
+ * refWidth - width of the reference plane
+ * pRefRect - reference plane valid region rectangle
+ * pSrcCurrBuf - pointer to the current block in the current macroblock
+ * buffer extracted from the original plane (linear array, 256
+ * entries); must be aligned on a 16-byte boundary. The number of
+ * bytes between lines (step) is 16.
+ * pSearchPointRefPos - position of the starting point for half pixel
+ * search (specified in terms of integer pixel units) in the
+ * reference plane, i.e., the reference position pointed to by the
+ * predicted motion vector.
+ * rndVal - rounding control parameter: 0 - disabled; 1 - enabled.
+ * pSrcDstMV - pointer to the initial MV estimate; typically generated
+ * during a prior 16X16 integer search; specified in terms of
+ * half-pixel units.
+ *
+ * Output Arguments:
+ *
+ * pSrcDstMV - pointer to estimated MV
+ * pDstSAD - pointer to minimum SAD
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments. Returned if one of the following
+ * conditions is true:
+ * - at least one of the following pointers is NULL: pSrcRefBuf,
+ * pRefRect, pSrcCurrBuff, pSearchPointRefPos, pSrcDstMV.
+ * - pSrcCurrBuf is not 16-byte aligned, or
+ *
+ */
+
+OMXResult omxVCM4P2_BlockMatch_Half_16x16(
+ const OMX_U8 *pSrcRefBuf,
+ OMX_INT refWidth,
+ const OMXRect *pRefRect,
+ const OMX_U8 *pSrcCurrBuf,
+ const OMXVCM4P2Coordinate *pSearchPointRefPos,
+ OMX_INT rndVal,
+ OMXVCMotionVector *pSrcDstMV,
+ OMX_INT *pDstSAD
+)
+{
+
+ /* For a blocksize of 16x16 */
+ OMX_U8 BlockSize = 16;
+
+ /* Argument error checks */
+ armRetArgErrIf(pSrcRefBuf == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pRefRect == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pSrcCurrBuf == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pSearchPointRefPos == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pSrcDstMV == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs16ByteAligned(pSrcCurrBuf), OMX_Sts_BadArgErr);
+
+ return (armVCM4P2_BlockMatch_Half(
+ pSrcRefBuf,
+ refWidth,
+ pRefRect,
+ pSrcCurrBuf,
+ pSearchPointRefPos,
+ rndVal,
+ pSrcDstMV,
+ pDstSAD,
+ BlockSize));
+
+
+}
+
+/* End of file */
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_BlockMatch_Half_8x8.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_BlockMatch_Half_8x8.c
new file mode 100644
index 0000000..6996e6d
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_BlockMatch_Half_8x8.c
@@ -0,0 +1,109 @@
+/**
+ *
+ * File Name: omxVCM4P2_BlockMatch_Half_8x8.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for Block matching, a full search algorithm
+ * is implemented
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+
+
+/**
+ * Function: omxVCM4P2_BlockMatch_Half_8x8 (6.2.4.2.4)
+ *
+ * Description:
+ * Performs an 8x8 block match with half-pixel resolution. Returns the
+ * estimated motion vector and associated minimum SAD. This function
+ * estimates the half-pixel motion vector by interpolating the integer
+ * resolution motion vector referenced by the input parameter pSrcDstMV, i.e.,
+ * the initial integer MV is generated externally. The input parameters
+ * pSrcRefBuf and pSearchPointRefPos should be shifted by the winning MV of
+ * 8x8 integer search prior to calling BlockMatch_Half_8x8. The function
+ * BlockMatch_Integer_8x8 may be used for integer motion estimation.
+ *
+ * Input Arguments:
+ *
+ * pSrcRefBuf - pointer to the reference Y plane; points to the reference
+ * block that corresponds to the location of the current 8x8 block
+ * in the current plane.
+ * refWidth - width of the reference plane
+ * pRefRect - reference plane valid region rectangle
+ * pSrcCurrBuf - pointer to the current block in the current macroblock
+ * buffer extracted from the original plane (linear array, 128
+ * entries); must be aligned on a 8-byte boundary. The number of
+ * bytes between lines (step) is 16.
+ * pSearchPointRefPos - position of the starting point for half pixel
+ * search (specified in terms of integer pixel units) in the
+ * reference plane.
+ * rndVal - rounding control parameter: 0 - disabled; 1 - enabled.
+ * pSrcDstMV - pointer to the initial MV estimate; typically generated
+ * during a prior 8x8 integer search, specified in terms of
+ * half-pixel units.
+ *
+ * Output Arguments:
+ *
+ * pSrcDstMV - pointer to estimated MV
+ * pDstSAD - pointer to minimum SAD
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments. Returned if one of the following
+ * conditions is true:
+ * - at least one of the following pointers is NULL:
+ * pSrcRefBuf, pRefRect, pSrcCurrBuff, pSearchPointRefPos, pSrcDstMV
+ * - pSrcCurrBuf is not 8-byte aligned
+ *
+ */
+
+OMXResult omxVCM4P2_BlockMatch_Half_8x8(
+ const OMX_U8 *pSrcRefBuf,
+ OMX_INT refWidth,
+ const OMXRect *pRefRect,
+ const OMX_U8 *pSrcCurrBuf,
+ const OMXVCM4P2Coordinate *pSearchPointRefPos,
+ OMX_INT rndVal,
+ OMXVCMotionVector *pSrcDstMV,
+ OMX_INT *pDstSAD
+)
+{
+ /* For a blocksize of 8x8 */
+ OMX_U8 BlockSize = 8;
+
+ /* Argument error checks */
+ armRetArgErrIf(pSrcRefBuf == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pRefRect == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pSrcCurrBuf == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pSearchPointRefPos == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pSrcDstMV == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs8ByteAligned(pSrcCurrBuf), OMX_Sts_BadArgErr);
+
+ return (armVCM4P2_BlockMatch_Half(
+ pSrcRefBuf,
+ refWidth,
+ pRefRect,
+ pSrcCurrBuf,
+ pSearchPointRefPos,
+ rndVal,
+ pSrcDstMV,
+ pDstSAD,
+ BlockSize));
+
+}
+
+/* End of file */
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_BlockMatch_Integer_16x16.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_BlockMatch_Integer_16x16.c
new file mode 100644
index 0000000..e714ef1
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_BlockMatch_Integer_16x16.c
@@ -0,0 +1,114 @@
+/**
+ *
+ * File Name: omxVCM4P2_BlockMatch_Integer_16x16.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for Block matching, a full search algorithm
+ * is implemented
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+
+/**
+ * Function: omxVCM4P2_BlockMatch_Integer_16x16 (6.2.4.2.1)
+ *
+ * Description:
+ * Performs a 16x16 block search; estimates motion vector and associated
+ * minimum SAD. Both the input and output motion vectors are represented using
+ * half-pixel units, and therefore a shift left or right by 1 bit may be
+ * required, respectively, to match the input or output MVs with other
+ * functions that either generate output MVs or expect input MVs represented
+ * using integer pixel units.
+ *
+ * Input Arguments:
+ *
+ * pSrcRefBuf - pointer to the reference Y plane; points to the reference
+ * MB that corresponds to the location of the current macroblock in
+ * the current plane.
+ * refWidth - width of the reference plane
+ * pRefRect - pointer to the valid reference plane rectangle; coordinates
+ * are specified relative to the image origin. Rectangle
+ * boundaries may extend beyond image boundaries if the image has
+ * been padded. For example, if padding extends 4 pixels beyond
+ * frame border, then the value for the left border could be set to
+ * -4.
+ * pSrcCurrBuf - pointer to the current block in the current macroblock
+ * buffer extracted from the original plane (linear array, 256
+ * entries); must be aligned on a 16-byte boundary. The number of
+ * bytes between lines (step) is 16.
+ * pCurrPointPos - position of the current macroblock in the current plane
+ * pSrcPreMV - pointer to predicted motion vector; NULL indicates no
+ * predicted MV
+ * pSrcPreSAD - pointer to SAD associated with the predicted MV (referenced
+ * by pSrcPreMV); may be set to NULL if unavailable.
+ * pMESpec - vendor-specific motion estimation specification structure;
+ * must have been allocated and then initialized using
+ * omxVCM4P2_MEInit prior to calling the block matching function.
+ *
+ * Output Arguments:
+ *
+ * pDstMV - pointer to estimated MV
+ * pDstSAD - pointer to minimum SAD
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments. Returned if one of the following
+ * conditions is true:
+ * - at least one of the following pointers is NULL: pSrcRefBuf,
+ * pRefRect, pSrcCurrBuff, pCurrPointPos, pDstMV, pDstSAD or
+ * pMESpec, or
+ * - pSrcCurrBuf is not 16-byte aligned
+ *
+ */
+
+OMXResult omxVCM4P2_BlockMatch_Integer_16x16(
+ const OMX_U8 *pSrcRefBuf,
+ OMX_INT refWidth,
+ const OMXRect *pRefRect,
+ const OMX_U8 *pSrcCurrBuf,
+ const OMXVCM4P2Coordinate *pCurrPointPos,
+ const OMXVCMotionVector *pSrcPreMV,
+ const OMX_INT *pSrcPreSAD,
+ void *pMESpec,
+ OMXVCMotionVector *pDstMV,
+ OMX_INT *pDstSAD
+)
+{
+
+ OMX_U8 BlockSize = 16;
+
+ /* Argument error checks */
+ armRetArgErrIf(!armIs16ByteAligned(pSrcCurrBuf), OMX_Sts_BadArgErr);
+
+ return ( armVCM4P2_BlockMatch_Integer(
+ pSrcRefBuf,
+ refWidth,
+ pRefRect,
+ pSrcCurrBuf,
+ pCurrPointPos,
+ pSrcPreMV,
+ pSrcPreSAD,
+ pMESpec,
+ pDstMV,
+ pDstSAD,
+ BlockSize)
+ );
+
+
+}
+
+/* End of file */
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_BlockMatch_Integer_8x8.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_BlockMatch_Integer_8x8.c
new file mode 100644
index 0000000..607e64c
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_BlockMatch_Integer_8x8.c
@@ -0,0 +1,110 @@
+/**
+ *
+ * File Name: omxVCM4P2_BlockMatch_Integer_8x8.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for Block matching, a full search algorithm
+ * is implemented
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+
+/**
+ * Function: omxVCM4P2_BlockMatch_Integer_8x8 (6.2.4.2.2)
+ *
+ * Description:
+ * Performs an 8x8 block search; estimates motion vector and associated
+ * minimum SAD. Both the input and output motion vectors are represented
+ * using half-pixel units, and therefore a shift left or right by 1 bit may be
+ * required, respectively, to match the input or output MVs with other
+ * functions that either generate output MVs or expect input MVs represented
+ * using integer pixel units.
+ *
+ * Input Arguments:
+ *
+ * pSrcRefBuf - pointer to the reference Y plane; points to the reference
+ * block that corresponds to the location of the current 8x8 block
+ * in the current plane.
+ * refWidth - width of the reference plane
+ * pRefRect - pointer to the valid reference plane rectangle; coordinates
+ * are specified relative to the image origin. Rectangle
+ * boundaries may extend beyond image boundaries if the image has
+ * been padded.
+ * pSrcCurrBuf - pointer to the current block in the current macroblock
+ * buffer extracted from the original plane (linear array, 128
+ * entries); must be aligned on an 8-byte boundary. The number of
+ * bytes between lines (step) is 16 bytes.
+ * pCurrPointPos - position of the current block in the current plane
+ * pSrcPreMV - pointer to predicted motion vector; NULL indicates no
+ * predicted MV
+ * pSrcPreSAD - pointer to SAD associated with the predicted MV (referenced
+ * by pSrcPreMV); may be set to NULL if unavailable.
+ * pMESpec - vendor-specific motion estimation specification structure;
+ * must have been allocated and then initialized using
+ * omxVCM4P2_MEInit prior to calling the block matching function.
+ *
+ * Output Arguments:
+ *
+ * pDstMV - pointer to estimated MV
+ * pDstSAD - pointer to minimum SAD
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments. Returned if one of the following
+ * conditions is true:
+ * - at least one of the following pointers is NULL: pSrcRefBuf,
+ * pRefRect, pSrcCurrBuff, pCurrPointPos, pDstMV, pDstSAD or
+ * pMESpec, or
+ * - pSrcCurrBuf is not 8-byte aligned
+ *
+ */
+
+OMXResult omxVCM4P2_BlockMatch_Integer_8x8(
+ const OMX_U8 *pSrcRefBuf,
+ OMX_INT refWidth,
+ const OMXRect *pRefRect,
+ const OMX_U8 *pSrcCurrBuf,
+ const OMXVCM4P2Coordinate *pCurrPointPos,
+ const OMXVCMotionVector *pSrcPreMV,
+ const OMX_INT *pSrcPreSAD,
+ void *pMESpec,
+ OMXVCMotionVector *pDstMV,
+ OMX_INT *pDstSAD
+)
+{
+ OMX_U8 BlockSize = 8;
+
+ /* Argument error checks */
+ armRetArgErrIf(!armIs8ByteAligned(pSrcCurrBuf), OMX_Sts_BadArgErr);
+
+ return ( armVCM4P2_BlockMatch_Integer(
+ pSrcRefBuf,
+ refWidth,
+ pRefRect,
+ pSrcCurrBuf,
+ pCurrPointPos,
+ pSrcPreMV,
+ pSrcPreSAD,
+ pMESpec,
+ pDstMV,
+ pDstSAD,
+ BlockSize)
+ );
+
+}
+
+/* End of file */
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DCT8x8blk.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DCT8x8blk.c
new file mode 100644
index 0000000..a077ac8
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DCT8x8blk.c
@@ -0,0 +1,87 @@
+/**
+ *
+ * File Name: omxVCM4P2_DCT8x8blk.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for 8x8 block DCT
+ *
+ */
+
+#include <math.h>
+#include "omxtypes.h"
+#include "armOMX.h"
+
+#include "armCOMM.h"
+#include "armVCM4P2_DCT_Table.h"
+
+/**
+ * Function: omxVCM4P2_DCT8x8blk (6.2.4.4.1)
+ *
+ * Description:
+ * Computes a 2D forward DCT for a single 8x8 block, as defined in
+ * [ISO14496-2].
+ *
+ * Input Arguments:
+ *
+ * pSrc - pointer to the start of the linearly arranged input buffer; must
+ * be aligned on a 16-byte boundary. Input values (pixel
+ * intensities) are valid in the range [-255,255].
+ *
+ * Output Arguments:
+ *
+ * pDst - pointer to the start of the linearly arranged output buffer; must
+ * be aligned on a 16-byte boundary.
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments, returned if:
+ * - pSrc or pDst is NULL.
+ * - pSrc or pDst is not 16-byte aligned.
+ *
+ */
+
+OMXResult omxVCM4P2_DCT8x8blk (const OMX_S16 *pSrc, OMX_S16 *pDst)
+{
+ OMX_INT x, y, u, v;
+
+ /* Argument error checks */
+ armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs16ByteAligned(pSrc), OMX_Sts_BadArgErr);
+ armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs16ByteAligned(pDst), OMX_Sts_BadArgErr);
+
+
+ for (u = 0; u < 8; u++)
+ {
+ for (v = 0; v < 8; v++)
+ {
+ OMX_F64 sum = 0.0;
+ for (x = 0; x < 8; x++)
+ {
+ for (y = 0; y < 8; y++)
+ {
+ sum += pSrc[(x * 8) + y] *
+ armVCM4P2_preCalcDCTCos[x][u] *
+ armVCM4P2_preCalcDCTCos[y][v];
+ }
+ }
+ pDst[(u * 8) + v]= armRoundFloatToS16 (sum);
+ }
+ }
+
+ return OMX_Sts_NoErr;
+}
+
+
+
+/* End of file */
+
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeBlockCoef_Inter.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeBlockCoef_Inter.c
new file mode 100644
index 0000000..51f7bab
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeBlockCoef_Inter.c
@@ -0,0 +1,115 @@
+/**
+ *
+ * File Name: omxVCM4P2_DecodeBlockCoef_Inter.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for inter reconstruction
+ *
+ */
+
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armCOMM.h"
+
+
+/**
+ * Function: omxVCM4P2_DecodeBlockCoef_Inter (6.2.5.4.2)
+ *
+ * Description:
+ * Decodes the INTER block coefficients. This function performs inverse
+ * quantization, inverse zigzag positioning, and IDCT (with appropriate
+ * clipping on each step) on the coefficients. The results (residuals) are
+ * placed in a contiguous array of 64 elements. For INTER block, the output
+ * buffer holds the residuals for further reconstruction.
+ *
+ * Input Arguments:
+ *
+ * ppBitStream - pointer to the pointer to the current byte in the bit
+ * stream buffer. There is no boundary check for the bit stream
+ * buffer.
+ * pBitOffset - pointer to the bit position in the byte pointed to by
+ * *ppBitStream. *pBitOffset is valid within [0-7]
+ * QP - quantization parameter
+ * shortVideoHeader - binary flag indicating presence of
+ * short_video_header; shortVideoHeader==1 selects linear intra DC
+ * mode, and shortVideoHeader==0 selects non linear intra DC mode.
+ *
+ * Output Arguments:
+ *
+ * ppBitStream - *ppBitStream is updated after the block is decoded, so
+ * that it points to the current byte in the bit stream buffer
+ * pBitOffset - *pBitOffset is updated so that it points to the current bit
+ * position in the byte pointed by *ppBitStream
+ * pDst - pointer to the decoded residual buffer (a contiguous array of 64
+ * elements of OMX_S16 data type); must be aligned on a 16-byte
+ * boundary.
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments, if:
+ * - At least one of the following pointers is Null:
+ * ppBitStream, *ppBitStream, pBitOffset , pDst
+ * - *pBitOffset exceeds [0,7]
+ * - QP <= 0.
+ * - pDst is not 16-byte aligned
+ * OMX_Sts_Err - status error. Refer to OMX_Sts_Err of DecodeVLCZigzag_Inter .
+ *
+ */
+OMXResult omxVCM4P2_DecodeBlockCoef_Inter(
+ const OMX_U8 ** ppBitStream,
+ OMX_INT * pBitOffset,
+ OMX_S16 * pDst,
+ OMX_INT QP,
+ OMX_INT shortVideoHeader
+)
+{
+ /* 64 elements are needed but to align it to 16 bytes need
+ 15 more elements of padding */
+ OMX_S16 tempBuf[79];
+ OMX_S16 *pTempBuf1;
+ OMXResult errorCode;
+ /* Aligning the local buffers */
+ pTempBuf1 = armAlignTo16Bytes(tempBuf);
+
+ /* Argument error checks */
+ armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs16ByteAligned(pDst), OMX_Sts_BadArgErr);
+ armRetArgErrIf(((QP <= 0) || (QP >= 32)), OMX_Sts_BadArgErr);
+ armRetArgErrIf(((*pBitOffset < 0) || (*pBitOffset > 7)), OMX_Sts_BadArgErr);
+
+
+ /* VLD and zigzag */
+ errorCode = omxVCM4P2_DecodeVLCZigzag_Inter(ppBitStream, pBitOffset,
+ pTempBuf1,shortVideoHeader);
+ armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
+
+ /* Dequantization */
+ errorCode = omxVCM4P2_QuantInvInter_I(
+ pTempBuf1,
+ QP);
+ armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
+
+ /* Inverse transform */
+ errorCode = omxVCM4P2_IDCT8x8blk(pTempBuf1, pDst);
+ armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
+
+ return OMX_Sts_NoErr;
+}
+
+/* End of file */
+
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeBlockCoef_Intra.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeBlockCoef_Intra.c
new file mode 100644
index 0000000..a0b2376
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeBlockCoef_Intra.c
@@ -0,0 +1,225 @@
+/**
+ *
+ * File Name: omxVCM4P2_DecodeBlockCoef_Intra.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for intra reconstruction
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armCOMM.h"
+#include "armVC.h"
+
+/**
+ * Function: omxVCM4P2_DecodeBlockCoef_Intra (6.2.5.4.1)
+ *
+ * Description:
+ * Decodes the INTRA block coefficients. Inverse quantization, inversely
+ * zigzag positioning, and IDCT, with appropriate clipping on each step, are
+ * performed on the coefficients. The results are then placed in the output
+ * frame/plane on a pixel basis. Note: This function will be used only when
+ * at least one non-zero AC coefficient of current block exists in the bit
+ * stream. The DC only condition will be handled in another function.
+ *
+ *
+ * Input Arguments:
+ *
+ * ppBitStream - pointer to the pointer to the current byte in the bit
+ * stream buffer. There is no boundary check for the bit stream
+ * buffer.
+ * pBitOffset - pointer to the bit position in the byte pointed to by
+ * *ppBitStream. *pBitOffset is valid within [0-7].
+ * step - width of the destination plane
+ * pCoefBufRow - pointer to the coefficient row buffer; must be aligned on
+ * an 8-byte boundary.
+ * pCoefBufCol - pointer to the coefficient column buffer; must be aligned
+ * on an 8-byte boundary.
+ * curQP - quantization parameter of the macroblock which the current block
+ * belongs to
+ * pQPBuf - pointer to the quantization parameter buffer
+ * blockIndex - block index indicating the component type and position as
+ * defined in [ISO14496-2], subclause 6.1.3.8, Figure 6-5.
+ * intraDCVLC - a code determined by intra_dc_vlc_thr and QP. This allows a
+ * mechanism to switch between two VLC for coding of Intra DC
+ * coefficients as per [ISO14496-2], Table 6-21.
+ * ACPredFlag - a flag equal to ac_pred_flag (of luminance) indicating if
+ * the ac coefficients of the first row or first column are
+ * differentially coded for intra coded macroblock.
+ * shortVideoHeader - binary flag indicating presence of
+ * short_video_header; shortVideoHeader==1 selects linear intra DC
+ * mode, and shortVideoHeader==0 selects non linear intra DC mode.
+ *
+ * Output Arguments:
+ *
+ * ppBitStream - *ppBitStream is updated after the block is decoded, so
+ * that it points to the current byte in the bit stream buffer
+ * pBitOffset - *pBitOffset is updated so that it points to the current bit
+ * position in the byte pointed by *ppBitStream
+ * pDst - pointer to the block in the destination plane; must be aligned on
+ * an 8-byte boundary.
+ * pCoefBufRow - pointer to the updated coefficient row buffer.
+ * pCoefBufCol - pointer to the updated coefficient column buffer Note:
+ * The coefficient buffers must be updated in accordance with the
+ * update procedure defined in section 6.2.2.
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments, if:
+ * - At least one of the following pointers is NULL:
+ * ppBitStream, *ppBitStream, pBitOffset, pCoefBufRow, pCoefBufCol,
+ * pQPBuf, pDst.
+ * - *pBitOffset exceeds [0,7]
+ * - curQP exceeds (1, 31)
+ * - blockIndex exceeds [0,5]
+ * - step is not the multiple of 8
+ * - a pointer alignment requirement was violated.
+ * OMX_Sts_Err - status error. Refer to OMX_Sts_Err of DecodeVLCZigzag_Intra.
+ *
+ */
+
+OMXResult omxVCM4P2_DecodeBlockCoef_Intra(
+ const OMX_U8 ** ppBitStream,
+ OMX_INT *pBitOffset,
+ OMX_U8 *pDst,
+ OMX_INT step,
+ OMX_S16 *pCoefBufRow,
+ OMX_S16 *pCoefBufCol,
+ OMX_U8 curQP,
+ const OMX_U8 *pQPBuf,
+ OMX_INT blockIndex,
+ OMX_INT intraDCVLC,
+ OMX_INT ACPredFlag,
+ OMX_INT shortVideoHeader
+ )
+{
+ OMX_S16 tempBuf1[79], tempBuf2[79];
+ OMX_S16 *pTempBuf1, *pTempBuf2;
+ OMX_INT predDir, predACDir, i, j, count;
+ OMX_INT predQP;
+ OMXVCM4P2VideoComponent videoComp;
+ OMXResult errorCode;
+
+ /* Argument error checks */
+ armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pCoefBufRow == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pCoefBufCol == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pQPBuf == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs8ByteAligned(pDst), OMX_Sts_BadArgErr);
+ armRetArgErrIf(((curQP <= 0) || (curQP >= 32)), OMX_Sts_BadArgErr);
+ armRetArgErrIf((*pBitOffset < 0) || (*pBitOffset >7), OMX_Sts_BadArgErr);
+ armRetArgErrIf((blockIndex < 0) || (blockIndex > 5), OMX_Sts_BadArgErr);
+ armRetArgErrIf((step % 8) != 0, OMX_Sts_BadArgErr);
+
+
+ /* Aligning the local buffers */
+ pTempBuf1 = armAlignTo16Bytes(tempBuf1);
+ pTempBuf2 = armAlignTo16Bytes(tempBuf2);
+
+ /* Setting the AC prediction direction and prediction direction */
+ armVCM4P2_SetPredDir(
+ blockIndex,
+ pCoefBufRow,
+ pCoefBufCol,
+ &predDir,
+ &predQP,
+ pQPBuf);
+
+ predACDir = predDir;
+
+ armRetArgErrIf(((predQP <= 0) || (predQP >= 32)), OMX_Sts_BadArgErr);
+
+ if (ACPredFlag == 0)
+ {
+ predACDir = OMX_VC_NONE;
+ }
+
+ /* Setting the videoComp */
+ if (blockIndex <= 3)
+ {
+ videoComp = OMX_VC_LUMINANCE;
+ }
+ else
+ {
+ videoComp = OMX_VC_CHROMINANCE;
+ }
+
+
+ /* VLD and zigzag */
+ if (intraDCVLC == 1)
+ {
+ errorCode = omxVCM4P2_DecodeVLCZigzag_IntraDCVLC(
+ ppBitStream,
+ pBitOffset,
+ pTempBuf1,
+ predACDir,
+ shortVideoHeader,
+ videoComp);
+ armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
+ }
+ else
+ {
+ errorCode = omxVCM4P2_DecodeVLCZigzag_IntraACVLC(
+ ppBitStream,
+ pBitOffset,
+ pTempBuf1,
+ predACDir,
+ shortVideoHeader);
+ armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
+ }
+
+ /* AC DC prediction */
+ errorCode = omxVCM4P2_PredictReconCoefIntra(
+ pTempBuf1,
+ pCoefBufRow,
+ pCoefBufCol,
+ curQP,
+ predQP,
+ predDir,
+ ACPredFlag,
+ videoComp);
+ armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
+
+ /* Dequantization */
+ errorCode = omxVCM4P2_QuantInvIntra_I(
+ pTempBuf1,
+ curQP,
+ videoComp,
+ shortVideoHeader);
+ armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
+
+ /* Inverse transform */
+ errorCode = omxVCM4P2_IDCT8x8blk (pTempBuf1, pTempBuf2);
+ armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
+
+ /* Placing the linear array into the destination plane and clipping
+ it to 0 to 255 */
+ for (j = 0, count = 0; j < 8; j++)
+ {
+ for(i = 0; i < 8; i++, count++)
+ {
+ pDst[i] = armClip (0, 255, pTempBuf2[count]);
+ }
+ pDst += step;
+ }
+
+ return OMX_Sts_NoErr;
+}
+
+/* End of file */
+
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodePadMV_PVOP.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodePadMV_PVOP.c
new file mode 100644
index 0000000..7e159b7
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodePadMV_PVOP.c
@@ -0,0 +1,243 @@
+/**
+ *
+ * File Name: omxVCM4P2_DecodePadMV_PVOP.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains module for decoding MV and padding the same
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armCOMM_Bitstream.h"
+#include "armCOMM.h"
+#include "armVCM4P2_Huff_Tables_VLC.h"
+
+
+
+/**
+ * Function: omxVCM4P2_DecodePadMV_PVOP (6.2.5.1.1)
+ *
+ * Description:
+ * Decodes and pads the four motion vectors associated with a non-intra P-VOP
+ * macroblock. For macroblocks of type OMX_VC_INTER4V, the output MV is
+ * padded as specified in [ISO14496-2], subclause 7.6.1.6. Otherwise, for
+ * macroblocks of types other than OMX_VC_INTER4V, the decoded MV is copied to
+ * all four output MV buffer entries.
+ *
+ * Input Arguments:
+ *
+ * ppBitStream - pointer to the pointer to the current byte in the bit
+ * stream buffer
+ * pBitOffset - pointer to the bit position in the byte pointed to by
+ * *ppBitStream. *pBitOffset is valid within [0-7].
+ * pSrcMVLeftMB, pSrcMVUpperMB, and pSrcMVUpperRightMB - pointers to the
+ * motion vector buffers of the macroblocks specially at the left,
+ * upper, and upper-right side of the current macroblock,
+ * respectively; a value of NULL indicates unavailability. Note:
+ * Any neighborhood macroblock outside the current VOP or video
+ * packet or outside the current GOB (when short_video_header is
+ * 1 ) for which gob_header_empty is 0 is treated as
+ * transparent, according to [ISO14496-2], subclause 7.6.5.
+ * fcodeForward - a code equal to vop_fcode_forward in MPEG-4 bit stream
+ * syntax
+ * MBType - the type of the current macroblock. If MBType is not equal to
+ * OMX_VC_INTER4V, the destination motion vector buffer is still
+ * filled with the same decoded vector.
+ *
+ * Output Arguments:
+ *
+ * ppBitStream - *ppBitStream is updated after the block is decoded, so
+ * that it points to the current byte in the bit stream buffer
+ * pBitOffset - *pBitOffset is updated so that it points to the current bit
+ * position in the byte pointed by *ppBitStream
+ * pDstMVCurMB - pointer to the motion vector buffer for the current
+ * macroblock; contains four decoded motion vectors
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments:
+ * - At least one of the following pointers is NULL:
+ * ppBitStream, *ppBitStream, pBitOffset, pDstMVCurMB
+ * - *pBitOffset exceeds [0,7]
+ * - fcodeForward exceeds (0,7]
+ * - MBType less than zero
+ * - motion vector buffer is not 4-byte aligned.
+ * OMX_Sts_Err - status error
+ *
+ */
+
+OMXResult omxVCM4P2_DecodePadMV_PVOP(
+ const OMX_U8 ** ppBitStream,
+ OMX_INT * pBitOffset,
+ OMXVCMotionVector * pSrcMVLeftMB,
+ OMXVCMotionVector *pSrcMVUpperMB,
+ OMXVCMotionVector * pSrcMVUpperRightMB,
+ OMXVCMotionVector * pDstMVCurMB,
+ OMX_INT fcodeForward,
+ OMXVCM4P2MacroblockType MBType
+ )
+{
+ OMXVCMotionVector diffMV;
+ OMXVCMotionVector dstMVPredME[12];
+ OMX_INT iBlk, i, count = 1;
+ OMX_S32 mvHorResidual = 1, mvVerResidual = 1, mvHorData, mvVerData;
+ OMX_S8 scaleFactor, index;
+ OMX_S16 high, low, range;
+
+
+ /* Argument error checks */
+ armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pDstMVCurMB == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(((*pBitOffset < 0) || (*pBitOffset > 7)), OMX_Sts_BadArgErr);
+ armRetArgErrIf(((fcodeForward < 1) || (fcodeForward > 7)), \
+ OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs4ByteAligned(pDstMVCurMB), OMX_Sts_BadArgErr);
+
+ if ((MBType == OMX_VC_INTRA) ||
+ (MBType == OMX_VC_INTRA_Q)
+ )
+ {
+ /* All MV's are zero */
+ for (i = 0; i < 4; i++)
+ {
+ pDstMVCurMB[i].dx = 0;
+ pDstMVCurMB[i].dy = 0;
+ }
+
+ return OMX_Sts_NoErr;
+ }
+
+ if ((MBType == OMX_VC_INTER4V) || (MBType == OMX_VC_INTER4V_Q))
+ {
+ count = 4;
+ }
+ else if ((MBType == OMX_VC_INTER) || (MBType == OMX_VC_INTER_Q))
+ {
+ count = 1;
+ }
+
+ /* Calculating the scale factor */
+ scaleFactor = 1 << (fcodeForward -1);
+ high = ( 32 * scaleFactor) - 1;
+ low = ( (-32) * scaleFactor);
+ range = ( 64 * scaleFactor);
+
+ /* Huffman decoding and MV reconstruction */
+ for (iBlk = 0; iBlk < count; iBlk++)
+ {
+
+ /* Huffman decoding to get Horizontal data and residual */
+ index = armUnPackVLC32(ppBitStream, pBitOffset,
+ armVCM4P2_aVlcMVD);
+ armRetDataErrIf(index == -1, OMX_Sts_Err);
+
+ mvHorData = index - 32;
+
+ if ((fcodeForward > 1) && (mvHorData != 0))
+ {
+ mvHorResidual = (OMX_S32) armGetBits(ppBitStream,
+ pBitOffset, (fcodeForward -1));
+ }
+
+ /* Huffman decoding to get Vertical data and residual */
+ index = armUnPackVLC32(ppBitStream, pBitOffset, armVCM4P2_aVlcMVD);
+ armRetDataErrIf(index == -1, OMX_Sts_Err);
+
+ mvVerData = index - 32;
+
+ if ((fcodeForward > 1) && (mvVerData != 0))
+ {
+ mvVerResidual = (OMX_S32) armGetBits(ppBitStream,
+ pBitOffset, (fcodeForward -1));
+ }
+
+ /* Calculating the differtial MV */
+ if ( (scaleFactor == 1) || (mvHorData == 0) )
+ {
+ diffMV.dx = mvHorData;
+ }
+ else
+ {
+ diffMV.dx = ((armAbs(mvHorData) - 1) * fcodeForward)
+ + mvHorResidual + 1;
+ if (mvHorData < 0)
+ {
+ diffMV.dx = -diffMV.dx;
+ }
+ }
+
+ if ( (scaleFactor == 1) || (mvVerData == 0) )
+ {
+ diffMV.dy = mvVerData;
+ }
+ else
+ {
+ diffMV.dy = ((armAbs(mvVerData) - 1) * fcodeForward)
+ + mvVerResidual + 1;
+ if (mvVerData < 0)
+ {
+ diffMV.dy = -diffMV.dy;
+ }
+ }
+
+ /* Find the predicted vector */
+ omxVCM4P2_FindMVpred (
+ pDstMVCurMB,
+ pSrcMVLeftMB,
+ pSrcMVUpperMB,
+ pSrcMVUpperRightMB,
+ &pDstMVCurMB[iBlk],
+ dstMVPredME,
+ iBlk);
+
+ /* Adding the difference to the predicted MV to reconstruct MV */
+ pDstMVCurMB[iBlk].dx += diffMV.dx;
+ pDstMVCurMB[iBlk].dy += diffMV.dy;
+
+ /* Checking the range and keeping it within the limits */
+ if ( pDstMVCurMB[iBlk].dx < low )
+ {
+ pDstMVCurMB[iBlk].dx += range;
+ }
+ if (pDstMVCurMB[iBlk].dx > high)
+ {
+ pDstMVCurMB[iBlk].dx -= range;
+ }
+
+ if ( pDstMVCurMB[iBlk].dy < low )
+ {
+ pDstMVCurMB[iBlk].dy += range;
+ }
+ if (pDstMVCurMB[iBlk].dy > high)
+ {
+ pDstMVCurMB[iBlk].dy -= range;
+ }
+ }
+
+ if ((MBType == OMX_VC_INTER) || (MBType == OMX_VC_INTER_Q))
+ {
+ pDstMVCurMB[1] = pDstMVCurMB[0];
+ pDstMVCurMB[2] = pDstMVCurMB[0];
+ pDstMVCurMB[3] = pDstMVCurMB[0];
+ }
+
+ return OMX_Sts_NoErr;
+}
+
+
+/* End of file */
+
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeVLCZigzag_Inter.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeVLCZigzag_Inter.c
new file mode 100644
index 0000000..88a8d04
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeVLCZigzag_Inter.c
@@ -0,0 +1,120 @@
+/**
+ *
+ * File Name: omxVCM4P2_DecodeVLCZigzag_Inter.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for zigzag scanning and VLC decoding
+ * for inter block.
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+#include "armCOMM_Bitstream.h"
+#include "armCOMM.h"
+#include "armVCM4P2_Huff_Tables_VLC.h"
+#include "armVCM4P2_ZigZag_Tables.h"
+
+
+
+/**
+ * Function: omxVCM4P2_DecodeVLCZigzag_Inter (6.2.5.2.3)
+ *
+ * Description:
+ * Performs VLC decoding and inverse zigzag scan for one inter-coded block.
+ *
+ * Input Arguments:
+ *
+ * ppBitStream - double pointer to the current byte in the stream buffer
+ * pBitOffset - pointer to the next available bit in the current stream
+ * byte referenced by *ppBitStream. The parameter *pBitOffset is
+ * valid within the range [0-7].
+ * shortVideoHeader - binary flag indicating presence of
+ * short_video_header; escape modes 0-3 are used if
+ * shortVideoHeader==0, and escape mode 4 is used when
+ * shortVideoHeader==1.
+ *
+ * Output Arguments:
+ *
+ * ppBitStream - *ppBitStream is updated after the block is decoded such
+ * that it points to the current byte in the stream buffer
+ * pBitOffset - *pBitOffset is updated after decoding such that it points
+ * to the next available bit in the stream byte referenced by
+ * *ppBitStream
+ * pDst - pointer to the coefficient buffer of current block; must be
+ * 4-byte aligned.
+ *
+ * Return Value:
+ *
+ * OMX_Sts_BadArgErr - bad arguments:
+ * - At least one of the following pointers is NULL:
+ * ppBitStream, *ppBitStream, pBitOffset, pDst
+ * - pDst is not 4-byte aligned
+ * - *pBitOffset exceeds [0,7]
+ * OMX_Sts_Err - status error, if:
+ * - At least one mark bit is equal to zero
+ * - Encountered an illegal stream code that cannot be found in the VLC table
+ * - Encountered an illegal code in the VLC FLC table
+ * - The number of coefficients is greater than 64
+ *
+ */
+
+OMXResult omxVCM4P2_DecodeVLCZigzag_Inter(
+ const OMX_U8 ** ppBitStream,
+ OMX_INT * pBitOffset,
+ OMX_S16 * pDst,
+ OMX_INT shortVideoHeader
+)
+{
+ OMX_U8 last,start = 0;
+ const OMX_U8 *pZigzagTable = armVCM4P2_aClassicalZigzagScan;
+ OMXResult errorCode;
+
+ /* Argument error checks */
+ armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs4ByteAligned(pDst), OMX_Sts_BadArgErr);
+
+ errorCode = armVCM4P2_GetVLCBits (
+ ppBitStream,
+ pBitOffset,
+ pDst,
+ shortVideoHeader,
+ start,
+ &last,
+ 11,
+ 42,
+ 2,
+ 5,
+ armVCM4P2_InterL0RunIdx,
+ armVCM4P2_InterVlcL0,
+ armVCM4P2_InterL1RunIdx,
+ armVCM4P2_InterVlcL1,
+ armVCM4P2_InterL0LMAX,
+ armVCM4P2_InterL1LMAX,
+ armVCM4P2_InterL0RMAX,
+ armVCM4P2_InterL1RMAX,
+ pZigzagTable );
+ armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
+
+ if (last == 0)
+ {
+ return OMX_Sts_Err;
+ }
+ return OMX_Sts_NoErr;
+}
+
+/* End of file */
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeVLCZigzag_IntraACVLC.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeVLCZigzag_IntraACVLC.c
new file mode 100644
index 0000000..96593d1
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeVLCZigzag_IntraACVLC.c
@@ -0,0 +1,103 @@
+/**
+ *
+ * File Name: omxVCM4P2_DecodeVLCZigzag_IntraACVLC.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for zigzag scanning and VLC decoding
+ * for intra block.
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+
+
+
+/**
+ * Function: omxVCM4P2_DecodeVLCZigzag_IntraACVLC (6.2.5.2.2)
+ *
+ * Description:
+ * Performs VLC decoding and inverse zigzag scan of AC and DC coefficients
+ * for one intra block. Two versions of the function (DCVLC and ACVLC) are
+ * provided in order to support the two different methods of processing DC
+ * coefficients, as described in [ISO14496-2], subclause 7.4.1.4, Intra DC
+ * Coefficient Decoding for the Case of Switched VLC Encoding.
+ *
+ * Input Arguments:
+ *
+ * ppBitStream - pointer to the pointer to the current byte in the
+ * bitstream buffer
+ * pBitOffset - pointer to the bit position in the current byte referenced
+ * by *ppBitStream. The parameter *pBitOffset is valid in the
+ * range [0-7]. Bit Position in one byte: |Most Least| *pBitOffset
+ * |0 1 2 3 4 5 6 7|
+ * predDir - AC prediction direction; used to select the zigzag scan
+ * pattern; takes one of the following values: OMX_VC_NONE - AC
+ * prediction not used; performs classical zigzag scan.
+ * OMX_VC_HORIZONTAL - Horizontal prediction; performs
+ * alternate-vertical zigzag scan; OMX_VC_VERTICAL - Vertical
+ * prediction; performs alternate-horizontal zigzag scan.
+ * shortVideoHeader - binary flag indicating presence of
+ * short_video_header; escape modes 0-3 are used if
+ * shortVideoHeader==0, and escape mode 4 is used when
+ * shortVideoHeader==1.
+ * videoComp - video component type (luminance or chrominance) of the
+ * current block
+ *
+ * Output Arguments:
+ *
+ * ppBitStream - *ppBitStream is updated after the block is decoded such
+ * that it points to the current byte in the bit stream buffer
+ * pBitOffset - *pBitOffset is updated such that it points to the current
+ * bit position in the byte pointed by *ppBitStream
+ * pDst - pointer to the coefficient buffer of current block; must be
+ * 4-byte aligned.
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments At least one of the following
+ * pointers is NULL: ppBitStream, *ppBitStream, pBitOffset, pDst,
+ * or At least one of the following conditions is true:
+ * *pBitOffset exceeds [0,7], preDir exceeds [0,2], or pDst is
+ * not 4-byte aligned
+ * OMX_Sts_Err In DecodeVLCZigzag_IntraDCVLC, dc_size > 12 At least one of
+ * mark bits equals zero Illegal stream encountered; code cannot
+ * be located in VLC table Forbidden code encountered in the VLC
+ * FLC table The number of coefficients is greater than 64
+ *
+ */
+
+
+OMXResult omxVCM4P2_DecodeVLCZigzag_IntraACVLC(
+ const OMX_U8 ** ppBitStream,
+ OMX_INT * pBitOffset,
+ OMX_S16 * pDst,
+ OMX_U8 predDir,
+ OMX_INT shortVideoHeader
+)
+{
+ OMX_U8 start = 0;
+
+ return armVCM4P2_DecodeVLCZigzag_Intra(
+ ppBitStream,
+ pBitOffset,
+ pDst,
+ predDir,
+ shortVideoHeader,
+ start);
+}
+
+/* End of file */
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeVLCZigzag_IntraDCVLC.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeVLCZigzag_IntraDCVLC.c
new file mode 100644
index 0000000..95e00d7
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_DecodeVLCZigzag_IntraDCVLC.c
@@ -0,0 +1,170 @@
+/**
+ *
+ * File Name: omxVCM4P2_DecodeVLCZigzag_IntraDCVLC.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for zigzag scanning and VLC decoding
+ * for intra block.
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+#include "armCOMM_Bitstream.h"
+#include "armCOMM.h"
+#include "armVCM4P2_Huff_Tables_VLC.h"
+#include "armVCM4P2_ZigZag_Tables.h"
+
+
+
+
+/**
+ * Function: omxVCM4P2_DecodeVLCZigzag_IntraDCVLC (6.2.5.2.2)
+ *
+ * Description:
+ * Performs VLC decoding and inverse zigzag scan of AC and DC coefficients
+ * for one intra block. Two versions of the function (DCVLC and ACVLC) are
+ * provided in order to support the two different methods of processing DC
+ * coefficients, as described in [ISO14496-2], subclause 7.4.1.4, Intra DC
+ * Coefficient Decoding for the Case of Switched VLC Encoding.
+ *
+ * Input Arguments:
+ *
+ * ppBitStream - pointer to the pointer to the current byte in the
+ * bitstream buffer
+ * pBitOffset - pointer to the bit position in the current byte referenced
+ * by *ppBitStream. The parameter *pBitOffset is valid in the
+ * range [0-7].
+ * Bit Position in one byte: |Most Least|
+ * *pBitOffset |0 1 2 3 4 5 6 7|
+ * predDir - AC prediction direction; used to select the zigzag scan
+ * pattern; takes one of the following values:
+ * - OMX_VC_NONE - AC prediction not used;
+ * performs classical zigzag scan.
+ * - OMX_VC_HORIZONTAL - Horizontal prediction;
+ * performs alternate-vertical zigzag scan;
+ * - OMX_VC_VERTICAL - Vertical prediction;
+ * performs alternate-horizontal zigzag scan.
+ * shortVideoHeader - binary flag indicating presence of
+ * short_video_header; escape modes 0-3 are used if
+ * shortVideoHeader==0, and escape mode 4 is used when
+ * shortVideoHeader==1.
+ * videoComp - video component type (luminance or chrominance) of the
+ * current block
+ *
+ * Output Arguments:
+ *
+ * ppBitStream - *ppBitStream is updated after the block is decoded such
+ * that it points to the current byte in the bit stream buffer
+ * pBitOffset - *pBitOffset is updated such that it points to the current
+ * bit position in the byte pointed by *ppBitStream
+ * pDst - pointer to the coefficient buffer of current block; must be
+ * 4-byte aligned.
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments, if:
+ * - At least one of the following pointers is NULL:
+ * ppBitStream, *ppBitStream, pBitOffset, pDst
+ * - *pBitOffset exceeds [0,7]
+ * - preDir exceeds [0,2]
+ * - pDst is not 4-byte aligned
+ * OMX_Sts_Err - if:
+ * - In DecodeVLCZigzag_IntraDCVLC, dc_size > 12
+ * - At least one of mark bits equals zero
+ * - Illegal stream encountered; code cannot be located in VLC table
+ * - Forbidden code encountered in the VLC FLC table.
+ * - The number of coefficients is greater than 64
+ *
+ */
+
+OMXResult omxVCM4P2_DecodeVLCZigzag_IntraDCVLC(
+ const OMX_U8 ** ppBitStream,
+ OMX_INT * pBitOffset,
+ OMX_S16 * pDst,
+ OMX_U8 predDir,
+ OMX_INT shortVideoHeader,
+ OMXVCM4P2VideoComponent videoComp
+)
+{
+ /* Dummy initilaization to remove compilation error */
+ OMX_S8 DCValueSize = 0;
+ OMX_U16 powOfSize, fetchDCbits;
+ OMX_U8 start = 1;
+
+ /* Argument error checks */
+ armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs4ByteAligned(pDst), OMX_Sts_BadArgErr);
+ armRetArgErrIf((*pBitOffset < 0) || (*pBitOffset > 7), OMX_Sts_BadArgErr);
+ armRetArgErrIf((predDir > 2), OMX_Sts_BadArgErr);
+
+ /* Insert the code into the bitstream */
+ if (videoComp == OMX_VC_LUMINANCE)
+ {
+ DCValueSize = armUnPackVLC32(ppBitStream,
+ pBitOffset, armVCM4P2_aIntraDCLumaIndex);
+ }
+ else if (videoComp == OMX_VC_CHROMINANCE)
+ {
+ DCValueSize = armUnPackVLC32(ppBitStream,
+ pBitOffset, armVCM4P2_aIntraDCChromaIndex);
+ }
+ armRetDataErrIf(DCValueSize == -1, OMX_Sts_Err);
+ armRetDataErrIf(DCValueSize > 12, OMX_Sts_Err);
+
+
+ if (DCValueSize == 0)
+ {
+ pDst[0] = 0;
+ }
+ else
+ {
+ fetchDCbits = (OMX_U16) armGetBits(ppBitStream, pBitOffset, \
+ DCValueSize);
+
+ if ( (fetchDCbits >> (DCValueSize - 1)) == 0)
+ {
+ /* calulate pow */
+ powOfSize = (1 << DCValueSize);
+
+ pDst[0] = (OMX_S16) (fetchDCbits ^ (powOfSize - 1));
+ pDst[0] = -pDst[0];
+ }
+ else
+ {
+ pDst[0] = fetchDCbits;
+ }
+
+ if (DCValueSize > 8)
+ {
+ /* reading and checking the marker bit*/
+ armRetDataErrIf (armGetBits(ppBitStream, pBitOffset, 1) == 0, \
+ OMX_Sts_Err);
+ }
+ }
+
+ return armVCM4P2_DecodeVLCZigzag_Intra(
+ ppBitStream,
+ pBitOffset,
+ pDst,
+ predDir,
+ shortVideoHeader,
+ start);
+}
+
+/* End of file */
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_EncodeMV.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_EncodeMV.c
new file mode 100644
index 0000000..def2b6d
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_EncodeMV.c
@@ -0,0 +1,212 @@
+/**
+ *
+ * File Name: omxVCM4P2_EncodeMV.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains module for predicting MV of MB
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armCOMM.h"
+#include "armCOMM_Bitstream.h"
+#include "armVCM4P2_Huff_Tables_VLC.h"
+
+
+
+/**
+ * Function: omxVCM4P2_EncodeMV (6.2.4.5.4)
+ *
+ * Description:
+ * Predicts a motion vector for the current macroblock, encodes the
+ * difference, and writes the output to the stream buffer. The input MVs
+ * pMVCurMB, pSrcMVLeftMB, pSrcMVUpperMB, and pSrcMVUpperRightMB should lie
+ * within the ranges associated with the input parameter fcodeForward, as
+ * described in [ISO14496-2], subclause 7.6.3. This function provides a
+ * superset of the functionality associated with the function
+ * omxVCM4P2_FindMVpred.
+ *
+ * Input Arguments:
+ *
+ * ppBitStream - double pointer to the current byte in the bitstream buffer
+ * pBitOffset - index of the first free (next available) bit in the stream
+ * buffer referenced by *ppBitStream, valid in the range 0 to 7.
+ * pMVCurMB - pointer to the current macroblock motion vector; a value of
+ * NULL indicates unavailability.
+ * pSrcMVLeftMB - pointer to the source left macroblock motion vector; a
+ * value of NULLindicates unavailability.
+ * pSrcMVUpperMB - pointer to source upper macroblock motion vector; a
+ * value of NULL indicates unavailability.
+ * pSrcMVUpperRightMB - pointer to source upper right MB motion vector; a
+ * value of NULL indicates unavailability.
+ * fcodeForward - an integer with values from 1 to 7; used in encoding
+ * motion vectors related to search range, as described in
+ * [ISO14496-2], subclause 7.6.3.
+ * MBType - macro block type, valid in the range 0 to 5
+ *
+ * Output Arguments:
+ *
+ * ppBitStream - updated pointer to the current byte in the bit stream
+ * buffer
+ * pBitOffset - updated index of the next available bit position in stream
+ * buffer referenced by *ppBitStream
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments
+ * - At least one of the following pointers is NULL: ppBitStream,
+ * *ppBitStream, pBitOffset, pMVCurMB
+ * - *pBitOffset < 0, or *pBitOffset >7.
+ * - fcodeForward <= 0, or fcodeForward > 7, or MBType < 0.
+ *
+ */
+
+OMXResult omxVCM4P2_EncodeMV(
+ OMX_U8 **ppBitStream,
+ OMX_INT *pBitOffset,
+ const OMXVCMotionVector * pMVCurMB,
+ const OMXVCMotionVector * pSrcMVLeftMB,
+ const OMXVCMotionVector * pSrcMVUpperMB,
+ const OMXVCMotionVector * pSrcMVUpperRightMB,
+ OMX_INT fcodeForward,
+ OMXVCM4P2MacroblockType MBType
+)
+{
+ OMXVCMotionVector dstMVPred, diffMV;
+ OMXVCMotionVector dstMVPredME[12];
+ /* Initialized to remove compilation warning */
+ OMX_INT iBlk, i, count = 1;
+ OMX_S32 mvHorResidual, mvVerResidual, mvHorData, mvVerData;
+ OMX_U8 scaleFactor, index;
+
+ /* Argument error checks */
+ armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pMVCurMB == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(((*pBitOffset < 0) || (*pBitOffset > 7)), OMX_Sts_BadArgErr);
+ armRetArgErrIf(((fcodeForward < 1) || (fcodeForward > 7)), \
+ OMX_Sts_BadArgErr);
+
+ if ((MBType == OMX_VC_INTRA) ||
+ (MBType == OMX_VC_INTRA_Q)
+ )
+ {
+ /* No candidate vectors hence make them zero */
+ for (i = 0; i < 12; i++)
+ {
+ dstMVPredME[i].dx = 0;
+ dstMVPredME[i].dy = 0;
+ }
+
+ return OMX_Sts_NoErr;
+ }
+
+ if ((MBType == OMX_VC_INTER4V) || (MBType == OMX_VC_INTER4V_Q))
+ {
+ count = 4;
+ }
+ else if ((MBType == OMX_VC_INTER) || (MBType == OMX_VC_INTER_Q))
+ {
+ count = 1;
+ }
+
+ /* Calculating the scale factor */
+ scaleFactor = 1 << (fcodeForward -1);
+
+ for (iBlk = 0; iBlk < count; iBlk++)
+ {
+
+ /* Find the predicted vector */
+ omxVCM4P2_FindMVpred (
+ pMVCurMB,
+ pSrcMVLeftMB,
+ pSrcMVUpperMB,
+ pSrcMVUpperRightMB,
+ &dstMVPred,
+ dstMVPredME,
+ iBlk );
+
+ /* Calculating the differential motion vector (diffMV) */
+ diffMV.dx = pMVCurMB[iBlk].dx - dstMVPred.dx;
+ diffMV.dy = pMVCurMB[iBlk].dy - dstMVPred.dy;
+
+ /* Calculating the mv_data and mv_residual for Horizantal MV */
+ if (diffMV.dx == 0)
+ {
+ mvHorResidual = 0;
+ mvHorData = 0;
+ }
+ else
+ {
+ mvHorResidual = ( armAbs(diffMV.dx) - 1) % scaleFactor;
+ mvHorData = (armAbs(diffMV.dx) - mvHorResidual + (scaleFactor - 1))
+ / scaleFactor;
+ if (diffMV.dx < 0)
+ {
+ mvHorData = -mvHorData;
+ }
+ }
+
+ /* Calculating the mv_data and mv_residual for Vertical MV */
+ if (diffMV.dy == 0)
+ {
+ mvVerResidual = 0;
+ mvVerData = 0;
+ }
+ else
+ {
+ mvVerResidual = ( armAbs(diffMV.dy) - 1) % scaleFactor;
+ mvVerData = (armAbs(diffMV.dy) - mvVerResidual + (scaleFactor - 1))
+ / scaleFactor;
+ if (diffMV.dy < 0)
+ {
+ mvVerData = -mvVerData;
+ }
+ }
+
+ /* Huffman encoding */
+
+ /* The index is actually calculate as
+ index = ((float) (mvHorData/2) + 16) * 2,
+ meaning the MV data is halfed and then normalized
+ to begin with zero and then doubled to take care of indexing
+ the fractional part included */
+ index = mvHorData + 32;
+ armPackVLC32 (ppBitStream, pBitOffset, armVCM4P2_aVlcMVD[index]);
+ if ((fcodeForward > 1) && (diffMV.dx != 0))
+ {
+ armPackBits (ppBitStream, pBitOffset, mvHorResidual, (fcodeForward -1));
+ }
+
+ /* The index is actually calculate as
+ index = ((float) (mvVerData/2) + 16) * 2,
+ meaning the MV data is halfed and then normalized
+ to begin with zero and then doubled to take care of indexing
+ the fractional part included */
+ index = mvVerData + 32;
+ armPackVLC32 (ppBitStream, pBitOffset, armVCM4P2_aVlcMVD[index]);
+ if ((fcodeForward > 1) && (diffMV.dy != 0))
+ {
+ armPackBits (ppBitStream, pBitOffset, mvVerResidual, (fcodeForward -1));
+ }
+ }
+
+ return OMX_Sts_NoErr;
+}
+
+
+/* End of file */
+
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_EncodeVLCZigzag_Inter.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_EncodeVLCZigzag_Inter.c
new file mode 100644
index 0000000..b6c73ea
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_EncodeVLCZigzag_Inter.c
@@ -0,0 +1,112 @@
+/**
+ *
+ * File Name: omxVCM4P2_EncodeVLCZigzag_Inter.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for zigzag scanning and VLC encoding
+ * for inter block.
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+#include "armCOMM_Bitstream.h"
+#include "armCOMM.h"
+#include "armVCM4P2_Huff_Tables_VLC.h"
+#include "armVCM4P2_ZigZag_Tables.h"
+
+
+
+/**
+ * Function: omxVCM4P2_EncodeVLCZigzag_Inter (6.2.4.5.3)
+ *
+ * Description:
+ * Performs classical zigzag scanning and VLC encoding for one inter block.
+ *
+ * Input Arguments:
+ *
+ * ppBitStream - pointer to the pointer to the current byte in the bit
+ * stream
+ * pBitOffset - pointer to the bit position in the byte pointed by
+ * *ppBitStream. Valid within 0 to 7
+ * pQDctBlkCoef - pointer to the quantized DCT coefficient
+ * pattern - block pattern which is used to decide whether this block is
+ * encoded
+ * shortVideoHeader - binary flag indicating presence of
+ * short_video_header; escape modes 0-3 are used if
+ * shortVideoHeader==0, and escape mode 4 is used when
+ * shortVideoHeader==1.
+ *
+ * Output Arguments:
+ *
+ * ppBitStream - *ppBitStream is updated after the block is encoded so that
+ * it points to the current byte in the bit stream buffer.
+ * pBitOffset - *pBitOffset is updated so that it points to the current bit
+ * position in the byte pointed by *ppBitStream.
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - Bad arguments
+ * - At least one of the pointers: is NULL: ppBitStream, *ppBitStream,
+ * pBitOffset, pQDctBlkCoef
+ * - *pBitOffset < 0, or *pBitOffset >7.
+ *
+ */
+OMXResult omxVCM4P2_EncodeVLCZigzag_Inter(
+ OMX_U8 **ppBitStream,
+ OMX_INT * pBitOffset,
+ const OMX_S16 *pQDctBlkCoef,
+ OMX_U8 pattern,
+ OMX_INT shortVideoHeader
+)
+{
+ OMX_U8 start = 0;
+ const OMX_U8 *pZigzagTable = armVCM4P2_aClassicalZigzagScan;
+
+ /* Argument error checks */
+ armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pQDctBlkCoef == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf((*pBitOffset < 0) || (*pBitOffset >7), OMX_Sts_BadArgErr);
+
+ if (pattern)
+ {
+ armVCM4P2_PutVLCBits (
+ ppBitStream,
+ pBitOffset,
+ pQDctBlkCoef,
+ shortVideoHeader,
+ start,
+ 26,
+ 40,
+ 10,
+ 1,
+ armVCM4P2_InterL0RunIdx,
+ armVCM4P2_InterVlcL0,
+ armVCM4P2_InterL1RunIdx,
+ armVCM4P2_InterVlcL1,
+ armVCM4P2_InterL0LMAX,
+ armVCM4P2_InterL1LMAX,
+ armVCM4P2_InterL0RMAX,
+ armVCM4P2_InterL1RMAX,
+ pZigzagTable
+ );
+ } /* Pattern check ends*/
+
+ return OMX_Sts_NoErr;
+
+}
+
+/* End of file */
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_EncodeVLCZigzag_IntraACVLC.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_EncodeVLCZigzag_IntraACVLC.c
new file mode 100644
index 0000000..d047942
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_EncodeVLCZigzag_IntraACVLC.c
@@ -0,0 +1,97 @@
+/**
+ *
+ * File Name: omxVCM4P2_EncodeVLCZigzag_IntraACVLC.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for zigzag scanning and VLC encoding
+ * for intra block.
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+
+
+/**
+ * Function: omxVCM4P2_EncodeVLCZigzag_IntraACVLC (6.2.4.5.2)
+ *
+ * Description:
+ * Performs zigzag scan and VLC encoding of AC and DC coefficients for one
+ * intra block. Two versions of the function (DCVLC and ACVLC) are provided
+ * in order to support the two different methods of processing DC
+ * coefficients, as described in [ISO14496-2], subclause 7.4.1.4, Intra DC
+ * Coefficient Decoding for the Case of Switched VLC Encoding.
+ *
+ * Input Arguments:
+ *
+ * ppBitStream - double pointer to the current byte in the bitstream
+ * pBitOffset - pointer to the bit position in the byte pointed by
+ * *ppBitStream. Valid within 0 to 7.
+ * pQDctBlkCoef - pointer to the quantized DCT coefficient
+ * predDir - AC prediction direction, which is used to decide the zigzag
+ * scan pattern; takes one of the following values:
+ * - OMX_VC_NONE - AC prediction not used.
+ * Performs classical zigzag scan.
+ * - OMX_VC_HORIZONTAL - Horizontal prediction.
+ * Performs alternate-vertical zigzag scan.
+ * - OMX_VC_VERTICAL - Vertical prediction.
+ * Performs alternate-horizontal zigzag scan.
+ * pattern - block pattern which is used to decide whether this block is
+ * encoded
+ * shortVideoHeader - binary flag indicating presence of
+ * short_video_header; escape modes 0-3 are used if
+ * shortVideoHeader==0, and escape mode 4 is used when
+ * shortVideoHeader==1.
+ *
+ * Output Arguments:
+ *
+ * ppBitStream - *ppBitStream is updated after the block is encoded, so
+ * that it points to the current byte in the bit stream buffer.
+ * pBitOffset - *pBitOffset is updated so that it points to the current bit
+ * position in the byte pointed by *ppBitStream.
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - Bad arguments:
+ * - At least one of the following pointers is NULL: ppBitStream,
+ * *ppBitStream, pBitOffset, pQDctBlkCoef.
+ * - *pBitOffset < 0, or *pBitOffset >7.
+ * - PredDir is not one of: OMX_VC_NONE, OMX_VC_HORIZONTAL, or
+ * OMX_VC_VERTICAL.
+ * - VideoComp is not one component of enum OMXVCM4P2VideoComponent.
+ *
+ */
+
+OMXResult omxVCM4P2_EncodeVLCZigzag_IntraACVLC(
+ OMX_U8 **ppBitStream,
+ OMX_INT *pBitOffset,
+ const OMX_S16 *pQDctBlkCoef,
+ OMX_U8 predDir,
+ OMX_U8 pattern,
+ OMX_INT shortVideoHeader
+)
+{
+ OMX_U8 start = 0;
+
+ return armVCM4P2_EncodeVLCZigzag_Intra(
+ ppBitStream,
+ pBitOffset,
+ pQDctBlkCoef,
+ predDir,
+ pattern,
+ shortVideoHeader,
+ start);
+}
+
+/* End of file */
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_EncodeVLCZigzag_IntraDCVLC.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_EncodeVLCZigzag_IntraDCVLC.c
new file mode 100644
index 0000000..c57acd2
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_EncodeVLCZigzag_IntraDCVLC.c
@@ -0,0 +1,160 @@
+/**
+ *
+ * File Name: omxVCM4P2_EncodeVLCZigzag_IntraDCVLC.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for zigzag scanning and VLC encoding
+ * for intra block.
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+#include "armCOMM_Bitstream.h"
+#include "armCOMM.h"
+#include "armVCM4P2_Huff_Tables_VLC.h"
+#include "armVCM4P2_ZigZag_Tables.h"
+
+
+
+/**
+ * Function: omxVCM4P2_EncodeVLCZigzag_IntraDCVLC (6.2.4.5.2)
+ *
+ * Description:
+ * Performs zigzag scan and VLC encoding of AC and DC coefficients for one
+ * intra block. Two versions of the function (DCVLC and ACVLC) are provided
+ * in order to support the two different methods of processing DC
+ * coefficients, as described in [ISO14496-2], subclause 7.4.1.4, "Intra DC
+ * Coefficient Decoding for the Case of Switched VLC Encoding".
+ *
+ * Input Arguments:
+ *
+ * ppBitStream - double pointer to the current byte in the bitstream
+ * pBitOffset - pointer to the bit position in the byte pointed by
+ * *ppBitStream. Valid within 0 to 7.
+ * pQDctBlkCoef - pointer to the quantized DCT coefficient
+ * predDir - AC prediction direction, which is used to decide the zigzag
+ * scan pattern; takes one of the following values:
+ * - OMX_VC_NONE - AC prediction not used.
+ * Performs classical zigzag scan.
+ * - OMX_VC_HORIZONTAL - Horizontal prediction.
+ * Performs alternate-vertical zigzag scan.
+ * - OMX_VC_VERTICAL - Vertical prediction.
+ * Performs alternate-horizontal zigzag scan.
+ * pattern - block pattern which is used to decide whether this block is
+ * encoded
+ * shortVideoHeader - binary flag indicating presence of
+ * short_video_header; escape modes 0-3 are used if
+ * shortVideoHeader==0, and escape mode 4 is used when
+ * shortVideoHeader==1.
+ * videoComp - video component type (luminance, chrominance) of the current
+ * block
+ *
+ * Output Arguments:
+ *
+ * ppBitStream - *ppBitStream is updated after the block is encoded, so
+ * that it points to the current byte in the bit stream buffer.
+ * pBitOffset - *pBitOffset is updated so that it points to the current bit
+ * position in the byte pointed by *ppBitStream.
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - Bad arguments:
+ * - At least one of the following pointers is NULL: ppBitStream,
+ * *ppBitStream, pBitOffset, pQDctBlkCoef.
+ * - *pBitOffset < 0, or *pBitOffset >7.
+ * - PredDir is not one of: OMX_VC_NONE, OMX_VC_HORIZONTAL, or
+ * OMX_VC_VERTICAL.
+ * - VideoComp is not one component of enum OMXVCM4P2VideoComponent.
+ *
+ */
+
+OMXResult omxVCM4P2_EncodeVLCZigzag_IntraDCVLC(
+ OMX_U8 **ppBitStream,
+ OMX_INT *pBitOffset,
+ const OMX_S16 *pQDctBlkCoef,
+ OMX_U8 predDir,
+ OMX_U8 pattern,
+ OMX_INT shortVideoHeader,
+ OMXVCM4P2VideoComponent videoComp
+)
+{
+ OMX_S16 dcValue, powOfSize;
+ OMX_U8 DCValueSize, start = 1;
+ OMX_U16 absDCValue;
+
+ /* Argument error checks */
+ armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pQDctBlkCoef == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf((*pBitOffset < 0) || (*pBitOffset >7), OMX_Sts_BadArgErr);
+ armRetArgErrIf((videoComp != OMX_VC_LUMINANCE) && (videoComp != OMX_VC_CHROMINANCE), OMX_Sts_BadArgErr);
+ armRetArgErrIf((predDir != OMX_VC_NONE) && (predDir != OMX_VC_HORIZONTAL) && (predDir != OMX_VC_VERTICAL) , OMX_Sts_BadArgErr);
+
+ if (pattern)
+ {
+ dcValue = pQDctBlkCoef[0];
+ absDCValue = armAbs(dcValue);
+
+ /* Find the size */
+ DCValueSize = armLogSize (absDCValue);
+ absDCValue = armAbs(dcValue);
+
+ /* Insert the code into the bitstream */
+ if (videoComp == OMX_VC_LUMINANCE)
+ {
+
+ armPackVLC32 (ppBitStream, pBitOffset,
+ armVCM4P2_aIntraDCLumaIndex[DCValueSize]);
+ }
+ else if (videoComp == OMX_VC_CHROMINANCE)
+ {
+
+ armPackVLC32 (ppBitStream, pBitOffset,
+ armVCM4P2_aIntraDCChromaIndex[DCValueSize]);
+ }
+
+ /* Additional code generation in case of negative
+ dc value the additional */
+ if (DCValueSize > 0)
+ {
+ if (dcValue < 0)
+ {
+ /* calulate 2 pow */
+ powOfSize = (1 << DCValueSize);
+
+ absDCValue = absDCValue ^ (powOfSize - 1);
+ }
+ armPackBits(ppBitStream, pBitOffset, (OMX_U32)absDCValue, \
+ DCValueSize);
+
+ if (DCValueSize > 8)
+ {
+ armPackBits(ppBitStream, pBitOffset, 1, 1);
+ }
+ }
+ }
+
+ return armVCM4P2_EncodeVLCZigzag_Intra(
+ ppBitStream,
+ pBitOffset,
+ pQDctBlkCoef,
+ predDir,
+ pattern,
+ shortVideoHeader,
+ start);
+}
+
+/* End of file */
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_FindMVpred.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_FindMVpred.c
new file mode 100644
index 0000000..a0cff48
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_FindMVpred.c
@@ -0,0 +1,188 @@
+/**
+ *
+ * File Name: omxVCM4P2_FindMVpred.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains module for predicting MV of MB
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armCOMM.h"
+
+/**
+ * Function: omxVCM4P2_FindMVpred (6.2.3.1.1)
+ *
+ * Description:
+ * Predicts a motion vector for the current block using the procedure
+ * specified in [ISO14496-2], subclause 7.6.5. The resulting predicted MV is
+ * returned in pDstMVPred. If the parameter pDstMVPredME if is not NULL then
+ * the set of three MV candidates used for prediction is also returned,
+ * otherwise pDstMVPredMEis NULL upon return.
+ *
+ * Input Arguments:
+ *
+ * pSrcMVCurMB - pointer to the MV buffer associated with the current Y
+ * macroblock; a value of NULL indicates unavailability.
+ * pSrcCandMV1 - pointer to the MV buffer containing the 4 MVs associated
+ * with the MB located to the left of the current MB; set to NULL
+ * if there is no MB to the left.
+ * pSrcCandMV2 - pointer to the MV buffer containing the 4 MVs associated
+ * with the MB located above the current MB; set to NULL if there
+ * is no MB located above the current MB.
+ * pSrcCandMV3 - pointer to the MV buffer containing the 4 MVs associated
+ * with the MB located to the right and above the current MB; set
+ * to NULL if there is no MB located to the above-right.
+ * iBlk - the index of block in the current macroblock
+ * pDstMVPredME - MV candidate return buffer; if set to NULL then
+ * prediction candidate MVs are not returned and pDstMVPredME will
+ * be NULL upon function return; if pDstMVPredME is non-NULL then it
+ * must point to a buffer containing sufficient space for three
+ * return MVs.
+ *
+ * Output Arguments:
+ *
+ * pDstMVPred - pointer to the predicted motion vector
+ * pDstMVPredME - if non-NULL upon input then pDstMVPredME points upon
+ * return to a buffer containing the three motion vector candidates
+ * used for prediction as specified in [ISO14496-2], subclause
+ * 7.6.5, otherwise if NULL upon input then pDstMVPredME is NULL
+ * upon output.
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments; returned under any of the following
+ * conditions:
+ * - the pointer pDstMVPred is NULL
+ * - the parameter iBlk does not fall into the range 0 <= iBlk<=3
+ *
+ */
+
+OMXResult omxVCM4P2_FindMVpred(
+ const OMXVCMotionVector* pSrcMVCurMB,
+ const OMXVCMotionVector* pSrcCandMV1,
+ const OMXVCMotionVector* pSrcCandMV2,
+ const OMXVCMotionVector* pSrcCandMV3,
+ OMXVCMotionVector* pDstMVPred,
+ OMXVCMotionVector* pDstMVPredME,
+ OMX_INT iBlk
+ )
+{
+ OMXVCMotionVector CandMV;
+ const OMXVCMotionVector *pCandMV1;
+ const OMXVCMotionVector *pCandMV2;
+ const OMXVCMotionVector *pCandMV3;
+
+ /* Argument error checks */
+ armRetArgErrIf(iBlk!=0 && pSrcMVCurMB == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pDstMVPred == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf((iBlk < 0) || (iBlk > 3), OMX_Sts_BadArgErr);
+
+ CandMV.dx = CandMV.dy = 0;
+ /* Based on the position of the block extract the motion vectors and
+ the tranperancy status */
+
+
+ /* Set the default value for these to be used if pSrcCandMV[1|2|3] == NULL */
+ pCandMV1 = pCandMV2 = pCandMV3 = &CandMV;
+
+
+ switch (iBlk)
+ {
+ case 0:
+ {
+ if(pSrcCandMV1 != NULL)
+ {
+ pCandMV1 = &pSrcCandMV1[1];
+ }
+ if(pSrcCandMV2 != NULL)
+ {
+ pCandMV2 = &pSrcCandMV2[2];
+ }
+ if(pSrcCandMV3 != NULL)
+ {
+ pCandMV3 = &pSrcCandMV3[2];
+ }
+ if ((pSrcCandMV1 == NULL) && (pSrcCandMV2 == NULL))
+ {
+ pCandMV1 = pCandMV2 = pCandMV3;
+ }
+ else if((pSrcCandMV1 == NULL) && (pSrcCandMV3 == NULL))
+ {
+ pCandMV1 = pCandMV3 = pCandMV2;
+ }
+ else if((pSrcCandMV2 == NULL) && (pSrcCandMV3 == NULL))
+ {
+ pCandMV2 = pCandMV3 = pCandMV1;
+ }
+ break;
+ }
+ case 1:
+ {
+ pCandMV1 = &pSrcMVCurMB[0];
+ if(pSrcCandMV2 != NULL)
+ {
+ pCandMV2 = &pSrcCandMV2[3];
+ }
+ if(pSrcCandMV3 != NULL)
+ {
+ pCandMV3 = &pSrcCandMV3[2];
+ }
+ if((pSrcCandMV2 == NULL) && (pSrcCandMV3 == NULL))
+ {
+ pCandMV2 = pCandMV3 = pCandMV1;
+ }
+ break;
+ }
+ case 2:
+ {
+ if(pSrcCandMV1 != NULL)
+ {
+ pCandMV1 = &pSrcCandMV1[3];
+ }
+ pCandMV2 = &pSrcMVCurMB[0];
+ pCandMV3 = &pSrcMVCurMB[1];
+ break;
+ }
+ case 3:
+ {
+ pCandMV1 = &pSrcMVCurMB[2];
+ pCandMV2 = &pSrcMVCurMB[0];
+ pCandMV3 = &pSrcMVCurMB[1];
+ break;
+ }
+ }
+
+ /* Find the median of the 3 candidate MV's */
+ pDstMVPred->dx = armMedianOf3 (pCandMV1->dx, pCandMV2->dx, pCandMV3->dx);
+ pDstMVPred->dy = armMedianOf3 (pCandMV1->dy, pCandMV2->dy, pCandMV3->dy);
+
+ if (pDstMVPredME != NULL)
+ {
+ /* Store the candidate MV's into the pDstMVPredME, these can be used
+ in the fast algorithm if implemented */
+ pDstMVPredME[0].dx = pCandMV1->dx;
+ pDstMVPredME[0].dy = pCandMV1->dy;
+ pDstMVPredME[1].dx = pCandMV2->dx;
+ pDstMVPredME[1].dy = pCandMV2->dy;
+ pDstMVPredME[2].dx = pCandMV3->dx;
+ pDstMVPredME[2].dy = pCandMV3->dy;
+ }
+
+ return OMX_Sts_NoErr;
+}
+
+
+/* End of file */
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_IDCT8x8blk.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_IDCT8x8blk.c
new file mode 100644
index 0000000..1886d92
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_IDCT8x8blk.c
@@ -0,0 +1,92 @@
+/**
+ *
+ * File Name: omxVCM4P2_IDCT8x8blk.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for 8x8 block IDCT
+ *
+ */
+
+
+#include <math.h>
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armCOMM.h"
+#include "armVCM4P2_DCT_Table.h"
+
+/**
+ * Function: omxVCM4P2_IDCT8x8blk (6.2.3.2.1)
+ *
+ * Description:
+ * Computes a 2D inverse DCT for a single 8x8 block, as defined in
+ * [ISO14496-2].
+ *
+ * Input Arguments:
+ *
+ * pSrc - pointer to the start of the linearly arranged IDCT input buffer;
+ * must be aligned on a 16-byte boundary. According to
+ * [ISO14496-2], the input coefficient values should lie within the
+ * range [-2048, 2047].
+ *
+ * Output Arguments:
+ *
+ * pDst - pointer to the start of the linearly arranged IDCT output buffer;
+ * must be aligned on a 16-byte boundary.
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments:
+ * - pSrc or pDst is NULL.
+ * - pSrc or pDst is not 16-byte aligned.
+ *
+ */
+OMXResult omxVCM4P2_IDCT8x8blk (const OMX_S16 *pSrc, OMX_S16 *pDst)
+{
+ OMX_INT x, y, u, v;
+
+ /* Argument error checks */
+ armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs16ByteAligned(pSrc), OMX_Sts_BadArgErr);
+ armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs16ByteAligned(pDst), OMX_Sts_BadArgErr);
+
+ for (x = 0; x < 8; x++)
+ {
+ for (y = 0; y < 8; y++)
+ {
+ OMX_F64 sum = 0.0;
+ for (u = 0; u < 8; u++)
+ {
+ for (v = 0; v < 8; v++)
+ {
+ sum += pSrc[(u * 8) + v] *
+ armVCM4P2_preCalcDCTCos[x][u] *
+ armVCM4P2_preCalcDCTCos[y][v];
+ }
+ }
+ pDst[(x * 8) + y] = (OMX_S16) floor(sum + 0.5);
+
+ /* Saturate to [-256, 255] */
+ pDst[(x * 8) + y] = armClip (
+ -256,
+ 255,
+ pDst[(x * 8) + y]);
+ }
+ }
+
+ return OMX_Sts_NoErr;
+}
+
+/* End of file */
+
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_MCReconBlock.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_MCReconBlock.c
new file mode 100644
index 0000000..7b3faee
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_MCReconBlock.c
@@ -0,0 +1,357 @@
+/**
+ *
+ * File Name: omxVCM4P2_MCReconBlock.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ * Description:
+ * MPEG4 motion compensation prediction for an 8x8 block using
+ * interpolation
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armCOMM.h"
+
+/**
+ * Function: armVCM4P2_HalfPelVer
+ *
+ * Description:
+ * Performs half pel motion compensation for an 8x8 block using vertical
+ * interpolation described in ISO/IEC 14496-2, subclause 7.6.2.
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] pSrc pointer to the block in the reference plane.
+ * [in] srcStep distance between the start of consecutive lines
+ * in the reference plane, in bytes; must be a multiple
+ * of 8.
+ * [in] rndVal rounding control parameter: 0 - disabled; 1 - enabled.
+ * [out] pDst pointer to the linaer 8x8 destination buffer;
+ *
+ */
+static OMXVoid armVCM4P2_HalfPelVer(
+ const OMX_U8 *pSrc,
+ OMX_INT srcStep,
+ OMX_U8 *pDst,
+ OMX_INT rndVal)
+{
+ const OMX_U8 *pTempSrc1;
+ const OMX_U8 *pTempSrc2;
+ OMX_INT y, x;
+
+ pTempSrc1 = pSrc;
+ pTempSrc2 = pSrc + srcStep;
+ srcStep -= 8;
+ for (y = 0; y < 8; y++)
+ {
+ for (x = 0; x < 8; x++)
+ {
+ *pDst++ = ((*pTempSrc1++ + *pTempSrc2++) + 1 - rndVal) >> 1;
+ }
+ pTempSrc1 += srcStep;
+ pTempSrc2 += srcStep;
+ }
+}
+
+/**
+ * Function: armVCM4P2_HalfPelHor
+ *
+ * Description:
+ * Performs half pel motion compensation for an 8x8 block using horizontal
+ * interpolation described in ISO/IEC 14496-2, subclause 7.6.2.
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] pSrc pointer to the block in the reference plane.
+ * [in] srcStep distance between the start of consecutive lines
+ * in the reference plane, in bytes; must be a multiple
+ * of 8.
+ * [in] rndVal rounding control parameter: 0 - disabled; 1 - enabled.
+ * [out] pDst pointer to the linaer 8x8 destination buffer;
+ *
+ */
+static OMXVoid armVCM4P2_HalfPelHor(
+ const OMX_U8 *pSrc,
+ OMX_INT srcStep,
+ OMX_U8 *pDst,
+ OMX_INT rndVal)
+{
+ const OMX_U8 *pTempSrc1;
+ const OMX_U8 *pTempSrc2;
+ OMX_INT y, x;
+
+ pTempSrc1 = pSrc;
+ pTempSrc2 = pTempSrc1 + 1;
+
+ srcStep -= 8;
+ for (y=0; y<8; y++)
+ {
+ for (x=0; x<8; x++)
+ {
+ *pDst++ = ((*pTempSrc1++ + *pTempSrc2++) + 1 - rndVal) >> 1;
+ }
+ pTempSrc1 += srcStep;
+ pTempSrc2 += srcStep;
+ }
+}
+
+
+/**
+ * Function: armVCM4P2_HalfPelVerHor
+ *
+ * Description:
+ * Performs half pel motion compensation for an 8x8 block using both
+ * horizontal and vertical interpolation described in ISO/IEC 14496-2,
+ * subclause 7.6.2.
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] pSrc pointer to the block in the reference plane.
+ * [in] srcStep distance between the start of consecutive lines
+ * in the reference plane, in bytes; must be a multiple
+ * of 8.
+ * [in] rndVal rounding control parameter: 0 - disabled; 1 - enabled.
+ * [out] pDst pointer to the linaer 8x8 destination buffer;
+ *
+ */
+static OMXVoid armVCM4P2_HalfPelVerHor(
+ const OMX_U8 *pSrc,
+ OMX_INT srcStep,
+ OMX_U8 *pDst,
+ OMX_INT rndVal)
+{
+ const OMX_U8 *pTempSrc1;
+ const OMX_U8 *pTempSrc2;
+ const OMX_U8 *pTempSrc3;
+ const OMX_U8 *pTempSrc4;
+ OMX_INT y, x;
+
+ pTempSrc1 = pSrc;
+ pTempSrc2 = pSrc + srcStep;
+ pTempSrc3 = pSrc + 1;
+ pTempSrc4 = pSrc + srcStep + 1;
+
+ srcStep -= 8;
+ for (y=0; y<8; y++)
+ {
+ for (x=0; x<8; x++)
+ {
+ *pDst++ = ((*pTempSrc1++ + *pTempSrc2++ + *pTempSrc3++ + *pTempSrc4++) +
+ 2 - rndVal) >> 2;
+ }
+ pTempSrc1 += srcStep;
+ pTempSrc2 += srcStep;
+ pTempSrc3 += srcStep;
+ pTempSrc4 += srcStep;
+ }
+}
+
+/**
+ * Function: armVCM4P2_MCReconBlock_NoRes
+ *
+ * Description:
+ * Do motion compensation and copy the result to the current block.
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] pSrc pointer to the block in the reference plane.
+ * [in] srcStep distance between the start of consecutive lines
+ * in the reference plane, in bytes; must be a multiple
+ * of 8.
+ * [in] dstStep distance between the start of consecutive lines in the
+ * destination plane, in bytes; must be a multiple of 8.
+ * [in] predictType bilinear interpolation type, as defined in section 6.2.1.2.
+ * [in] rndVal rounding control parameter: 0 - disabled; 1 - enabled.
+ * [out] pDst pointer to the destination buffer; must be 8-byte aligned.
+ * If prediction residuals are added then output intensities
+ * are clipped to the range [0,255].
+ *
+ */
+static OMXVoid armVCM4P2_MCReconBlock_NoRes(
+ const OMX_U8 *pSrc,
+ OMX_INT srcStep,
+ OMX_U8 *pDst,
+ OMX_INT dstStep)
+{
+ OMX_U8 x,y,count,index;
+
+ /* Copying the ref 8x8 blk to the curr blk */
+ for (y = 0, count = 0, index = 0; y < 8; y++,index += (srcStep -8), count += (dstStep - 8))
+ {
+ for (x = 0; x < 8; x++, count++,index++)
+ {
+ pDst[count] = pSrc[index];
+ }
+ }
+}
+
+/**
+ * Function: armVCM4P2_MCReconBlock_Res
+ *
+ * Description:
+ * Reconstructs INTER block by summing the motion compensation results
+ * and the results of the inverse transformation (prediction residuals).
+ * Output intensities are clipped to the range [0,255].
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] pSrc pointer to the block in the reference plane.
+ * [in] pSrcResidue pointer to a buffer containing the 16-bit prediction
+ * residuals. If the pointer is NULL,then no prediction
+ * is done, only motion compensation, i.e., the block is
+ * moved with interpolation.
+ * [in] dstStep distance between the start of consecutive lines in the
+ * destination plane, in bytes; must be a multiple of 8.
+ * [out] pDst pointer to the destination buffer; must be 8-byte aligned.
+ * If prediction residuals are added then output intensities
+ * are clipped to the range [0,255].
+ *
+ */
+static OMXVoid armVCM4P2_MCReconBlock_Res(
+ const OMX_U8 *pSrc,
+ const OMX_S16 *pSrcResidue,
+ OMX_U8 *pDst,
+ OMX_INT dstStep)
+{
+
+ OMX_U8 x,y;
+ OMX_INT temp;
+
+ for(y = 0; y < 8; y++)
+ {
+ for(x = 0; x < 8; x++)
+ {
+ temp = pSrc[x] + pSrcResidue[x];
+ pDst[x] = armClip(0,255,temp);
+ }
+ pDst += dstStep;
+ pSrc += 8;
+ pSrcResidue += 8;
+ }
+}
+
+/**
+ * Function: omxVCM4P2_MCReconBlock (6.2.5.5.1)
+ *
+ * Description:
+ * Performs motion compensation prediction for an 8x8 block using
+ * interpolation described in [ISO14496-2], subclause 7.6.2.
+ *
+ * Input Arguments:
+ *
+ * pSrc - pointer to the block in the reference plane.
+ * srcStep - distance between the start of consecutive lines in the
+ * reference plane, in bytes; must be a multiple of 8.
+ * dstStep - distance between the start of consecutive lines in the
+ * destination plane, in bytes; must be a multiple of 8.
+ * pSrcResidue - pointer to a buffer containing the 16-bit prediction
+ * residuals; must be 16-byte aligned. If the pointer is NULL, then
+ * no prediction is done, only motion compensation, i.e., the block
+ * is moved with interpolation.
+ * predictType - bilinear interpolation type, as defined in section
+ * 6.2.1.2.
+ * rndVal - rounding control parameter: 0 - disabled; 1 - enabled.
+ *
+ * Output Arguments:
+ *
+ * pDst - pointer to the destination buffer; must be 8-byte aligned. If
+ * prediction residuals are added then output intensities are
+ * clipped to the range [0,255].
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments; returned under any of the following
+ * conditions:
+ * - pDst is not 8-byte aligned.
+ * - pSrcResidue is not 16-byte aligned.
+ * - one or more of the following pointers is NULL: pSrc or pDst.
+ * - either srcStep or dstStep is not a multiple of 8.
+ * - invalid type specified for the parameter predictType.
+ * - the parameter rndVal is not equal either to 0 or 1.
+ *
+ */
+OMXResult omxVCM4P2_MCReconBlock(
+ const OMX_U8 *pSrc,
+ OMX_INT srcStep,
+ const OMX_S16 *pSrcResidue,
+ OMX_U8 *pDst,
+ OMX_INT dstStep,
+ OMX_INT predictType,
+ OMX_INT rndVal)
+{
+ /* Definitions and Initializations*/
+ OMX_U8 pTempDst[64];
+
+ /* Argument error checks */
+ armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs8ByteAligned(pDst), OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs16ByteAligned(pSrcResidue), OMX_Sts_BadArgErr);
+ armRetArgErrIf(((dstStep % 8) || (srcStep % 8)), OMX_Sts_BadArgErr);
+ armRetArgErrIf(((predictType != OMX_VC_INTEGER_PIXEL) &&
+ (predictType != OMX_VC_HALF_PIXEL_X) &&
+ (predictType != OMX_VC_HALF_PIXEL_Y) &&
+ (predictType != OMX_VC_HALF_PIXEL_XY)
+ ),OMX_Sts_BadArgErr);
+ armRetArgErrIf(((rndVal != 0) && (rndVal != 1)),OMX_Sts_BadArgErr);
+
+ switch(predictType)
+ {
+ case OMX_VC_INTEGER_PIXEL:
+ armVCM4P2_MCReconBlock_NoRes(pSrc,
+ srcStep,
+ &(pTempDst[0]),
+ 8);
+ break;
+ case OMX_VC_HALF_PIXEL_X:
+ armVCM4P2_HalfPelHor(pSrc,
+ srcStep,
+ &(pTempDst[0]),
+ rndVal);
+ break;
+ case OMX_VC_HALF_PIXEL_Y:
+ armVCM4P2_HalfPelVer(pSrc,
+ srcStep,
+ &(pTempDst[0]),
+ rndVal);
+ break;
+ case OMX_VC_HALF_PIXEL_XY:
+ armVCM4P2_HalfPelVerHor(pSrc,
+ srcStep,
+ &(pTempDst[0]),
+ rndVal);
+ break;
+ }
+
+ if(pSrcResidue == NULL)
+ {
+ armVCM4P2_MCReconBlock_NoRes(&(pTempDst[0]),
+ 8,
+ pDst,
+ dstStep);
+ }
+ else
+ {
+ armVCM4P2_MCReconBlock_Res(&(pTempDst[0]),
+ pSrcResidue,
+ pDst,
+ dstStep);
+ }
+
+ return OMX_Sts_NoErr;
+}
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_MEGetBufSize.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_MEGetBufSize.c
new file mode 100644
index 0000000..a8e51da
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_MEGetBufSize.c
@@ -0,0 +1,70 @@
+/**
+ *
+ * File Name: omxVCM4P2_MEGetBufSize.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Initialization modules for the vendor specific Motion Estimation structure.
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+
+/**
+ * Function: omxVCM4P2_MEGetBufSize (6.2.4.1.1)
+ *
+ * Description:
+ * Computes the size, in bytes, of the vendor-specific specification
+ * structure for the following motion estimation functions:
+ * BlockMatch_Integer_8x8, BlockMatch_Integer_16x16, and MotionEstimationMB.
+ *
+ * Input Arguments:
+ *
+ * MEmode - motion estimation mode; available modes are defined by the
+ * enumerated type OMXVCM4P2MEMode
+ * pMEParams - motion estimation parameters
+ *
+ * Output Arguments:
+ *
+ * pSize - pointer to the number of bytes required for the specification
+ * structure
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - one or more of the following is true:
+ * - an invalid value was specified for the parameter MEmode
+ * - a negative or zero value was specified for the
+ * parameter pMEParams->searchRange
+ *
+ */
+
+OMXResult omxVCM4P2_MEGetBufSize(
+ OMXVCM4P2MEMode MEMode,
+ const OMXVCM4P2MEParams *pMEParams,
+ OMX_U32 *pSize
+ )
+{
+ armRetArgErrIf(!pMEParams, OMX_Sts_BadArgErr);
+ armRetArgErrIf(!pSize, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pMEParams->searchRange <= 0, OMX_Sts_BadArgErr);
+ armRetArgErrIf((MEMode != OMX_VC_M4P10_FAST_SEARCH) &&
+ (MEMode != OMX_VC_M4P10_FULL_SEARCH), OMX_Sts_BadArgErr);
+
+ *pSize = (OMX_INT) sizeof(ARMVCM4P2_MESpec);
+
+ return OMX_Sts_NoErr;
+}
+
+/* End of file */
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_MEInit.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_MEInit.c
new file mode 100644
index 0000000..419e71a
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_MEInit.c
@@ -0,0 +1,84 @@
+/**
+ *
+ * File Name: omxVCM4P2_MEInit.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Initialization modules for the vendor specific Motion Estimation structure.
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+
+/**
+ * Function: omxVCM4P2_MEInit (6.2.4.1.2)
+ *
+ * Description:
+ * Initializes the vendor-specific specification structure required for the
+ * following motion estimation functions: BlockMatch_Integer_8x8,
+ * BlockMatch_Integer_16x16, and MotionEstimationMB. Memory for the
+ * specification structure *pMESpec must be allocated prior to calling the
+ * function, and should be aligned on a 4-byte boundary. Following
+ * initialization by this function, the vendor-specific structure *pMESpec
+ * should contain an implementation-specific representation of all motion
+ * estimation parameters received via the structure pMEParams, for example
+ * rndVal, searchRange, etc. The number of bytes required for the
+ * specification structure can be determined using the function
+ * omxVCM4P2_MEGetBufSize.
+ *
+ * Input Arguments:
+ *
+ * MEmode - motion estimation mode; available modes are defined by the
+ * enumerated type OMXVCM4P2MEMode
+ * pMEParams - motion estimation parameters
+ * pMESpec - pointer to the uninitialized ME specification structure
+ *
+ * Output Arguments:
+ *
+ * pMESpec - pointer to the initialized ME specification structure
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - one or more of the following is true:
+ * - an invalid value was specified for the parameter MEmode
+ * - a negative or zero value was specified for the
+ * parameter pMEParams->searchRange
+ *
+ */
+
+OMXResult omxVCM4P2_MEInit(
+ OMXVCM4P2MEMode MEMode,
+ const OMXVCM4P2MEParams *pMEParams,
+ void *pMESpec
+ )
+{
+ ARMVCM4P2_MESpec *armMESpec = (ARMVCM4P2_MESpec *) pMESpec;
+
+ armRetArgErrIf(!pMEParams, OMX_Sts_BadArgErr);
+ armRetArgErrIf(!pMESpec, OMX_Sts_BadArgErr);
+ armRetArgErrIf((MEMode != OMX_VC_M4P2_FAST_SEARCH) &&
+ (MEMode != OMX_VC_M4P2_FULL_SEARCH), OMX_Sts_BadArgErr);
+ armRetArgErrIf(pMEParams->searchRange <= 0, OMX_Sts_BadArgErr);
+
+ armMESpec->MEParams.searchEnable8x8 = pMEParams->searchEnable8x8;
+ armMESpec->MEParams.halfPelSearchEnable = pMEParams->halfPelSearchEnable;
+ armMESpec->MEParams.searchRange = pMEParams->searchRange;
+ armMESpec->MEParams.rndVal = pMEParams->rndVal;
+ armMESpec->MEMode = MEMode;
+
+ return OMX_Sts_NoErr;
+}
+
+/* End of file */
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_MotionEstimationMB.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_MotionEstimationMB.c
new file mode 100644
index 0000000..9549050
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_MotionEstimationMB.c
@@ -0,0 +1,630 @@
+/**
+ *
+ * File Name: omxVCM4P2_MotionEstimationMB.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains module for motion search 16x16 macroblock
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armVC.h"
+#include "armCOMM.h"
+
+/**
+ * Function: armVCM4P2_BlockMatch_16x16
+ *
+ * Description:
+ * 16x16 block match wrapper function, calls omxVCM4P2_BlockMatch_Integer_16x16.
+ * If half pel search is enabled it also calls omxVCM4P2_BlockMatch_Half_16x16
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] pSrcRefBuf pointer to the reference Y plane; points to the reference MB that
+ * corresponds to the location of the current macroblock in the current
+ * plane.
+ * [in] srcRefStep width of the reference plane
+ * [in] pRefRect pointer to the valid rectangular in reference plane. Relative to image origin.
+ * It's not limited to the image boundary, but depended on the padding. For example,
+ * if you pad 4 pixels outside the image border, then the value for left border
+ * can be -4
+ * [in] pSrcCurrBuf pointer to the current macroblock extracted from original plane (linear array,
+ * 256 entries); must be aligned on an 16-byte boundary.
+ * [in] pCurrPointPos position of the current macroblock in the current plane
+ * [in] pSrcPreMV pointer to predicted motion vector; NULL indicates no predicted MV
+ * [in] pSrcPreSAD pointer to SAD associated with the predicted MV (referenced by pSrcPreMV); may be set to NULL if unavailable.
+ * [in] pMESpec vendor-specific motion estimation specification structure; must have been allocated
+ * and then initialized using omxVCM4P2_MEInit prior to calling the block matching
+ * function.
+ * [out] pDstMV pointer to estimated MV
+ * [out] pDstSAD pointer to minimum SAD
+ * *
+ * Return Value:
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments
+ *
+ */
+static OMXResult armVCM4P2_BlockMatch_16x16(
+ const OMX_U8 *pSrcRefBuf,
+ const OMX_INT srcRefStep,
+ const OMXRect *pRefRect,
+ const OMX_U8 *pSrcCurrBuf,
+ const OMXVCM4P2Coordinate *pCurrPointPos,
+ OMXVCMotionVector *pSrcPreMV,
+ OMX_INT *pSrcPreSAD,
+ void *pMESpec,
+ OMXVCMotionVector *pDstMV,
+ OMX_INT *pDstSAD
+)
+{
+ OMXVCM4P2MEParams *pMEParams = (OMXVCM4P2MEParams *)pMESpec;
+ OMX_INT rndVal;
+
+ rndVal = pMEParams->rndVal;
+
+ omxVCM4P2_BlockMatch_Integer_16x16(
+ pSrcRefBuf,
+ srcRefStep,
+ pRefRect,
+ pSrcCurrBuf,
+ pCurrPointPos,
+ pSrcPreMV,
+ pSrcPreSAD,
+ pMEParams,
+ pDstMV,
+ pDstSAD);
+
+ if (pMEParams->halfPelSearchEnable)
+ {
+ omxVCM4P2_BlockMatch_Half_16x16(
+ pSrcRefBuf,
+ srcRefStep,
+ pRefRect,
+ pSrcCurrBuf,
+ pCurrPointPos,
+ rndVal,
+ pDstMV,
+ pDstSAD);
+ }
+
+ return OMX_Sts_NoErr;
+}
+
+/**
+ * Function: armVCM4P2_BlockMatch_8x8
+ *
+ * Description:
+ * 8x8 block match wrapper function, calls omxVCM4P2_BlockMatch_Integer_8x8.
+ * If half pel search is enabled it also calls omxVCM4P2_BlockMatch_Half_8x8
+ *
+ * Remarks:
+ *
+ * Parameters:
+ * [in] pSrcRefBuf pointer to the reference Y plane; points to the reference MB that
+ * corresponds to the location of the current macroblock in the current
+ * plane.
+ * [in] srcRefStep width of the reference plane
+ * [in] pRefRect pointer to the valid rectangular in reference plane. Relative to image origin.
+ * It's not limited to the image boundary, but depended on the padding. For example,
+ * if you pad 4 pixels outside the image border, then the value for left border
+ * can be -4
+ * [in] pSrcCurrBuf pointer to the current macroblock extracted from original plane (linear array,
+ * 256 entries); must be aligned on an 16-byte boundary.
+ * [in] pCurrPointPos position of the current macroblock in the current plane
+ * [in] pSrcPreMV pointer to predicted motion vector; NULL indicates no predicted MV
+ * [in] pSrcPreSAD pointer to SAD associated with the predicted MV (referenced by pSrcPreMV); may be set to NULL if unavailable.
+ * [in] pMESpec vendor-specific motion estimation specification structure; must have been allocated
+ * and then initialized using omxVCM4P2_MEInit prior to calling the block matching
+ * function.
+ * [out] pDstMV pointer to estimated MV
+ * [out] pDstSAD pointer to minimum SAD
+ * *
+ * Return Value:
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments
+ *
+ */
+static OMXResult armVCM4P2_BlockMatch_8x8(
+ const OMX_U8 *pSrcRefBuf,
+ OMX_INT srcRefStep,
+ const OMXRect *pRefRect,
+ const OMX_U8 *pSrcCurrBuf,
+ const OMXVCM4P2Coordinate *pCurrPointPos,
+ OMXVCMotionVector *pSrcPreMV,
+ OMX_INT *pSrcPreSAD,
+ void *pMESpec,
+ OMXVCMotionVector *pSrcDstMV,
+ OMX_INT *pDstSAD
+)
+{
+ OMXVCM4P2MEParams *pMEParams = (OMXVCM4P2MEParams *)pMESpec;
+ OMX_INT rndVal;
+
+ rndVal = pMEParams->rndVal;
+
+ omxVCM4P2_BlockMatch_Integer_8x8(
+ pSrcRefBuf,
+ srcRefStep,
+ pRefRect,
+ pSrcCurrBuf,
+ pCurrPointPos,
+ pSrcPreMV,
+ pSrcPreSAD,
+ pMEParams,
+ pSrcDstMV,
+ pDstSAD);
+
+ if (pMEParams->halfPelSearchEnable)
+ {
+ omxVCM4P2_BlockMatch_Half_8x8(
+ pSrcRefBuf,
+ srcRefStep,
+ pRefRect,
+ pSrcCurrBuf,
+ pCurrPointPos,
+ rndVal,
+ pSrcDstMV,
+ pDstSAD);
+ }
+
+ return OMX_Sts_NoErr;
+}
+
+
+/**
+ * Function: omxVCM4P2_MotionEstimationMB (6.2.4.3.1)
+ *
+ * Description:
+ * Performs motion search for a 16x16 macroblock. Selects best motion search
+ * strategy from among inter-1MV, inter-4MV, and intra modes. Supports
+ * integer and half pixel resolution.
+ *
+ * Input Arguments:
+ *
+ * pSrcCurrBuf - pointer to the top-left corner of the current MB in the
+ * original picture plane; must be aligned on a 16-byte boundary.
+ * The function does not expect source data outside the region
+ * bounded by the MB to be available; for example it is not
+ * necessary for the caller to guarantee the availability of
+ * pSrcCurrBuf[-SrcCurrStep], i.e., the row of pixels above the MB
+ * to be processed.
+ * srcCurrStep - width of the original picture plane, in terms of full
+ * pixels; must be a multiple of 16.
+ * pSrcRefBuf - pointer to the reference Y plane; points to the reference
+ * plane location corresponding to the location of the current
+ * macroblock in the current plane; must be aligned on a 16-byte
+ * boundary.
+ * srcRefStep - width of the reference picture plane, in terms of full
+ * pixels; must be a multiple of 16.
+ * pRefRect - reference plane valid region rectangle, specified relative to
+ * the image origin
+ * pCurrPointPos - position of the current macroblock in the current plane
+ * pMESpec - pointer to the vendor-specific motion estimation specification
+ * structure; must be allocated and then initialized using
+ * omxVCM4P2_MEInit prior to calling this function.
+ * pMBInfo - array, of dimension four, containing pointers to information
+ * associated with four nearby MBs:
+ * - pMBInfo[0] - pointer to left MB information
+ * - pMBInfo[1] - pointer to top MB information
+ * - pMBInfo[2] - pointer to top-left MB information
+ * - pMBInfo[3] - pointer to top-right MB information
+ * Any pointer in the array may be set equal to NULL if the
+ * corresponding MB doesn't exist. For each MB, the following structure
+ * members are used:
+ * - mbType - macroblock type, either OMX_VC_INTRA, OMX_VC_INTER, or
+ * OMX_VC_INTER4V
+ * - pMV0[2][2] - estimated motion vectors; represented
+ * in 1/2 pixel units
+ * - sliceID - number of the slice to which the MB belongs
+ * pSrcDstMBCurr - pointer to information structure for the current MB.
+ * The following entries should be set prior to calling the
+ * function: sliceID - the number of the slice the to which the
+ * current MB belongs. The structure elements cbpy and cbpc are
+ * ignored.
+ *
+ * Output Arguments:
+ *
+ * pSrcDstMBCurr - pointer to updated information structure for the current
+ * MB after MB-level motion estimation has been completed. The
+ * following structure members are updated by the ME function:
+ * - mbType - macroblock type: OMX_VC_INTRA, OMX_VC_INTER, or
+ * OMX_VC_INTER4V.
+ * - pMV0[2][2] - estimated motion vectors; represented in
+ * terms of 1/2 pel units.
+ * - pMVPred[2][2] - predicted motion vectors; represented
+ * in terms of 1/2 pel units.
+ * The structure members cbpy and cbpc are not updated by the function.
+ * pDstSAD - pointer to the minimum SAD for INTER1V, or sum of minimum SADs
+ * for INTER4V
+ * pDstBlockSAD - pointer to an array of SAD values for each of the four
+ * 8x8 luma blocks in the MB. The block SADs are in scan order for
+ * each MB.
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments. Returned if one or more of the
+ * following conditions is true:
+ * - at least one of the following pointers is NULL: pSrcCurrBuf,
+ * pSrcRefBuf, pRefRect, pCurrPointPos, pMBInter, pMBIntra,
+ * pSrcDstMBCurr, or pDstSAD.
+ *
+ */
+
+OMXResult omxVCM4P2_MotionEstimationMB (
+ const OMX_U8 *pSrcCurrBuf,
+ OMX_S32 srcCurrStep,
+ const OMX_U8 *pSrcRefBuf,
+ OMX_S32 srcRefStep,
+ const OMXRect*pRefRect,
+ const OMXVCM4P2Coordinate *pCurrPointPos,
+ void *pMESpec,
+ const OMXVCM4P2MBInfoPtr *pMBInfo,
+ OMXVCM4P2MBInfo *pSrcDstMBCurr,
+ OMX_U16 *pDstSAD,
+ OMX_U16 *pDstBlockSAD
+)
+{
+
+ OMX_INT intraSAD, average, count, index, x, y;
+ OMXVCMotionVector dstMV16x16;
+ OMX_INT dstSAD16x16;
+ OMX_INT dstSAD8x8;
+ OMXVCM4P2MEParams *pMEParams;
+ OMXVCM4P2Coordinate TempCurrPointPos;
+ OMXVCM4P2Coordinate *pTempCurrPointPos;
+ OMX_U8 aTempSrcCurrBuf[271];
+ OMX_U8 *pTempSrcCurrBuf;
+ OMX_U8 *pDst;
+ OMX_U8 aDst[71];
+ OMX_S32 dstStep = 8;
+ OMX_INT predictType;
+ OMX_S32 Sad;
+ const OMX_U8 *pTempSrcRefBuf;
+ OMXVCMotionVector* pSrcCandMV1[4];
+ OMXVCMotionVector* pSrcCandMV2[4];
+ OMXVCMotionVector* pSrcCandMV3[4];
+
+ /* Argument error checks */
+ armRetArgErrIf(!armIs16ByteAligned(pSrcCurrBuf), OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs16ByteAligned(pSrcRefBuf), OMX_Sts_BadArgErr);
+ armRetArgErrIf(((srcCurrStep % 16) || (srcRefStep % 16)), OMX_Sts_BadArgErr);
+ armRetArgErrIf(pSrcCurrBuf == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pSrcRefBuf == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pRefRect == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pCurrPointPos == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pSrcDstMBCurr == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pDstSAD == NULL, OMX_Sts_BadArgErr);
+
+
+ pTempCurrPointPos = &(TempCurrPointPos);
+ pTempSrcCurrBuf = armAlignTo16Bytes(aTempSrcCurrBuf);
+ pMEParams = (OMXVCM4P2MEParams *)pMESpec;
+ pTempCurrPointPos->x = pCurrPointPos->x;
+ pTempCurrPointPos->y = pCurrPointPos->y;
+ pSrcDstMBCurr->mbType = OMX_VC_INTER;
+
+ /* Preparing a linear buffer for block match */
+ for (y = 0, index = count = 0; y < 16; y++, index += srcCurrStep - 16)
+ {
+ for(x = 0; x < 16; x++, count++, index++)
+ {
+ pTempSrcCurrBuf[count] = pSrcCurrBuf[index];
+ }
+ }
+ for(y = 0, index = 0; y < 2; y++)
+ {
+ for(x = 0; x < 2; x++,index++)
+ {
+ if((pMBInfo[0] != NULL) && (pMBInfo[0]->mbType != OMX_VC_INTRA))
+ {
+ pSrcCandMV1[index] = &(pMBInfo[0]->pMV0[y][x]);
+ }
+ else
+ {
+ pSrcCandMV1[index] = NULL;
+ }
+ if((pMBInfo[1] != NULL) && (pMBInfo[1]->mbType != OMX_VC_INTRA))
+ {
+ pSrcCandMV2[index] = &(pMBInfo[1]->pMV0[y][x]);
+ }
+ else
+ {
+ pSrcCandMV2[index] = NULL;
+ }
+ if((pMBInfo[3] != NULL) && (pMBInfo[3]->mbType != OMX_VC_INTRA))
+ {
+ pSrcCandMV3[index] = &(pMBInfo[3]->pMV0[y][x]);
+ }
+ else
+ {
+ pSrcCandMV3[index] = NULL;
+ }
+ }
+ }
+ /* Calculating SAD at MV(0,0) */
+ armVCCOMM_SAD(pTempSrcCurrBuf,
+ 16,
+ pSrcRefBuf,
+ srcRefStep,
+ &Sad,
+ 16,
+ 16);
+ *pDstSAD = Sad;
+
+ /* Mode decision for NOT_CODED MB */
+ if(*pDstSAD == 0)
+ {
+ pSrcDstMBCurr->pMV0[0][0].dx = 0;
+ pSrcDstMBCurr->pMV0[0][0].dy = 0;
+ *pDstSAD = 0;
+ return OMX_Sts_NoErr;
+ }
+
+ omxVCM4P2_FindMVpred(
+ &(pSrcDstMBCurr->pMV0[0][0]),
+ pSrcCandMV1[0],
+ pSrcCandMV2[0],
+ pSrcCandMV3[0],
+ &(pSrcDstMBCurr->pMVPred[0][0]),
+ NULL,
+ 0);
+
+ /* Inter 1 MV */
+ armVCM4P2_BlockMatch_16x16(
+ pSrcRefBuf,
+ srcRefStep,
+ pRefRect,
+ pTempSrcCurrBuf,
+ pCurrPointPos,
+ &(pSrcDstMBCurr->pMVPred[0][0]),
+ NULL,
+ pMEParams,
+ &dstMV16x16,
+ &dstSAD16x16);
+
+ /* Initialize all with 1 MV values */
+ pSrcDstMBCurr->pMV0[0][0].dx = dstMV16x16.dx;
+ pSrcDstMBCurr->pMV0[0][0].dy = dstMV16x16.dy;
+ pSrcDstMBCurr->pMV0[0][1].dx = dstMV16x16.dx;
+ pSrcDstMBCurr->pMV0[0][1].dy = dstMV16x16.dy;
+ pSrcDstMBCurr->pMV0[1][0].dx = dstMV16x16.dx;
+ pSrcDstMBCurr->pMV0[1][0].dy = dstMV16x16.dy;
+ pSrcDstMBCurr->pMV0[1][1].dx = dstMV16x16.dx;
+ pSrcDstMBCurr->pMV0[1][1].dy = dstMV16x16.dy;
+
+ *pDstSAD = dstSAD16x16;
+
+ if (pMEParams->searchEnable8x8)
+ {
+ /* Inter 4MV */
+ armVCM4P2_BlockMatch_8x8 (pSrcRefBuf,
+ srcRefStep, pRefRect,
+ pTempSrcCurrBuf, pTempCurrPointPos,
+ &(pSrcDstMBCurr->pMVPred[0][0]), NULL,
+ pMEParams, &(pSrcDstMBCurr->pMV0[0][0]),
+ &dstSAD8x8
+ );
+ pDstBlockSAD[0] = dstSAD8x8;
+ *pDstSAD = dstSAD8x8;
+ pTempCurrPointPos->x += 8;
+ pSrcRefBuf += 8;
+ omxVCM4P2_FindMVpred(
+ &(pSrcDstMBCurr->pMV0[0][1]),
+ pSrcCandMV1[1],
+ pSrcCandMV2[1],
+ pSrcCandMV3[1],
+ &(pSrcDstMBCurr->pMVPred[0][1]),
+ NULL,
+ 1);
+
+ armVCM4P2_BlockMatch_8x8 (pSrcRefBuf,
+ srcRefStep, pRefRect,
+ pTempSrcCurrBuf, pTempCurrPointPos,
+ &(pSrcDstMBCurr->pMVPred[0][1]), NULL,
+ pMEParams, &(pSrcDstMBCurr->pMV0[0][1]),
+ &dstSAD8x8
+ );
+ pDstBlockSAD[1] = dstSAD8x8;
+ *pDstSAD += dstSAD8x8;
+ pTempCurrPointPos->x -= 8;
+ pTempCurrPointPos->y += 8;
+ pSrcRefBuf += (srcRefStep * 8) - 8;
+
+ omxVCM4P2_FindMVpred(
+ &(pSrcDstMBCurr->pMV0[1][0]),
+ pSrcCandMV1[2],
+ pSrcCandMV2[2],
+ pSrcCandMV3[2],
+ &(pSrcDstMBCurr->pMVPred[1][0]),
+ NULL,
+ 2);
+ armVCM4P2_BlockMatch_8x8 (pSrcRefBuf,
+ srcRefStep, pRefRect,
+ pTempSrcCurrBuf, pTempCurrPointPos,
+ &(pSrcDstMBCurr->pMVPred[1][0]), NULL,
+ pMEParams, &(pSrcDstMBCurr->pMV0[1][0]),
+ &dstSAD8x8
+ );
+ pDstBlockSAD[2] = dstSAD8x8;
+ *pDstSAD += dstSAD8x8;
+ pTempCurrPointPos->x += 8;
+ pSrcRefBuf += 8;
+ omxVCM4P2_FindMVpred(
+ &(pSrcDstMBCurr->pMV0[1][1]),
+ pSrcCandMV1[3],
+ pSrcCandMV2[3],
+ pSrcCandMV3[3],
+ &(pSrcDstMBCurr->pMVPred[1][1]),
+ NULL,
+ 3);
+ armVCM4P2_BlockMatch_8x8 (pSrcRefBuf,
+ srcRefStep, pRefRect,
+ pTempSrcCurrBuf, pTempCurrPointPos,
+ &(pSrcDstMBCurr->pMVPred[1][1]), NULL,
+ pMEParams, &(pSrcDstMBCurr->pMV0[1][1]),
+ &dstSAD8x8
+ );
+ pDstBlockSAD[3] = dstSAD8x8;
+ *pDstSAD += dstSAD8x8;
+
+
+ /* Checking if 4MV is equal to 1MV */
+ if (
+ (pSrcDstMBCurr->pMV0[0][0].dx != dstMV16x16.dx) ||
+ (pSrcDstMBCurr->pMV0[0][0].dy != dstMV16x16.dy) ||
+ (pSrcDstMBCurr->pMV0[0][1].dx != dstMV16x16.dx) ||
+ (pSrcDstMBCurr->pMV0[0][1].dy != dstMV16x16.dy) ||
+ (pSrcDstMBCurr->pMV0[1][0].dx != dstMV16x16.dx) ||
+ (pSrcDstMBCurr->pMV0[1][0].dy != dstMV16x16.dy) ||
+ (pSrcDstMBCurr->pMV0[1][1].dx != dstMV16x16.dx) ||
+ (pSrcDstMBCurr->pMV0[1][1].dy != dstMV16x16.dy)
+ )
+ {
+ /* select the 4 MV */
+ pSrcDstMBCurr->mbType = OMX_VC_INTER4V;
+ }
+ }
+
+ /* finding the error in intra mode */
+ for (count = 0, average = 0; count < 256 ; count++)
+ {
+ average = average + pTempSrcCurrBuf[count];
+ }
+ average = average/256;
+
+ intraSAD = 0;
+
+ /* Intra SAD calculation */
+ for (count = 0; count < 256 ; count++)
+ {
+ intraSAD += armAbs ((pTempSrcCurrBuf[count]) - (average));
+ }
+
+ /* Using the MPEG4 VM formula for intra/inter mode decision
+ Var < (SAD - 2*NB) where NB = N^2 is the number of pixels
+ of the macroblock.*/
+
+ if (intraSAD <= (*pDstSAD - 512))
+ {
+ pSrcDstMBCurr->mbType = OMX_VC_INTRA;
+ pSrcDstMBCurr->pMV0[0][0].dx = 0;
+ pSrcDstMBCurr->pMV0[0][0].dy = 0;
+ *pDstSAD = intraSAD;
+ pDstBlockSAD[0] = 0xFFFF;
+ pDstBlockSAD[1] = 0xFFFF;
+ pDstBlockSAD[2] = 0xFFFF;
+ pDstBlockSAD[3] = 0xFFFF;
+ }
+
+ if(pSrcDstMBCurr->mbType == OMX_VC_INTER)
+ {
+ pTempSrcRefBuf = pSrcRefBuf + (srcRefStep * dstMV16x16.dy) + dstMV16x16.dx;
+
+ if((dstMV16x16.dx & 0x1) && (dstMV16x16.dy & 0x1))
+ {
+ predictType = OMX_VC_HALF_PIXEL_XY;
+ }
+ else if(dstMV16x16.dx & 0x1)
+ {
+ predictType = OMX_VC_HALF_PIXEL_X;
+ }
+ else if(dstMV16x16.dy & 0x1)
+ {
+ predictType = OMX_VC_HALF_PIXEL_Y;
+ }
+ else
+ {
+ predictType = OMX_VC_INTEGER_PIXEL;
+ }
+
+ pDst = armAlignTo8Bytes(&(aDst[0]));
+ /* Calculating Block SAD at MV(dstMV16x16.dx,dstMV16x16.dy) */
+ /* Block 0 */
+ omxVCM4P2_MCReconBlock(pTempSrcRefBuf,
+ srcRefStep,
+ NULL,
+ pDst,
+ dstStep,
+ predictType,
+ pMEParams->rndVal);
+
+ armVCCOMM_SAD(pTempSrcCurrBuf,
+ 16,
+ pDst,
+ dstStep,
+ &Sad,
+ 8,
+ 8);
+ pDstBlockSAD[0] = Sad;
+
+ /* Block 1 */
+ omxVCM4P2_MCReconBlock(pTempSrcRefBuf + 8,
+ srcRefStep,
+ NULL,
+ pDst,
+ dstStep,
+ predictType,
+ pMEParams->rndVal);
+
+ armVCCOMM_SAD(pTempSrcCurrBuf + 8,
+ 16,
+ pDst,
+ dstStep,
+ &Sad,
+ 8,
+ 8);
+ pDstBlockSAD[1] = Sad;
+
+ /* Block 2 */
+ omxVCM4P2_MCReconBlock(pTempSrcRefBuf + (srcRefStep*8),
+ srcRefStep,
+ NULL,
+ pDst,
+ dstStep,
+ predictType,
+ pMEParams->rndVal);
+
+ armVCCOMM_SAD(pTempSrcCurrBuf + (16*8),
+ 16,
+ pDst,
+ dstStep,
+ &Sad,
+ 8,
+ 8);
+ pDstBlockSAD[2] = Sad;
+
+ /* Block 3 */
+ omxVCM4P2_MCReconBlock(pTempSrcRefBuf + (srcRefStep*8) + 8,
+ srcRefStep,
+ NULL,
+ pDst,
+ dstStep,
+ predictType,
+ pMEParams->rndVal);
+
+ armVCCOMM_SAD(pTempSrcCurrBuf + (16*8) + 8,
+ 16,
+ pDst,
+ dstStep,
+ &Sad,
+ 8,
+ 8);
+ pDstBlockSAD[3] = Sad;
+ }
+ return OMX_Sts_NoErr;
+}
+
+/* End of file */
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_PredictReconCoefIntra.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_PredictReconCoefIntra.c
new file mode 100644
index 0000000..1613f47
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_PredictReconCoefIntra.c
@@ -0,0 +1,121 @@
+ /**
+ *
+ * File Name: omxVCM4P2_PredictReconCoefIntra.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * File: omxVCM4P2_PredictReconCoefIntra_S16.c
+ * Description: Contains modules for AC DC prediction
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armCOMM.h"
+#include "armVC.h"
+
+/**
+ * Function: omxVCM4P2_PredictReconCoefIntra (6.2.5.4.3)
+ *
+ * Description:
+ * Performs adaptive DC/AC coefficient prediction for an intra block. Prior
+ * to the function call, prediction direction (predDir) should be selected as
+ * specified in [ISO14496-2], subclause 7.4.3.1.
+ *
+ * Input Arguments:
+ *
+ * pSrcDst - pointer to the coefficient buffer which contains the quantized
+ * coefficient residuals (PQF) of the current block; must be
+ * aligned on a 4-byte boundary. The output coefficients are
+ * saturated to the range [-2048, 2047].
+ * pPredBufRow - pointer to the coefficient row buffer; must be aligned on
+ * a 4-byte boundary.
+ * pPredBufCol - pointer to the coefficient column buffer; must be aligned
+ * on a 4-byte boundary.
+ * curQP - quantization parameter of the current block. curQP may equal to
+ * predQP especially when the current block and the predictor block
+ * are in the same macroblock.
+ * predQP - quantization parameter of the predictor block
+ * predDir - indicates the prediction direction which takes one of the
+ * following values: OMX_VC_HORIZONTAL - predict horizontally
+ * OMX_VC_VERTICAL - predict vertically
+ * ACPredFlag - a flag indicating if AC prediction should be performed. It
+ * is equal to ac_pred_flag in the bit stream syntax of MPEG-4
+ * videoComp - video component type (luminance or chrominance) of the
+ * current block
+ *
+ * Output Arguments:
+ *
+ * pSrcDst - pointer to the coefficient buffer which contains the quantized
+ * coefficients (QF) of the current block
+ * pPredBufRow - pointer to the updated coefficient row buffer
+ * pPredBufCol - pointer to the updated coefficient column buffer Note:
+ * Buffer update: Update the AC prediction buffer (both row and
+ * column buffer).
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments, if:
+ * - At least one of the pointers is NULL:
+ * pSrcDst, pPredBufRow, or pPredBufCol.
+ * - curQP <= 0,
+ * - predQP <= 0,
+ * - curQP >31,
+ * - predQP > 31,
+ * - preDir exceeds [1,2]
+ * - pSrcDst, pPredBufRow, or pPredBufCol is not 4-byte aligned.
+ *
+ */
+
+OMXResult omxVCM4P2_PredictReconCoefIntra(
+ OMX_S16 * pSrcDst,
+ OMX_S16 * pPredBufRow,
+ OMX_S16 * pPredBufCol,
+ OMX_INT curQP,
+ OMX_INT predQP,
+ OMX_INT predDir,
+ OMX_INT ACPredFlag,
+ OMXVCM4P2VideoComponent videoComp
+ )
+{
+ OMX_U8 flag;
+ /* Argument error checks */
+ armRetArgErrIf(pSrcDst == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pPredBufRow == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pPredBufCol == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(curQP <= 0, OMX_Sts_BadArgErr);
+ armRetArgErrIf(predQP <= 0, OMX_Sts_BadArgErr);
+ armRetArgErrIf(curQP > 31, OMX_Sts_BadArgErr);
+ armRetArgErrIf(predQP > 31, OMX_Sts_BadArgErr);
+ armRetArgErrIf((predDir != 1) && (predDir != 2), OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs4ByteAligned(pSrcDst), OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs4ByteAligned(pPredBufRow), OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs4ByteAligned(pPredBufCol), OMX_Sts_BadArgErr);
+
+ flag = 0;
+ return armVCM4P2_ACDCPredict(
+ pSrcDst,
+ NULL,
+ pPredBufRow,
+ pPredBufCol,
+ curQP,
+ predQP,
+ predDir,
+ ACPredFlag,
+ videoComp,
+ flag,
+ NULL);
+
+}
+
+/* End of file */
+
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_QuantInter_I.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_QuantInter_I.c
new file mode 100644
index 0000000..5964f73
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_QuantInter_I.c
@@ -0,0 +1,117 @@
+/**
+ *
+ * File Name: omxVCM4P2_QuantInter_I.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for inter Quantization
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armCOMM.h"
+
+/**
+ * Function: omxVCM4P2_QuantInter_I (6.2.4.4.3)
+ *
+ * Description:
+ * Performs quantization on an inter coefficient block; supports
+ * bits_per_pixel == 8.
+ *
+ * Input Arguments:
+ *
+ * pSrcDst - pointer to the input inter block coefficients; must be aligned
+ * on a 16-byte boundary.
+ * QP - quantization parameter (quantizer_scale)
+ * shortVideoHeader - binary flag indicating presence of short_video_header;
+ * shortVideoHeader==1 selects linear intra DC mode, and
+ * shortVideoHeader==0 selects non linear intra DC mode.
+ *
+ * Output Arguments:
+ *
+ * pSrcDst - pointer to the output (quantized) interblock coefficients.
+ * When shortVideoHeader==1, AC coefficients are saturated on the
+ * interval [-127, 127], and DC coefficients are saturated on the
+ * interval [1, 254]. When shortVideoHeader==0, AC coefficients
+ * are saturated on the interval [-2047, 2047].
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments:
+ * - pSrcDst is NULL.
+ * - QP <= 0 or QP >= 32.
+ *
+ */
+
+OMXResult omxVCM4P2_QuantInter_I(
+ OMX_S16 * pSrcDst,
+ OMX_U8 QP,
+ OMX_INT shortVideoHeader
+)
+{
+
+ /* Definitions and Initializations*/
+ OMX_INT coeffCount;
+ OMX_INT fSign;
+ OMX_INT maxClpAC = 0, minClpAC = 0;
+ OMX_INT maxClpDC = 0, minClpDC = 0;
+
+ /* Argument error checks */
+ armRetArgErrIf(pSrcDst == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(((QP <= 0) || (QP >= 32)), OMX_Sts_BadArgErr);
+ /* One argument check is delayed until we have ascertained that */
+ /* pQMatrix is not NULL. */
+
+ /* Set the Clip Range based on SVH on/off */
+ if(shortVideoHeader == 1)
+ {
+ maxClpDC = 254;
+ minClpDC = 1;
+ maxClpAC = 127;
+ minClpAC = -127;
+ }
+ else
+ {
+ maxClpDC = 2047;
+ minClpDC = -2047;
+ maxClpAC = 2047;
+ minClpAC = -2047;
+ }
+
+ /* Second Inverse quantisation method */
+ for (coeffCount = 0; coeffCount < 64; coeffCount++)
+ {
+ fSign = armSignCheck (pSrcDst[coeffCount]);
+ pSrcDst[coeffCount] = (armAbs(pSrcDst[coeffCount])
+ - (QP/2))/(2 * QP);
+ pSrcDst[coeffCount] *= fSign;
+
+ /* Clip */
+ if (coeffCount == 0)
+ {
+ pSrcDst[coeffCount] =
+ (OMX_S16) armClip (minClpDC, maxClpDC, pSrcDst[coeffCount]);
+ }
+ else
+ {
+ pSrcDst[coeffCount] =
+ (OMX_S16) armClip (minClpAC, maxClpAC, pSrcDst[coeffCount]);
+ }
+ }
+ return OMX_Sts_NoErr;
+
+}
+
+/* End of file */
+
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_QuantIntra_I.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_QuantIntra_I.c
new file mode 100644
index 0000000..a10da68
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_QuantIntra_I.c
@@ -0,0 +1,153 @@
+/**
+ *
+ * File Name: omxVCM4P2_QuantIntra_I.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for intra Quantization
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armCOMM.h"
+/**
+ * Function: omxVCM4P2_QuantIntra_I (6.2.4.4.2)
+ *
+ * Description:
+ * Performs quantization on intra block coefficients. This function supports
+ * bits_per_pixel == 8.
+ *
+ * Input Arguments:
+ *
+ * pSrcDst - pointer to the input intra block coefficients; must be aligned
+ * on a 16-byte boundary.
+ * QP - quantization parameter (quantizer_scale).
+ * blockIndex - block index indicating the component type and position,
+ * valid in the range 0 to 5, as defined in [ISO14496-2], subclause
+ * 6.1.3.8.
+ * shortVideoHeader - binary flag indicating presence of
+ * short_video_header; shortVideoHeader==1 selects linear intra DC
+ * mode, and shortVideoHeader==0 selects non linear intra DC mode.
+ *
+ * Output Arguments:
+ *
+ * pSrcDst - pointer to the output (quantized) interblock coefficients.
+ * When shortVideoHeader==1, AC coefficients are saturated on the
+ * interval [-127, 127], and DC coefficients are saturated on the
+ * interval [1, 254]. When shortVideoHeader==0, AC coefficients
+ * are saturated on the interval [-2047, 2047].
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments:
+ * - pSrcDst is NULL.
+ * - blockIndex < 0 or blockIndex >= 10
+ * - QP <= 0 or QP >= 32.
+ *
+ */
+
+OMXResult omxVCM4P2_QuantIntra_I(
+ OMX_S16 * pSrcDst,
+ OMX_U8 QP,
+ OMX_INT blockIndex,
+ OMX_INT shortVideoHeader
+ )
+{
+
+ /* Definitions and Initializations*/
+ /* Initialized to remove compilation error */
+ OMX_INT dcScaler = 0, coeffCount,fSign;
+ OMX_INT maxClpAC, minClpAC;
+
+ /* Argument error checks */
+ armRetArgErrIf(pSrcDst == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(((blockIndex < 0) || (blockIndex >= 10)), OMX_Sts_BadArgErr);
+ armRetArgErrIf(((QP <= 0) || (QP >= 32)), OMX_Sts_BadArgErr);
+ /* One argument check is delayed until we have ascertained that */
+ /* pQMatrix is not NULL. */
+
+
+ /* Set the Clip Range based on SVH on/off */
+ if(shortVideoHeader == 1)
+ {
+ maxClpAC = 127;
+ minClpAC = -127;
+ dcScaler = 8;
+ /* Dequant the DC value, this applies to both the methods */
+ pSrcDst[0] = armIntDivAwayFromZero (pSrcDst[0], dcScaler);
+
+ /* Clip between 1 and 254 */
+ pSrcDst[0] = (OMX_S16) armClip (1, 254, pSrcDst[0]);
+ }
+ else
+ {
+ maxClpAC = 2047;
+ minClpAC = -2047;
+ /* Calculate the DC scaler value */
+ if ((blockIndex < 4) || (blockIndex > 5))
+ {
+ if (QP >= 1 && QP <= 4)
+ {
+ dcScaler = 8;
+ }
+ else if (QP >= 5 && QP <= 8)
+ {
+ dcScaler = 2 * QP;
+ }
+ else if (QP >= 9 && QP <= 24)
+ {
+ dcScaler = QP + 8;
+ }
+ else
+ {
+ dcScaler = (2 * QP) - 16;
+ }
+ }
+ else if (blockIndex < 6)
+ {
+ if (QP >= 1 && QP <= 4)
+ {
+ dcScaler = 8;
+ }
+ else if (QP >= 5 && QP <= 24)
+ {
+ dcScaler = (QP + 13)/2;
+ }
+ else
+ {
+ dcScaler = QP - 6;
+ }
+ }
+
+ /* Dequant the DC value, this applies to both the methods */
+ pSrcDst[0] = armIntDivAwayFromZero (pSrcDst[0], dcScaler);
+ }
+
+ /* Second Inverse quantisation method */
+ for (coeffCount = 1; coeffCount < 64; coeffCount++)
+ {
+ fSign = armSignCheck (pSrcDst[coeffCount]);
+ pSrcDst[coeffCount] = armAbs(pSrcDst[coeffCount])/(2 * QP);
+ pSrcDst[coeffCount] *= fSign;
+
+ /* Clip */
+ pSrcDst[coeffCount] =
+ (OMX_S16) armClip (minClpAC, maxClpAC, pSrcDst[coeffCount]);
+ }
+ return OMX_Sts_NoErr;
+
+}
+
+/* End of file */
+
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_QuantInvInter_I.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_QuantInvInter_I.c
new file mode 100644
index 0000000..6e0de5c
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_QuantInvInter_I.c
@@ -0,0 +1,96 @@
+/**
+ *
+ * File Name: omxVCM4P2_QuantInvInter_I.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for inter inverse Quantization
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armCOMM.h"
+
+
+/**
+ * Function: omxVCM4P2_QuantInvInter_I (6.2.5.3.2)
+ *
+ * Description:
+ * Performs the second inverse quantization mode on an intra/inter coded
+ * block. Supports bits_per_pixel = 8. The output coefficients are clipped to
+ * the range [-2048, 2047].
+ *
+ * Input Arguments:
+ *
+ * pSrcDst - pointer to the input (quantized) intra/inter block; must be
+ * aligned on a 16-byte boundary.
+ * QP - quantization parameter (quantizer_scale)
+ * videoComp - video component type of the current block. Takes one of the
+ * following flags: OMX_VC_LUMINANCE, OMX_VC_CHROMINANCE (intra
+ * version only).
+ * shortVideoHeader - binary flag indicating presence of short_video_header
+ * (intra version only).
+ *
+ * Output Arguments:
+ *
+ * pSrcDst - pointer to the output (dequantized) intra/inter block
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments; one or more of the following is
+ * true:
+ * - pSrcDst is NULL
+ * - QP <= 0 or QP >=31
+ * - videoComp is neither OMX_VC_LUMINANCE nor OMX_VC_CHROMINANCE.
+ *
+ */
+
+OMXResult omxVCM4P2_QuantInvInter_I(
+ OMX_S16 * pSrcDst,
+ OMX_INT QP
+ )
+{
+
+ OMX_INT coeffCount, Sign;
+
+ /* Argument error checks */
+ armRetArgErrIf(pSrcDst == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(((QP <= 0) || (QP >= 32)), OMX_Sts_BadArgErr);
+
+ /* Second Inverse quantisation method */
+ for (coeffCount = 0; coeffCount < 64; coeffCount++)
+ {
+ /* check sign */
+ Sign = armSignCheck (pSrcDst[coeffCount]);
+
+ /* Quantize the coeff */
+ if (QP & 0x1)
+ {
+ pSrcDst[coeffCount] = (2* armAbs(pSrcDst[coeffCount]) + 1) * QP;
+ pSrcDst[coeffCount] *= Sign;
+ }
+ else
+ {
+ pSrcDst[coeffCount] = (2* armAbs(pSrcDst[coeffCount]) + 1)
+ * QP - 1;
+ pSrcDst[coeffCount] *= Sign;
+ }
+ /* Saturate */
+ pSrcDst[coeffCount] = armClip (-2048, 2047, pSrcDst[coeffCount]);
+ }
+ return OMX_Sts_NoErr;
+}
+
+/* End of file */
+
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_QuantInvIntra_I.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_QuantInvIntra_I.c
new file mode 100644
index 0000000..a946d7b
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_QuantInvIntra_I.c
@@ -0,0 +1,153 @@
+/**
+ *
+ * File Name: omxVCM4P2_QuantInvIntra_I.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules for intra inverse Quantization
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armCOMM.h"
+
+/**
+ * Function: omxVCM4P2_QuantInvIntra_I (6.2.5.3.2)
+ *
+ * Description:
+ * Performs the second inverse quantization mode on an intra/inter coded
+ * block. Supports bits_per_pixel = 8. The output coefficients are clipped to
+ * the range [-2048, 2047].
+ *
+ * Input Arguments:
+ *
+ * pSrcDst - pointer to the input (quantized) intra/inter block; must be
+ * aligned on a 16-byte boundary.
+ * QP - quantization parameter (quantizer_scale)
+ * videoComp - video component type of the current block. Takes one of the
+ * following flags: OMX_VC_LUMINANCE, OMX_VC_CHROMINANCE (intra
+ * version only).
+ * shortVideoHeader - binary flag indicating presence of short_video_header
+ * (intra version only).
+ *
+ * Output Arguments:
+ *
+ * pSrcDst - pointer to the output (dequantized) intra/inter block
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments; one or more of the following is
+ * true:
+ * - pSrcDst is NULL
+ * - QP <= 0 or QP >=31
+ * - videoComp is neither OMX_VC_LUMINANCE nor OMX_VC_CHROMINANCE.
+ *
+ */
+
+OMXResult omxVCM4P2_QuantInvIntra_I(
+ OMX_S16 * pSrcDst,
+ OMX_INT QP,
+ OMXVCM4P2VideoComponent videoComp,
+ OMX_INT shortVideoHeader
+)
+{
+
+ /* Initialized to remove compilation error */
+ OMX_INT dcScaler = 0, coeffCount, Sign;
+
+ /* Argument error checks */
+ armRetArgErrIf(pSrcDst == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(((QP <= 0) || (QP >= 32)), OMX_Sts_BadArgErr);
+ armRetArgErrIf(((videoComp != OMX_VC_LUMINANCE) && (videoComp != OMX_VC_CHROMINANCE)), OMX_Sts_BadArgErr);
+
+ /* Calculate the DC scaler value */
+
+ /* linear intra DC mode */
+ if(shortVideoHeader)
+ {
+ dcScaler = 8;
+ }
+ /* nonlinear intra DC mode */
+ else
+ {
+
+ if (videoComp == OMX_VC_LUMINANCE)
+ {
+ if (QP >= 1 && QP <= 4)
+ {
+ dcScaler = 8;
+ }
+ else if (QP >= 5 && QP <= 8)
+ {
+ dcScaler = 2 * QP;
+ }
+ else if (QP >= 9 && QP <= 24)
+ {
+ dcScaler = QP + 8;
+ }
+ else
+ {
+ dcScaler = (2 * QP) - 16;
+ }
+ }
+
+ else if (videoComp == OMX_VC_CHROMINANCE)
+ {
+ if (QP >= 1 && QP <= 4)
+ {
+ dcScaler = 8;
+ }
+ else if (QP >= 5 && QP <= 24)
+ {
+ dcScaler = (QP + 13)/2;
+ }
+ else
+ {
+ dcScaler = QP - 6;
+ }
+ }
+ }
+ /* Dequant the DC value, this applies to both the methods */
+ pSrcDst[0] = pSrcDst[0] * dcScaler;
+
+ /* Saturate */
+ pSrcDst[0] = armClip (-2048, 2047, pSrcDst[0]);
+
+ /* Second Inverse quantisation method */
+ for (coeffCount = 1; coeffCount < 64; coeffCount++)
+ {
+ /* check sign */
+ Sign = armSignCheck (pSrcDst[coeffCount]);
+
+ if (QP & 0x1)
+ {
+ pSrcDst[coeffCount] = (2* armAbs(pSrcDst[coeffCount]) + 1) * QP;
+ pSrcDst[coeffCount] *= Sign;
+ }
+ else
+ {
+ pSrcDst[coeffCount] =
+ (2* armAbs(pSrcDst[coeffCount]) + 1) * QP - 1;
+ pSrcDst[coeffCount] *= Sign;
+ }
+
+ /* Saturate */
+ pSrcDst[coeffCount] = armClip (-2048, 2047, pSrcDst[coeffCount]);
+ }
+ return OMX_Sts_NoErr;
+
+}
+
+/* End of file */
+
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_TransRecBlockCoef_inter.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_TransRecBlockCoef_inter.c
new file mode 100644
index 0000000..6e0c59b
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_TransRecBlockCoef_inter.c
@@ -0,0 +1,108 @@
+/**
+ *
+ * File Name: omxVCM4P2_TransRecBlockCoef_inter.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules DCT->quant and reconstructing the inter texture data
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armCOMM.h"
+
+
+/**
+ * Function: omxVCM4P2_TransRecBlockCoef_inter (6.2.4.4.5)
+ *
+ * Description:
+ * Implements DCT, and quantizes the DCT coefficients of the inter block
+ * while reconstructing the texture residual. There is no boundary check for
+ * the bit stream buffer.
+ *
+ * Input Arguments:
+ *
+ * pSrc -pointer to the residuals to be encoded; must be aligned on an
+ * 16-byte boundary.
+ * QP - quantization parameter.
+ * shortVideoHeader - binary flag indicating presence of short_video_header;
+ * shortVideoHeader==1 selects linear intra DC mode, and
+ * shortVideoHeader==0 selects non linear intra DC mode.
+ *
+ * Output Arguments:
+ *
+ * pDst - pointer to the quantized DCT coefficients buffer; must be aligned
+ * on a 16-byte boundary.
+ * pRec - pointer to the reconstructed texture residuals; must be aligned
+ * on a 16-byte boundary.
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - bad arguments:
+ * - At least one of the following pointers is either NULL or
+ * not 16-byte aligned:
+ * - pSrc
+ * - pDst
+ * - pRec
+ * - QP <= 0 or QP >= 32.
+ *
+ */
+
+OMXResult omxVCM4P2_TransRecBlockCoef_inter(
+ const OMX_S16 *pSrc,
+ OMX_S16 * pDst,
+ OMX_S16 * pRec,
+ OMX_U8 QP,
+ OMX_INT shortVideoHeader
+)
+{
+ /* 64 elements are needed but to align it to 16 bytes need
+ 8 more elements of padding */
+ OMX_S16 tempBuffer[72];
+ OMX_S16 *pTempBuffer;
+ OMX_INT i;
+
+ /* Aligning the local buffers */
+ pTempBuffer = armAlignTo16Bytes(tempBuffer);
+
+ /* Argument error checks */
+ armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pRec == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs16ByteAligned(pSrc), OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs16ByteAligned(pRec), OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs16ByteAligned(pDst), OMX_Sts_BadArgErr);
+ armRetArgErrIf(((QP <= 0) || (QP >= 32)), OMX_Sts_BadArgErr);
+
+ omxVCM4P2_DCT8x8blk (pSrc, pDst);
+ omxVCM4P2_QuantInter_I(
+ pDst,
+ QP,
+ shortVideoHeader);
+
+ for (i = 0; i < 64; i++)
+ {
+ pTempBuffer[i] = pDst[i];
+ }
+
+ omxVCM4P2_QuantInvInter_I(
+ pTempBuffer,
+ QP);
+ omxVCM4P2_IDCT8x8blk (pTempBuffer, pRec);
+
+ return OMX_Sts_NoErr;
+}
+
+/* End of file */
+
+
diff --git a/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_TransRecBlockCoef_intra.c b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_TransRecBlockCoef_intra.c
new file mode 100644
index 0000000..dd444f9
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/omxdl/reference/vc/m4p2/src/omxVCM4P2_TransRecBlockCoef_intra.c
@@ -0,0 +1,260 @@
+/**
+ *
+ * File Name: omxVCM4P2_TransRecBlockCoef_intra.c
+ * OpenMAX DL: v1.0.2
+ * Revision: 9641
+ * Date: Thursday, February 7, 2008
+ *
+ * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
+ *
+ *
+ *
+ * Description:
+ * Contains modules DCT->quant and reconstructing the intra texture data
+ *
+ */
+
+#include "omxtypes.h"
+#include "armOMX.h"
+#include "omxVC.h"
+
+#include "armCOMM.h"
+#include "armVC.h"
+
+
+/**
+ * Function: omxVCM4P2_TransRecBlockCoef_intra (6.2.4.4.4)
+ *
+ * Description:
+ * Quantizes the DCT coefficients, implements intra block AC/DC coefficient
+ * prediction, and reconstructs the current intra block texture for prediction
+ * on the next frame. Quantized row and column coefficients are returned in
+ * the updated coefficient buffers.
+ *
+ * Input Arguments:
+ *
+ * pSrc - pointer to the pixels of current intra block; must be aligned on
+ * an 8-byte boundary.
+ * pPredBufRow - pointer to the coefficient row buffer containing
+ * ((num_mb_per_row * 2 + 1) * 8) elements of type OMX_S16.
+ * Coefficients are organized into blocks of eight as described
+ * below (Internal Prediction Coefficient Update Procedures). The
+ * DC coefficient is first, and the remaining buffer locations
+ * contain the quantized AC coefficients. Each group of eight row
+ * buffer elements combined with one element eight elements ahead
+ * contains the coefficient predictors of the neighboring block
+ * that is spatially above or to the left of the block currently to
+ * be decoded. A negative-valued DC coefficient indicates that this
+ * neighboring block is not INTRA-coded or out of bounds, and
+ * therefore the AC and DC coefficients are invalid. Pointer must
+ * be aligned on an 8-byte boundary.
+ * pPredBufCol - pointer to the prediction coefficient column buffer
+ * containing 16 elements of type OMX_S16. Coefficients are
+ * organized as described in section 6.2.2.5. Pointer must be
+ * aligned on an 8-byte boundary.
+ * pSumErr - pointer to a flag indicating whether or not AC prediction is
+ * required; AC prediction is enabled if *pSumErr >=0, but the
+ * value is not used for coefficient prediction, i.e., the sum of
+ * absolute differences starts from 0 for each call to this
+ * function. Otherwise AC prediction is disabled if *pSumErr < 0 .
+ * blockIndex - block index indicating the component type and position, as
+ * defined in [ISO14496-2], subclause 6.1.3.8.
+ * curQp - quantization parameter of the macroblock to which the current
+ * block belongs
+ * pQpBuf - pointer to a 2-element quantization parameter buffer; pQpBuf[0]
+ * contains the quantization parameter associated with the 8x8
+ * block left of the current block (QPa), and pQpBuf[1] contains
+ * the quantization parameter associated with the 8x8 block above
+ * the current block (QPc). In the event that the corresponding
+ * block is outside of the VOP bound, the Qp value will not affect
+ * the intra prediction process, as described in [ISO14496-2],
+ * sub-clause 7.4.3.3, Adaptive AC Coefficient Prediction.
+ * srcStep - width of the source buffer; must be a multiple of 8.
+ * dstStep - width of the reconstructed destination buffer; must be a
+ * multiple of 16.
+ * shortVideoHeader - binary flag indicating presence of
+ * short_video_header; shortVideoHeader==1 selects linear intra DC
+ * mode, and shortVideoHeader==0 selects non linear intra DC mode.
+ *
+ * Output Arguments:
+ *
+ * pDst - pointer to the quantized DCT coefficient buffer; pDst[0] contains
+ * the predicted DC coefficient; the remaining entries contain the
+ * quantized AC coefficients (without prediction). The pointer
+ * pDstmust be aligned on a 16-byte boundary.
+ * pRec - pointer to the reconstructed texture; must be aligned on an
+ * 8-byte boundary.
+ * pPredBufRow - pointer to the updated coefficient row buffer
+ * pPredBufCol - pointer to the updated coefficient column buffer
+ * pPreACPredict - if prediction is enabled, the parameter points to the
+ * start of the buffer containing the coefficient differences for
+ * VLC encoding. The entry pPreACPredict[0]indicates prediction
+ * direction for the current block and takes one of the following
+ * values: OMX_VC_NONE (prediction disabled), OMX_VC_HORIZONTAL, or
+ * OMX_VC_VERTICAL. The entries
+ * pPreACPredict[1]-pPreACPredict[7]contain predicted AC
+ * coefficients. If prediction is disabled (*pSumErr<0) then the
+ * contents of this buffer are undefined upon return from the
+ * function
+ * pSumErr - pointer to the value of the accumulated AC coefficient errors,
+ * i.e., sum of the absolute differences between predicted and
+ * unpredicted AC coefficients
+ *
+ * Return Value:
+ *
+ * OMX_Sts_NoErr - no error
+ * OMX_Sts_BadArgErr - Bad arguments:
+ * - At least one of the following pointers is NULL: pSrc, pDst, pRec,
+ * pCoefBufRow, pCoefBufCol, pQpBuf, pPreACPredict, pSumErr.
+ * - blockIndex < 0 or blockIndex >= 10;
+ * - curQP <= 0 or curQP >= 32.
+ * - srcStep, or dstStep <= 0 or not a multiple of 8.
+ * - pDst is not 16-byte aligned: .
+ * - At least one of the following pointers is not 8-byte aligned:
+ * pSrc, pRec.
+ *
+ * Note: The coefficient buffers must be updated in accordance with the
+ * update procedures defined in section in 6.2.2.
+ *
+ */
+
+OMXResult omxVCM4P2_TransRecBlockCoef_intra(
+ const OMX_U8 *pSrc,
+ OMX_S16 * pDst,
+ OMX_U8 * pRec,
+ OMX_S16 *pPredBufRow,
+ OMX_S16 *pPredBufCol,
+ OMX_S16 * pPreACPredict,
+ OMX_INT *pSumErr,
+ OMX_INT blockIndex,
+ OMX_U8 curQp,
+ const OMX_U8 *pQpBuf,
+ OMX_INT srcStep,
+ OMX_INT dstStep,
+ OMX_INT shortVideoHeader
+)
+{
+ /* 64 elements are needed but to align it to 16 bytes need
+ 8 more elements of padding */
+ OMX_S16 tempBuf1[79], tempBuf2[79];
+ OMX_S16 tempBuf3[79];
+ OMX_S16 *pTempBuf1, *pTempBuf2,*pTempBuf3;
+ OMXVCM4P2VideoComponent videoComp;
+ OMX_U8 flag;
+ OMX_INT x, y, count, predDir;
+ OMX_INT predQP, ACPredFlag;
+
+
+ /* Aligning the local buffers */
+ pTempBuf1 = armAlignTo16Bytes(tempBuf1);
+ pTempBuf2 = armAlignTo16Bytes(tempBuf2);
+ pTempBuf3 = armAlignTo16Bytes(tempBuf3);
+
+ /* Argument error checks */
+ armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pRec == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs8ByteAligned(pSrc), OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs8ByteAligned(pRec), OMX_Sts_BadArgErr);
+ armRetArgErrIf(!armIs16ByteAligned(pDst), OMX_Sts_BadArgErr);
+ armRetArgErrIf(pPredBufRow == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pPredBufCol == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pPreACPredict == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pSumErr == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf(pQpBuf == NULL, OMX_Sts_BadArgErr);
+ armRetArgErrIf((srcStep <= 0) || (dstStep <= 0) ||
+ (dstStep & 7) || (srcStep & 7)
+ , OMX_Sts_BadArgErr);
+ armRetArgErrIf((blockIndex < 0) || (blockIndex > 9), OMX_Sts_BadArgErr);
+
+ armRetArgErrIf((curQp <= 0) || (curQp >=32), OMX_Sts_BadArgErr);
+
+
+ /* Setting the videoComp */
+ if (blockIndex <= 3)
+ {
+ videoComp = OMX_VC_LUMINANCE;
+ }
+ else
+ {
+ videoComp = OMX_VC_CHROMINANCE;
+ }
+ /* Converting from 2-d to 1-d buffer */
+ for (y = 0, count = 0; y < 8; y++)
+ {
+ for(x= 0; x < 8; x++, count++)
+ {
+ pTempBuf1[count] = pSrc[(y*srcStep) + x];
+ }
+ }
+
+ omxVCM4P2_DCT8x8blk (pTempBuf1, pTempBuf2);
+ omxVCM4P2_QuantIntra_I(
+ pTempBuf2,
+ curQp,
+ blockIndex,
+ shortVideoHeader);
+
+ /* Converting from 1-D to 2-D buffer */
+ for (y = 0, count = 0; y < 8; y++)
+ {
+ for(x = 0; x < 8; x++, count++)
+ {
+ /* storing tempbuf2 to tempbuf1 */
+ pTempBuf1[count] = pTempBuf2[count];
+ pDst[(y*dstStep) + x] = pTempBuf2[count];
+ }
+ }
+
+ /* AC and DC prediction */
+ armVCM4P2_SetPredDir(
+ blockIndex,
+ pPredBufRow,
+ pPredBufCol,
+ &predDir,
+ &predQP,
+ pQpBuf);
+
+ armRetDataErrIf(((predQP <= 0) || (predQP >= 32)), OMX_Sts_BadArgErr);
+
+ flag = 1;
+ if (*pSumErr < 0)
+ {
+ ACPredFlag = 0;
+ }
+ else
+ {
+ ACPredFlag = 1;
+ }
+
+ armVCM4P2_ACDCPredict(
+ pTempBuf2,
+ pPreACPredict,
+ pPredBufRow,
+ pPredBufCol,
+ curQp,
+ predQP,
+ predDir,
+ ACPredFlag,
+ videoComp,
+ flag,
+ pSumErr);
+
+ /* Reconstructing the texture data */
+ omxVCM4P2_QuantInvIntra_I(
+ pTempBuf1,
+ curQp,
+ videoComp,
+ shortVideoHeader);
+ omxVCM4P2_IDCT8x8blk (pTempBuf1, pTempBuf3);
+ for(count = 0; count < 64; count++)
+ {
+ pRec[count] = armMax(0,pTempBuf3[count]);
+ }
+
+ return OMX_Sts_NoErr;
+}
+
+/* End of file */
+
+