PageRenderTime 37ms CodeModel.GetById 15ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

/Show/avc/avcdec_bitstream.h

http://github.com/mbebenita/Broadway
C Header | 125 lines | 25 code | 18 blank | 82 comment | 0 complexity | 988f4d07197f0112b510d305c3c9121a MD5 | raw file
  1/* ------------------------------------------------------------------
  2 * Copyright (C) 1998-2009 PacketVideo
  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
 13 * express or implied.
 14 * See the License for the specific language governing permissions
 15 * and limitations under the License.
 16 * -------------------------------------------------------------------
 17 */
 18/**
 19This file contains bitstream related functions.
 20@publishedAll
 21*/
 22
 23#ifndef _AVCDEC_BITSTREAM_H_
 24#define _AVCDEC_BITSTREAM_H_
 25
 26#include "avcdec_lib.h"
 27
 28#define WORD_SIZE   32  /* this can vary, default to 32 bit for now */
 29
 30#ifndef __cplusplus
 31
 32#define AVC_GETDATA(x,y)   userData->AVC_GetData(x,y)
 33
 34#endif
 35
 36#ifdef __cplusplus
 37extern "C"
 38{
 39#endif
 40#define BitstreamFlushBits(A,B)     {(A)->bitcnt += (B); (A)->incnt -= (B); (A)->curr_word <<= (B);}
 41
 42    AVCDec_Status AVC_BitstreamFillCache(AVCDecBitstream *stream);
 43    /**
 44    This function populates bitstream structure.
 45    \param "stream" "Pointer to bitstream structure."
 46    \param "buffer" "Pointer to the bitstream buffer."
 47    \param "size"   "Size of the buffer."
 48    \param "nal_size"   "Size of the NAL unit."
 49    \param "resetall"   "Flag for reset everything."
 50    \return "AVCDEC_SUCCESS for success and AVCDEC_FAIL for fail."
 51    */
 52    AVCDec_Status BitstreamInit(AVCDecBitstream *stream, uint8 *buffer, int size);
 53
 54    /**
 55    This function reads next aligned word and remove the emulation prevention code
 56    if necessary.
 57    \param "stream" "Pointer to bitstream structure."
 58    \return "Next word."
 59    */
 60    uint BitstreamNextWord(AVCDecBitstream *stream);
 61
 62    /**
 63    This function reads nBits bits from the current position and advance the pointer.
 64    \param "stream" "Pointer to bitstream structure."
 65    \param "nBits" "Number of bits to be read."
 66    \param "code"   "Point to the read value."
 67    \return "AVCDEC_SUCCESS if successed, AVCDEC_FAIL if number of bits
 68                is greater than the word-size, AVCDEC_PACKET_LOSS or
 69                AVCDEC_NO_DATA if callback to get data fails."
 70    */
 71    AVCDec_Status BitstreamReadBits(AVCDecBitstream *stream, int nBits, uint *code);
 72
 73    /**
 74    This function shows nBits bits from the current position without advancing the pointer.
 75    \param "stream" "Pointer to bitstream structure."
 76    \param "nBits" "Number of bits to be read."
 77    \param "code"   "Point to the read value."
 78    \return "AVCDEC_SUCCESS if successed, AVCDEC_FAIL if number of bits
 79                    is greater than the word-size, AVCDEC_NO_DATA if it needs
 80                    to callback to get data."
 81    */
 82    AVCDec_Status BitstreamShowBits(AVCDecBitstream *stream, int nBits, uint *code);
 83
 84
 85    /**
 86    This function flushes nBits bits from the current position.
 87    \param "stream" "Pointer to bitstream structure."
 88    \param "nBits" "Number of bits to be read."
 89    \return "AVCDEC_SUCCESS if successed, AVCDEC_FAIL if number of bits
 90                    is greater than the word-size It will not call back to get
 91                   more data. Users should call BitstreamShowBits to determine
 92                   how much they want to flush."
 93    */
 94
 95    /**
 96    This function read 1 bit from the current position and advance the pointer.
 97    \param "stream" "Pointer to bitstream structure."
 98    \param "nBits" "Number of bits to be read."
 99    \param "code"   "Point to the read value."
100    \return "AVCDEC_SUCCESS if successed, AVCDEC_FAIL if number of bits
101                is greater than the word-size, AVCDEC_PACKET_LOSS or
102                AVCDEC_NO_DATA if callback to get data fails."
103    */
104    AVCDec_Status BitstreamRead1Bit(AVCDecBitstream *stream, uint *code);
105
106    /**
107    This function checks whether the current bit position is byte-aligned or not.
108    \param "stream" "Pointer to the bitstream structure."
109    \return "TRUE if byte-aligned, FALSE otherwise."
110    */
111    bool byte_aligned(AVCDecBitstream *stream);
112    AVCDec_Status BitstreamByteAlign(AVCDecBitstream  *stream);
113    /**
114    This function checks whether there are more RBSP data before the trailing bits.
115    \param "stream" "Pointer to the bitstream structure."
116    \return "TRUE if yes, FALSE otherwise."
117    */
118    bool more_rbsp_data(AVCDecBitstream *stream);
119
120
121#ifdef __cplusplus
122}
123#endif /* __cplusplus  */
124
125#endif /* _AVCDEC_BITSTREAM_H_ */