armVCM4P2_SetPredDir.c revision 78e52bfac041d71ce53b5b13c2abf78af742b09d
1/*
2 * Copyright (C) 2007-2008 ARM Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17/**
18 *
19 * File Name:  armVCM4P2_SetPredDir.c
20 * OpenMAX DL: v1.0.2
21 * Revision:   9641
22 * Date:       Thursday, February 7, 2008
23 *
24 *
25 *
26 *
27 * Description:
28 * Contains module for detecting the prediction direction
29 *
30 */
31
32#include "omxtypes.h"
33#include "armOMX.h"
34
35#include "armVC.h"
36#include "armCOMM.h"
37
38/**
39 * Function: armVCM4P2_SetPredDir
40 *
41 * Description:
42 * Performs detecting the prediction direction
43 *
44 * Remarks:
45 *
46 * Parameters:
47 * [in] blockIndex  block index indicating the component type and
48 *                          position as defined in subclause 6.1.3.8, of ISO/IEC
49 *                          14496-2. Furthermore, indexes 6 to 9 indicate the
50 *                          alpha blocks spatially corresponding to luminance
51 *                          blocks 0 to 3 in the same macroblock.
52 * [in] pCoefBufRow pointer to the coefficient row buffer
53 * [in] pQpBuf      pointer to the quantization parameter buffer
54 * [out]    predQP      quantization parameter of the predictor block
55 * [out]    predDir     indicates the prediction direction which takes one
56 *                          of the following values:
57 *                          OMX_VC_HORIZONTAL    predict horizontally
58 *                          OMX_VC_VERTICAL      predict vertically
59 *
60 * Return Value:
61 * Standard OMXResult result. See enumeration for possible result codes.
62 *
63 */
64
65OMXResult armVCM4P2_SetPredDir(
66     OMX_INT blockIndex,
67     OMX_S16 *pCoefBufRow,
68     OMX_S16 *pCoefBufCol,
69     OMX_INT *predDir,
70     OMX_INT *predQP,
71     const OMX_U8 *pQpBuf
72)
73{
74    OMX_U8  blockDCLeft;
75    OMX_U8  blockDCTop;
76    OMX_U8  blockDCTopLeft;
77
78    if (blockIndex == 3)
79    {
80        blockDCTop = *(pCoefBufCol - 8);
81    }
82    else
83    {
84        blockDCTop = *pCoefBufRow;
85    }
86    blockDCLeft = *pCoefBufCol;
87    blockDCTopLeft = *(pCoefBufRow - 8);
88
89    if (armAbs(blockDCLeft - blockDCTopLeft) < armAbs(blockDCTopLeft \
90                                                        - blockDCTop))
91    {
92        *predDir = OMX_VC_VERTICAL;
93        *predQP = pQpBuf[1];
94    }
95    else
96    {
97        *predDir = OMX_VC_HORIZONTAL;
98        *predQP = pQpBuf[0];
99    }
100    return OMX_Sts_NoErr;
101}
102
103
104/*End of File*/
105