armVCM4P10_UnpackBlock2x2.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 *
20 * File Name:  armVCM4P10_UnpackBlock2x2.c
21 * OpenMAX DL: v1.0.2
22 * Revision:   9641
23 * Date:       Thursday, February 7, 2008
24 *
25 *
26 *
27 *
28 * H.264 inverse quantize and transform helper module
29 *
30 */
31
32#include "omxtypes.h"
33#include "armOMX.h"
34#include "omxVC.h"
35
36#include "armVC.h"
37
38/*
39 * Description
40 * Unpack a 2x2 block of coefficient-residual pair values
41 *
42 * Parameters:
43 * [in]	ppSrc	Double pointer to residual coefficient-position pair
44 *						buffer output by CALVC decoding
45 * [out]	ppSrc	*ppSrc is updated to the start of next non empty block
46 * [out]	pDst	Pointer to unpacked 4x4 block
47 */
48
49void armVCM4P10_UnpackBlock2x2(
50     const OMX_U8 **ppSrc,
51     OMX_S16* pDst
52)
53{
54    const OMX_U8 *pSrc = *ppSrc;
55    int i;
56    int Flag, Value;
57
58    for (i=0; i<4; i++)
59    {
60        pDst[i] = 0;
61    }
62
63    do
64    {
65        Flag  = *pSrc++;
66        if (Flag & 0x10)
67        {
68            /* 16 bit */
69            Value = *pSrc++;
70            Value = Value | ((*pSrc++)<<8);
71            if (Value & 0x8000)
72            {
73                Value -= 0x10000;
74            }
75        }
76        else
77        {
78            /* 8 bit */
79            Value = *pSrc++;
80            if (Value & 0x80)
81            {
82                Value -= 0x100;
83            }
84        }
85        i = Flag & 15;
86        pDst[i] = (OMX_S16)Value;
87    }
88    while ((Flag & 0x20)==0);
89
90    *ppSrc = pSrc;
91}
92
93/* End of file */
94