armVCM4P2_FillVLDBuffer.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_FillVLDBuffer.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 VLC get bits from the stream
29 *
30 */
31
32#include "omxtypes.h"
33#include "armOMX.h"
34
35#include "armVCM4P2_ZigZag_Tables.h"
36
37
38/**
39 * Function: armVCM4P2_FillVLDBuffer
40 *
41 * Description:
42 * Performs filling of the coefficient buffer according to the run, level
43 * and sign, also updates the index
44 *
45 * Parameters:
46 * [in]  storeRun        Stored Run value (count of zeros)
47 * [in]  storeLevel      Stored Level value (non-zero value)
48 * [in]  sign            Flag indicating the sign of level
49 * [in]  last            status of the last flag
50 * [in]  pIndex          pointer to coefficient index in 8x8 matrix
51 * [out] pIndex          pointer to updated coefficient index in 8x8
52 *                       matrix
53 * [in]  pZigzagTable    pointer to the zigzag tables
54 * [out] pDst            pointer to the coefficient buffer of current
55 *                       block. Should be 32-bit aligned
56 * Return Value:
57 * Standard OMXResult result. See enumeration for possible result codes.
58 *
59 */
60
61OMXResult armVCM4P2_FillVLDBuffer(
62    OMX_U32 storeRun,
63    OMX_S16 * pDst,
64    OMX_S16 storeLevel,
65    OMX_U8  sign,
66    OMX_U8  last,
67    OMX_U8  * pIndex,
68    const OMX_U8 * pZigzagTable
69)
70{
71    /* Store the zero's as per the run length count */
72    for (;storeRun > 0; storeRun--, (*pIndex)++)
73    {
74        pDst[pZigzagTable[*pIndex]] = 0;
75    }
76    /* Store the level depending on the sign*/
77    if (sign == 1)
78    {
79        pDst[pZigzagTable[*pIndex]] = -storeLevel;
80    }
81    else
82    {
83        pDst[pZigzagTable[*pIndex]] = storeLevel;
84    }
85    (*pIndex)++;
86
87    /* If last is 1, fill the remaining elments of the buffer with zeros */
88    if (last == 1)
89    {
90        while (*pIndex < 64)
91        {
92            pDst[pZigzagTable[*pIndex]] = 0;
93            (*pIndex)++;
94        }
95    }
96
97    return OMX_Sts_NoErr;
98}
99
100