159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong/* ------------------------------------------------------------------
259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * Copyright (C) 1998-2009 PacketVideo
359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong *
459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * Licensed under the Apache License, Version 2.0 (the "License");
559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * you may not use this file except in compliance with the License.
659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * You may obtain a copy of the License at
759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong *
859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong *      http://www.apache.org/licenses/LICENSE-2.0
959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong *
1059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * Unless required by applicable law or agreed to in writing, software
1159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * distributed under the License is distributed on an "AS IS" BASIS,
1259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
1359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * express or implied.
1459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * See the License for the specific language governing permissions
1559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * and limitations under the License.
1659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * -------------------------------------------------------------------
1759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong */
1859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#ifndef _BITSTREAM_IO_H_
1959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#define _BITSTREAM_IO_H_
2059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
2159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#define BitstreamPut1Bits(x,y)  BitstreamPutBits(x,1,y)
2259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#define BitstreamPutGT8Bits(x,y,z) BitstreamPutBits(x,y,z)
2359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
2459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#include "mp4lib_int.h"
2559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#ifdef __cplusplus
2659f566c4ec3dfc097ad8163523e522280b27e5c3James Dongextern "C"
2759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
2859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#endif
2959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
3059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    BitstreamEncVideo *BitStreamCreateEnc(Int bufferSize);
3159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Void  BitstreamCloseEnc(BitstreamEncVideo *stream);
3259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    PV_STATUS BitstreamPutBits(BitstreamEncVideo *stream, Int Length, UInt Value);
3359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    PV_STATUS BitstreamPutGT16Bits(BitstreamEncVideo *stream, Int Length, ULong Value);
3459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    PV_STATUS BitstreamSaveWord(BitstreamEncVideo *stream);
3559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    PV_STATUS BitstreamSavePartial(BitstreamEncVideo *stream, Int *fraction);
3659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int BitstreamGetPos(BitstreamEncVideo *stream);
3759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    void BitstreamEncReset(BitstreamEncVideo *stream);
3859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
3959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int BitstreamShortHeaderByteAlignStuffing(BitstreamEncVideo *stream);
4059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int BitstreamMpeg4ByteAlignStuffing(BitstreamEncVideo *stream);
4159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    PV_STATUS BitstreamAppendEnc(BitstreamEncVideo *bitstream1, BitstreamEncVideo *bitstream2);
4259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    PV_STATUS BitstreamAppendPacket(BitstreamEncVideo *bitstream1, BitstreamEncVideo *bitstream2);
4359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    PV_STATUS BitstreamAppendPacketNoOffset(BitstreamEncVideo *bitstream1, BitstreamEncVideo *bitstream2);
4459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    PV_STATUS BitstreamRepos(BitstreamEncVideo *bitstream, Int byteCount, Int bitCount);
4559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    PV_STATUS BitstreamFlushBits(BitstreamEncVideo *bitstream1, Int num_bit_left);
4659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    PV_STATUS BitstreamPrependPacket(BitstreamEncVideo *bitstream1, BitstreamEncVideo *bitstream2);
4759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
4859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
4959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Void  BitstreamSetOverrunBuffer(BitstreamEncVideo *stream, UChar *overrunBuffer, Int oBSize, VideoEncData *video);
5059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    PV_STATUS BitstreamUseOverrunBuffer(BitstreamEncVideo* stream, Int numExtraBytes);
5159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
5259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
5359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#ifdef __cplusplus
5459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong}
5559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#endif
5659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
5759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#endif /* _BITSTREAM_IO_H_ */
58