Home | History | Annotate | Download | only in api
      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:  armCOMM_Bitstream.h
     20  * OpenMAX DL: v1.0.2
     21  * Revision:   12290
     22  * Date:       Wednesday, April 9, 2008
     23  *
     24  *
     25  *
     26  *
     27  * File: armCOMM_Bitstream.h
     28  * Brief: Declares common API's/Data types used across the OpenMax Encoders/Decoders.
     29  *
     30  */
     31 
     32 #ifndef _armCodec_H_
     33 #define _armCodec_H_
     34 
     35 #include "omxtypes.h"
     36 
     37 typedef struct {
     38     OMX_U8   codeLen;
     39     OMX_U32	 codeWord;
     40 } ARM_VLC32;
     41 
     42 /* The above should be renamed as "ARM_VLC32" */
     43 
     44 /**
     45  * Function: armLookAheadBits()
     46  *
     47  * Description:
     48  * Get the next N bits from the bitstream without advancing the bitstream pointer
     49  *
     50  * Parameters:
     51  * [in]     **ppBitStream
     52  * [in]     *pOffset
     53  * [in]     N=1...32
     54  *
     55  * Returns  Value
     56  */
     57 
     58 OMX_U32 armLookAheadBits(const OMX_U8 **ppBitStream, OMX_INT *pOffset, OMX_INT N);
     59 
     60 /**
     61  * Function: armGetBits()
     62  *
     63  * Description:
     64  * Read N bits from the bitstream
     65  *
     66  * Parameters:
     67  * [in]     *ppBitStream
     68  * [in]     *pOffset
     69  * [in]     N=1..32
     70  *
     71  * [out]    *ppBitStream
     72  * [out]    *pOffset
     73  * Returns  Value
     74  */
     75 
     76 OMX_U32 armGetBits(const OMX_U8 **ppBitStream, OMX_INT *pOffset, OMX_INT N);
     77 
     78 /**
     79  * Function: armByteAlign()
     80  *
     81  * Description:
     82  * Align the pointer *ppBitStream to the next byte boundary
     83  *
     84  * Parameters:
     85  * [in]     *ppBitStream
     86  * [in]     *pOffset
     87  *
     88  * [out]    *ppBitStream
     89  * [out]    *pOffset
     90  *
     91  **/
     92 
     93 OMXVoid armByteAlign(const OMX_U8 **ppBitStream,OMX_INT *pOffset);
     94 
     95 /**
     96  * Function: armSkipBits()
     97  *
     98  * Description:
     99  * Skip N bits from the value at *ppBitStream
    100  *
    101  * Parameters:
    102  * [in]     *ppBitStream
    103  * [in]     *pOffset
    104  * [in]     N
    105  *
    106  * [out]    *ppBitStream
    107  * [out]    *pOffset
    108  *
    109  **/
    110 
    111 OMXVoid armSkipBits(const OMX_U8 **ppBitStream,OMX_INT *pOffset,OMX_INT N);
    112 
    113 /***************************************
    114  * Variable bit length Decode
    115  ***************************************/
    116 
    117 /**
    118  * Function: armUnPackVLC32()
    119  *
    120  * Description:
    121  * Variable length decode of variable length symbol (max size 32 bits) read from
    122  * the bit stream pointed by *ppBitStream at *pOffset by using the table
    123  * pointed by pCodeBook
    124  *
    125  * Parameters:
    126  * [in]     **ppBitStream
    127  * [in]     *pOffset
    128  * [in]     pCodeBook
    129  *
    130  * [out]    **ppBitStream
    131  * [out]    *pOffset
    132  *
    133  * Returns : Code Book Index if successfull.
    134  *         : "ARM_NO_CODEBOOK_INDEX = 0xFFFF" if search fails.
    135  **/
    136 
    137 #define ARM_NO_CODEBOOK_INDEX (OMX_U16)(0xFFFF)
    138 
    139 OMX_U16 armUnPackVLC32(
    140     const OMX_U8 **ppBitStream,
    141     OMX_INT *pOffset,
    142     const ARM_VLC32 *pCodeBook
    143 );
    144 
    145 /***************************************
    146  * Fixed bit length Encode
    147  ***************************************/
    148 
    149 /**
    150  * Function: armPackBits
    151  *
    152  * Description:
    153  * Pack a VLC code word into the bitstream
    154  *
    155  * Remarks:
    156  *
    157  * Parameters:
    158  * [in]	ppBitStream		pointer to the pointer to the current byte
    159  *                      in the bit stream.
    160  * [in]	pOffset	        pointer to the bit position in the byte
    161  *                      pointed by *ppBitStream. Valid within 0
    162  *                      to 7.
    163  * [in]	codeWord		Code word that need to be inserted in to the
    164  *                          bitstream
    165  * [in]	codeLength		Length of the code word valid range 1...32
    166  *
    167  * [out] ppBitStream	*ppBitStream is updated after the block is encoded,
    168  *	                        so that it points to the current byte in the bit
    169  *							stream buffer.
    170  * [out] pBitOffset		*pBitOffset is updated so that it points to the
    171  *							current bit position in the byte pointed by
    172  *							*ppBitStream.
    173  *
    174  * Return Value:
    175  * Standard OMX_RESULT result. See enumeration for possible result codes.
    176  *
    177  */
    178 
    179 OMXResult armPackBits (
    180     OMX_U8  **ppBitStream,
    181     OMX_INT *pOffset,
    182     OMX_U32 codeWord,
    183     OMX_INT codeLength
    184 );
    185 
    186 /***************************************
    187  * Variable bit length Encode
    188  ***************************************/
    189 
    190 /**
    191  * Function: armPackVLC32
    192  *
    193  * Description:
    194  * Pack a VLC code word into the bitstream
    195  *
    196  * Remarks:
    197  *
    198  * Parameters:
    199  * [in]	ppBitStream		pointer to the pointer to the current byte
    200  *                      in the bit stream.
    201  * [in]	pBitOffset	    pointer to the bit position in the byte
    202  *                      pointed by *ppBitStream. Valid within 0
    203  *                      to 7.
    204  * [in]	 code     		VLC code word that need to be inserted in to the
    205  *                      bitstream
    206  *
    207  * [out] ppBitStream	*ppBitStream is updated after the block is encoded,
    208  *	                    so that it points to the current byte in the bit
    209  *						stream buffer.
    210  * [out] pBitOffset		*pBitOffset is updated so that it points to the
    211  *						current bit position in the byte pointed by
    212  *						*ppBitStream.
    213  *
    214  * Return Value:
    215  * Standard OMX_RESULT result. See enumeration for possible result codes.
    216  *
    217  */
    218 
    219 OMXResult armPackVLC32 (
    220     OMX_U8 **ppBitStream,
    221     OMX_INT *pBitOffset,
    222     ARM_VLC32 code
    223 );
    224 
    225 #endif      /*_armCodec_H_*/
    226 
    227 /*End of File*/
    228