Skip to content

Commit

Permalink
IMAGE: Miscellaneous cleanup for Indeo decompressors
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Sep 11, 2016
1 parent 23b1dbb commit 2f7da2d
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 189 deletions.
19 changes: 9 additions & 10 deletions image/codecs/indeo/indeo.cpp
Expand Up @@ -162,7 +162,7 @@ int IVIHuffTab::decodeHuffDesc(IVI45DecContext *ctx, int descCoded, int whichTab
_custDesc.huffDescCopy(&newHuff);

if (_custTab._table)
_custTab.ff_free_vlc();
_custTab.freeVlc();
result = _custDesc.createHuffFromDesc(&_custTab, false);
if (result) {
// reset faulty description
Expand Down Expand Up @@ -391,7 +391,7 @@ void IVIPlaneDesc::freeBuffers(IVIPlaneDesc *planes) {
avFreeP(&planes[p]._bands[b]._bufs[3]);

if (planes[p]._bands[b]._blkVlc._custTab._table)
planes[p]._bands[b]._blkVlc._custTab.ff_free_vlc();
planes[p]._bands[b]._blkVlc._custTab.freeVlc();
for (t = 0; t < planes[p]._bands[b]._numTiles; t++)
avFreeP(&planes[p]._bands[b]._tiles[t]._mbs);
avFreeP(&planes[p]._bands[b]._tiles);
Expand Down Expand Up @@ -462,10 +462,10 @@ IVI45DecContext::IVI45DecContext() : _gb(nullptr), _frameNum(0), _frameType(0),

for (int i = 0; i < 8; i++) {
_iviMbVlcTabs[i]._table = _tableData + i * 2 * 8192;
_iviMbVlcTabs[i]._table_allocated = 8192;
_iviMbVlcTabs[i]._tableAllocated = 8192;
ivi_mb_huff_desc[i].createHuffFromDesc(&_iviMbVlcTabs[i], true);
_iviBlkVlcTabs[i]._table = _tableData + (i * 2 + 1) * 8192;
_iviBlkVlcTabs[i]._table_allocated = 8192;
_iviBlkVlcTabs[i]._tableAllocated = 8192;
ivi_blk_huff_desc[i].createHuffFromDesc(&_iviBlkVlcTabs[i], true);
}
}
Expand All @@ -485,7 +485,7 @@ IndeoDecoderBase::~IndeoDecoderBase() {
delete _surface;
IVIPlaneDesc::freeBuffers(_ctx._planes);
if (_ctx._mbVlc._custTab._table)
_ctx._mbVlc._custTab.ff_free_vlc();
_ctx._mbVlc._custTab.freeVlc();

delete _ctx._pFrame;
}
Expand Down Expand Up @@ -638,8 +638,8 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
for (i = 0; i < band->_numCorr; i++) {
idx1 = band->_corr[i * 2];
idx2 = band->_corr[i * 2 + 1];
FFSWAP(uint8, band->_rvMap->_runtab[idx1], band->_rvMap->_runtab[idx2]);
FFSWAP(int16, band->_rvMap->_valtab[idx1], band->_rvMap->_valtab[idx2]);
SWAP(band->_rvMap->_runtab[idx1], band->_rvMap->_runtab[idx2]);
SWAP(band->_rvMap->_valtab[idx1], band->_rvMap->_valtab[idx2]);
if (idx1 == band->_rvMap->_eobSym || idx2 == band->_rvMap->_eobSym)
band->_rvMap->_eobSym ^= idx1 ^ idx2;
if (idx1 == band->_rvMap->_escSym || idx2 == band->_rvMap->_escSym)
Expand Down Expand Up @@ -696,8 +696,8 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
for (i = band->_numCorr - 1; i >= 0; i--) {
idx1 = band->_corr[i * 2];
idx2 = band->_corr[i * 2 + 1];
FFSWAP(uint8, band->_rvMap->_runtab[idx1], band->_rvMap->_runtab[idx2]);
FFSWAP(int16, band->_rvMap->_valtab[idx1], band->_rvMap->_valtab[idx2]);
SWAP(band->_rvMap->_runtab[idx1], band->_rvMap->_runtab[idx2]);
SWAP(band->_rvMap->_valtab[idx1], band->_rvMap->_valtab[idx2]);
if (idx1 == band->_rvMap->_eobSym || idx2 == band->_rvMap->_eobSym)
band->_rvMap->_eobSym ^= idx1 ^ idx2;
if (idx1 == band->_rvMap->_escSym || idx2 == band->_rvMap->_escSym)
Expand Down Expand Up @@ -1726,6 +1726,5 @@ const RVMapDesc IVI45DecContext::_ff_ivi_rvmap_tabs[9] = {
}
};


} // End of namespace Indeo
} // End of namespace Image
6 changes: 3 additions & 3 deletions image/codecs/indeo/indeo.h
Expand Up @@ -64,10 +64,10 @@ enum {
* Declare inverse transform function types
*/
typedef void (InvTransformPtr)(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags);
typedef void (DCTransformPtr) (const int32 *in, int16 *out, uint32 pitch, int blkSize);
typedef void (DCTransformPtr)(const int32 *in, int16 *out, uint32 pitch, int blkSize);

typedef void(*IviMCFunc) (int16 *buf, const int16 *refBuf, uint32 pitch, int mcType);
typedef void(*IviMCAvgFunc) (int16 *buf, const int16 *refBuf1, const int16 *refBuf2,
typedef void (*IviMCFunc)(int16 *buf, const int16 *refBuf, uint32 pitch, int mcType);
typedef void (*IviMCAvgFunc)(int16 *buf, const int16 *refBuf1, const int16 *refBuf2,
uint32 pitch, int mcType, int mcType2);

///< max number of bits of the ivi's huffman codes
Expand Down
12 changes: 8 additions & 4 deletions image/codecs/indeo/mem.cpp
Expand Up @@ -166,13 +166,17 @@ uint16 invertBits(uint16 val, int nbits) {
}

uint8 avClipUint8(int a) {
if (a&(~0xFF)) return (-a) >> 31;
else return a;
if (a & (~0xFF))
return (-a) >> 31;
else
return a;
}

unsigned avClipUintp2(int a, int p) {
if (a & ~((1 << p) - 1)) return -a >> 31 & ((1 << p) - 1);
else return a;
if (a & ~((1 << p) - 1))
return -a >> 31 & ((1 << p) - 1);
else
return a;
}

} // End of namespace Indeo
Expand Down
1 change: 0 additions & 1 deletion image/codecs/indeo/mem.h
Expand Up @@ -36,7 +36,6 @@ namespace Indeo {

#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
#define FFALIGN(x, a) (((x) + (a)-1) & ~((a)-1))
#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
#define FFSIGN(a) ((a) > 0 ? 1 : -1)
#define MAX_INTEGER 0x7ffffff

Expand Down

0 comments on commit 2f7da2d

Please sign in to comment.