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:  omxVCCOMM_Copy16x16.c
20 * OpenMAX DL: v1.0.2
21 * Revision:   9641
22 * Date:       Thursday, February 7, 2008
23 *
24 *
25 *
26 * Description:
27 * MPEG4 16x16 Copy module
28 *
29 */
30
31#include "omxtypes.h"
32#include "armOMX.h"
33#include "omxVC.h"
34
35#include "armCOMM.h"
36
37/**
38 * Function:  omxVCCOMM_Copy16x16   (6.1.3.3.2)
39 *
40 * Description:
41 * Copies the reference 16x16 macroblock to the current macroblock.
42 *
43 * Input Arguments:
44 *
45 *   pSrc - pointer to the reference macroblock in the source frame; must be
46 *            aligned on a 16-byte boundary.
47 *   step - distance between the starts of consecutive lines in the reference
48 *            frame, in bytes; must be a multiple of 16 and must be larger
49 *            than or equal to 16.
50 *
51 * Output Arguments:
52 *
53 *   pDst - pointer to the destination macroblock; must be aligned on a
54 *            16-byte boundary.
55 *
56 * Return Value:
57 *
58 *    OMX_Sts_NoErr - no error
59 *    OMX_Sts_BadArgErr - bad arguments; returned under any of the following
60 *              conditions:
61 *    -   one or more of the following pointers is NULL: pSrc, pDst
62 *    -   one or more of the following pointers is not aligned on a 16-byte
63 *              boundary: pSrc, pDst
64 *    -    step <16 or step is not a multiple of 16.
65 *
66 */
67
68OMXResult omxVCCOMM_Copy16x16(
69		const OMX_U8 *pSrc,
70		OMX_U8 *pDst,
71		OMX_INT step)
72 {
73    /* Definitions and Initializations*/
74
75    OMX_INT count,index, x, y;
76
77    /* Argument error checks */
78    armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr);
79    armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
80    armRetArgErrIf(!armIs16ByteAligned(pSrc), OMX_Sts_BadArgErr);
81    armRetArgErrIf(!armIs16ByteAligned(pDst), OMX_Sts_BadArgErr);
82    armRetArgErrIf(((step < 16) || (step % 16)), OMX_Sts_BadArgErr);
83
84
85    /* Copying the ref 16x16 blk to the curr blk */
86    for (y = 0, count = 0, index = 0; y < 16; y++, count = count + step - 16)
87    {
88        for (x = 0; x < 16; x++, count++, index++)
89        {
90            pDst[index] = pSrc[count];
91        }
92    }
93    return OMX_Sts_NoErr;
94 }
95