aboutsummaryrefslogtreecommitdiff
path: root/image
diff options
context:
space:
mode:
authorPaul Gilbert2016-09-09 22:47:09 -0400
committerPaul Gilbert2016-09-10 10:08:20 -0400
commit0910e642a229d8f477f35943c6845f3b5a4dea42 (patch)
tree73d7706fe24e66d017b04bcd2b4f6f9bc611928b /image
parent3a2ee8ea23247f72628294b48b43716c1b84d8a8 (diff)
downloadscummvm-rg350-0910e642a229d8f477f35943c6845f3b5a4dea42.tar.gz
scummvm-rg350-0910e642a229d8f477f35943c6845f3b5a4dea42.tar.bz2
scummvm-rg350-0910e642a229d8f477f35943c6845f3b5a4dea42.zip
IMAGE: Fix decoding tile data in Indeo4 decoder
Diffstat (limited to 'image')
-rw-r--r--image/codecs/indeo/get_bits.cpp5
-rw-r--r--image/codecs/indeo/indeo.cpp44
-rw-r--r--image/codecs/indeo/indeo.h14
-rw-r--r--image/codecs/indeo4.cpp7
4 files changed, 36 insertions, 34 deletions
diff --git a/image/codecs/indeo/get_bits.cpp b/image/codecs/indeo/get_bits.cpp
index f16532948b..60c82c4607 100644
--- a/image/codecs/indeo/get_bits.cpp
+++ b/image/codecs/indeo/get_bits.cpp
@@ -248,10 +248,7 @@ uint GetBits::getBits1() {
result <<= index & 7;
result >>= 8 - 1;
#endif
-#if !UNCHECKED_BITSTREAM_READER
- if (_index < _sizeInBitsPlus8)
-#endif
- index++;
+ index++;
_index = index;
return result;
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index 83cd9fd83b..31e8e9864a 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -138,43 +138,31 @@ void IVIHuffDesc::ivi_huff_desc_copy(const IVIHuffDesc *src) {
/*------------------------------------------------------------------------*/
-IVIHuffTab::IVIHuffTab() {
- tab = nullptr;
- for (int idx = 0; idx < (8192 * 16); ++idx)
- table_data[idx][0] = table_data[idx][1] = 0;
-
- for (int i = 0; i < 8; i++) {
- ivi_mb_vlc_tabs[i]._table = table_data + i * 2 * 8192;
- ivi_mb_vlc_tabs[i]._table_allocated = 8192;
- ivi_mb_huff_desc[i].ivi_create_huff_from_desc(&ivi_mb_vlc_tabs[i], 1);
- ivi_blk_vlc_tabs[i]._table = table_data + (i * 2 + 1) * 8192;
- ivi_blk_vlc_tabs[i]._table_allocated = 8192;
- ivi_blk_huff_desc[i].ivi_create_huff_from_desc(&ivi_blk_vlc_tabs[i], 1);
- }
+IVIHuffTab::IVIHuffTab() : tab(nullptr) {
}
-int IVIHuffTab::ff_ivi_dec_huff_desc(GetBits *gb, int desc_coded, int which_tab) {
+int IVIHuffTab::ff_ivi_dec_huff_desc(IVI45DecContext *ctx, int desc_coded, int which_tab) {
int i, result;
IVIHuffDesc new_huff;
if (!desc_coded) {
// select default table
- tab = (which_tab) ? &ivi_blk_vlc_tabs[7]
- : &ivi_mb_vlc_tabs[7];
+ tab = (which_tab) ? &ctx->ivi_blk_vlc_tabs[7]
+ : &ctx->ivi_mb_vlc_tabs[7];
return 0;
}
- tab_sel = gb->getBits(3);
+ tab_sel = ctx->gb->getBits(3);
if (tab_sel == 7) {
// custom huffman table (explicitly encoded)
- new_huff.num_rows = gb->getBits(4);
+ new_huff.num_rows = ctx->gb->getBits(4);
if (!new_huff.num_rows) {
warning("Empty custom Huffman table!");
return -1;
}
for (i = 0; i < new_huff.num_rows; i++)
- new_huff.xbits[i] = gb->getBits(4);
+ new_huff.xbits[i] = ctx->gb->getBits(4);
// Have we got the same custom table? Rebuild if not.
if (new_huff.ivi_huff_desc_cmp(&cust_desc) || !cust_tab._table) {
@@ -193,8 +181,8 @@ int IVIHuffTab::ff_ivi_dec_huff_desc(GetBits *gb, int desc_coded, int which_tab)
tab = &cust_tab;
} else {
// select one of predefined tables
- tab = (which_tab) ? &ivi_blk_vlc_tabs[tab_sel]
- : &ivi_mb_vlc_tabs[tab_sel];
+ tab = (which_tab) ? &ctx->ivi_blk_vlc_tabs[tab_sel]
+ : &ctx->ivi_mb_vlc_tabs[tab_sel];
}
return 0;
@@ -438,6 +426,18 @@ IVI45DecContext::IVI45DecContext() : gb(nullptr), frame_num(0), frame_type(0),
is_indeo4(0), p_frame(nullptr), got_p_frame(0) {
Common::fill(&buf_invalid[0], &buf_invalid[4], 0);
Common::copy(&_ff_ivi_rvmap_tabs[0], &_ff_ivi_rvmap_tabs[9], &rvmap_tabs[0]);
+
+ for (int idx = 0; idx < (8192 * 16); ++idx)
+ table_data[idx][0] = table_data[idx][1] = 0;
+
+ for (int i = 0; i < 8; i++) {
+ ivi_mb_vlc_tabs[i]._table = table_data + i * 2 * 8192;
+ ivi_mb_vlc_tabs[i]._table_allocated = 8192;
+ ivi_mb_huff_desc[i].ivi_create_huff_from_desc(&ivi_mb_vlc_tabs[i], 1);
+ ivi_blk_vlc_tabs[i]._table = table_data + (i * 2 + 1) * 8192;
+ ivi_blk_vlc_tabs[i]._table_allocated = 8192;
+ ivi_blk_huff_desc[i].ivi_create_huff_from_desc(&ivi_blk_vlc_tabs[i], 1);
+ }
}
/*------------------------------------------------------------------------*/
@@ -676,6 +676,8 @@ int IndeoDecoderBase::ff_set_dimensions(uint16 width, uint16 height) {
int IndeoDecoderBase::ff_get_buffer(AVFrame *frame, int flags) {
frame->data[0] = (uint8 *)_surface->getBasePtr(0, 0);
+ frame->linesize[0] = _surface->pitch;
+
return 0;
}
diff --git a/image/codecs/indeo/indeo.h b/image/codecs/indeo/indeo.h
index f49a9b76b4..cd6920d26c 100644
--- a/image/codecs/indeo/indeo.h
+++ b/image/codecs/indeo/indeo.h
@@ -113,14 +113,12 @@ struct IVIHuffDesc {
void ivi_huff_desc_copy(const IVIHuffDesc *src);
};
+class IVI45DecContext;
+
/**
* macroblock/block huffman table descriptor
*/
struct IVIHuffTab {
-private:
- VLC_TYPE table_data[8192 * 16][2];
- VLC ivi_mb_vlc_tabs[8]; ///< static macroblock Huffman tables
- VLC ivi_blk_vlc_tabs[8]; ///< static block Huffman tables
public:
int32 tab_sel; /// index of one of the predefined tables
/// or "7" for custom one
@@ -135,7 +133,7 @@ public:
*/
IVIHuffTab();
- int ff_ivi_dec_huff_desc(GetBits *gb, int desc_coded, int which_tab);
+ int ff_ivi_dec_huff_desc(IVI45DecContext *ctx, int desc_coded, int which_tab);
};
/**
@@ -315,6 +313,12 @@ struct AVFrame {
};
struct IVI45DecContext {
+ friend class IVIHuffTab;
+private:
+ VLC_TYPE table_data[8192 * 16][2];
+ VLC ivi_mb_vlc_tabs[8]; ///< static macroblock Huffman tables
+ VLC ivi_blk_vlc_tabs[8]; ///< static block Huffman tables
+public:
GetBits * gb;
RVMapDesc rvmap_tabs[9]; ///< local corrected copy of the static rvmap tables
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index 11a6577a7a..79874cd5a7 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -205,8 +205,8 @@ int Indeo4Decoder::decodePictureHeader() {
_ctx.gb->skipBits(8);
// decode macroblock and block huffman codebooks
- if (_ctx.mb_vlc.ff_ivi_dec_huff_desc(_ctx.gb, _ctx.gb->getBits1(), IVI_MB_HUFF) ||
- _ctx.blk_vlc.ff_ivi_dec_huff_desc(_ctx.gb, _ctx.gb->getBits1(), IVI_BLK_HUFF))
+ if (_ctx.mb_vlc.ff_ivi_dec_huff_desc(&_ctx, _ctx.gb->getBits1(), IVI_MB_HUFF) ||
+ _ctx.blk_vlc.ff_ivi_dec_huff_desc(&_ctx, _ctx.gb->getBits1(), IVI_BLK_HUFF))
return -1;
_ctx.rvmap_sel = _ctx.gb->getBits1() ? _ctx.gb->getBits(3) : 8;
@@ -223,7 +223,6 @@ int Indeo4Decoder::decodePictureHeader() {
// skip picture header extension if any
while (_ctx.gb->getBits1()) {
- warning("Pic hdr extension encountered!");
_ctx.gb->skipBits(8);
}
@@ -402,7 +401,7 @@ int Indeo4Decoder::decode_band_hdr(IVIBandDesc *band) {
if (!_ctx.gb->getBits1())
band->blk_vlc.tab = _ctx.blk_vlc.tab;
else
- if (band->blk_vlc.ff_ivi_dec_huff_desc(_ctx.gb, 1, IVI_BLK_HUFF))
+ if (band->blk_vlc.ff_ivi_dec_huff_desc(&_ctx, 1, IVI_BLK_HUFF))
return -1;
// select appropriate rvmap table for this band