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_DecodeChromaDcCoeffsToPairCAVLC.c
21 * OpenMAX DL: v1.0.2
22 * Revision:   9641
23 * Date:       Thursday, February 7, 2008
24 *
25 *
26 *
27 *
28 * H.264 decode coefficients module
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 * Function:  omxVCM4P10_DecodeChromaDcCoeffsToPairCAVLC   (6.3.4.1.1)
41 *
42 * Description:
43 * Performs CAVLC decoding and inverse raster scan for a 2x2 block of
44 * ChromaDCLevel.  The decoded coefficients in the packed position-coefficient
45 * buffer are stored in reverse zig-zag order, i.e., the first buffer element
46 * contains the last non-zero postion-coefficient pair of the block. Within
47 * each position-coefficient pair, the position entry indicates the
48 * raster-scan position of the coefficient, while the coefficient entry
49 * contains the coefficient value.
50 *
51 * Input Arguments:
52 *
53 *   ppBitStream - Double pointer to current byte in bit stream buffer
54 *   pOffset - Pointer to current bit position in the byte pointed to by
55 *            *ppBitStream; valid in the range [0,7].
56 *
57 * Output Arguments:
58 *
59 *   ppBitStream - *ppBitStream is updated after each block is decoded
60 *   pOffset - *pOffset is updated after each block is decoded
61 *   pNumCoeff - Pointer to the number of nonzero coefficients in this block
62 *   ppPosCoefBuf - Double pointer to destination residual
63 *            coefficient-position pair buffer.  Buffer position
64 *            (*ppPosCoefBuf) is updated upon return, unless there are only
65 *            zero coefficients in the currently decoded block.  In this case
66 *            the caller is expected to bypass the transform/dequantization of
67 *            the empty blocks.
68 *
69 * Return Value:
70 *
71 *    OMX_Sts_NoErr, if the function runs without error.
72 *
73 *    OMX_Sts_BadArgErr - bad arguments: if one of the following cases occurs:
74 *    -    ppBitStream or pOffset is NULL.
75 *    -    ppPosCoefBuf or pNumCoeff is NULL.
76 *    OMX_Sts_Err - if one of the following is true:
77 *    -    an illegal code is encountered in the bitstream
78 *
79 */
80
81OMXResult omxVCM4P10_DecodeChromaDcCoeffsToPairCAVLC (
82     const OMX_U8** ppBitStream,
83     OMX_S32* pOffset,
84     OMX_U8* pNumCoeff,
85     OMX_U8** ppPosCoefbuf
86 )
87
88{
89    armRetArgErrIf(ppBitStream==NULL   , OMX_Sts_BadArgErr);
90    armRetArgErrIf(*ppBitStream==NULL  , OMX_Sts_BadArgErr);
91    armRetArgErrIf(pOffset==NULL       , OMX_Sts_BadArgErr);
92    armRetArgErrIf(*pOffset<0          , OMX_Sts_BadArgErr);
93    armRetArgErrIf(*pOffset>7          , OMX_Sts_BadArgErr);
94    armRetArgErrIf(pNumCoeff==NULL     , OMX_Sts_BadArgErr);
95    armRetArgErrIf(ppPosCoefbuf==NULL  , OMX_Sts_BadArgErr);
96    armRetArgErrIf(*ppPosCoefbuf==NULL , OMX_Sts_BadArgErr);
97
98    return armVCM4P10_DecodeCoeffsToPair(ppBitStream, pOffset, pNumCoeff,
99                                         ppPosCoefbuf, 4, 4);
100
101}
102