M4_BitStreamParser.h revision 7c9d8018755adf1857571125ba1b3598c96ea506
1/* 2 * Copyright (C) 2004-2011 NXP Software 3 * Copyright (C) 2011 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17/** 18 ************************************************************************ 19 * @file M4_BitStreamParser.h 20 * @brief MPEG-4 File Format bit stream utility 21 * @note This file contains utility functions used to parse MPEG specific 22 * data structures. 23 ************************************************************************ 24*/ 25#ifndef __M4_BITSTREAMPARSER_H__ 26#define __M4_BITSTREAMPARSER_H__ 27 28#include "M4OSA_Types.h" 29 30/** 31* M4_BitStreamParser_Init. 32* 33* Allocates the context and initializes internal data 34* 35* @param pContext : A pointer to the context internally used by the package - ALLOCATED BY THE 36* FUNCTION (M4OSA_NULL if allocation fails) 37* @param bitStream : A pointer to the bitstream - must be 32 bits as access are 32 bits 38* @param size : The size of the bitstream in bytes 39* 40*/ 41void M4_BitStreamParser_Init(void** pContext, void* pBitStream, M4OSA_Int32 size); 42 43/** 44 ************************************************************************ 45 * @brief Clean up context 46 * @param pContext (IN/OUT) M4_BitStreamParser context. 47 ************************************************************************ 48*/ 49void M4_BitStreamParser_CleanUp(void* pContext); 50 51/** 52 ************************************************************************ 53 * @brief Read the next <length> bits in the bitstream. 54 * @note The function does not update the bitstream pointer. 55 * @param pContext (IN/OUT) M4_BitStreamParser context. 56 * @param length (IN) The number of bits to extract from the bitstream 57 * @return the read bits 58 ************************************************************************ 59*/ 60M4OSA_UInt32 M4_BitStreamParser_ShowBits(void* pContext, M4OSA_Int32 length); 61 62/** 63 ************************************************************************ 64 * @brief Increment the bitstream pointer of <length> bits. 65 * @param pContext (IN/OUT) M4_BitStreamParser context. 66 * @param length (IN) The number of bit to shift the bitstream 67 ************************************************************************ 68*/ 69void M4_BitStreamParser_FlushBits(void* pContext, M4OSA_Int32 length); 70 71/** 72 ************************************************************************ 73 * @brief Get a pointer to the current byte pointed by the bitstream pointer. 74 * It does not update the bitstream pointer 75 * 76 * @param pContext : A pointer to the context internally used by the package 77 * @param length : The number of bit to extract from the bitstream 78 * 79 * @returns the read bits 80*/ 81M4OSA_UInt32 M4_BitStreamParser_GetBits(void* pContext,M4OSA_Int32 bitPos, M4OSA_Int32 length); 82 83/** 84* M4_BitStreamParser_Restart resets the bitstream indexes. 85* 86* @param pContext : A pointer to the context internally used by the package 87* 88*/ 89void M4_BitStreamParser_Restart(void* pContext); 90 91/** 92 ************************************************************************ 93 * @brief Get a pointer to the current byte pointed by the bitstream pointer. 94 * @returns pointer to the current location in the bitstream 95 * @note It should be used carefully as the pointer is in the bitstream itself 96 * and no copy is made. 97 * @param pContext (IN/OUT) M4_BitStreamParser context. 98*/ 99M4OSA_UInt8* M4_BitStreamParser_GetCurrentbitStreamPointer(void* pContext); 100 101/** 102* M4_BitStreamParser_GetSize gets the size of the bitstream in bytes 103* 104* @param pContext : A pointer to the context internally used by the package 105* 106* @returns the size of the bitstream in bytes 107*/ 108M4OSA_Int32 M4_BitStreamParser_GetSize(void* pContext); 109 110void M4_MPEG4BitStreamParser_Init(void** pContext, void* pBitStream, M4OSA_Int32 size); 111 112/** 113* getMpegLengthFromInteger returns a decoded size value from an encoded one (SDL) 114* 115* @param pContext : A pointer to the context internally used by the package 116* @param val : encoded value 117* 118* @returns size in a human readable form 119*/ 120 121M4OSA_Int32 M4_MPEG4BitStreamParser_GetMpegLengthFromInteger(void* pContext, M4OSA_UInt32 val); 122 123 124/** 125 ************************************************************************ 126 * @brief Decode an MPEG4 Systems descriptor size from an encoded SDL size data. 127 * @note The value is read from the current bitstream location. 128 * @param pContext (IN/OUT) M4_BitStreamParser context. 129 * @return Size in a human readable form 130 ************************************************************************ 131*/ 132M4OSA_Int32 M4_MPEG4BitStreamParser_GetMpegLengthFromStream(void* pContext); 133 134#endif /*__M4_BITSTREAMPARSER_H__*/ 135 136