1bebc99d6fa433c04139294a5057f8439d772dbd9James Dong /**
2bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
3bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * File Name:  omxVCM4P2_PredictReconCoefIntra.c
4bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * OpenMAX DL: v1.0.2
5bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Revision:   9641
6bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Date:       Thursday, February 7, 2008
7bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
8bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
9bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
10bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
11bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
12bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * File:        omxVCM4P2_PredictReconCoefIntra_S16.c
13bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Description: Contains modules for AC DC prediction
14bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
15bebc99d6fa433c04139294a5057f8439d772dbd9James Dong */
16bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
17bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "omxtypes.h"
18bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "armOMX.h"
19bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "omxVC.h"
20bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
21bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "armCOMM.h"
22bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "armVC.h"
23bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
24bebc99d6fa433c04139294a5057f8439d772dbd9James Dong/**
25bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Function:  omxVCM4P2_PredictReconCoefIntra   (6.2.5.4.3)
26bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
27bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Description:
28bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Performs adaptive DC/AC coefficient prediction for an intra block.  Prior
29bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * to the function call, prediction direction (predDir) should be selected as
30bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * specified in [ISO14496-2], subclause 7.4.3.1.
31bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
32bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Input Arguments:
33bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
34bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   pSrcDst - pointer to the coefficient buffer which contains the quantized
35bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *            coefficient residuals (PQF) of the current block; must be
36bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *            aligned on a 4-byte boundary.  The output coefficients are
37bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *            saturated to the range [-2048, 2047].
38bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   pPredBufRow - pointer to the coefficient row buffer; must be aligned on
39bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *            a 4-byte boundary.
40bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   pPredBufCol - pointer to the coefficient column buffer; must be aligned
41bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *            on a 4-byte boundary.
42bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   curQP - quantization parameter of the current block. curQP may equal to
43bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *            predQP especially when the current block and the predictor block
44bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *            are in the same macroblock.
45bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   predQP - quantization parameter of the predictor block
46bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   predDir - indicates the prediction direction which takes one of the
47bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *            following values: OMX_VC_HORIZONTAL - predict horizontally
48bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *            OMX_VC_VERTICAL - predict vertically
49bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   ACPredFlag - a flag indicating if AC prediction should be performed. It
50bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *            is equal to ac_pred_flag in the bit stream syntax of MPEG-4
51bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   videoComp - video component type (luminance or chrominance) of the
52bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *            current block
53bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
54bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Output Arguments:
55bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
56bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   pSrcDst - pointer to the coefficient buffer which contains the quantized
57bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *            coefficients (QF) of the current block
58bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   pPredBufRow - pointer to the updated coefficient row buffer
59bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   pPredBufCol - pointer to the updated coefficient column buffer  Note:
60bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *            Buffer update: Update the AC prediction buffer (both row and
61bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *            column buffer).
62bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
63bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Return Value:
64bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
65bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *    OMX_Sts_NoErr - no error
66bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *    OMX_Sts_BadArgErr - bad arguments, if:
67bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *        -    At least one of the pointers is NULL:
68bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *              pSrcDst, pPredBufRow, or pPredBufCol.
69bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *        -    curQP <= 0,
70bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *        -    predQP <= 0,
71bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *        -    curQP >31,
72bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *        -    predQP > 31,
73bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *        -    preDir exceeds [1,2]
74bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *        -    pSrcDst, pPredBufRow, or pPredBufCol is not 4-byte aligned.
75bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
76bebc99d6fa433c04139294a5057f8439d772dbd9James Dong */
77bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
78bebc99d6fa433c04139294a5057f8439d772dbd9James DongOMXResult omxVCM4P2_PredictReconCoefIntra(
79bebc99d6fa433c04139294a5057f8439d772dbd9James Dong     OMX_S16 * pSrcDst,
80bebc99d6fa433c04139294a5057f8439d772dbd9James Dong     OMX_S16 * pPredBufRow,
81bebc99d6fa433c04139294a5057f8439d772dbd9James Dong     OMX_S16 * pPredBufCol,
82bebc99d6fa433c04139294a5057f8439d772dbd9James Dong     OMX_INT curQP,
83bebc99d6fa433c04139294a5057f8439d772dbd9James Dong     OMX_INT predQP,
84bebc99d6fa433c04139294a5057f8439d772dbd9James Dong     OMX_INT predDir,
85bebc99d6fa433c04139294a5057f8439d772dbd9James Dong     OMX_INT ACPredFlag,
86bebc99d6fa433c04139294a5057f8439d772dbd9James Dong     OMXVCM4P2VideoComponent videoComp
87bebc99d6fa433c04139294a5057f8439d772dbd9James Dong )
88bebc99d6fa433c04139294a5057f8439d772dbd9James Dong{
89bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    OMX_U8 flag;
90bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    /* Argument error checks */
91bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf(pSrcDst == NULL, OMX_Sts_BadArgErr);
92bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf(pPredBufRow == NULL, OMX_Sts_BadArgErr);
93bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf(pPredBufCol == NULL, OMX_Sts_BadArgErr);
94bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf(curQP <= 0, OMX_Sts_BadArgErr);
95bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf(predQP <= 0, OMX_Sts_BadArgErr);
96bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf(curQP > 31, OMX_Sts_BadArgErr);
97bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf(predQP > 31, OMX_Sts_BadArgErr);
98bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf((predDir != 1) && (predDir != 2), OMX_Sts_BadArgErr);
99bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf(!armIs4ByteAligned(pSrcDst), OMX_Sts_BadArgErr);
100bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf(!armIs4ByteAligned(pPredBufRow), OMX_Sts_BadArgErr);
101bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf(!armIs4ByteAligned(pPredBufCol), OMX_Sts_BadArgErr);
102bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
103bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    flag = 0;
104bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    return armVCM4P2_ACDCPredict(
105bebc99d6fa433c04139294a5057f8439d772dbd9James Dong        pSrcDst,
106bebc99d6fa433c04139294a5057f8439d772dbd9James Dong        NULL,
107bebc99d6fa433c04139294a5057f8439d772dbd9James Dong        pPredBufRow,
108bebc99d6fa433c04139294a5057f8439d772dbd9James Dong        pPredBufCol,
109bebc99d6fa433c04139294a5057f8439d772dbd9James Dong        curQP,
110bebc99d6fa433c04139294a5057f8439d772dbd9James Dong        predQP,
111bebc99d6fa433c04139294a5057f8439d772dbd9James Dong        predDir,
112bebc99d6fa433c04139294a5057f8439d772dbd9James Dong        ACPredFlag,
113bebc99d6fa433c04139294a5057f8439d772dbd9James Dong        videoComp,
114bebc99d6fa433c04139294a5057f8439d772dbd9James Dong        flag,
115bebc99d6fa433c04139294a5057f8439d772dbd9James Dong        NULL);
116bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
117bebc99d6fa433c04139294a5057f8439d772dbd9James Dong}
118bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
119bebc99d6fa433c04139294a5057f8439d772dbd9James Dong/* End of file */
120bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
121bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
122