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 *
20 * File Name:  omxVCM4P10_DeblockLuma_I.c
21 * OpenMAX DL: v1.0.2
22 * Revision:   9641
23 * Date:       Thursday, February 7, 2008
24 *
25 *
26 *
27 *
28 * H.264 luma deblock
29 *
30 */
31
32#include "omxtypes.h"
33#include "armOMX.h"
34#include "omxVC.h"
35
36#include "armCOMM.h"
37#include "armVC.h"
38
39
40/**
41 * Function:  omxVCM4P10_DeblockLuma_I   (6.3.3.3.5)
42 *
43 * Description:
44 * This function performs in-place deblock filtering the horizontal and
45 * vertical edges of a luma macroblock (16x16).
46 *
47 * Input Arguments:
48 *
49 *   pSrcDst - pointer to the input macroblock; must be 16-byte aligned.
50 *   srcdstStep - image width; must be a multiple of 16.
51 *   pAlpha - pointer to a 2x2 table of alpha thresholds, organized as
52 *            follows: {external vertical edge, internal vertical edge,
53 *            external horizontal edge, internal horizontal edge }.  Per
54 *            [ISO14496-10] alpha values must be in the range [0,255].
55 *   pBeta - pointer to a 2x2 table of beta thresholds, organized as follows:
56 *            {external vertical edge, internal vertical edge, external
57 *            horizontal edge, internal horizontal edge }.  Per [ISO14496-10]
58 *            beta values must be in the range [0,18].
59 *   pThresholds - pointer to a 16x2 table of threshold (TC0), organized as
60 *            follows: {values for the left or above edge of each 4x4 block,
61 *            arranged in vertical block order and then in horizontal block
62 *            order}; must be aligned on a 4-byte boundary.  Per [ISO14496-10]
63 *            values must be in the range [0,25].
64 *   pBS - pointer to a 16x2 table of BS parameters arranged in scan block
65 *            order for vertical edges and then horizontal edges; valid in the
66 *            range [0,4] with the following restrictions: i) pBS[i]== 4 may
67 *            occur only for 0<=i<=3, ii) pBS[i]== 4 if and only if pBS[i^3]==
68 *            4. Must be 4-byte aligned.
69 *
70 * Output Arguments:
71 *
72 *   pSrcDst - pointer to filtered output macroblock.
73 *
74 * Return Value:
75 *
76 *    OMX_Sts_NoErr - no error
77 *    OMX_Sts_BadArgErr - bad arguments
78 *    -     one or more of the following pointers is NULL: pSrcDst, pAlpha,
79 *              pBeta, pThresholds or pBS. pSrcDst is not 16-byte aligned.
80 *              either pThresholds or pBS is not aligned on a 4-byte boundary.
81 *    -    one or more entries in the table pAlpha[0..3] is outside the range
82 *              [0,255].
83 *    -    one or more entries in the table pBeta[0..3] is outside the range
84 *              [0,18].
85 *    -    one or more entries in the table pThresholds[0..31]is outside of
86 *              the range [0,25].
87 *    -    pBS is out of range, i.e., one of the following conditions is true:
88 *              pBS[i]<0, pBS[i]>4, pBS[i]==4 for i>=4, or
89 *             (pBS[i]==4 && pBS[i^3]!=4) for 0<=i<=3.
90 *    -    srcdstStep is not a multiple of 16.
91 *
92 */
93
94OMXResult omxVCM4P10_DeblockLuma_I(
95	OMX_U8* pSrcDst,
96	OMX_S32 srcdstStep,
97	const OMX_U8* pAlpha,
98	const OMX_U8* pBeta,
99	const OMX_U8* pThresholds,
100	const OMX_U8 *pBS
101)
102{
103    OMXResult errorCode;
104
105    armRetArgErrIf(pSrcDst == NULL,             OMX_Sts_BadArgErr);
106    armRetArgErrIf(armNot16ByteAligned(pSrcDst), OMX_Sts_BadArgErr);
107    armRetArgErrIf(srcdstStep & 15,              OMX_Sts_BadArgErr);
108    armRetArgErrIf(pAlpha == NULL,              OMX_Sts_BadArgErr);
109    armRetArgErrIf(pBeta == NULL,               OMX_Sts_BadArgErr);
110    armRetArgErrIf(pThresholds == NULL,         OMX_Sts_BadArgErr);
111    armRetArgErrIf(armNot4ByteAligned(pThresholds), OMX_Sts_BadArgErr);
112    armRetArgErrIf(pBS == NULL,                     OMX_Sts_BadArgErr);
113    armRetArgErrIf(armNot4ByteAligned(pBS),         OMX_Sts_BadArgErr);
114
115    errorCode = omxVCM4P10_FilterDeblockingLuma_VerEdge_I(
116        pSrcDst, srcdstStep, pAlpha, pBeta, pThresholds, pBS);
117
118    armRetArgErrIf(errorCode != OMX_Sts_NoErr, errorCode)
119
120    errorCode = omxVCM4P10_FilterDeblockingLuma_HorEdge_I(
121        pSrcDst, srcdstStep, pAlpha+2, pBeta+2, pThresholds+16, pBS+16);
122
123    return errorCode;
124}
125