3
Copyright (C) 2000 Martin Vogt
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU Library General Public License as published by
7
the Free Software Foundation.
9
For more information look at the file COPYRIGHT in this package
15
#ifndef __MPEGVIDEOBITWINDOW_H
16
#define __MPEGVIDEOBITWINDOW_H
18
#include "../input/inputPlugin.h"
21
#define ISO_11172_END_CODE ((unsigned int)0x000001b9)
23
class MpegVideoBitWindow {
24
int size; /* size of buffer */
25
unsigned int bit_offset; /* Bit offset in stream. */
26
unsigned int *buffer; /* Pointer to next byte in buffer */
27
int buf_length; /* Length of remaining buffer.*/
28
unsigned int *buf_start; /* Pointer to buffer start. */
29
int max_buf_length; /* Max length of buffer. */
30
unsigned int num_left; /* from ReadPacket - leftover */
31
unsigned int leftover_bytes; /* from ReadPacket - leftover */
32
unsigned int curBits; /* current bits */
35
unsigned int nBitMask[33];
40
~MpegVideoBitWindow();
42
int appendToBuffer(unsigned char* ptr,int len);
44
// true if feof() is true and the buffer is emtpy
46
void flushByteOffset();
47
void appendToBuffer(unsigned int startCode);
50
inline void updateCurBits() {
51
curBits = *buffer << bit_offset;
54
inline unsigned int showBits(int bits) {
56
unsigned int mask=nBitMask[bits];
59
shift=(curBits & mask)>>shift;
60
bO = bit_offset + bits;
62
return (shift | (*(buffer+1)>>(64-bO)));
67
inline unsigned int showBits32() {
69
return (curBits | (*(buffer+1) >> (32 - bit_offset)));
74
inline void flushBitsDirect(unsigned int bits) {
76
if (bit_offset & 0x20) {
88
inline unsigned int getBits(int bits) {
89
unsigned int result=showBits(bits);
90
flushBitsDirect(bits);
97
int hasBytes(int bytes);
99
void printChar(int bytes);
100
void printInt(int bytes);
102
void resizeBuffer(int insertBytes);
103
void fillWithIsoEndCode(int bytes);