IMAGE: Miscellaneous cleanup for Indeo decompressors

This commit is contained in:
Paul Gilbert 2016-09-10 21:05:49 -04:00
parent 23b1dbbb0e
commit 2f7da2d3d9
10 changed files with 166 additions and 189 deletions

View File

@ -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
@ -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);
@ -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);
}
}
@ -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;
}
@ -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)
@ -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)
@ -1726,6 +1726,5 @@ const RVMapDesc IVI45DecContext::_ff_ivi_rvmap_tabs[9] = {
}
};
} // End of namespace Indeo
} // End of namespace Image

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -32,7 +32,7 @@
#include "common/util.h"
namespace Image {
namespace Indeo {
namespace Indeo {
/**
* Quicksort
@ -42,62 +42,62 @@ namespace Image {
*/
#define AV_QSORT(p, num, type, cmp) do {\
void *stack[64][2];\
int sp= 1;\
int sp = 1;\
stack[0][0] = p;\
stack[0][1] = (p)+(num)-1;\
while(sp){\
type *start= (type *)stack[--sp][0];\
type *end = (type *)stack[ sp][1];\
while(start < end){\
if(start < end-1) {\
int checksort=0;\
type *right = end-2;\
type *left = start+1;\
type *mid = start + ((end-start)>>1);\
type *start = (type *)stack[--sp][0];\
type *end = (type *)stack[ sp][1];\
while (start < end) {\
if (start < end-1) {\
int checksort = 0;\
type *right = end - 2;\
type *left = start + 1;\
type *mid = start + ((end - start) >> 1);\
if(cmp(start, end) > 0) {\
if(cmp( end, mid) > 0) FFSWAP(type, *start, *mid);\
else FFSWAP(type, *start, *end);\
}else{\
if(cmp(start, mid) > 0) FFSWAP(type, *start, *mid);\
else checksort= 1;\
if(cmp( end, mid) > 0) SWAP(*start, *mid);\
else SWAP(*start, *end);\
} else {\
if(cmp(start, mid) > 0) SWAP(*start, *mid);\
else checksort = 1;\
}\
if(cmp(mid, end) > 0){ \
FFSWAP(type, *mid, *end);\
checksort=0;\
if (cmp(mid, end) > 0) { \
SWAP(*mid, *end);\
checksort = 0;\
}\
if(start == end-2) break;\
FFSWAP(type, end[-1], *mid);\
while(left <= right){\
while(left<=right && cmp(left, end-1) < 0)\
if(start == end - 2) break;\
SWAP(end[-1], *mid);\
while (left <= right) {\
while (left<=right && cmp(left, end - 1) < 0)\
left++;\
while(left<=right && cmp(right, end-1) > 0)\
while (left<=right && cmp(right, end - 1) > 0)\
right--;\
if(left <= right){\
FFSWAP(type, *left, *right);\
if (left <= right) {\
SWAP(*left, *right);\
left++;\
right--;\
}\
}\
FFSWAP(type, end[-1], *left);\
if(checksort && (mid == left-1 || mid == left)){\
SWAP(end[-1], *left);\
if(checksort && (mid == left - 1 || mid == left)){\
mid= start;\
while(mid<end && cmp(mid, mid+1) <= 0)\
mid++;\
if(mid==end)\
break;\
}\
if(end-left < left-start){\
stack[sp ][0]= start;\
stack[sp++][1]= right;\
start = left+1;\
}else{\
stack[sp ][0]= left+1;\
stack[sp++][1]= end;\
if (end - left < left - start){\
stack[sp ][0] = start;\
stack[sp++][1] = right;\
start = left + 1;\
} else {\
stack[sp ][0] = left+1;\
stack[sp++][1] = end;\
end = right;\
}\
}else{\
if(cmp(start, end) > 0)\
FFSWAP(type, *start, *end);\
} else {\
if (cmp(start, end) > 0)\
SWAP(*start, *end);\
break;\
}\
}\
@ -105,29 +105,29 @@ namespace Image {
} while (0)
#define COPY(condition)\
for (i = 0; i < nb_codes; i++) { \
buf[j].bits = getData(p_bits, i, bits_wrap, bits_size); \
for (i = 0; i < nbCodes; i++) { \
buf[j].bits = getData(p_bits, i, bitsWrap, bitsSize); \
if (!(condition)) \
continue; \
if (buf[j].bits > 3*nb_bits || buf[j].bits>32) { \
if (buf[j].bits > (3 * nbBits) || buf[j].bits > 32) { \
warning("Too long VLC (%d) in init_vlc", buf[j].bits); \
if (!(flags & INIT_VLC_USE_NEW_STATIC)) \
free(buf); \
return -1; \
} \
buf[j].code = getData(codes, i, codes_wrap, codes_size); \
if (buf[j].code >= (1LL<<buf[j].bits)) { \
buf[j].code = getData(codes, i, codesWrap, codesSize); \
if (buf[j].code >= (1LL << buf[j].bits)) { \
warning("Invalid code %x for %d in init_vlc", buf[j].code, i); \
if (!(flags & INIT_VLC_USE_NEW_STATIC)) \
free(buf); \
return -1; \
} \
if (flags & INIT_VLC_LE) \
buf[j].code = bitswap32(buf[j].code); \
buf[j].code = bitswap32(buf[j].code); \
else \
buf[j].code <<= 32 - buf[j].bits; \
if (symbols) \
buf[j].symbol = getData(symbols, i, symbols_wrap, symbols_size); \
buf[j].symbol = getData(symbols, i, symbolsWrap, symbolsSize); \
else \
buf[j].symbol = i; \
j++; \
@ -135,55 +135,55 @@ namespace Image {
/*------------------------------------------------------------------------*/
VLC::VLC() : _bits(0), _table_size(0), _table_allocated(0), _table(nullptr) {
VLC::VLC() : _bits(0), _tableSize(0), _tableAllocated(0), _table(nullptr) {
}
int VLC::init_vlc(int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size,
const void *codes, int codes_wrap, int codes_size, int flags) {
return init_vlc(nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap,
codes_size, nullptr, 0, 0, flags);
int VLC::init_vlc(int nbBits, int nbCodes, const void *bits, int bitsWrap, int bitsSize,
const void *codes, int codesWrap, int codesSize, int flags) {
return init_vlc(nbBits, nbCodes, bits, bitsWrap, bitsSize, codes, codesWrap,
codesSize, nullptr, 0, 0, flags);
}
int VLC::init_vlc(int nb_bits, int nb_codes, const void *p_bits, int bits_wrap,
int bits_size, const void *codes, int codes_wrap, int codes_size,
const void *symbols, int symbols_wrap, int symbols_size, int flags) {
int VLC::init_vlc(int nbBits, int nbCodes, const void *p_bits, int bitsWrap,
int bitsSize, const void *codes, int codesWrap, int codesSize,
const void *symbols, int symbolsWrap, int symbolsSize, int flags) {
VLCcode *buf;
int i, j, ret;
VLCcode localbuf[1500]; // the maximum currently needed is 1296 by rv34
VLC localvlc, *vlc;
vlc = this;
vlc->_bits = nb_bits;
vlc->_bits = nbBits;
if (flags & INIT_VLC_USE_NEW_STATIC) {
assert((nb_codes + 1) <= FF_ARRAY_ELEMS(localbuf));
assert((nbCodes + 1) <= FF_ARRAY_ELEMS(localbuf));
buf = localbuf;
localvlc = *this;
vlc = &localvlc;
vlc->_table_size = 0;
vlc->_tableSize = 0;
} else {
vlc->_table = NULL;
vlc->_table_allocated = 0;
vlc->_table_size = 0;
vlc->_tableAllocated = 0;
vlc->_tableSize = 0;
buf = (VLCcode *)avMallocArray((nb_codes + 1), sizeof(VLCcode));
buf = (VLCcode *)avMallocArray((nbCodes + 1), sizeof(VLCcode));
assert(buf);
}
assert(symbols_size <= 2 || !symbols);
assert(symbolsSize <= 2 || !symbols);
j = 0;
COPY(buf[j].bits > nb_bits);
COPY(buf[j].bits > nbBits);
// qsort is the slowest part of init_vlc, and could probably be improved or avoided
AV_QSORT(buf, j, VLCcode, compare_vlcspec);
COPY(buf[j].bits && buf[j].bits <= nb_bits);
nb_codes = j;
AV_QSORT(buf, j, VLCcode, compareVlcSpec);
COPY(buf[j].bits && buf[j].bits <= nbBits);
nbCodes = j;
ret = vlc->build_table(nb_bits, nb_codes, buf, flags);
ret = vlc->buildTable(nbBits, nbCodes, buf, flags);
if (flags & INIT_VLC_USE_NEW_STATIC) {
if (vlc->_table_size != vlc->_table_allocated)
warning("needed %d had %d", vlc->_table_size, vlc->_table_allocated);
if (vlc->_tableSize != vlc->_tableAllocated)
warning("needed %d had %d", vlc->_tableSize, vlc->_tableAllocated);
assert(ret >= 0);
*this = *vlc;
@ -198,43 +198,43 @@ int VLC::init_vlc(int nb_bits, int nb_codes, const void *p_bits, int bits_wrap,
return 0;
}
void VLC::ff_free_vlc() {
void VLC::freeVlc() {
free(_table);
}
int VLC::compare_vlcspec(const void *a, const void *b) {
int VLC::compareVlcSpec(const void *a, const void *b) {
const VLCcode *sa = (VLCcode *)a, *sb = (VLCcode *)b;
return (sa->code >> 1) - (sb->code >> 1);
}
int VLC::build_table(int table_nb_bits, int nb_codes,
int VLC::buildTable(int tableNbBits, int nbCodes,
VLCcode *codes, int flags) {
VLC *vlc = this;
int table_size, table_index, index, code_prefix, symbol, subtable_bits;
int tableSize, tableIndex, index, codePrefix, symbol, subtableBits;
int i, j, k, n, nb, inc;
uint32 code;
VLC_TYPE (*table)[2];
table_size = 1 << table_nb_bits;
if (table_nb_bits > 30)
tableSize = 1 << tableNbBits;
if (tableNbBits > 30)
return -1;
table_index = alloc_table(table_size, flags & INIT_VLC_USE_NEW_STATIC);
//warning("new table index=%d size=%d", table_index, table_size);
if (table_index < 0)
return table_index;
table = &vlc->_table[table_index];
tableIndex = allocTable(tableSize, flags & INIT_VLC_USE_NEW_STATIC);
//warning("new table index=%d size=%d", tableIndex, tableSize);
if (tableIndex < 0)
return tableIndex;
table = &vlc->_table[tableIndex];
// first pass: map codes and compute auxiliary table sizes
for (i = 0; i < nb_codes; i++) {
for (i = 0; i < nbCodes; i++) {
n = codes[i].bits;
code = codes[i].code;
symbol = codes[i].symbol;
//warning("i=%d n=%d code=0x%x", i, n, code);
if (n <= table_nb_bits) {
if (n <= tableNbBits) {
// no need to add another table
j = code >> (32 - table_nb_bits);
nb = 1 << (table_nb_bits - n);
j = code >> (32 - tableNbBits);
nb = 1 << (tableNbBits - n);
inc = 1;
if (flags & INIT_VLC_LE) {
j = bitswap32(code);
@ -255,70 +255,67 @@ int VLC::build_table(int table_nb_bits, int nb_codes,
}
} else {
// fill auxiliary table recursively
n -= table_nb_bits;
code_prefix = code >> (32 - table_nb_bits);
subtable_bits = n;
n -= tableNbBits;
codePrefix = code >> (32 - tableNbBits);
subtableBits = n;
codes[i].bits = n;
codes[i].code = code << table_nb_bits;
for (k = i + 1; k < nb_codes; k++) {
n = codes[k].bits - table_nb_bits;
codes[i].code = code << tableNbBits;
for (k = i + 1; k < nbCodes; k++) {
n = codes[k].bits - tableNbBits;
if (n <= 0)
break;
code = codes[k].code;
if (code >> (32 - table_nb_bits) != (uint)code_prefix)
if (code >> (32 - tableNbBits) != (uint)codePrefix)
break;
codes[k].bits = n;
codes[k].code = code << table_nb_bits;
subtable_bits = MAX(subtable_bits, n);
codes[k].code = code << tableNbBits;
subtableBits = MAX(subtableBits, n);
}
subtable_bits = MIN(subtable_bits, table_nb_bits);
j = (flags & INIT_VLC_LE) ? bitswap32(code_prefix) >> (32 - table_nb_bits) : code_prefix;
table[j][1] = -subtable_bits;
//warning("%4x: n=%d (subtable)", j, codes[i].bits + table_nb_bits);
index = vlc->build_table(subtable_bits, k - i, codes + i, flags);
subtableBits = MIN(subtableBits, tableNbBits);
j = (flags & INIT_VLC_LE) ? bitswap32(codePrefix) >> (32 - tableNbBits) : codePrefix;
table[j][1] = -subtableBits;
//warning("%4x: n=%d (subtable)", j, codes[i].bits + tableNbBits);
index = vlc->buildTable(subtableBits, k - i, codes + i, flags);
if (index < 0)
return index;
// note: realloc has been done, so reload tables
table = (VLC_TYPE (*)[2])&vlc->_table[table_index];
table = (VLC_TYPE (*)[2])&vlc->_table[tableIndex];
table[j][0] = index; //code
i = k - 1;
}
}
for (i = 0; i < table_size; i++) {
for (i = 0; i < tableSize; i++) {
if (table[i][1] == 0) //bits
table[i][0] = -1; //codes
}
return table_index;
return tableIndex;
}
int VLC::alloc_table(int size, int use_static) {
int VLC::allocTable(int size, int useStatic) {
VLC *vlc = this;
int index = vlc->_table_size;
int index = vlc->_tableSize;
vlc->_table_size += size;
if (vlc->_table_size > vlc->_table_allocated) {
vlc->_tableSize += size;
if (vlc->_tableSize > vlc->_tableAllocated) {
// cannot do anything, init_vlc() is used with too little memory
assert(!use_static);
assert(!useStatic);
vlc->_table_allocated += (1 << vlc->_bits);
vlc->_table = (int16(*)[2])avReallocF(vlc->_table, vlc->_table_allocated, sizeof(VLC_TYPE) * 2);
vlc->_tableAllocated += (1 << vlc->_bits);
vlc->_table = (int16(*)[2])avReallocF(vlc->_table, vlc->_tableAllocated, sizeof(VLC_TYPE) * 2);
if (!vlc->_table) {
vlc->_table_allocated = 0;
vlc->_table_size = 0;
vlc->_tableAllocated = 0;
vlc->_tableSize = 0;
return -2;
}
memset(vlc->_table + vlc->_table_allocated - (1 << vlc->_bits), 0, sizeof(VLC_TYPE) * 2 << vlc->_bits);
memset(vlc->_table + vlc->_tableAllocated - (1 << vlc->_bits), 0, sizeof(VLC_TYPE) * 2 << vlc->_bits);
}
return index;
}
/**
* VLC decoding
*/
uint VLC::getData(const void *table, uint idx, uint wrap, uint size) {
const uint8 *ptr = (const uint8 *)table + idx * wrap;

View File

@ -56,7 +56,7 @@ struct VLCcode {
struct VLC {
private:
static int compare_vlcspec(const void *a, const void *b);
static int compareVlcSpec(const void *a, const void *b);
/**
* Gets a value of a given size from a table
@ -69,17 +69,17 @@ private:
public:
int _bits;
VLC_TYPE (*_table)[2]; ///< code, bits
int _table_size, _table_allocated;
int _tableSize, _tableAllocated;
VLC();
/* Build VLC decoding tables suitable for use with get_vlc().
'nb_bits' sets the decoding table size (2^nb_bits) entries. The
'nbBits' sets the decoding table size (2^nbBits) entries. The
bigger it is, the faster is the decoding. But it should not be too
big to save memory and L1 cache. '9' is a good compromise.
'nb_codes' : number of vlcs codes
'nbCodes' : number of vlcs codes
'bits' : table which gives the size (in bits) of each vlc code.
@ -96,52 +96,39 @@ public:
'wrap' and 'size' make it possible to use any memory configuration and types
(byte/word/long) to store the 'bits', 'codes', and 'symbols' tables.
'use_static' should be set to 1 for tables, which should be freed
with av_free_static(), 0 if ff_free_vlc() will be used.
'useStatic' should be set to 1 for tables, which should be freed
with av_free_static(), 0 if freeVlc() will be used.
*/
int init_vlc(int nb_bits, int nb_codes, const void *bits, int bits_wrap,
int bits_size, const void *codes, int codes_wrap, int codes_size,
const void *symbols, int symbols_wrap, int symbols_size, int flags);
int init_vlc(int nbBits, int nbCodes, const void *bits, int bitsWrap,
int bitsSize, const void *codes, int codesWrap, int codesSize,
const void *symbols, int symbolsWrap, int symbolsSize, int flags);
int init_vlc(int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size,
const void *codes, int codes_wrap, int codes_size, int flags);
int init_vlc(int nbBits, int nbCodes, const void *bits, int bitsWrap, int bitsSize,
const void *codes, int codesWrap, int codesSize, int flags);
/**
* Free VLC data
*/
void ff_free_vlc();
void freeVlc();
/**
* Build VLC decoding tables suitable for use with get_vlc().
*
* @param table_nb_bits max length of vlc codes to store directly in this table
* @param tableNbBits max length of vlc codes to store directly in this table
* (Longer codes are delegated to subtables.)
*
* @param nb_codes number of elements in codes[]
* @param nbCodes number of elements in codes[]
*
* @param codes descriptions of the vlc codes
* These must be ordered such that codes going into the same subtable are contiguous.
* Sorting by VLCcode.code is sufficient, though not necessary.
*/
int build_table(int table_nb_bits, int nb_codes,
VLCcode *codes, int flags);
int buildTable(int tableNbBits, int nbCodes, VLCcode *codes, int flags);
int alloc_table(int size, int use_static);
int allocTable(int size, int useStatic);
};
/**
* Reverse "nbits" bits of the value "val" and return the result
* in the least significant bits.
*/
extern uint16 inv_bits(uint16 val, int nbits);
/**
* Swap the order of the bytes in the passed value
*/
extern uint32 bitswap_32(uint32 x);
} // End of namespace Indeo
} // End of namespace Image

View File

@ -35,6 +35,7 @@
#include "common/util.h"
#include "graphics/yuv_to_rgb.h"
#include "image/codecs/indeo4.h"
#include "image/codecs/indeo/indeo_dsp.h"
#include "image/codecs/indeo/mem.h"
namespace Image {
@ -259,10 +260,10 @@ void Indeo4Decoder::switchBuffers() {
}
if (is_prev_ref && is_ref) {
FFSWAP(int, _ctx._dstBuf, _ctx._refBuf);
SWAP(_ctx._dstBuf, _ctx._refBuf);
} else if (is_prev_ref) {
FFSWAP(int, _ctx._refBuf, _ctx._bRefBuf);
FFSWAP(int, _ctx._dstBuf, _ctx._refBuf);
SWAP(_ctx._refBuf, _ctx._bRefBuf);
SWAP(_ctx._dstBuf, _ctx._refBuf);
}
}
@ -459,7 +460,7 @@ int Indeo4Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
blksPerMb = band->_mbSize != band->_blkSize ? 4 : 1;
mbTypeBits = _ctx._frameType == IVI4_FRAMETYPE_BIDIR ? 2 : 1;
/* scale factor for motion vectors */
// scale factor for motion vectors
mvScale = (_ctx._planes[0]._bands[0]._mbSize >> 3) - (band->_mbSize >> 3);
mvX = mvY = 0;

View File

@ -20,9 +20,6 @@
*
*/
#include "common/scummsys.h"
#include "image/codecs/indeo/get_bits.h"
/* Intel Indeo 4 decompressor, derived from ffmpeg.
*
* Original copyright note:
@ -35,8 +32,6 @@
#include "image/codecs/indeo/get_bits.h"
#include "image/codecs/indeo/indeo.h"
#include "image/codecs/indeo/indeo_dsp.h"
#include "graphics/managed_surface.h"
namespace Image {
@ -81,7 +76,7 @@ protected:
* Decode Indeo 4 band header.
*
* @param[in,out] band pointer to the band descriptor
* @return result code: 0 = OK, negative number = error
* @returns result code: 0 = OK, negative number = error
*/
virtual int decodeBandHeader(IVIBandDesc *band);
@ -91,7 +86,7 @@ protected:
*
* @param[in,out] band pointer to the band descriptor
* @param[in,out] tile pointer to the tile descriptor
* @return result code: 0 = OK, negative number = error
* @returns result code: 0 = OK, negative number = error
*/
virtual int decodeMbInfo(IVIBandDesc *band, IVITile *tile);
private:

View File

@ -35,6 +35,7 @@
#include "common/util.h"
#include "graphics/yuv_to_rgb.h"
#include "image/codecs/indeo5.h"
#include "image/codecs/indeo/indeo_dsp.h"
#include "image/codecs/indeo/mem.h"
namespace Image {
@ -104,7 +105,6 @@ const Graphics::Surface *Indeo5Decoder::decodeFrame(Common::SeekableReadStream &
}
int Indeo5Decoder::decodePictureHeader() {
int picSizeIndx, i, p;
IVIPicConfig picConf;
int ret;
@ -176,7 +176,7 @@ void Indeo5Decoder::switchBuffers() {
_ctx._ref2Buf = 2;
_ctx._interScal = 1;
}
FFSWAP(int, _ctx._dstBuf, _ctx._ref2Buf);
SWAP(_ctx._dstBuf, _ctx._ref2Buf);
_ctx._refBuf = _ctx._ref2Buf;
break;
@ -206,8 +206,8 @@ bool Indeo5Decoder::isNonNullFrame() const {
}
int Indeo5Decoder::decodeBandHeader(IVIBandDesc *band) {
int i, ret;
uint8 bandFlags;
int i, ret;
uint8 bandFlags;
bandFlags = _ctx._gb->getBits(8);
@ -369,10 +369,10 @@ int Indeo5Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
s = band->_isHalfpel;
if (mb->_type)
if (x + (mb->_mvX >> s) + (y + (mb->_mvY >> s))*band->_pitch < 0 ||
if (x + (mb->_mvX >> s) + (y + (mb->_mvY >> s)) * band->_pitch < 0 ||
x + ((mb->_mvX + s) >> s) + band->_mbSize - 1
+ (y + band->_mbSize - 1 + ((mb->_mvY + s) >> s))*band->_pitch > band->_bufSize - 1) {
warning("motion vector %d %d outside reference", x*s + mb->_mvX, y*s + mb->_mvY);
+ (y + band->_mbSize - 1 + ((mb->_mvY + s) >> s)) * band->_pitch > band->_bufSize - 1) {
warning("motion vector %d %d outside reference", x*s + mb->_mvX, y * s + mb->_mvY);
return -1;
}
@ -391,7 +391,7 @@ int Indeo5Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
}
int Indeo5Decoder::decode_gop_header() {
int result, i, p, tile_size, picSizeIndx, mbSize, blkSize, isScalable;
int result, i, p, tileSize, picSizeIndx, mbSize, blkSize, isScalable;
int quantMat;
bool blkSizeChanged = false;
IVIBandDesc *band, *band1, *band2;
@ -404,9 +404,9 @@ int Indeo5Decoder::decode_gop_header() {
if (_ctx._gopFlags & IVI5_IS_PROTECTED)
_ctx._lockWord = _ctx._gb->getBits(32);
tile_size = (_ctx._gopFlags & 0x40) ? 64 << _ctx._gb->getBits(2) : 0;
if (tile_size > 256) {
warning("Invalid tile size: %d", tile_size);
tileSize = (_ctx._gopFlags & 0x40) ? 64 << _ctx._gb->getBits(2) : 0;
if (tileSize > 256) {
warning("Invalid tile size: %d", tileSize);
return -1;
}
@ -438,11 +438,11 @@ int Indeo5Decoder::decode_gop_header() {
picConf._chromaHeight = (picConf._picHeight + 3) >> 2;
picConf._chromaWidth = (picConf._picWidth + 3) >> 2;
if (!tile_size) {
if (!tileSize) {
picConf._tileHeight = picConf._picHeight;
picConf._tileWidth = picConf._picWidth;
} else {
picConf._tileHeight = picConf._tileWidth = tile_size;
picConf._tileHeight = picConf._tileWidth = tileSize;
}
// check if picture layout was changed and reallocate buffers
@ -465,8 +465,8 @@ int Indeo5Decoder::decode_gop_header() {
mbSize = _ctx._gb->getBit();
blkSize = 8 >> _ctx._gb->getBit();
mbSize = blkSize << !mbSize;
mbSize = blkSize << (!mbSize ? 1 : 0);
if (p == 0 && blkSize == 4) {
warning("4x4 luma blocks are unsupported!");
return -2;

View File

@ -20,9 +20,6 @@
*
*/
#include "common/scummsys.h"
#include "image/codecs/indeo/get_bits.h"
/* Intel Indeo 4 decompressor, derived from ffmpeg.
*
* Original copyright note:
@ -35,8 +32,6 @@
#include "image/codecs/indeo/get_bits.h"
#include "image/codecs/indeo/indeo.h"
#include "image/codecs/indeo/indeo_dsp.h"
#include "graphics/managed_surface.h"
namespace Image {