10c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
20c1bc742181ded4930842b46e9507372f0b1b963James Dong *
30c1bc742181ded4930842b46e9507372f0b1b963James Dong * File Name:  armCOMM_Bitstream.h
40c1bc742181ded4930842b46e9507372f0b1b963James Dong * OpenMAX DL: v1.0.2
50c1bc742181ded4930842b46e9507372f0b1b963James Dong * Revision:   12290
60c1bc742181ded4930842b46e9507372f0b1b963James Dong * Date:       Wednesday, April 9, 2008
70c1bc742181ded4930842b46e9507372f0b1b963James Dong *
80c1bc742181ded4930842b46e9507372f0b1b963James Dong * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
90c1bc742181ded4930842b46e9507372f0b1b963James Dong *
100c1bc742181ded4930842b46e9507372f0b1b963James Dong *
110c1bc742181ded4930842b46e9507372f0b1b963James Dong *
120c1bc742181ded4930842b46e9507372f0b1b963James Dong * File: armCOMM_Bitstream.h
130c1bc742181ded4930842b46e9507372f0b1b963James Dong * Brief: Declares common API's/Data types used across the OpenMax Encoders/Decoders.
140c1bc742181ded4930842b46e9507372f0b1b963James Dong *
150c1bc742181ded4930842b46e9507372f0b1b963James Dong */
160c1bc742181ded4930842b46e9507372f0b1b963James Dong
170c1bc742181ded4930842b46e9507372f0b1b963James Dong#ifndef _armCodec_H_
180c1bc742181ded4930842b46e9507372f0b1b963James Dong#define _armCodec_H_
190c1bc742181ded4930842b46e9507372f0b1b963James Dong
200c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxtypes.h"
210c1bc742181ded4930842b46e9507372f0b1b963James Dong
220c1bc742181ded4930842b46e9507372f0b1b963James Dongtypedef struct {
230c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_U8   codeLen;
240c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_U32	 codeWord;
250c1bc742181ded4930842b46e9507372f0b1b963James Dong} ARM_VLC32;
260c1bc742181ded4930842b46e9507372f0b1b963James Dong
270c1bc742181ded4930842b46e9507372f0b1b963James Dong/* The above should be renamed as "ARM_VLC32" */
280c1bc742181ded4930842b46e9507372f0b1b963James Dong
290c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
300c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armLookAheadBits()
310c1bc742181ded4930842b46e9507372f0b1b963James Dong *
320c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
330c1bc742181ded4930842b46e9507372f0b1b963James Dong * Get the next N bits from the bitstream without advancing the bitstream pointer
340c1bc742181ded4930842b46e9507372f0b1b963James Dong *
350c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters:
360c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]     **ppBitStream
370c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]     *pOffset
380c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]     N=1...32
390c1bc742181ded4930842b46e9507372f0b1b963James Dong *
400c1bc742181ded4930842b46e9507372f0b1b963James Dong * Returns  Value
410c1bc742181ded4930842b46e9507372f0b1b963James Dong */
420c1bc742181ded4930842b46e9507372f0b1b963James Dong
430c1bc742181ded4930842b46e9507372f0b1b963James DongOMX_U32 armLookAheadBits(const OMX_U8 **ppBitStream, OMX_INT *pOffset, OMX_INT N);
440c1bc742181ded4930842b46e9507372f0b1b963James Dong
450c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
460c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armGetBits()
470c1bc742181ded4930842b46e9507372f0b1b963James Dong *
480c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
490c1bc742181ded4930842b46e9507372f0b1b963James Dong * Read N bits from the bitstream
500c1bc742181ded4930842b46e9507372f0b1b963James Dong *
510c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters:
520c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]     *ppBitStream
530c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]     *pOffset
540c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]     N=1..32
550c1bc742181ded4930842b46e9507372f0b1b963James Dong *
560c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out]    *ppBitStream
570c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out]    *pOffset
580c1bc742181ded4930842b46e9507372f0b1b963James Dong * Returns  Value
590c1bc742181ded4930842b46e9507372f0b1b963James Dong */
600c1bc742181ded4930842b46e9507372f0b1b963James Dong
610c1bc742181ded4930842b46e9507372f0b1b963James DongOMX_U32 armGetBits(const OMX_U8 **ppBitStream, OMX_INT *pOffset, OMX_INT N);
620c1bc742181ded4930842b46e9507372f0b1b963James Dong
630c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
640c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armByteAlign()
650c1bc742181ded4930842b46e9507372f0b1b963James Dong *
660c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
670c1bc742181ded4930842b46e9507372f0b1b963James Dong * Align the pointer *ppBitStream to the next byte boundary
680c1bc742181ded4930842b46e9507372f0b1b963James Dong *
690c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters:
700c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]     *ppBitStream
710c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]     *pOffset
720c1bc742181ded4930842b46e9507372f0b1b963James Dong *
730c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out]    *ppBitStream
740c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out]    *pOffset
750c1bc742181ded4930842b46e9507372f0b1b963James Dong *
760c1bc742181ded4930842b46e9507372f0b1b963James Dong **/
770c1bc742181ded4930842b46e9507372f0b1b963James Dong
780c1bc742181ded4930842b46e9507372f0b1b963James DongOMXVoid armByteAlign(const OMX_U8 **ppBitStream,OMX_INT *pOffset);
790c1bc742181ded4930842b46e9507372f0b1b963James Dong
800c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
810c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armSkipBits()
820c1bc742181ded4930842b46e9507372f0b1b963James Dong *
830c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
840c1bc742181ded4930842b46e9507372f0b1b963James Dong * Skip N bits from the value at *ppBitStream
850c1bc742181ded4930842b46e9507372f0b1b963James Dong *
860c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters:
870c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]     *ppBitStream
880c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]     *pOffset
890c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]     N
900c1bc742181ded4930842b46e9507372f0b1b963James Dong *
910c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out]    *ppBitStream
920c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out]    *pOffset
930c1bc742181ded4930842b46e9507372f0b1b963James Dong *
940c1bc742181ded4930842b46e9507372f0b1b963James Dong **/
950c1bc742181ded4930842b46e9507372f0b1b963James Dong
960c1bc742181ded4930842b46e9507372f0b1b963James DongOMXVoid armSkipBits(const OMX_U8 **ppBitStream,OMX_INT *pOffset,OMX_INT N);
970c1bc742181ded4930842b46e9507372f0b1b963James Dong
980c1bc742181ded4930842b46e9507372f0b1b963James Dong/***************************************
990c1bc742181ded4930842b46e9507372f0b1b963James Dong * Variable bit length Decode
1000c1bc742181ded4930842b46e9507372f0b1b963James Dong ***************************************/
1010c1bc742181ded4930842b46e9507372f0b1b963James Dong
1020c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
1030c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armUnPackVLC32()
1040c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1050c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
1060c1bc742181ded4930842b46e9507372f0b1b963James Dong * Variable length decode of variable length symbol (max size 32 bits) read from
1070c1bc742181ded4930842b46e9507372f0b1b963James Dong * the bit stream pointed by *ppBitStream at *pOffset by using the table
1080c1bc742181ded4930842b46e9507372f0b1b963James Dong * pointed by pCodeBook
1090c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1100c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters:
1110c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]     **ppBitStream
1120c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]     *pOffset
1130c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]     pCodeBook
1140c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1150c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out]    **ppBitStream
1160c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out]    *pOffset
1170c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1180c1bc742181ded4930842b46e9507372f0b1b963James Dong * Returns : Code Book Index if successfull.
1190c1bc742181ded4930842b46e9507372f0b1b963James Dong *         : "ARM_NO_CODEBOOK_INDEX = 0xFFFF" if search fails.
1200c1bc742181ded4930842b46e9507372f0b1b963James Dong **/
1210c1bc742181ded4930842b46e9507372f0b1b963James Dong
1220c1bc742181ded4930842b46e9507372f0b1b963James Dong#define ARM_NO_CODEBOOK_INDEX (OMX_U16)(0xFFFF)
1230c1bc742181ded4930842b46e9507372f0b1b963James Dong
1240c1bc742181ded4930842b46e9507372f0b1b963James DongOMX_U16 armUnPackVLC32(
1250c1bc742181ded4930842b46e9507372f0b1b963James Dong    const OMX_U8 **ppBitStream,
1260c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_INT *pOffset,
1270c1bc742181ded4930842b46e9507372f0b1b963James Dong    const ARM_VLC32 *pCodeBook
1280c1bc742181ded4930842b46e9507372f0b1b963James Dong);
1290c1bc742181ded4930842b46e9507372f0b1b963James Dong
1300c1bc742181ded4930842b46e9507372f0b1b963James Dong/***************************************
1310c1bc742181ded4930842b46e9507372f0b1b963James Dong * Fixed bit length Encode
1320c1bc742181ded4930842b46e9507372f0b1b963James Dong ***************************************/
1330c1bc742181ded4930842b46e9507372f0b1b963James Dong
1340c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
1350c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armPackBits
1360c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1370c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
1380c1bc742181ded4930842b46e9507372f0b1b963James Dong * Pack a VLC code word into the bitstream
1390c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1400c1bc742181ded4930842b46e9507372f0b1b963James Dong * Remarks:
1410c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1420c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters:
1430c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	ppBitStream		pointer to the pointer to the current byte
1440c1bc742181ded4930842b46e9507372f0b1b963James Dong *                      in the bit stream.
1450c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	pOffset	        pointer to the bit position in the byte
1460c1bc742181ded4930842b46e9507372f0b1b963James Dong *                      pointed by *ppBitStream. Valid within 0
1470c1bc742181ded4930842b46e9507372f0b1b963James Dong *                      to 7.
1480c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	codeWord		Code word that need to be inserted in to the
1490c1bc742181ded4930842b46e9507372f0b1b963James Dong *                          bitstream
1500c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	codeLength		Length of the code word valid range 1...32
1510c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1520c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out] ppBitStream	*ppBitStream is updated after the block is encoded,
1530c1bc742181ded4930842b46e9507372f0b1b963James Dong *	                        so that it points to the current byte in the bit
1540c1bc742181ded4930842b46e9507372f0b1b963James Dong *							stream buffer.
1550c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out] pBitOffset		*pBitOffset is updated so that it points to the
1560c1bc742181ded4930842b46e9507372f0b1b963James Dong *							current bit position in the byte pointed by
1570c1bc742181ded4930842b46e9507372f0b1b963James Dong *							*ppBitStream.
1580c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1590c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value:
1600c1bc742181ded4930842b46e9507372f0b1b963James Dong * Standard OMX_RESULT result. See enumeration for possible result codes.
1610c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1620c1bc742181ded4930842b46e9507372f0b1b963James Dong */
1630c1bc742181ded4930842b46e9507372f0b1b963James Dong
1640c1bc742181ded4930842b46e9507372f0b1b963James DongOMXResult armPackBits (
1650c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_U8  **ppBitStream,
1660c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_INT *pOffset,
1670c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_U32 codeWord,
1680c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_INT codeLength
1690c1bc742181ded4930842b46e9507372f0b1b963James Dong);
1700c1bc742181ded4930842b46e9507372f0b1b963James Dong
1710c1bc742181ded4930842b46e9507372f0b1b963James Dong/***************************************
1720c1bc742181ded4930842b46e9507372f0b1b963James Dong * Variable bit length Encode
1730c1bc742181ded4930842b46e9507372f0b1b963James Dong ***************************************/
1740c1bc742181ded4930842b46e9507372f0b1b963James Dong
1750c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
1760c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armPackVLC32
1770c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1780c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
1790c1bc742181ded4930842b46e9507372f0b1b963James Dong * Pack a VLC code word into the bitstream
1800c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1810c1bc742181ded4930842b46e9507372f0b1b963James Dong * Remarks:
1820c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1830c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters:
1840c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	ppBitStream		pointer to the pointer to the current byte
1850c1bc742181ded4930842b46e9507372f0b1b963James Dong *                      in the bit stream.
1860c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	pBitOffset	    pointer to the bit position in the byte
1870c1bc742181ded4930842b46e9507372f0b1b963James Dong *                      pointed by *ppBitStream. Valid within 0
1880c1bc742181ded4930842b46e9507372f0b1b963James Dong *                      to 7.
1890c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	 code     		VLC code word that need to be inserted in to the
1900c1bc742181ded4930842b46e9507372f0b1b963James Dong *                      bitstream
1910c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1920c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out] ppBitStream	*ppBitStream is updated after the block is encoded,
1930c1bc742181ded4930842b46e9507372f0b1b963James Dong *	                    so that it points to the current byte in the bit
1940c1bc742181ded4930842b46e9507372f0b1b963James Dong *						stream buffer.
1950c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out] pBitOffset		*pBitOffset is updated so that it points to the
1960c1bc742181ded4930842b46e9507372f0b1b963James Dong *						current bit position in the byte pointed by
1970c1bc742181ded4930842b46e9507372f0b1b963James Dong *						*ppBitStream.
1980c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1990c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value:
2000c1bc742181ded4930842b46e9507372f0b1b963James Dong * Standard OMX_RESULT result. See enumeration for possible result codes.
2010c1bc742181ded4930842b46e9507372f0b1b963James Dong *
2020c1bc742181ded4930842b46e9507372f0b1b963James Dong */
2030c1bc742181ded4930842b46e9507372f0b1b963James Dong
2040c1bc742181ded4930842b46e9507372f0b1b963James DongOMXResult armPackVLC32 (
2050c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_U8 **ppBitStream,
2060c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_INT *pBitOffset,
2070c1bc742181ded4930842b46e9507372f0b1b963James Dong    ARM_VLC32 code
2080c1bc742181ded4930842b46e9507372f0b1b963James Dong);
2090c1bc742181ded4930842b46e9507372f0b1b963James Dong
2100c1bc742181ded4930842b46e9507372f0b1b963James Dong#endif      /*_armCodec_H_*/
2110c1bc742181ded4930842b46e9507372f0b1b963James Dong
2120c1bc742181ded4930842b46e9507372f0b1b963James Dong/*End of File*/
213