Skip to content

Commit

Permalink
IMAGE: Added Indeo4Decoder decodePictureHeader, and lots of dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Sep 10, 2016
1 parent 73e7903 commit 5f09626
Show file tree
Hide file tree
Showing 11 changed files with 1,788 additions and 10 deletions.
24 changes: 23 additions & 1 deletion image/codecs/indeo/get_bits.cpp
Expand Up @@ -21,6 +21,7 @@
*/

#include "image/codecs/indeo/get_bits.h"
#include "common/algorithm.h"
#include "common/endian.h"
#include "common/textconsole.h"

Expand Down Expand Up @@ -160,14 +161,35 @@ GetBits::GetBits(const byte *buffer, size_t totalBits) {
assert(buffer && totalBits < (INT_MAX - 7));

_buffer = buffer;
_disposeAfterUse = DisposeAfterUse::NO;
_sizeInBits = totalBits;
_sizeInBitsPlus8 = totalBits + 8;
_index = 0;
}

GetBits::GetBits(Common::SeekableReadStream &stream) {
byte *buffer = new byte[stream.size()];
stream.read(buffer, stream.size());
_buffer = buffer;
_disposeAfterUse = DisposeAfterUse::YES;
_sizeInBits = stream.size() * 8;
_sizeInBitsPlus8 = _sizeInBits + 8;
_index = 0;
}

GetBits::GetBits(const GetBits &src) : _index(src._index), _buffer(src._buffer),
_sizeInBits(src._sizeInBits), _sizeInBitsPlus8(src._sizeInBitsPlus8) {
_sizeInBits(src._sizeInBits), _sizeInBitsPlus8(src._sizeInBitsPlus8),
_disposeAfterUse(src._disposeAfterUse) {
if (_disposeAfterUse == DisposeAfterUse::YES) {
byte *buffer = new byte[src._sizeInBits / 8];
Common::copy(src._buffer, src._buffer + (src._sizeInBits / 8), buffer);
_buffer = buffer;
}
}

GetBits::~GetBits() {
if (_disposeAfterUse == DisposeAfterUse::YES)
delete[] _buffer;
}

int GetBits::getXbits(int n) {
Expand Down
19 changes: 18 additions & 1 deletion image/codecs/indeo/get_bits.h
Expand Up @@ -32,6 +32,8 @@
#define IMAGE_CODECS_INDEO_GET_BITS_H

#include "common/scummsys.h"
#include "common/stream.h"
#include "common/types.h"

namespace Image {
namespace Indeo {
Expand All @@ -44,22 +46,37 @@ namespace Indeo {
class GetBits {
private:
const byte *_buffer;
DisposeAfterUse::Flag _disposeAfterUse;
uint _index;
uint _sizeInBits;
uint _sizeInBitsPlus8;
public:
/**
* Constructor
* @param buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes
* @param buffer Bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes
* larger than the actual read bits because some optimized bitstream
* readers read 32 or 64 bit at once and could read over the end
* @param bit_size the size of the buffer in bits
* @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
*/
GetBits(const byte *buffer, size_t totalBits);

/**
* Constructor
* @param stream Stream to get data from
*/
GetBits(Common::SeekableReadStream &stream);

/**
* Copy constructor
*/
GetBits(const GetBits &src);

/**
* Destructor
*/
~GetBits();

/**
* Returns the number of bits read
*/
Expand Down

0 comments on commit 5f09626

Please sign in to comment.