omxVCM4P10_FilterDeblockingChroma_HorEdge_I.c revision 0c1bc742181ded4930842b46e9507372f0b1b963
1/* ----------------------------------------------------------------
2 *
3 *
4 * File Name:  omxVCM4P10_FilterDeblockingChroma_HorEdge_I.c
5 * OpenMAX DL: v1.0.2
6 * Revision:   9641
7 * Date:       Thursday, February 7, 2008
8 *
9 * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
10 *
11 *
12 *
13 * H.264 chroma deblock module
14 *
15 */
16
17#include "omxtypes.h"
18#include "armOMX.h"
19#include "omxVC.h"
20
21#include "armCOMM.h"
22#include "armVC.h"
23
24/**
25 * Function:  omxVCM4P10_FilterDeblockingChroma_HorEdge_I   (6.3.3.3.4)
26 *
27 * Description:
28 * Performs in-place deblock filtering on the horizontal edges of the chroma
29 * macroblock (8x8).
30 *
31 * Input Arguments:
32 *
33 *   pSrcDst - pointer to the input macroblock; must be 8-byte aligned.
34 *   srcdstStep - array step; must be a multiple of 8.
35 *   pAlpha - array of size 2 containing alpha thresholds; the first element
36 *            contains the threshold for the external horizontal edge, and the
37 *            second element contains the threshold for internal horizontal
38 *            edge.  Per [ISO14496-10] alpha values must be in the range
39 *            [0,255].
40 *   pBeta - array of size 2 containing beta thresholds; the first element
41 *            contains the threshold for the external horizontal edge, and the
42 *            second element contains the threshold for the internal
43 *            horizontal edge.  Per [ISO14496-10] beta values must be in the
44 *            range [0,18].
45 *   pThresholds - array of size 8 containing thresholds, TC0, for the top
46 *            horizontal edge of each 2x4 chroma block, arranged in horizontal
47 *            block order; must be aligned on a 4-byte boundary.  Per
48 *            [ISO14496-10] values must be in the range [0,25].
49 *   pBS - array of size 16 containing BS parameters for each 2x2 chroma
50 *            block, arranged in horizontal block order; valid in the range
51 *            [0,4] with the following restrictions: i) pBS[i]== 4 may occur
52 *            only for 0<=i<=3, ii) pBS[i]== 4 if and only if pBS[i^3]== 4.
53 *            Must be 4-byte aligned.
54 *
55 * Output Arguments:
56 *
57 *   pSrcDst -Pointer to filtered output macroblock.
58 *
59 * Return Value:
60 *
61 *    OMX_Sts_NoErr, if the function runs without error.
62 *
63 *    OMX_Sts_BadArgErr, if one of the following cases occurs:
64 *    -    any of the following pointers is NULL:
65 *         pSrcDst, pAlpha, pBeta, pThresholds, or pBS.
66 *    -    pSrcDst is not 8-byte aligned.
67 *    -    srcdstStep is not a multiple of 8.
68 *    -    pThresholds is not 4-byte aligned.
69 *    -    pAlpha[0] and/or pAlpha[1] is outside the range [0,255].
70 *    -    pBeta[0] and/or pBeta[1] is outside the range [0,18].
71 *    -    One or more entries in the table pThresholds[0..7] is outside
72 *         of the range [0,25].
73 *    -    pBS is out of range, i.e., one of the following conditions is true:
74 *              pBS[i]<0, pBS[i]>4, pBS[i]==4 for i>=4, or
75 *              (pBS[i]==4 && pBS[i^3]!=4) for 0<=i<=3.
76 *    -    pBS is not 4-byte aligned.
77 *
78 */
79
80OMXResult omxVCM4P10_FilterDeblockingChroma_HorEdge_I(
81     OMX_U8* pSrcDst,
82     OMX_S32 srcdstStep,
83     const OMX_U8* pAlpha,
84     const OMX_U8* pBeta,
85     const OMX_U8* pThresholds,
86     const OMX_U8 *pBS
87 )
88{
89    int I, X, Y, Internal=0;
90
91    armRetArgErrIf(pSrcDst == NULL,                 OMX_Sts_BadArgErr);
92    armRetArgErrIf(armNot8ByteAligned(pSrcDst),     OMX_Sts_BadArgErr);
93    armRetArgErrIf(srcdstStep & 7,                  OMX_Sts_BadArgErr);
94    armRetArgErrIf(pAlpha == NULL,                  OMX_Sts_BadArgErr);
95    armRetArgErrIf(pBeta == NULL,                   OMX_Sts_BadArgErr);
96    armRetArgErrIf(pThresholds == NULL,             OMX_Sts_BadArgErr);
97    armRetArgErrIf(armNot4ByteAligned(pThresholds), OMX_Sts_BadArgErr);
98    armRetArgErrIf(pBS == NULL,                     OMX_Sts_BadArgErr);
99    armRetArgErrIf(armNot4ByteAligned(pBS),         OMX_Sts_BadArgErr);
100
101    for (Y=0; Y<8; Y+=4, Internal=1)
102    {
103        for (X=0; X<8; X++)
104        {
105            I = (X>>1)+4*(Y>>1);
106
107            armRetArgErrIf(pBS[I] > 4, OMX_Sts_BadArgErr)
108
109            armRetArgErrIf( (I > 3) && (pBS[I] == 4),
110                            OMX_Sts_BadArgErr)
111
112            armRetArgErrIf( (I < 4)       &&
113                          ( (pBS[I] == 4) && (pBS[I^1] != 4) ),
114                            OMX_Sts_BadArgErr)
115
116
117            /* Filter horizontal edge with q0 at (X,Y) */
118            armVCM4P10_DeBlockPixel(
119                pSrcDst + Y*srcdstStep + X,
120                srcdstStep,
121                pThresholds[(X>>1)+4*(Y>>2)],
122                pAlpha[Internal],
123                pBeta[Internal],
124                pBS[I],
125                1);
126        }
127    }
128
129    return OMX_Sts_NoErr;
130}
131