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: omxVCM4P2_DecodeVLCZigzag_Inter.c 20 * OpenMAX DL: v1.0.2 21 * Revision: 9641 22 * Date: Thursday, February 7, 2008 23 * 24 * 25 * 26 * 27 * Description: 28 * Contains modules for zigzag scanning and VLC decoding 29 * for inter block. 30 * 31 */ 32 33#include "omxtypes.h" 34#include "armOMX.h" 35#include "omxVC.h" 36 37#include "armVC.h" 38#include "armCOMM_Bitstream.h" 39#include "armCOMM.h" 40#include "armVCM4P2_Huff_Tables_VLC.h" 41#include "armVCM4P2_ZigZag_Tables.h" 42 43 44 45/** 46 * Function: omxVCM4P2_DecodeVLCZigzag_Inter (6.2.5.2.3) 47 * 48 * Description: 49 * Performs VLC decoding and inverse zigzag scan for one inter-coded block. 50 * 51 * Input Arguments: 52 * 53 * ppBitStream - double pointer to the current byte in the stream buffer 54 * pBitOffset - pointer to the next available bit in the current stream 55 * byte referenced by *ppBitStream. The parameter *pBitOffset is 56 * valid within the range [0-7]. 57 * shortVideoHeader - binary flag indicating presence of 58 * short_video_header; escape modes 0-3 are used if 59 * shortVideoHeader==0, and escape mode 4 is used when 60 * shortVideoHeader==1. 61 * 62 * Output Arguments: 63 * 64 * ppBitStream - *ppBitStream is updated after the block is decoded such 65 * that it points to the current byte in the stream buffer 66 * pBitOffset - *pBitOffset is updated after decoding such that it points 67 * to the next available bit in the stream byte referenced by 68 * *ppBitStream 69 * pDst - pointer to the coefficient buffer of current block; must be 70 * 4-byte aligned. 71 * 72 * Return Value: 73 * 74 * OMX_Sts_BadArgErr - bad arguments: 75 * - At least one of the following pointers is NULL: 76 * ppBitStream, *ppBitStream, pBitOffset, pDst 77 * - pDst is not 4-byte aligned 78 * - *pBitOffset exceeds [0,7] 79 * OMX_Sts_Err - status error, if: 80 * - At least one mark bit is equal to zero 81 * - Encountered an illegal stream code that cannot be found in the VLC table 82 * - Encountered an illegal code in the VLC FLC table 83 * - The number of coefficients is greater than 64 84 * 85 */ 86 87OMXResult omxVCM4P2_DecodeVLCZigzag_Inter( 88 const OMX_U8 ** ppBitStream, 89 OMX_INT * pBitOffset, 90 OMX_S16 * pDst, 91 OMX_INT shortVideoHeader 92) 93{ 94 OMX_U8 last,start = 0; 95 const OMX_U8 *pZigzagTable = armVCM4P2_aClassicalZigzagScan; 96 OMXResult errorCode; 97 98 /* Argument error checks */ 99 armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr); 100 armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr); 101 armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr); 102 armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr); 103 armRetArgErrIf(!armIs4ByteAligned(pDst), OMX_Sts_BadArgErr); 104 105 errorCode = armVCM4P2_GetVLCBits ( 106 ppBitStream, 107 pBitOffset, 108 pDst, 109 shortVideoHeader, 110 start, 111 &last, 112 11, 113 42, 114 2, 115 5, 116 armVCM4P2_InterL0RunIdx, 117 armVCM4P2_InterVlcL0, 118 armVCM4P2_InterL1RunIdx, 119 armVCM4P2_InterVlcL1, 120 armVCM4P2_InterL0LMAX, 121 armVCM4P2_InterL1LMAX, 122 armVCM4P2_InterL0RMAX, 123 armVCM4P2_InterL1RMAX, 124 pZigzagTable ); 125 armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode); 126 127 if (last == 0) 128 { 129 return OMX_Sts_Err; 130 } 131 return OMX_Sts_NoErr; 132} 133 134/* End of file */ 135 136