[Scummvm-git-logs] scummvm master -> 0733cf65ba8f6babdf35547b49cd2d57c9daf646
sev-
sev at scummvm.org
Sun Sep 11 16:59:13 CEST 2016
This automated email contains information about 21 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
73e7903186 IMAGE: Beginning of Indeo 4 decoder, added GetBits class for reading bits
5f0962696f IMAGE: Added Indeo4Decoder decodePictureHeader, and lots of dependencies
c165826316 IMAGE: Created Indeo decoder base class for shared Indeo4/5 functionality
9e774af4d9 IMAGE: Further implementation of Indeo image decoding
c60a03019c IMAGE: Cleanup and warning fixes for Indeo decoder
400661182e IMAGE: Indeo4 header now being successfully loaded
3a2ee8ea23 IMAGE: Fixes for setup of Indeo4 decoder
0910e642a2 IMAGE: Fix decoding tile data in Indeo4 decoder
4e9933d3c9 IMAGE: Indeo4 decoder is now working
a6ffef9e26 IMAGE: Remove green lines from Indeo4 decoder
9c7b9e1667 IMAGE: Compilation fixes for Indeo4 decoder
bd010bc79f COMMON: Converted Common::BitStream to use DisposeAfterUse
fe6d624277 IMAGE: Implemented Indeo5 decoder
58ad70f351 IMAGE: Renaming structure fields for Indeo decoders
e06442afb6 IMAGE: Cleanup of method parameters and locals in Indeo decoders
9c6a55a2a6 IMAGE: Cleanup of miscellaneous methods and arrays in Indeo decoders
23b1dbbb0e IMAGE: Refactored Indeo GetBits class to derive from Common::BitStream
2f7da2d3d9 IMAGE: Miscellaneous cleanup for Indeo decompressors
a5f4366387 IMAGE: Fix leading spaces into tabs in Indeo decoders
08143af482 IMAGE: Further formatting of Indeo decoders
0733cf65ba Merge pull request #826 from dreammaster/indeo
Commit: 73e79031865a71dd5ced18fe3269f79ceba6e08c
https://github.com/scummvm/scummvm/commit/73e79031865a71dd5ced18fe3269f79ceba6e08c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T10:07:53-04:00
Commit Message:
IMAGE: Beginning of Indeo 4 decoder, added GetBits class for reading bits
Changed paths:
A image/codecs/indeo/get_bits.cpp
A image/codecs/indeo/get_bits.h
A image/codecs/indeo4.cpp
A image/codecs/indeo4.h
image/codecs/codec.cpp
image/module.mk
diff --git a/image/codecs/codec.cpp b/image/codecs/codec.cpp
index 9e5c1bf..105e41e 100644
--- a/image/codecs/codec.cpp
+++ b/image/codecs/codec.cpp
@@ -30,6 +30,7 @@
#include "image/codecs/cdtoons.h"
#include "image/codecs/cinepak.h"
#include "image/codecs/indeo3.h"
+#include "image/codecs/indeo4.h"
#include "image/codecs/mjpeg.h"
#include "image/codecs/mpeg.h"
#include "image/codecs/msvideo1.h"
@@ -209,6 +210,9 @@ Codec *createBitmapCodec(uint32 tag, int width, int height, int bitsPerPixel) {
return new CinepakDecoder(bitsPerPixel);
case MKTAG('I','V','3','2'):
return new Indeo3Decoder(width, height);
+ case MKTAG('I', 'V', '4', '1'):
+ case MKTAG('I', 'V', '4', '2'):
+ return new Indeo4Decoder(width, height);
#ifdef IMAGE_CODECS_TRUEMOTION1_H
case MKTAG('D','U','C','K'):
case MKTAG('d','u','c','k'):
diff --git a/image/codecs/indeo/get_bits.cpp b/image/codecs/indeo/get_bits.cpp
new file mode 100644
index 0000000..4878bc6
--- /dev/null
+++ b/image/codecs/indeo/get_bits.cpp
@@ -0,0 +1,462 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "image/codecs/indeo/get_bits.h"
+#include "common/endian.h"
+#include "common/textconsole.h"
+
+/* Intel Indeo 4 bitstream reader
+ *
+ * Original copyright note:
+ * Copyright (c) 2004 Michael Niedermayer
+ */
+
+namespace Image {
+namespace Indeo {
+
+/* Macro documentation
+ * name
+ * arbitrary name which is used as prefix for local variables
+ *
+ * OPEN_READER(name)
+ * load index into local variable
+ *
+ * CLOSE_READER(name)
+ * store local index back into class state
+ *
+ * UPDATE_CACHE(name)
+ * Refill the internal cache from the bitstream.
+ * After this call at least MIN_CACHE_BITS will be available.
+ *
+ * GET_CACHE(name)
+ * Will output the contents of the internal cache,
+ * next bit is MSB of 32 or 64 bits (FIXME 64 bits).
+ *
+ * SHOW_UBITS(name, num)
+ * Will return the next num bits.
+ *
+ * SHOW_SBITS(name, num)
+ * Will return the next num bits and do sign extension.
+ *
+ * SKIP_BITS(name, num)
+ * Will skip over the next num bits.
+ * Note, this is equivalent to SKIP_CACHE; SKIP_COUNTER.
+ *
+ * SKIP_CACHE(name, num)
+ * Will remove the next num bits from the cache (note SKIP_COUNTER
+ * MUST be called before UPDATE_CACHE / CLOSE_READER).
+ *
+ * SKIP_COUNTER(name, num)
+ * Will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS).
+ *
+ * LAST_SKIP_BITS(name, num)
+ * Like SKIP_BITS, to be used if next call is UPDATE_CACHE or CLOSE_READER.
+ *
+ * BITS_LEFT(name)
+ * Return the number of bits left
+ *
+ * For examples see getBits, show_bits, skip_bits, get_vlc.
+ */
+#define BITSTREAM_READER_LE
+
+#ifdef LONG_BITSTREAM_READER
+# define MIN_CACHE_BITS 32
+#else
+# define MIN_CACHE_BITS 25
+#endif
+
+#define NEG_USR32(a,s) (((uint32)(a)) >> (32 -(s)))
+
+#define OPEN_READER_NOSIZE(name) \
+ unsigned int name ## _index = _index; \
+ unsigned int name ## _cache
+
+#define OPEN_READER(name) OPEN_READER_NOSIZE(name)
+#define BITS_AVAILABLE(name) 1
+
+#define CLOSE_READER(name) _index = name ## _index
+
+# ifdef LONG_BITSTREAM_READER
+# define UPDATE_CACHE_LE(name) name ## _cache = \
+ AV_RL64(_buffer + (name ## _index >> 3)) >> (name ## _index & 7)
+
+# define UPDATE_CACHE_BE(name) name ## _cache = \
+ AV_RB64(_buffer + (name ## _index >> 3)) >> (32 - (name ## _index & 7))
+#else
+# define UPDATE_CACHE_LE(name) name ## _cache = \
+ READ_LE_UINT32(_buffer + (name ## _index >> 3)) >> (name ## _index & 7)
+
+# define UPDATE_CACHE_BE(name) name ## _cache = \
+ AV_RB32(_buffer + (name ## _index >> 3)) << (name ## _index & 7)
+#endif
+
+#ifdef BITSTREAM_READER_LE
+# define UPDATE_CACHE(name) UPDATE_CACHE_LE(name)
+# define SKIP_CACHE(name, num) name ## _cache >>= (num)
+#else
+# define UPDATE_CACHE(name) UPDATE_CACHE_BE(name)
+# define SKIP_CACHE(name, num) name ## _cache <<= (num)
+#endif
+
+#define SKIP_COUNTER(name, num) name ## _index += (num)
+
+#define BITS_LEFT(name) ((int)(_size_in_bits - name ## _index))
+
+#define SKIP_BITS(name, num) \
+ do { \
+ SKIP_CACHE(name, num); \
+ SKIP_COUNTER(name, num); \
+ } while (0)
+
+#define LAST_SKIP_BITS(name, num) SKIP_COUNTER(name, num)
+
+#define SHOW_UBITS_LE(name, num) zeroExtend(name ## _cache, num)
+#define SHOW_SBITS_LE(name, num) signExtend(name ## _cache, num)
+
+#define SHOW_UBITS_BE(name, num) NEG_USR32(name ## _cache, num)
+#define SHOW_SBITS_BE(name, num) NEG_SSR32(name ## _cache, num)
+
+#ifdef BITSTREAM_READER_LE
+# define SHOW_UBITS(name, num) SHOW_UBITS_LE(name, num)
+# define SHOW_SBITS(name, num) SHOW_SBITS_LE(name, num)
+#else
+# define SHOW_UBITS(name, num) SHOW_UBITS_BE(name, num)
+# define SHOW_SBITS(name, num) SHOW_SBITS_BE(name, num)
+#endif
+
+#define GET_CACHE(name) ((uint32) name ## _cache)
+
+
+static int signExtend(int val, uint bits) {
+ uint shift = 8 * sizeof(int) - bits;
+ union { uint u; int s; } v = { (unsigned)val << shift };
+ return v.s >> shift;
+}
+
+static uint zeroExtend(uint val, uint bits) {
+ return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits);
+}
+
+GetBits::GetBits(const byte *buffer, size_t totalBits) {
+ assert(buffer && totalBits < (INT_MAX - 7));
+
+ _buffer = buffer;
+ _sizeInBits = totalBits;
+ _sizeInBitsPlus8 = totalBits + 8;
+ _index = 0;
+}
+
+
+GetBits::GetBits(const GetBits &src) : _index(src._index), _buffer(src._buffer),
+ _sizeInBits(src._sizeInBits), _sizeInBitsPlus8(src._sizeInBitsPlus8) {
+}
+
+int GetBits::getXbits(int n) {
+ int sign;
+ int cache;
+ OPEN_READER(re);
+ assert(n > 0 && n <= 25);
+ UPDATE_CACHE(re);
+ cache = GET_CACHE(re);
+ sign = ~cache >> 31;
+ LAST_SKIP_BITS(re, n);
+ CLOSE_READER(re);
+ return (NEG_USR32(sign ^ cache, n) ^ sign) - sign;
+}
+
+int GetBits::getSbits(int n) {
+ int tmp;
+ OPEN_READER(re);
+ assert(n > 0 && n <= 25);
+ UPDATE_CACHE(re);
+ tmp = SHOW_SBITS(re, n);
+ LAST_SKIP_BITS(re, n);
+ CLOSE_READER(re);
+ return tmp;
+}
+
+/**
+* Read 1-25 bits.
+*/
+uint GetBits::getBits(int n) {
+ int tmp;
+ OPEN_READER(re);
+ assert(n > 0 && n <= 25);
+ UPDATE_CACHE(re);
+ tmp = SHOW_UBITS(re, n);
+ LAST_SKIP_BITS(re, n);
+ CLOSE_READER(re);
+ return tmp;
+}
+
+int GetBits::getBitsZ(int n) {
+ return n ? getBits(n) : 0;
+}
+
+uint GetBits::getBitsLE(int n) {
+ int tmp;
+ OPEN_READER(re);
+ assert(n > 0 && n <= 25);
+ UPDATE_CACHE_LE(re);
+ tmp = SHOW_UBITS_LE(re, n);
+ LAST_SKIP_BITS(re, n);
+ CLOSE_READER(re);
+ return tmp;
+}
+
+uint GetBits::showBits(int n) {
+ int tmp;
+ OPEN_READER_NOSIZE(re);
+ assert(n > 0 && n <= 25);
+ UPDATE_CACHE(re);
+ tmp = SHOW_UBITS(re, n);
+ return tmp;
+}
+
+void GetBits::skipBits(int n) {
+ OPEN_READER(re);
+ LAST_SKIP_BITS(re, n);
+ CLOSE_READER(re);
+}
+
+uint GetBits::getBits1() {
+ uint index = _index;
+ uint8 result = _buffer[index >> 3];
+#ifdef BITSTREAM_READER_LE
+ result >>= index & 7;
+ result &= 1;
+#else
+ result <<= index & 7;
+ result >>= 8 - 1;
+#endif
+#if !UNCHECKED_BITSTREAM_READER
+ if (_index < _sizeInBitsPlus8)
+#endif
+ index++;
+ _index = index;
+
+ return result;
+}
+
+uint GetBits::showBits1() {
+ return showBits(1);
+}
+
+void GetBits::skipBits1() {
+ skipBits(1);
+}
+
+/**
+* Read 0-32 bits.
+*/
+uint GetBits::getBitsLong(int n) {
+ if (!n) {
+ return 0;
+ } else if (n <= MIN_CACHE_BITS) {
+ return getBits(n);
+ } else {
+#ifdef BITSTREAM_READER_LE
+ unsigned ret = getBits(16);
+ return ret | (getBits(n - 16) << 16);
+#else
+ unsigned ret = getBits(16) << (n - 16);
+ return ret | getBits(n - 16);
+#endif
+ }
+}
+
+/**
+ * Read 0-64 bits.
+ */
+uint64 GetBits::getBits64(int n) {
+ if (n <= 32) {
+ return getBitsLong(n);
+ } else {
+#ifdef BITSTREAM_READER_LE
+ uint64 ret = getBitsLong(32);
+ return ret | (uint64)getBitsLong(n - 32) << 32;
+#else
+ uint64 ret = (uint64)getBitsLong(n - 32) << 32;
+ return ret | getBitsLong(32);
+#endif
+ }
+}
+
+int GetBits::getSbitsLong(int n) {
+ return signExtend(getBitsLong(n), n);
+}
+
+/**
+* Show 0-32 bits.
+*/
+uint GetBits::showBitsLong(int n) {
+ if (n <= MIN_CACHE_BITS) {
+ return showBits(n);
+ } else {
+ GetBits gb(*this);
+ return gb.getBitsLong(n);
+ }
+}
+
+int GetBits::checkMarker(void *logctx, const char *msg) {
+ int bit = getBits1();
+ if (!bit)
+ warning("Marker bit missing at %d of %d %s\n",
+ getBitsCount() - 1, _sizeInBits, msg);
+
+ return bit;
+}
+
+const byte *GetBits::alignGetBits() {
+ int n = -(int)getBitsCount() & 7;
+ if (n)
+ skipBits(n);
+
+ return _buffer + (_index >> 3);
+}
+
+/**
+ * If the vlc code is invalid and max_depth=1, then no bits will be removed.
+ * If the vlc code is invalid and max_depth>1, then the number of bits removed
+ * is undefined.
+ */
+#define GET_VLC(code, name, table, bits, max_depth) \
+ do { \
+ int n, nb_bits; \
+ unsigned int index; \
+ \
+ index = SHOW_UBITS(name, bits); \
+ code = table[index][0]; \
+ n = table[index][1]; \
+ \
+ if (max_depth > 1 && n < 0) { \
+ LAST_SKIP_BITS(name, bits); \
+ UPDATE_CACHE(name); \
+ \
+ nb_bits = -n; \
+ \
+ index = SHOW_UBITS(name, nb_bits) + code; \
+ code = table[index][0]; \
+ n = table[index][1]; \
+ if (max_depth > 2 && n < 0) { \
+ LAST_SKIP_BITS(name, nb_bits); \
+ UPDATE_CACHE(name); \
+ \
+ nb_bits = -n; \
+ \
+ index = SHOW_UBITS(name, nb_bits) + code; \
+ code = table[index][0]; \
+ n = table[index][1]; \
+ } \
+ } \
+ SKIP_BITS(name, n); \
+ } while (0)
+
+#define GET_RL_VLC(level, run, name, table, bits, \
+ max_depth, need_update) \
+ do { \
+ int n, nb_bits; \
+ unsigned int index; \
+ \
+ index = SHOW_UBITS(name, bits); \
+ level = table[index].level; \
+ n = table[index].len; \
+ \
+ if (max_depth > 1 && n < 0) { \
+ SKIP_BITS(name, bits); \
+ if (need_update) { \
+ UPDATE_CACHE(name); \
+ } \
+ \
+ nb_bits = -n; \
+ \
+ index = SHOW_UBITS(name, nb_bits) + level; \
+ level = table[index].level; \
+ n = table[index].len; \
+ if (max_depth > 2 && n < 0) { \
+ LAST_SKIP_BITS(name, nb_bits); \
+ if (need_update) { \
+ UPDATE_CACHE(name); \
+ } \
+ nb_bits = -n; \
+ \
+ index = SHOW_UBITS(name, nb_bits) + level; \
+ level = table[index].level; \
+ n = table[index].len; \
+ } \
+ } \
+ run = table[index].run; \
+ SKIP_BITS(name, n); \
+ } while (0)
+
+/**
+* Parse a vlc code.
+* @param bits is the number of bits which will be read at once, must be
+* identical to nb_bits in init_vlc()
+* @param max_depth is the number of times bits bits must be read to completely
+* read the longest vlc code
+* = (max_vlc_length + bits - 1) / bits
+*/
+int GetBits::getVLC2(int (*table)[2], int bits, int maxDepth) {
+ int code;
+
+ OPEN_READER(re);
+ UPDATE_CACHE(re);
+
+ GET_VLC(code, re, table, bits, maxDepth);
+
+ CLOSE_READER(re);
+
+ return code;
+}
+
+int GetBits::decode012() {
+ int n;
+ n = getBits1();
+ if (n == 0)
+ return 0;
+ else
+ return getBits1() + 1;
+}
+
+int GetBits::decode210() {
+ if (getBits1())
+ return 0;
+ else
+ return 2 - getBits1();
+}
+
+int GetBits::skip1stop8dataBits() {
+ if (getBitsLeft() <= 0)
+ return -1;
+
+ while (getBits1()) {
+ skipBits(8);
+ if (getBitsLeft() <= 0)
+ return -1;
+ }
+
+ return 0;
+}
+
+} // End of namespace Indeo
+} // End of namespace Image
diff --git a/image/codecs/indeo/get_bits.h b/image/codecs/indeo/get_bits.h
new file mode 100644
index 0000000..dd6ba55
--- /dev/null
+++ b/image/codecs/indeo/get_bits.h
@@ -0,0 +1,169 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+/* Intel Indeo 4 bitstream reader
+ *
+ * Original copyright note:
+ * Copyright (c) 2004 Michael Niedermayer
+ */
+
+#ifndef IMAGE_CODECS_INDEO_GET_BITS_H
+#define IMAGE_CODECS_INDEO_GET_BITS_H
+
+#include "common/scummsys.h"
+
+namespace Image {
+namespace Indeo {
+
+#define AV_INPUT_BUFFER_PADDING_SIZE 32
+
+/**
+ * Intel Indeo Bitstream reader
+ */
+class GetBits {
+private:
+ const byte *_buffer;
+ uint _index;
+ uint _sizeInBits;
+ uint _sizeInBitsPlus8;
+public:
+ /**
+ * Constructor
+ * @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);
+
+ GetBits(const GetBits &src);
+
+ /**
+ * Returns the number of bits read
+ */
+ uint getBitsCount() const { return _index; }
+
+ /**
+ * The number of bits left
+ */
+ int getBitsLeft() const { return _sizeInBits - _index; }
+
+ void skipBitsLong(uint n) { _index += n; }
+
+ /**
+ * Read MPEG-1 dc-style VLC (sign bit + mantissa with no MSB).
+ * if MSB not set it is negative
+ * @param n length in bits
+ */
+ int getXbits(int n);
+
+ /**
+ * Returns the next n bits, and does sign extension
+ */
+ int getSbits(int n);
+
+ /**
+ * Read 1-25 bits.
+ */
+ uint getBits(int n);
+
+ /**
+ * Read 0-25 bits.
+ */
+ int getBitsZ(int n);
+
+ uint getBitsLE(int n);
+
+ /**
+ * Show 1-25 bits.
+ * Returns the data without updating the index
+ */
+ uint showBits(int n);
+
+ /**
+ * Skips a specified number of bits
+ */
+ void skipBits(int n);
+
+ /**
+ * Returns the next bit
+ */
+ uint getBits1();
+
+ /**
+ * Shows the next following bit
+ */
+ uint showBits1();
+
+ /**
+ * Skips the next bit
+ */
+ void skipBits1();
+
+ /**
+ * Read 0-32 bits.
+ */
+ uint getBitsLong(int n);
+
+ /**
+ * Read 0-64 bits.
+ */
+ uint64 getBits64(int n);
+
+ /**
+ * Read 0-32 bits as a signed integer.
+ */
+ int getSbitsLong(int n);
+
+ /**
+ * Show 0-32 bits.
+ */
+ uint showBitsLong(int n);
+
+ int checkMarker(void *logctx, const char *msg);
+
+ /**
+ * Parse a VLC code.
+ * @param bits is the number of bits which will be read at once, must be
+ * identical to nb_bits in init_vlc()
+ * @param max_depth is the number of times bits bits must be read to completely
+ * read the longest vlc code
+ * = (max_vlc_length + bits - 1) / bits
+ */
+ int getVLC2(int(*table)[2], int bits, int maxDepth);
+
+ int decode012();
+
+ int decode210();
+
+ int skip1stop8dataBits();
+
+ const byte *alignGetBits();
+};
+
+} // End of namespace Indeo
+} // End of namespace Image
+
+#endif
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
new file mode 100644
index 0000000..465e3ad
--- /dev/null
+++ b/image/codecs/indeo4.cpp
@@ -0,0 +1,81 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+/* Intel Indeo 4 decompressor, derived from ffmpeg.
+ *
+ * Original copyright note: * Intel Indeo 3 (IV31, IV32, etc.) video decoder for ffmpeg
+ * written, produced, and directed by Alan Smithee
+ */
+
+#include "common/system.h"
+#include "common/endian.h"
+#include "common/stream.h"
+#include "common/textconsole.h"
+#include "common/util.h"
+
+#include "graphics/yuv_to_rgb.h"
+
+#include "image/codecs/indeo4.h"
+#include "image/codecs/indeo/get_bits.h"
+
+namespace Image {
+
+Indeo4Decoder::Indeo4Decoder(uint16 width, uint16 height) {
+ _pixelFormat = g_system->getScreenFormat();
+ _surface = new Graphics::ManagedSurface();
+ _surface->create(width, height, _pixelFormat);
+
+}
+
+Indeo4Decoder::~Indeo4Decoder() {
+ delete _surface;
+}
+
+bool Indeo4Decoder::isIndeo4(Common::SeekableReadStream &stream) {
+ // Less than 16 bytes? This can't be right
+ if (stream.size() < 16)
+ return false;
+
+ // Read in the start of the data
+ byte buffer[16];
+ stream.read(buffer, 16);
+ stream.seek(-16, SEEK_CUR);
+
+ // Validate the first 18-bit word has the correct identifier
+ Indeo::GetBits gb(buffer, 16 * 8);
+ bool isIndeo4 = gb.getBits(18) == 0x3FFF8;
+
+ return isIndeo4;
+}
+
+const Graphics::Surface *Indeo4Decoder::decodeFrame(Common::SeekableReadStream &stream) {
+ // Not Indeo 4? Fail
+ if (!isIndeo4(stream))
+ return 0;
+
+ // TODO
+ return nullptr;
+}
+
+} // End of namespace Image
diff --git a/image/codecs/indeo4.h b/image/codecs/indeo4.h
new file mode 100644
index 0000000..44007e0
--- /dev/null
+++ b/image/codecs/indeo4.h
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+/* Intel Indeo 4 decompressor, derived from ffmpeg.
+ *
+ * Original copyright note:
+ * Intel Indeo 4 (IV31, IV32, etc.) video decoder for ffmpeg
+ * written, produced, and directed by Alan Smithee
+ */
+
+#ifndef IMAGE_CODECS_INDEO4_H
+#define IMAGE_CODECS_INDEO4_H
+
+#include "image/codecs/codec.h"
+#include "graphics/managed_surface.h"
+
+namespace Image {
+
+/**
+ * Intel Indeo 4 decoder.
+ *
+ * Used by AVI.
+ *
+ * Used in video:
+ * - AVIDecoder
+ */
+class Indeo4Decoder : public Codec {
+public:
+ Indeo4Decoder(uint16 width, uint16 height);
+ ~Indeo4Decoder();
+
+ const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream);
+ Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; }
+
+ static bool isIndeo4(Common::SeekableReadStream &stream);
+private:
+ Graphics::PixelFormat _pixelFormat;
+ Graphics::ManagedSurface *_surface;
+};
+
+} // End of namespace Image
+
+#endif
diff --git a/image/module.mk b/image/module.mk
index 3742fb9..af4284d 100644
--- a/image/module.mk
+++ b/image/module.mk
@@ -13,6 +13,7 @@ MODULE_OBJS := \
codecs/cinepak.o \
codecs/codec.o \
codecs/indeo3.o \
+ codecs/indeo4.o \
codecs/mjpeg.o \
codecs/msrle.o \
codecs/msrle4.o \
@@ -21,7 +22,8 @@ MODULE_OBJS := \
codecs/rpza.o \
codecs/smc.o \
codecs/svq1.o \
- codecs/truemotion1.o
+ codecs/truemotion1.o \
+ codecs/indeo/get_bits.o
ifdef USE_MPEG2
MODULE_OBJS += \
Commit: 5f0962696f97df2cce27d065d99b04243de59334
https://github.com/scummvm/scummvm/commit/5f0962696f97df2cce27d065d99b04243de59334
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T10:08:10-04:00
Commit Message:
IMAGE: Added Indeo4Decoder decodePictureHeader, and lots of dependencies
Changed paths:
A image/codecs/indeo/indeo.cpp
A image/codecs/indeo/indeo.h
A image/codecs/indeo/mem.cpp
A image/codecs/indeo/mem.h
A image/codecs/indeo/vlc.cpp
A image/codecs/indeo/vlc.h
image/codecs/indeo/get_bits.cpp
image/codecs/indeo/get_bits.h
image/codecs/indeo4.cpp
image/codecs/indeo4.h
image/module.mk
diff --git a/image/codecs/indeo/get_bits.cpp b/image/codecs/indeo/get_bits.cpp
index 4878bc6..98cef7f 100644
--- a/image/codecs/indeo/get_bits.cpp
+++ b/image/codecs/indeo/get_bits.cpp
@@ -21,6 +21,7 @@
*/
#include "image/codecs/indeo/get_bits.h"
+#include "common/algorithm.h"
#include "common/endian.h"
#include "common/textconsole.h"
@@ -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) {
diff --git a/image/codecs/indeo/get_bits.h b/image/codecs/indeo/get_bits.h
index dd6ba55..313fe7e 100644
--- a/image/codecs/indeo/get_bits.h
+++ b/image/codecs/indeo/get_bits.h
@@ -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 {
@@ -44,13 +46,14 @@ 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
@@ -58,9 +61,23 @@ public:
*/
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
*/
uint getBitsCount() const { return _index; }
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
new file mode 100644
index 0000000..9de32fa
--- /dev/null
+++ b/image/codecs/indeo/indeo.cpp
@@ -0,0 +1,394 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/* Common structures and macros shared by both Indeo4 and Indeo5 decoders,
+ * derived from ffmpeg. We don't currently support Indeo5 decoding, but
+ * just in case we eventually need it, this is kept as a separate file
+ * like it is in ffmpeg.
+ *
+ * Original copyright note: * Intel Indeo 4 (IV41, IV42, etc.) video decoder for ffmpeg
+ * written, produced, and directed by Alan Smithee
+ */
+
+#include "image/codecs/indeo/indeo.h"
+#include "image/codecs/indeo/mem.h"
+#include "common/textconsole.h"
+#include "common/util.h"
+
+namespace Image {
+namespace Indeo {
+
+/**
+ * These are 2x8 predefined Huffman codebooks for coding macroblock/block
+ * signals. They are specified using "huffman descriptors" in order to
+ * avoid huge static tables. The decoding tables will be generated at
+ * startup from these descriptors.
+ */
+
+ /**
+ * Static macroblock huffman tables
+ */
+static const IVIHuffDesc ivi_mb_huff_desc[8] = {
+ {8, {0, 4, 5, 4, 4, 4, 6, 6}},
+ {12, {0, 2, 2, 3, 3, 3, 3, 5, 3, 2, 2, 2}},
+ {12, {0, 2, 3, 4, 3, 3, 3, 3, 4, 3, 2, 2}},
+ {12, {0, 3, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2}},
+ {13, {0, 4, 4, 3, 3, 3, 3, 2, 3, 3, 2, 1, 1}},
+ {9, {0, 4, 4, 4, 4, 3, 3, 3, 2}},
+ {10, {0, 4, 4, 4, 4, 3, 3, 2, 2, 2}},
+ {12, {0, 4, 4, 4, 3, 3, 2, 3, 2, 2, 2, 2}}
+};
+
+/**
+ * static block huffman tables
+ */
+static const IVIHuffDesc ivi_blk_huff_desc[8] = {
+ {10, {1, 2, 3, 4, 4, 7, 5, 5, 4, 1}},
+ {11, {2, 3, 4, 4, 4, 7, 5, 4, 3, 3, 2}},
+ {12, {2, 4, 5, 5, 5, 5, 6, 4, 4, 3, 1, 1}},
+ {13, {3, 3, 4, 4, 5, 6, 6, 4, 4, 3, 2, 1, 1}},
+ {11, {3, 4, 4, 5, 5, 5, 6, 5, 4, 2, 2}},
+ {13, {3, 4, 5, 5, 5, 5, 6, 4, 3, 3, 2, 1, 1}},
+ {13, {3, 4, 5, 5, 5, 6, 5, 4, 3, 3, 2, 1, 1}},
+ {9, {3, 4, 4, 5, 5, 5, 6, 5, 5}}
+};
+
+/*------------------------------------------------------------------------*/
+
+/**
+ * calculate number of tiles in a stride
+ */
+#define IVI_NUM_TILES(stride, tile_size) (((stride) + (tile_size) - 1) / (tile_size))
+
+
+/**
+ * calculate number of macroblocks in a tile
+ */
+#define IVI_MBs_PER_TILE(tile_width, tile_height, mb_size) \
+ ((((tile_width) + (mb_size) - 1) / (mb_size)) * (((tile_height) + (mb_size) - 1) / (mb_size)))
+
+/*------------------------------------------------------------------------*/
+
+int IVIHuffDesc::ivi_create_huff_from_desc(VLC *vlc, int flag) const {
+ int pos, i, j, codes_per_row, prefix, not_last_row;
+ uint16 codewords[256];
+ uint8 bits[256];
+
+ pos = 0; // current position = 0
+
+ for (i = 0; i < num_rows; i++) {
+ codes_per_row = 1 << xbits[i];
+ not_last_row = (i != num_rows - 1);
+ prefix = ((1 << i) - 1) << (xbits[i] + not_last_row);
+
+ for (j = 0; j < codes_per_row; j++) {
+ if (pos >= 256) // Some Indeo5 codebooks can have more than 256
+ break; // elements, but only 256 codes are allowed!
+
+ bits[pos] = i + xbits[i] + not_last_row;
+ if (bits[pos] > IVI_VLC_BITS)
+ return -1; // invalid descriptor
+
+ codewords[pos] = inv_bits((prefix | j), bits[pos]);
+ if (!bits[pos])
+ bits[pos] = 1;
+
+ pos++;
+ }//for j
+ }//for i
+
+ // number of codewords = pos
+ return vlc->init_vlc(IVI_VLC_BITS, pos, bits, 1, 1, codewords, 2, 2,
+ (flag ? INIT_VLC_USE_NEW_STATIC : 0) | INIT_VLC_LE);
+}
+
+/*------------------------------------------------------------------------*/
+
+bool IVIHuffDesc::ivi_huff_desc_cmp(const IVIHuffDesc *desc2) const {
+ return num_rows != desc2->num_rows ||
+ memcmp(xbits, desc2->xbits, num_rows);
+}
+
+void IVIHuffDesc::ivi_huff_desc_copy(const IVIHuffDesc *src) {
+ num_rows = src->num_rows;
+ memcpy(xbits, src->xbits, src->num_rows);
+}
+
+/*------------------------------------------------------------------------*/
+
+IVIHuffTab::IVIHuffTab() {
+ tab = nullptr;
+
+ 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);
+ }
+}
+
+int IVIHuffTab::ff_ivi_dec_huff_desc(GetBits *gb, 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];
+ return 0;
+ }
+
+ tab_sel = gb->getBits(3);
+ if (tab_sel == 7) {
+ // custom huffman table (explicitly encoded)
+ new_huff.num_rows = 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);
+
+ // Have we got the same custom table? Rebuild if not.
+ if (new_huff.ivi_huff_desc_cmp(&cust_desc) || !cust_tab.table) {
+ cust_desc.ivi_huff_desc_copy(&new_huff);
+
+ if (cust_tab.table)
+ cust_tab.ff_free_vlc();
+ result = cust_desc.ivi_create_huff_from_desc(&cust_tab, 0);
+ if (result) {
+ // reset faulty description
+ cust_desc.num_rows = 0;
+ warning("Error while initializing custom vlc table!");
+ return result;
+ }
+ }
+ tab = &cust_tab;
+ } else {
+ // select one of predefined tables
+ tab = (which_tab) ? &ivi_blk_vlc_tabs[tab_sel]
+ : &ivi_mb_vlc_tabs[tab_sel];
+ }
+
+ return 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+bool IVIPicConfig::ivi_pic_config_cmp(const IVIPicConfig &cfg2) {
+ return pic_width != cfg2.pic_width || pic_height != cfg2.pic_height ||
+ chroma_width != cfg2.chroma_width || chroma_height != cfg2.chroma_height ||
+ tile_width != cfg2.tile_width || tile_height != cfg2.tile_height ||
+ luma_bands != cfg2.luma_bands || chroma_bands != cfg2.chroma_bands;
+}
+
+/*------------------------------------------------------------------------*/
+
+int IVIPlaneDesc::ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg, bool is_indeo4) {
+ int p, b;
+ uint32 b_width, b_height, align_fac, width_aligned,
+ height_aligned, buf_size;
+ IVIBandDesc *band;
+
+ ivi_free_buffers(planes);
+
+ if (av_image_check_size(cfg->pic_width, cfg->pic_height, 0, NULL) < 0 ||
+ cfg->luma_bands < 1 || cfg->chroma_bands < 1)
+ return -1;
+
+ // fill in the descriptor of the luminance plane
+ planes[0].width = cfg->pic_width;
+ planes[0].height = cfg->pic_height;
+ planes[0].num_bands = cfg->luma_bands;
+
+ // fill in the descriptors of the chrominance planes
+ planes[1].width = planes[2].width = (cfg->pic_width + 3) >> 2;
+ planes[1].height = planes[2].height = (cfg->pic_height + 3) >> 2;
+ planes[1].num_bands = planes[2].num_bands = cfg->chroma_bands;
+
+ for (p = 0; p < 3; p++) {
+ planes[p].bands = (IVIBandDesc *)av_mallocz_array(planes[p].num_bands, sizeof(IVIBandDesc));
+ if (!planes[p].bands)
+ return -2;
+
+ // select band dimensions: if there is only one band then it
+ // has the full size, if there are several bands each of them
+ // has only half size
+ b_width = planes[p].num_bands == 1 ? planes[p].width
+ : (planes[p].width + 1) >> 1;
+ b_height = planes[p].num_bands == 1 ? planes[p].height
+ : (planes[p].height + 1) >> 1;
+
+ // luma band buffers will be aligned on 16x16 (max macroblock size)
+ // chroma band buffers will be aligned on 8x8 (max macroblock size)
+ align_fac = p ? 8 : 16;
+ width_aligned = FFALIGN(b_width, align_fac);
+ height_aligned = FFALIGN(b_height, align_fac);
+ buf_size = width_aligned * height_aligned * sizeof(int16);
+
+ for (b = 0; b < planes[p].num_bands; b++) {
+ band = &planes[p].bands[b]; // select appropriate plane/band
+ band->plane = p;
+ band->band_num = b;
+ band->width = b_width;
+ band->height = b_height;
+ band->pitch = width_aligned;
+ band->aheight = height_aligned;
+ band->bufs[0] = (int16 *)av_mallocz(buf_size);
+ band->bufs[1] = (int16 *)av_mallocz(buf_size);
+ band->bufsize = buf_size / 2;
+ if (!band->bufs[0] || !band->bufs[1])
+ return -2;
+
+ // allocate the 3rd band buffer for scalability mode
+ if (cfg->luma_bands > 1) {
+ band->bufs[2] = (int16 *)av_mallocz(buf_size);
+ if (!band->bufs[2])
+ return -2;
+ }
+ if (is_indeo4) {
+ band->bufs[3] = (int16 *)av_mallocz(buf_size);
+ if (!band->bufs[3])
+ return -2;
+ }
+ // reset custom vlc
+ planes[p].bands[0].blk_vlc.cust_desc.num_rows = 0;
+ }
+ }
+
+ return 0;
+}
+
+int IVIPlaneDesc::ff_ivi_init_tiles(IVIPlaneDesc *planes,
+ int tile_width, int tile_height) {
+ int p, b, x_tiles, y_tiles, t_width, t_height, ret;
+ IVIBandDesc *band;
+
+ for (p = 0; p < 3; p++) {
+ t_width = !p ? tile_width : (tile_width + 3) >> 2;
+ t_height = !p ? tile_height : (tile_height + 3) >> 2;
+
+ if (!p && planes[0].num_bands == 4) {
+ t_width >>= 1;
+ t_height >>= 1;
+ }
+ if (t_width <= 0 || t_height <= 0)
+ return -3;
+
+ for (b = 0; b < planes[p].num_bands; b++) {
+ band = &planes[p].bands[b];
+ x_tiles = IVI_NUM_TILES(band->width, t_width);
+ y_tiles = IVI_NUM_TILES(band->height, t_height);
+ band->num_tiles = x_tiles * y_tiles;
+
+ av_freep(&band->tiles);
+ band->tiles = (IVITile *)av_mallocz_array(band->num_tiles, sizeof(IVITile));
+ if (!band->tiles)
+ return -2;
+
+ // use the first luma band as reference for motion vectors
+ // and quant
+ ret = band->ivi_init_tiles(planes[0].bands[0].tiles,
+ p, b, t_height, t_width);
+ if (ret < 0)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+void IVIPlaneDesc::ivi_free_buffers(IVIPlaneDesc *planes) {
+ int p, b, t;
+
+ for (p = 0; p < 3; p++) {
+ if (planes[p].bands)
+ for (b = 0; b < planes[p].num_bands; b++) {
+ av_freep(&planes[p].bands[b].bufs[0]);
+ av_freep(&planes[p].bands[b].bufs[1]);
+ av_freep(&planes[p].bands[b].bufs[2]);
+ av_freep(&planes[p].bands[b].bufs[3]);
+
+ if (planes[p].bands[b].blk_vlc.cust_tab.table)
+ planes[p].bands[b].blk_vlc.cust_tab.ff_free_vlc();
+ for (t = 0; t < planes[p].bands[b].num_tiles; t++)
+ av_freep(&planes[p].bands[b].tiles[t].mbs);
+ av_freep(&planes[p].bands[b].tiles);
+ }
+ av_freep(&planes[p].bands);
+ planes[p].num_bands = 0;
+ }
+}
+
+/*------------------------------------------------------------------------*/
+
+int IVIBandDesc::ivi_init_tiles(IVITile *ref_tile, int p, int b, int t_height, int t_width) {
+ int x, y;
+ IVITile *tile = tiles;
+
+ for (y = 0; y < height; y += t_height) {
+ for (x = 0; x < width; x += t_width) {
+ tile->xpos = x;
+ tile->ypos = y;
+ tile->mb_size = mb_size;
+ tile->width = MIN(width - x, t_width);
+ tile->height = MIN(height - y, t_height);
+ tile->is_empty = tile->data_size = 0;
+ // calculate number of macroblocks
+ tile->num_MBs = IVI_MBs_PER_TILE(tile->width, tile->height,
+ mb_size);
+
+ av_freep(&tile->mbs);
+ tile->mbs = (IVIMbInfo *)av_mallocz_array(tile->num_MBs, sizeof(IVIMbInfo));
+ if (!tile->mbs)
+ return -2;
+
+ tile->ref_mbs = 0;
+ if (p || b) {
+ if (tile->num_MBs != ref_tile->num_MBs) {
+ warning("ref_tile mismatch");
+ return -1;
+ }
+ tile->ref_mbs = ref_tile->mbs;
+ ref_tile++;
+ }
+ tile++;
+ }
+ }
+
+ return 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) {
+ if (((w + 128) * (uint64)(h + 128)) < (INT_MAX / 8))
+ return 0;
+
+ error("Picture size %ux%u is invalid", w, h);
+}
+
+} // End of namespace Indeo
+} // End of namespace Image
diff --git a/image/codecs/indeo/indeo.h b/image/codecs/indeo/indeo.h
new file mode 100644
index 0000000..d689994
--- /dev/null
+++ b/image/codecs/indeo/indeo.h
@@ -0,0 +1,350 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+/* Common structures and macros shared by both Indeo4 and Indeo5 decoders,
+ * derived from ffmpeg. We don't currently support Indeo5 decoding, but
+ * just in case we eventually need it, this is kept as a separate file
+ * like it is in ffmpeg.
+ *
+ * Original copyright note: * Intel Indeo 4 (IV41, IV42, etc.) video decoder for ffmpeg
+ * written, produced, and directed by Alan Smithee
+ */
+
+#ifndef IMAGE_CODECS_INDEO_INDEO_H
+#define IMAGE_CODECS_INDEO_INDEO_H
+
+#include "image/codecs/indeo/get_bits.h"
+#include "image/codecs/indeo/vlc.h"
+
+namespace Image {
+namespace Indeo {
+
+/**
+ * Indeo 4 frame types.
+ */
+enum {
+ IVI4_FRAMETYPE_INTRA = 0,
+ IVI4_FRAMETYPE_INTRA1 = 1, ///< intra frame with slightly different bitstream coding
+ IVI4_FRAMETYPE_INTER = 2, ///< non-droppable P-frame
+ IVI4_FRAMETYPE_BIDIR = 3, ///< bidirectional frame
+ IVI4_FRAMETYPE_INTER_NOREF = 4, ///< droppable P-frame
+ IVI4_FRAMETYPE_NULL_FIRST = 5, ///< empty frame with no data
+ IVI4_FRAMETYPE_NULL_LAST = 6 ///< empty frame with no data
+};
+
+#define IVI_VLC_BITS 13 ///< max number of bits of the ivi's huffman codes
+#define IVI5_IS_PROTECTED 0x20
+
+/**
+ * huffman codebook descriptor
+ */
+struct IVIHuffDesc {
+ int32 num_rows;
+ uint8 xbits[16];
+
+ /*
+ * Generate a huffman codebook from the given descriptor
+ * and convert it into the FFmpeg VLC table.
+ *
+ * @param[out] vlc where to place the generated VLC table
+ * @param[in] flag flag: 1 - for static or 0 for dynamic tables
+ * @return result code: 0 - OK, -1 = error (invalid codebook descriptor)
+ */
+ int ivi_create_huff_from_desc(VLC *vlc, int flag) const;
+
+ /*
+ * Compare two huffman codebook descriptors.
+ *
+ * @param[in] desc2 ptr to the 2nd descriptor to compare
+ * @return comparison result: 0 - equal, 1 - not equal
+ */
+ bool ivi_huff_desc_cmp(const IVIHuffDesc *desc2) const;
+
+ /*
+ * Copy huffman codebook descriptors.
+ *
+ * @param[in] src ptr to the source descriptor
+ */
+ void ivi_huff_desc_copy(const IVIHuffDesc *src);
+};
+
+/**
+ * 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
+ VLC *tab; /// pointer to the table associated with tab_sel
+
+ /// the following are used only when tab_sel == 7
+ IVIHuffDesc cust_desc; /// custom Huffman codebook descriptor
+ VLC cust_tab; /// vlc table for custom codebook
+
+ /**
+ * Constructor
+ */
+ IVIHuffTab();
+
+ int ff_ivi_dec_huff_desc(GetBits *gb, int desc_coded, int which_tab);
+};
+
+enum {
+ IVI_MB_HUFF = 0, /// Huffman table is used for coding macroblocks
+ IVI_BLK_HUFF = 1 /// Huffman table is used for coding blocks
+};
+
+
+/**
+ * Common scan patterns (defined in ivi_common.c)
+ */
+//extern const uint8 ff_ivi_vertical_scan_8x8[64];
+//extern const uint8 ff_ivi_horizontal_scan_8x8[64];
+//extern const uint8 ff_ivi_direct_scan_4x4[16];
+
+
+/**
+ * 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 blk_size);
+
+
+/**
+ * run-value (RLE) table descriptor
+ */
+struct RVMapDesc {
+ uint8 eob_sym; ///< end of block symbol
+ uint8 esc_sym; ///< escape symbol
+ uint8 runtab[256];
+ int8 valtab[256];
+};
+
+extern const RVMapDesc ff_ivi_rvmap_tabs[9];
+
+
+/**
+ * information for Indeo macroblock (16x16, 8x8 or 4x4)
+ */
+struct IVIMbInfo {
+ int16 xpos;
+ int16 ypos;
+ uint32 buf_offs; ///< address in the output buffer for this mb
+ uint8 type; ///< macroblock type: 0 - INTRA, 1 - INTER
+ uint8 cbp; ///< coded block pattern
+ int8 q_delta; ///< quant delta
+ int8 mv_x; ///< motion vector (x component)
+ int8 mv_y; ///< motion vector (y component)
+ int8 b_mv_x; ///< second motion vector (x component)
+ int8 b_mv_y; ///< second motion vector (y component)
+};
+
+
+/**
+ * information for Indeo tile
+ */
+struct IVITile {
+ int xpos;
+ int ypos;
+ int width;
+ int height;
+ int mb_size;
+ int is_empty; ///< = 1 if this tile doesn't contain any data
+ int data_size; ///< size of the data in bytes
+ int num_MBs; ///< number of macroblocks in this tile
+ IVIMbInfo * mbs; ///< array of macroblock descriptors
+ IVIMbInfo * ref_mbs; ///< ptr to the macroblock descriptors of the reference tile
+};
+
+
+/**
+ * information for Indeo wavelet band
+ */
+struct IVIBandDesc {
+ int plane; ///< plane number this band belongs to
+ int band_num; ///< band number
+ int width;
+ int height;
+ int aheight; ///< aligned band height
+ const uint8 * data_ptr; ///< ptr to the first byte of the band data
+ int data_size; ///< size of the band data
+ int16 * buf; ///< pointer to the output buffer for this band
+ int16 * ref_buf; ///< pointer to the reference frame buffer (for motion compensation)
+ int16 * b_ref_buf; ///< pointer to the second reference frame buffer (for motion compensation)
+ int16 * bufs[4]; ///< array of pointers to the band buffers
+ int pitch; ///< pitch associated with the buffers above
+ int is_empty; ///< = 1 if this band doesn't contain any data
+ int mb_size; ///< macroblock size
+ int blk_size; ///< block size
+ int is_halfpel; ///< precision of the motion compensation: 0 - fullpel, 1 - halfpel
+ int inherit_mv; ///< tells if motion vector is inherited from reference macroblock
+ int inherit_qdelta; ///< tells if quantiser delta is inherited from reference macroblock
+ int qdelta_present; ///< tells if Qdelta signal is present in the bitstream (Indeo5 only)
+ int quant_mat; ///< dequant matrix index
+ int glob_quant; ///< quant base for this band
+ const uint8 * scan; ///< ptr to the scan pattern
+ int scan_size; ///< size of the scantable
+
+ IVIHuffTab blk_vlc; ///< vlc table for decoding block data
+
+ int num_corr; ///< number of correction entries
+ uint8 corr[61 * 2]; ///< rvmap correction pairs
+ int rvmap_sel; ///< rvmap table selector
+ RVMapDesc * rv_map; ///< ptr to the RLE table for this band
+ int num_tiles; ///< number of tiles in this band
+ IVITile * tiles; ///< array of tile descriptors
+ InvTransformPtr *inv_transform;
+ int transform_size;
+ DCTransformPtr *dc_transform;
+ int is_2d_trans; ///< 1 indicates that the two-dimensional inverse transform is used
+ int32 checksum; ///< for debug purposes
+ int checksum_present;
+ int bufsize; ///< band buffer size in bytes
+ const uint16 * intra_base; ///< quantization matrix for intra blocks
+ const uint16 * inter_base; ///< quantization matrix for inter blocks
+ const uint8 * intra_scale; ///< quantization coefficient for intra blocks
+ const uint8 * inter_scale; ///< quantization coefficient for inter blocks
+
+ int ivi_init_tiles(IVITile *ref_tile, int p, int b, int t_height, int t_width);
+};
+
+struct IVIPicConfig {
+ uint16 pic_width;
+ uint16 pic_height;
+ uint16 chroma_width;
+ uint16 chroma_height;
+ uint16 tile_width;
+ uint16 tile_height;
+ uint8 luma_bands;
+ uint8 chroma_bands;
+
+ /**
+ * Compare some properties of two pictures
+ */
+ bool ivi_pic_config_cmp(const IVIPicConfig &cfg2);
+};
+
+/**
+ * color plane (luma or chroma) information
+ */
+struct IVIPlaneDesc {
+ uint16 width;
+ uint16 height;
+ uint8 num_bands; ///< number of bands this plane subdivided into
+ IVIBandDesc *bands; ///< array of band descriptors
+
+ static int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg, bool is_indeo4);
+
+ static int ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height);
+
+ /*
+ * Free planes, bands and macroblocks buffers.
+ *
+ * @param[in] planes pointer to the array of the plane descriptors
+ */
+ static void ivi_free_buffers(IVIPlaneDesc *planes);
+};
+
+struct IVI45DecContext {
+ GetBits * gb;
+ RVMapDesc rvmap_tabs[9]; ///< local corrected copy of the static rvmap tables
+
+ uint32 frame_num;
+ int frame_type;
+ int prev_frame_type; ///< frame type of the previous frame
+ uint32 data_size; ///< size of the frame data in bytes from picture header
+ int is_scalable;
+ const uint8 * frame_data; ///< input frame data pointer
+ int inter_scal; ///< signals a sequence of scalable inter frames
+ uint32 frame_size; ///< frame size in bytes
+ uint32 pic_hdr_size; ///< picture header size in bytes
+ uint8 frame_flags;
+ uint16 checksum; ///< frame checksum
+
+ IVIPicConfig pic_conf;
+ IVIPlaneDesc planes[3]; ///< color planes
+
+ int buf_switch; ///< used to switch between three buffers
+ int dst_buf; ///< buffer index for the currently decoded frame
+ int ref_buf; ///< inter frame reference buffer index
+ int ref2_buf; ///< temporal storage for switching buffers
+ int b_ref_buf; ///< second reference frame buffer index
+
+ IVIHuffTab mb_vlc; ///< current macroblock table descriptor
+ IVIHuffTab blk_vlc; ///< current block table descriptor
+
+ uint8 rvmap_sel;
+ uint8 in_imf;
+ uint8 in_q; ///< flag for explicitly stored quantiser delta
+ uint8 pic_glob_quant;
+ uint8 unknown1;
+
+ uint16 gop_hdr_size;
+ uint8 gop_flags;
+ uint32 lock_word;
+
+ int show_indeo4_info;
+ uint8 has_b_frames;
+ uint8 has_transp; ///< transparency mode status: 1 - enabled
+ uint8 uses_tiling;
+ uint8 uses_haar;
+ uint8 uses_fullpel;
+
+// int (*decode_pic_hdr) (struct IVI45DecContext *ctx, AVCodecContext *avctx);
+// int (*decode_band_hdr) (struct IVI45DecContext *ctx, IVIBandDesc *band, AVCodecContext *avctx);
+// int (*decode_mb_info) (struct IVI45DecContext *ctx, IVIBandDesc *band, IVITile *tile, AVCodecContext *avctx);
+// void (*switch_buffers) (struct IVI45DecContext *ctx);
+// int (*is_nonnull_frame)(struct IVI45DecContext *ctx);
+
+ int gop_invalid;
+ int buf_invalid[4];
+
+ int is_indeo4;
+
+// AVFrame * p_frame;
+ int got_p_frame;
+};
+
+/*------------------------------------------------------------------------*/
+
+/**
+ * Check if the given dimension of an image is valid, meaning that all
+ * bytes of the image can be addressed with a signed int.
+ *
+ * @param w the width of the picture
+ * @param h the height of the picture
+ * @param log_offset the offset to sum to the log level for logging with log_ctx
+ * @returns >= 0 if valid, a negative error code otherwise
+*/
+extern int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
+
+
+} // End of namespace Indeo
+} // End of namespace Image
+
+#endif
diff --git a/image/codecs/indeo/mem.cpp b/image/codecs/indeo/mem.cpp
new file mode 100644
index 0000000..03a39ca
--- /dev/null
+++ b/image/codecs/indeo/mem.cpp
@@ -0,0 +1,157 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/* VLC code
+ *
+ * Original copyright note: * Intel Indeo 4 (IV41, IV42, etc.) video decoder for ffmpeg
+ * written, produced, and directed by Alan Smithee
+ */
+
+#include "image/codecs/indeo/mem.h"
+
+namespace Image {
+namespace Indeo {
+
+const uint8 ff_reverse[256] = {
+ 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
+ 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8,
+ 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4,
+ 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC,
+ 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2,
+ 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA,
+ 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6,
+ 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE,
+ 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1,
+ 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9,
+ 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5,
+ 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD,
+ 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3,
+ 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB,
+ 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
+ 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF,
+};
+
+/*------------------------------------------------------------------------*/
+
+/**
+ * Multiply two `size_t` values checking for overflow.
+ *
+ * @param[in] a,b Operands of multiplication
+ * @param[out] r Pointer to the result of the operation
+ * @return 0 on success, AVERROR(EINVAL) on overflow
+ */
+static inline int av_size_mult(size_t a, size_t b, size_t *r) {
+ size_t t = a * b;
+
+ // Hack inspired from glibc: don't try the division if nelem and elsize
+ // are both less than sqrt(SIZE_MAX).
+ if ((a | b) >= ((size_t)1 << (sizeof(size_t) * 4)) && a && t / a != b)
+ return -1;
+ *r = t;
+ return 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+void *av_malloc(size_t size) {
+ return malloc(size);
+}
+
+void *av_mallocz(size_t size) {
+ void *ptr = av_malloc(size);
+ if (ptr)
+ memset(ptr, 0, size);
+
+ return ptr;
+}
+
+void *av_malloc_array(size_t nmemb, size_t size) {
+ if (!size || nmemb >= INT_MAX / size)
+ return nullptr;
+ return malloc(nmemb * size);
+}
+
+void *av_mallocz_array(size_t nmemb, size_t size) {
+ if (!size || nmemb >= INT_MAX / size)
+ return NULL;
+
+ return av_mallocz(nmemb * size);
+}
+
+void av_free(void *ptr) {
+ free(ptr);
+}
+
+void av_freep(void *arg) {
+ void **ptr = (void **)arg;
+ free(*ptr);
+ *ptr = nullptr;
+}
+
+static void *av_realloc(void *ptr, size_t size) {
+ return realloc(ptr, size + !size);
+}
+
+void *av_realloc_f(void *ptr, size_t nelem, size_t elsize) {
+ size_t size;
+ void *r;
+
+ if (av_size_mult(elsize, nelem, &size)) {
+ av_free(ptr);
+ return nullptr;
+ }
+ r = av_realloc(ptr, size);
+ if (!r)
+ av_free(ptr);
+
+ return r;
+}
+
+
+/**
+ * Swap the order of the bytes in the passed value
+ */
+uint32 bitswap_32(uint32 x) {
+ return (uint32)ff_reverse[x & 0xFF] << 24 |
+ (uint32)ff_reverse[(x >> 8) & 0xFF] << 16 |
+ (uint32)ff_reverse[(x >> 16) & 0xFF] << 8 |
+ (uint32)ff_reverse[x >> 24];
+}
+
+/**
+ * Reverse "nbits" bits of the value "val" and return the result
+ * in the least significant bits.
+ */
+uint16 inv_bits(uint16 val, int nbits) {
+ uint16 res;
+
+ if (nbits <= 8) {
+ res = ff_reverse[val] >> (8 - nbits);
+ } else
+ res = ((ff_reverse[val & 0xFF] << 8) +
+ (ff_reverse[val >> 8])) >> (16 - nbits);
+
+ return res;
+}
+
+} // End of namespace Indeo
+} // End of namespace Image
diff --git a/image/codecs/indeo/mem.h b/image/codecs/indeo/mem.h
new file mode 100644
index 0000000..4f9ebf0
--- /dev/null
+++ b/image/codecs/indeo/mem.h
@@ -0,0 +1,145 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+/* Common memory code used by the Indeo decoder
+ *
+ * Original copyright note: * Intel Indeo 4 (IV41, IV42, etc.) video decoder for ffmpeg
+ * written, produced, and directed by Alan Smithee
+ */
+
+#ifndef IMAGE_CODECS_INDEO_MEM_H
+#define IMAGE_CODECS_INDEO_MEM_H
+
+namespace Image {
+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)
+
+/**
+ * Allocate a memory block with alignment suitable for all memory accesses
+ * (including vectors if available on the CPU).
+ *
+ * @param size Size in bytes for the memory block to be allocated
+ * @return Pointer to the allocated block, or `NULL` if the block cannot
+ * be allocated
+ * @see av_mallocz()
+ */
+extern void *av_malloc(size_t size);
+
+/**
+ * Allocate a memory block with alignment suitable for all memory accesses
+ * (including vectors if available on the CPU) and zero all the bytes of the
+ * block.
+ *
+ * @param size Size in bytes for the memory block to be allocated
+ * @return Pointer to the allocated block, or `NULL` if it cannot be allocated
+ * @see av_malloc()
+ */
+extern void *av_mallocz(size_t size);
+
+/**
+ * Allocate a memory block for an array with av_malloc().
+ *
+ * The allocated memory will have size `size * nmemb` bytes.
+ *
+ * @param nmemb Number of element
+ * @param size Size of a single element
+ * @return Pointer to the allocated block, or `NULL` if the block cannot
+ * be allocated
+ * @see av_malloc()
+ */
+extern void *av_malloc_array(size_t nmemb, size_t size);
+
+/**
+ * Allocate a memory block for an array with av_mallocz().
+ *
+ * The allocated memory will have size `size * nmemb` bytes.
+ *
+ * @param nmemb Number of elements
+ * @param size Size of the single element
+ * @return Pointer to the allocated block, or `NULL` if the block cannot
+ * be allocated
+ *
+ * @see av_mallocz()
+ * @see av_malloc_array()
+ */
+extern void *av_mallocz_array(size_t nmemb, size_t size);
+
+/**
+ * Free a memory block which has been allocated with a function of av_malloc()
+ * or av_realloc() family.
+ *
+ * @param ptr Pointer to the memory block which should be freed.
+ *
+ * @note `ptr = NULL` is explicitly allowed.
+ * @note It is recommended that you use av_freep() instead, to prevent leaving
+ * behind dangling pointers.
+ * @see av_freep()
+ */
+extern void av_free(void *ptr);
+
+/**
+ * Free a memory block which has been allocated with a function of av_malloc()
+ * or av_realloc() family, and set the pointer pointing to it to `NULL`.
+ *
+ * @param ptr Pointer to the pointer to the memory block which should be freed
+ * @note `*ptr = NULL` is safe and leads to no action.
+ */
+extern void av_freep(void *arg);
+
+
+/**
+ * Allocate, reallocate, or free a block of memory.
+ *
+ * This function does the same thing as av_realloc(), except:
+ * - It takes two size arguments and allocates `nelem * elsize` bytes,
+ * after checking the result of the multiplication for integer overflow.
+ * - It frees the input block in case of failure, thus avoiding the memory
+ * leak with the classic
+ * @code{.c}
+ * buf = realloc(buf);
+ * if (!buf)
+ * return -1;
+ * @endcode
+ * pattern.
+ */
+extern void *av_realloc_f(void *ptr, size_t nelem, size_t elsize);
+
+/**
+ * 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
+
+#endif
diff --git a/image/codecs/indeo/vlc.cpp b/image/codecs/indeo/vlc.cpp
new file mode 100644
index 0000000..4415965
--- /dev/null
+++ b/image/codecs/indeo/vlc.cpp
@@ -0,0 +1,336 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/* VLC code
+ *
+ * Original copyright note: * Intel Indeo 4 (IV41, IV42, etc.) video decoder for ffmpeg
+ * written, produced, and directed by Alan Smithee
+ */
+
+#include "image/codecs/indeo/vlc.h"
+#include "image/codecs/indeo/mem.h"
+#include "common/textconsole.h"
+#include "common/util.h"
+
+namespace Image {
+namespace Indeo {
+
+/**
+ * Quicksort
+ * This sort is fast, and fully inplace but not stable and it is possible
+ * to construct input that requires O(n^2) time but this is very unlikely to
+ * happen with non constructed input.
+*/
+#define AV_QSORT(p, num, type, cmp) do {\
+ void *stack[64][2];\
+ 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);\
+ 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(mid, end) > 0){ \
+ FFSWAP(type, *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)\
+ left++;\
+ while(left<=right && cmp(right, end-1) > 0)\
+ right--;\
+ if(left <= right){\
+ FFSWAP(type, *left, *right);\
+ left++;\
+ right--;\
+ }\
+ }\
+ FFSWAP(type, 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;\
+ end = right;\
+ }\
+ }else{\
+ if(cmp(start, end) > 0)\
+ FFSWAP(type, *start, *end);\
+ break;\
+ }\
+ }\
+ }\
+} while (0)
+
+/**
+ * VLC decoding
+ */
+#define GET_DATA(v, table, i, wrap, size) \
+{ \
+ const uint8 *ptr = (const uint8 *)table + i * wrap; \
+ switch(size) { \
+ case 1: \
+ v = *(const uint8 *)ptr; \
+ break; \
+ case 2: \
+ v = *(const uint16 *)ptr; \
+ break; \
+ default: \
+ v = *(const uint32 *)ptr; \
+ break; \
+ } \
+}
+
+/*------------------------------------------------------------------------*/
+
+VLC::VLC() : bits(0), table_size(0), table_allocated(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 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) {
+ 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;
+ if (flags & INIT_VLC_USE_NEW_STATIC) {
+ assert((nb_codes + 1) <= FF_ARRAY_ELEMS(localbuf));
+ buf = localbuf;
+ localvlc = *this;
+ vlc = &localvlc;
+ vlc->table_size = 0;
+ } else {
+ vlc->table = NULL;
+ vlc->table_allocated = 0;
+ vlc->table_size = 0;
+
+ buf = (VLCcode *)av_malloc_array((nb_codes + 1), sizeof(VLCcode));
+ assert(buf);
+ }
+
+ assert(symbols_size <= 2 || !symbols);
+ j = 0;
+#define COPY(condition)\
+ for (i = 0; i < nb_codes; i++) { \
+ GET_DATA(buf[j].bits, p_bits, i, bits_wrap, bits_size); \
+ if (!(condition)) \
+ continue; \
+ if (buf[j].bits > 3*nb_bits || 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; \
+ } \
+ GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size); \
+ 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 = bitswap_32(buf[j].code); \
+ else \
+ buf[j].code <<= 32 - buf[j].bits; \
+ if (symbols) \
+ GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size) \
+ else \
+ buf[j].symbol = i; \
+ j++; \
+ }
+ COPY(buf[j].bits > nb_bits);
+
+ // 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;
+
+ ret = vlc->build_table(nb_bits, nb_codes, buf, flags);
+
+ if (flags & INIT_VLC_USE_NEW_STATIC) {
+ if (vlc->table_size != vlc->table_allocated)
+ warning("needed %d had %d", table_size, table_allocated);
+
+ assert(ret >= 0);
+ *this = *vlc;
+ } else {
+ free(buf);
+ if (ret < 0) {
+ av_freep(&vlc->table);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+void VLC::ff_free_vlc() {
+ free(table);
+}
+
+int VLC::compare_vlcspec(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,
+ VLCcode *codes, int flags) {
+ VLC *vlc = this;
+ int table_size, table_index, index, code_prefix, symbol, subtable_bits;
+ int i, j, k, n, nb, inc;
+ uint32 code;
+ // the double volatile is needed to prevent an internal compiler error in gcc 4.2
+ volatile VLC_TYPE(*volatile table)[2];
+
+
+ table_size = 1 << table_nb_bits;
+ if (table_nb_bits > 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 = (volatile VLC_TYPE(*)[2])&vlc->table[table_index];
+
+ /* first pass: map codes and compute auxiliary table sizes */
+ for (i = 0; i < nb_codes; 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) {
+ /* no need to add another table */
+ j = code >> (32 - table_nb_bits);
+ nb = 1 << (table_nb_bits - n);
+ inc = 1;
+ if (flags & INIT_VLC_LE) {
+ j = bitswap_32(code);
+ inc = 1 << n;
+ }
+ for (k = 0; k < nb; k++) {
+ int bits = table[j][1];
+ warning("%4x: code=%d n=%d", j, i, n);
+ if (bits != 0 && bits != n) {
+ warning("incorrect codes");
+ return -1;
+ }
+ table[j][1] = n; //bits
+ table[j][0] = symbol;
+ j += inc;
+ }
+ }
+ else {
+ /* fill auxiliary table recursively */
+ n -= table_nb_bits;
+ code_prefix = code >> (32 - table_nb_bits);
+ subtable_bits = 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;
+ if (n <= 0)
+ break;
+ code = codes[k].code;
+ if (code >> (32 - table_nb_bits) != code_prefix)
+ break;
+ codes[k].bits = n;
+ codes[k].code = code << table_nb_bits;
+ subtable_bits = MAX(subtable_bits, n);
+ }
+ subtable_bits = MIN(subtable_bits, table_nb_bits);
+ j = (flags & INIT_VLC_LE) ? bitswap_32(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);
+ if (index < 0)
+ return index;
+ /* note: realloc has been done, so reload tables */
+ table = (volatile VLC_TYPE(*)[2])&vlc->table[table_index];
+ table[j][0] = index; //code
+ i = k - 1;
+ }
+ }
+
+ for (i = 0; i < table_size; i++) {
+ if (table[i][1] == 0) //bits
+ table[i][0] = -1; //codes
+ }
+
+ return table_index;
+}
+
+int VLC::alloc_table(int size, int use_static) {
+ VLC *vlc = this;
+ int index = vlc->table_size;
+
+ vlc->table_size += size;
+ if (vlc->table_size > vlc->table_allocated) {
+ // cannot do anything, init_vlc() is used with too little memory
+ assert(!use_static);
+
+ vlc->table_allocated += (1 << vlc->bits);
+ vlc->table = (int16(*)[2])av_realloc_f(vlc->table, vlc->table_allocated, sizeof(VLC_TYPE) * 2);
+ if (!vlc->table) {
+ vlc->table_allocated = 0;
+ vlc->table_size = 0;
+ return -2;
+ }
+
+ memset(vlc->table + vlc->table_allocated - (1 << vlc->bits), 0, sizeof(VLC_TYPE) * 2 << vlc->bits);
+ }
+ return index;
+}
+
+} // End of namespace Indeo
+} // End of namespace Image
diff --git a/image/codecs/indeo/vlc.h b/image/codecs/indeo/vlc.h
new file mode 100644
index 0000000..682be66
--- /dev/null
+++ b/image/codecs/indeo/vlc.h
@@ -0,0 +1,138 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+/* VLC code
+ *
+ * Original copyright note: * Intel Indeo 4 (IV41, IV42, etc.) video decoder for ffmpeg
+ * written, produced, and directed by Alan Smithee
+ */
+
+#ifndef IMAGE_CODECS_INDEO_VLC_H
+#define IMAGE_CODECS_INDEO_VLC_H
+
+#include "image/codecs/indeo/get_bits.h"
+
+namespace Image {
+namespace Indeo {
+
+#define VLC_TYPE int16
+#define INIT_VLC_LE 2
+#define INIT_VLC_USE_NEW_STATIC 4
+
+struct VLCcode {
+ uint8 bits;
+ uint16 symbol;
+
+ /**
+ * codeword, with the first bit-to-be-read in the msb
+ * (even if intended for a little-endian bitstream reader)
+ */
+ uint32 code;
+};
+
+struct VLC {
+private:
+ static int compare_vlcspec(const void *a, const void *b);
+public:
+ int bits;
+ VLC_TYPE (*table)[2]; ///< code, bits
+ int table_size, table_allocated;
+
+ VLC();
+ ~VLC() { ff_free_vlc(); }
+
+
+ /* Build VLC decoding tables suitable for use with get_vlc().
+
+ 'nb_bits' sets the decoding table size (2^nb_bits) 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
+
+ 'bits' : table which gives the size (in bits) of each vlc code.
+
+ 'codes' : table which gives the bit pattern of of each vlc code.
+
+ 'symbols' : table which gives the values to be returned from get_vlc().
+
+ 'xxx_wrap' : give the number of bytes between each entry of the
+ 'bits' or 'codes' tables.
+
+ 'xxx_size' : gives the number of bytes of each entry of the 'bits'
+ or 'codes' tables.
+
+ '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.
+ */
+ 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 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);
+
+ /**
+ * Free VLC data
+ */
+ void ff_free_vlc();
+
+
+ /**
+ * 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
+ * (Longer codes are delegated to subtables.)
+ *
+ * @param nb_codes 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 alloc_table(int size, int use_static);
+};
+
+
+/**
+ * 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
+
+#endif
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index 465e3ad..bce9b5a 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -24,7 +24,7 @@
/* Intel Indeo 4 decompressor, derived from ffmpeg.
*
- * Original copyright note: * Intel Indeo 3 (IV31, IV32, etc.) video decoder for ffmpeg
+ * Original copyright note: * Intel Indeo 3 (IV41, IV42, etc.) video decoder for ffmpeg
* written, produced, and directed by Alan Smithee
*/
@@ -33,19 +33,22 @@
#include "common/stream.h"
#include "common/textconsole.h"
#include "common/util.h"
-
#include "graphics/yuv_to_rgb.h"
-
#include "image/codecs/indeo4.h"
-#include "image/codecs/indeo/get_bits.h"
namespace Image {
+#define IVI4_PIC_SIZE_ESC 7
+
Indeo4Decoder::Indeo4Decoder(uint16 width, uint16 height) {
_pixelFormat = g_system->getScreenFormat();
_surface = new Graphics::ManagedSurface();
_surface->create(width, height, _pixelFormat);
-
+ _ctx.gb = nullptr;
+ _ctx.pic_conf.pic_width = _ctx.pic_conf.pic_height = 0;
+ _ctx.is_indeo4 = true;
+ _ctx.show_indeo4_info = false;
+ _ctx.b_ref_buf = 3; // buffer 2 is used for scalability mode
}
Indeo4Decoder::~Indeo4Decoder() {
@@ -72,10 +75,191 @@ bool Indeo4Decoder::isIndeo4(Common::SeekableReadStream &stream) {
const Graphics::Surface *Indeo4Decoder::decodeFrame(Common::SeekableReadStream &stream) {
// Not Indeo 4? Fail
if (!isIndeo4(stream))
- return 0;
+ return nullptr;
+
+ // Set up the GetBits instance for reading the stream
+ _ctx.gb = new GetBits(stream);
+
+ // Decode the header
+ int err = decodePictureHeader();
+
+ delete _ctx.gb;
+ _ctx.gb = nullptr;
// TODO
- return nullptr;
+ err = -1;
+ return (err < 0) ? nullptr : &_surface->rawSurface();
}
+int Indeo4Decoder::decodePictureHeader() {
+ int pic_size_indx, i, p;
+ IVIPicConfig pic_conf;
+
+ if (_ctx.gb->getBits(18) != 0x3FFF8) {
+ warning("Invalid picture start code!");
+ return -1;
+ }
+
+ _ctx.prev_frame_type = _ctx.frame_type;
+ _ctx.frame_type = _ctx.gb->getBits(3);
+ if (_ctx.frame_type == 7) {
+ warning("Invalid frame type: %d", _ctx.frame_type);
+ return -1;
+ }
+
+ if (_ctx.frame_type == IVI4_FRAMETYPE_BIDIR)
+ _ctx.has_b_frames = 1;
+
+ _ctx.has_transp = _ctx.gb->getBits1();
+
+ // unknown bit: Mac decoder ignores this bit, XANIM returns error
+ if (_ctx.gb->getBits1()) {
+ warning("Sync bit is set!");
+ return -1;
+ }
+
+ _ctx.data_size = _ctx.gb->getBits1() ? _ctx.gb->getBits(24) : 0;
+
+ // null frames don't contain anything else so we just return
+ if (_ctx.frame_type >= IVI4_FRAMETYPE_NULL_FIRST) {
+ warning("Null frame encountered!");
+ return 0;
+ }
+
+ // Check key lock status. If enabled - ignore lock word.
+ // Usually we have to prompt the user for the password, but
+ // we don't do that because Indeo 4 videos can be decoded anyway
+ if (_ctx.gb->getBits1()) {
+ _ctx.gb->skipBitsLong(32);
+ warning("Password-protected clip!");
+ }
+
+ pic_size_indx = _ctx.gb->getBits(3);
+ if (pic_size_indx == IVI4_PIC_SIZE_ESC) {
+ pic_conf.pic_height = _ctx.gb->getBits(16);
+ pic_conf.pic_width = _ctx.gb->getBits(16);
+ } else {
+ pic_conf.pic_height = _ivi4_common_pic_sizes[pic_size_indx * 2 + 1];
+ pic_conf.pic_width = _ivi4_common_pic_sizes[pic_size_indx * 2];
+ }
+
+ // Decode tile dimensions.
+ _ctx.uses_tiling = _ctx.gb->getBits1();
+ if (_ctx.uses_tiling) {
+ pic_conf.tile_height = scaleTileSize(pic_conf.pic_height, _ctx.gb->getBits(4));
+ pic_conf.tile_width = scaleTileSize(pic_conf.pic_width, _ctx.gb->getBits(4));
+ } else {
+ pic_conf.tile_height = pic_conf.pic_height;
+ pic_conf.tile_width = pic_conf.pic_width;
+ }
+
+ // Decode chroma subsampling. We support only 4:4 aka YVU9.
+ if (_ctx.gb->getBits(2)) {
+ warning("Only YVU9 picture format is supported!");
+ return -1;
+ }
+ pic_conf.chroma_height = (pic_conf.pic_height + 3) >> 2;
+ pic_conf.chroma_width = (pic_conf.pic_width + 3) >> 2;
+
+ // decode subdivision of the planes
+ pic_conf.luma_bands = decodePlaneSubdivision();
+ pic_conf.chroma_bands = 0;
+ if (pic_conf.luma_bands)
+ pic_conf.chroma_bands = decodePlaneSubdivision();
+ _ctx.is_scalable = pic_conf.luma_bands != 1 || pic_conf.chroma_bands != 1;
+ if (_ctx.is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) {
+ warning("Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d",
+ pic_conf.luma_bands, pic_conf.chroma_bands);
+ return -1;
+ }
+
+ // check if picture layout was changed and reallocate buffers
+ if (pic_conf.ivi_pic_config_cmp(_ctx.pic_conf)) {
+ if (IVIPlaneDesc::ff_ivi_init_planes(_ctx.planes, &pic_conf, 1)) {
+ warning("Couldn't reallocate color planes!");
+ _ctx.pic_conf.luma_bands = 0;
+ return -2;
+ }
+
+ _ctx.pic_conf = pic_conf;
+
+ // set default macroblock/block dimensions
+ for (p = 0; p <= 2; p++) {
+ for (i = 0; i < (!p ? pic_conf.luma_bands : pic_conf.chroma_bands); i++) {
+ _ctx.planes[p].bands[i].mb_size = !p ? (!_ctx.is_scalable ? 16 : 8) : 4;
+ _ctx.planes[p].bands[i].blk_size = !p ? 8 : 4;
+ }
+ }
+
+ if (IVIPlaneDesc::ff_ivi_init_tiles(_ctx.planes, _ctx.pic_conf.tile_width,
+ _ctx.pic_conf.tile_height)) {
+ warning("Couldn't reallocate internal structures!");
+ return -2;
+ }
+ }
+
+ _ctx.frame_num = _ctx.gb->getBits1() ? _ctx.gb->getBits(20) : 0;
+
+ // skip decTimeEst field if present
+ if (_ctx.gb->getBits1())
+ _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))
+ return -1;
+
+ _ctx.rvmap_sel = _ctx.gb->getBits1() ? _ctx.gb->getBits(3) : 8;
+
+ _ctx.in_imf = _ctx.gb->getBits1();
+ _ctx.in_q = _ctx.gb->getBits1();
+
+ _ctx.pic_glob_quant = _ctx.gb->getBits(5);
+
+ // TODO: ignore this parameter if unused
+ _ctx.unknown1 = _ctx.gb->getBits1() ? _ctx.gb->getBits(3) : 0;
+
+ _ctx.checksum = _ctx.gb->getBits1() ? _ctx.gb->getBits(16) : 0;
+
+ // skip picture header extension if any
+ while (_ctx.gb->getBits1()) {
+ warning("Pic hdr extension encountered!");
+ _ctx.gb->skipBits(8);
+ }
+
+ if (_ctx.gb->getBits1()) {
+ warning("Bad blocks bits encountered!");
+ }
+
+ _ctx.gb->alignGetBits();
+
+ return 0;
+}
+
+int Indeo4Decoder::scaleTileSize(int def_size, int size_factor) {
+ return size_factor == 15 ? def_size : (size_factor + 1) << 5;
+}
+
+int Indeo4Decoder::decodePlaneSubdivision() {
+ int i;
+
+ switch (_ctx.gb->getBits(2)) {
+ case 3:
+ return 1;
+ case 2:
+ for (i = 0; i < 4; i++)
+ if (_ctx.gb->getBits(2) != 3)
+ return 0;
+ return 4;
+ default:
+ return 0;
+ }
+}
+
+/*------------------------------------------------------------------------*/
+
+const uint Indeo4Decoder::_ivi4_common_pic_sizes[14] = {
+ 640, 480, 320, 240, 160, 120, 704, 480, 352, 240, 352, 288, 176, 144
+};
+
} // End of namespace Image
diff --git a/image/codecs/indeo4.h b/image/codecs/indeo4.h
index 44007e0..838b0c3 100644
--- a/image/codecs/indeo4.h
+++ b/image/codecs/indeo4.h
@@ -21,6 +21,7 @@
*/
#include "common/scummsys.h"
+#include "image/codecs/indeo/get_bits.h"
/* Intel Indeo 4 decompressor, derived from ffmpeg.
*
@@ -33,10 +34,14 @@
#define IMAGE_CODECS_INDEO4_H
#include "image/codecs/codec.h"
+#include "image/codecs/indeo/get_bits.h"
+#include "image/codecs/indeo/indeo.h"
#include "graphics/managed_surface.h"
namespace Image {
+using namespace Indeo;
+
/**
* Intel Indeo 4 decoder.
*
@@ -57,6 +62,33 @@ public:
private:
Graphics::PixelFormat _pixelFormat;
Graphics::ManagedSurface *_surface;
+ IVI45DecContext _ctx;
+
+ /**
+ * Decode the Indeo 4 picture header.
+ * @returns 0 = Ok, negative number = error
+ */
+ int decodePictureHeader();
+
+ int scaleTileSize(int def_size, int size_factor);
+
+ /**
+ * Decode subdivision of a plane.
+ * This is a simplified version that checks for two supported subdivisions:
+ * - 1 wavelet band per plane, size factor 1:1, code pattern: 3
+ * - 4 wavelet bands per plane, size factor 1:4, code pattern: 2,3,3,3,3
+ * Anything else is either unsupported or corrupt.
+ *
+ * @param[in,out] gb the GetBit context
+ * @return number of wavelet bands or 0 on error
+ */
+ int decodePlaneSubdivision();
+
+private:
+ /**
+ * Standard picture dimensions
+ */
+ static const uint _ivi4_common_pic_sizes[14];
};
} // End of namespace Image
diff --git a/image/module.mk b/image/module.mk
index af4284d..6d55b17 100644
--- a/image/module.mk
+++ b/image/module.mk
@@ -23,7 +23,10 @@ MODULE_OBJS := \
codecs/smc.o \
codecs/svq1.o \
codecs/truemotion1.o \
- codecs/indeo/get_bits.o
+ codecs/indeo/get_bits.o \
+ codecs/indeo/indeo.o \
+ codecs/indeo/mem.o \
+ codecs/indeo/vlc.o
ifdef USE_MPEG2
MODULE_OBJS += \
Commit: c165826316a71b378e3493a4a5fb6a6e1740bbab
https://github.com/scummvm/scummvm/commit/c165826316a71b378e3493a4a5fb6a6e1740bbab
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T10:08:12-04:00
Commit Message:
IMAGE: Created Indeo decoder base class for shared Indeo4/5 functionality
Changed paths:
image/codecs/indeo/indeo.cpp
image/codecs/indeo/indeo.h
image/codecs/indeo4.cpp
image/codecs/indeo4.h
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index 9de32fa..820823b 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -20,10 +20,10 @@
*
*/
-/* Common structures and macros shared by both Indeo4 and Indeo5 decoders,
- * derived from ffmpeg. We don't currently support Indeo5 decoding, but
- * just in case we eventually need it, this is kept as a separate file
- * like it is in ffmpeg.
+/* Common structures, macros, and base class shared by both Indeo4 and
+ * Indeo5 decoders, derived from ffmpeg. We don't currently support Indeo5
+ * decoding, but just in case we eventually need it, this is kept as a separate
+ * file like it is in ffmpeg.
*
* Original copyright note: * Intel Indeo 4 (IV41, IV42, etc.) video decoder for ffmpeg
* written, produced, and directed by Alan Smithee
@@ -31,6 +31,7 @@
#include "image/codecs/indeo/indeo.h"
#include "image/codecs/indeo/mem.h"
+#include "common/system.h"
#include "common/textconsole.h"
#include "common/util.h"
@@ -383,6 +384,49 @@ int IVIBandDesc::ivi_init_tiles(IVITile *ref_tile, int p, int b, int t_height, i
/*------------------------------------------------------------------------*/
+IndeoDecoderBase::IndeoDecoderBase(uint16 width, uint16 height) : Codec() {
+ _pixelFormat = g_system->getScreenFormat();
+ _surface = new Graphics::ManagedSurface();
+ _surface->create(width, height, _pixelFormat);
+ _ctx.gb = nullptr;
+ _ctx.pic_conf.pic_width = _ctx.pic_conf.pic_height = 0;
+ _ctx.show_indeo4_info = false;
+ _ctx.b_ref_buf = 3; // buffer 2 is used for scalability mode
+}
+
+IndeoDecoderBase::~IndeoDecoderBase() {
+ delete _surface;
+}
+
+int IndeoDecoderBase::decodeIndeoFrame() {
+ // Decode the header
+ int err = decodePictureHeader();
+
+ if (!err && _ctx.gop_invalid)
+ err = -1;
+
+ if (!err && _ctx.frame_type == IVI4_FRAMETYPE_NULL_LAST) {
+ // Returning the previous frame, so exit wth success
+ return 0;
+ }
+
+ if (!err && _ctx.gop_flags & IVI5_IS_PROTECTED) {
+ warning("Password-protected clip");
+ err = -1;
+ }
+
+ if (!err && !_ctx.planes[0].bands) {
+ warning("Color planes not initialized yet");
+ err = -1;
+ }
+
+ // TODO
+
+ return err;
+}
+
+/*------------------------------------------------------------------------*/
+
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) {
if (((w + 128) * (uint64)(h + 128)) < (INT_MAX / 8))
return 0;
diff --git a/image/codecs/indeo/indeo.h b/image/codecs/indeo/indeo.h
index d689994..c84f257 100644
--- a/image/codecs/indeo/indeo.h
+++ b/image/codecs/indeo/indeo.h
@@ -21,11 +21,13 @@
*/
#include "common/scummsys.h"
+#include "graphics/managed_surface.h"
+#include "image/codecs/codec.h"
-/* Common structures and macros shared by both Indeo4 and Indeo5 decoders,
- * derived from ffmpeg. We don't currently support Indeo5 decoding, but
- * just in case we eventually need it, this is kept as a separate file
- * like it is in ffmpeg.
+/* Common structures, macros, and base class shared by both Indeo4 and
+ * Indeo5 decoders, derived from ffmpeg. We don't currently support Indeo5
+ * decoding, but just in case we eventually need it, this is kept as a separate
+ * file like it is in ffmpeg.
*
* Original copyright note: * Intel Indeo 4 (IV41, IV42, etc.) video decoder for ffmpeg
* written, produced, and directed by Alan Smithee
@@ -330,6 +332,33 @@ struct IVI45DecContext {
int got_p_frame;
};
+class IndeoDecoderBase : public Codec {
+protected:
+ IVI45DecContext _ctx;
+ Graphics::PixelFormat _pixelFormat;
+ Graphics::ManagedSurface *_surface;
+protected:
+ /**
+ * Returns the pixel format for the decoder's surface
+ */
+ virtual Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; }
+
+ /**
+ * Decode the Indeo picture header.
+ * @returns 0 = Ok, negative number = error
+ */
+ virtual int decodePictureHeader() = 0;
+
+ /**
+ * Decodes the Indeo frame from the bit reader already
+ * loaded into the context
+ */
+ int decodeIndeoFrame();
+public:
+ IndeoDecoderBase(uint16 width, uint16 height);
+ virtual ~IndeoDecoderBase();
+};
+
/*------------------------------------------------------------------------*/
/**
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index bce9b5a..29616e9 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -28,7 +28,6 @@
* written, produced, and directed by Alan Smithee
*/
-#include "common/system.h"
#include "common/endian.h"
#include "common/stream.h"
#include "common/textconsole.h"
@@ -40,19 +39,8 @@ namespace Image {
#define IVI4_PIC_SIZE_ESC 7
-Indeo4Decoder::Indeo4Decoder(uint16 width, uint16 height) {
- _pixelFormat = g_system->getScreenFormat();
- _surface = new Graphics::ManagedSurface();
- _surface->create(width, height, _pixelFormat);
- _ctx.gb = nullptr;
- _ctx.pic_conf.pic_width = _ctx.pic_conf.pic_height = 0;
+Indeo4Decoder::Indeo4Decoder(uint16 width, uint16 height) : IndeoDecoderBase(width, height) {
_ctx.is_indeo4 = true;
- _ctx.show_indeo4_info = false;
- _ctx.b_ref_buf = 3; // buffer 2 is used for scalability mode
-}
-
-Indeo4Decoder::~Indeo4Decoder() {
- delete _surface;
}
bool Indeo4Decoder::isIndeo4(Common::SeekableReadStream &stream) {
@@ -80,14 +68,13 @@ const Graphics::Surface *Indeo4Decoder::decodeFrame(Common::SeekableReadStream &
// Set up the GetBits instance for reading the stream
_ctx.gb = new GetBits(stream);
- // Decode the header
- int err = decodePictureHeader();
+ // Decode the frame
+ int err = decodeIndeoFrame();
+ // Free the bit reader
delete _ctx.gb;
_ctx.gb = nullptr;
- // TODO
- err = -1;
return (err < 0) ? nullptr : &_surface->rawSurface();
}
diff --git a/image/codecs/indeo4.h b/image/codecs/indeo4.h
index 838b0c3..b2d89d5 100644
--- a/image/codecs/indeo4.h
+++ b/image/codecs/indeo4.h
@@ -33,7 +33,6 @@
#ifndef IMAGE_CODECS_INDEO4_H
#define IMAGE_CODECS_INDEO4_H
-#include "image/codecs/codec.h"
#include "image/codecs/indeo/get_bits.h"
#include "image/codecs/indeo/indeo.h"
#include "graphics/managed_surface.h"
@@ -50,26 +49,21 @@ using namespace Indeo;
* Used in video:
* - AVIDecoder
*/
-class Indeo4Decoder : public Codec {
+class Indeo4Decoder : public IndeoDecoderBase {
public:
Indeo4Decoder(uint16 width, uint16 height);
- ~Indeo4Decoder();
+ virtual ~Indeo4Decoder() {}
- const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream);
- Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; }
+ virtual const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream);
static bool isIndeo4(Common::SeekableReadStream &stream);
-private:
- Graphics::PixelFormat _pixelFormat;
- Graphics::ManagedSurface *_surface;
- IVI45DecContext _ctx;
-
+protected:
/**
* Decode the Indeo 4 picture header.
* @returns 0 = Ok, negative number = error
*/
- int decodePictureHeader();
-
+ virtual int decodePictureHeader();
+private:
int scaleTileSize(int def_size, int size_factor);
/**
Commit: 9e774af4d91cb3adddfb6acc2024653620e725db
https://github.com/scummvm/scummvm/commit/9e774af4d91cb3adddfb6acc2024653620e725db
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T10:08:14-04:00
Commit Message:
IMAGE: Further implementation of Indeo image decoding
Changed paths:
A image/codecs/indeo/indeo_dsp.cpp
A image/codecs/indeo/indeo_dsp.h
image/codecs/indeo/get_bits.cpp
image/codecs/indeo/get_bits.h
image/codecs/indeo/indeo.cpp
image/codecs/indeo/indeo.h
image/codecs/indeo/mem.cpp
image/codecs/indeo/mem.h
image/codecs/indeo4.cpp
image/codecs/indeo4.h
image/module.mk
diff --git a/image/codecs/indeo/get_bits.cpp b/image/codecs/indeo/get_bits.cpp
index 98cef7f..fce773d 100644
--- a/image/codecs/indeo/get_bits.cpp
+++ b/image/codecs/indeo/get_bits.cpp
@@ -438,7 +438,7 @@ const byte *GetBits::alignGetBits() {
* read the longest vlc code
* = (max_vlc_length + bits - 1) / bits
*/
-int GetBits::getVLC2(int (*table)[2], int bits, int maxDepth) {
+int GetBits::getVLC2(int16 (*table)[2], int bits, int maxDepth) {
int code;
OPEN_READER(re);
diff --git a/image/codecs/indeo/get_bits.h b/image/codecs/indeo/get_bits.h
index 313fe7e..f9f577c 100644
--- a/image/codecs/indeo/get_bits.h
+++ b/image/codecs/indeo/get_bits.h
@@ -169,7 +169,7 @@ public:
* read the longest vlc code
* = (max_vlc_length + bits - 1) / bits
*/
- int getVLC2(int(*table)[2], int bits, int maxDepth);
+ int getVLC2(int16 (*table)[2], int bits, int maxDepth);
int decode012();
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index 820823b..e530c57 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -30,6 +30,7 @@
*/
#include "image/codecs/indeo/indeo.h"
+#include "image/codecs/indeo/indeo_dsp.h"
#include "image/codecs/indeo/mem.h"
#include "common/system.h"
#include "common/textconsole.h"
@@ -390,7 +391,6 @@ IndeoDecoderBase::IndeoDecoderBase(uint16 width, uint16 height) : Codec() {
_surface->create(width, height, _pixelFormat);
_ctx.gb = nullptr;
_ctx.pic_conf.pic_width = _ctx.pic_conf.pic_height = 0;
- _ctx.show_indeo4_info = false;
_ctx.b_ref_buf = 3; // buffer 2 is used for scalability mode
}
@@ -399,32 +399,893 @@ IndeoDecoderBase::~IndeoDecoderBase() {
}
int IndeoDecoderBase::decodeIndeoFrame() {
+ int result, p, b;
+ AVFrame frameData;
+ AVFrame *frame = &frameData;
+
// Decode the header
- int err = decodePictureHeader();
+ if (decodePictureHeader() < 0)
+ return -1;
- if (!err && _ctx.gop_invalid)
- err = -1;
+ if (_ctx.gop_invalid)
+ return -1;
- if (!err && _ctx.frame_type == IVI4_FRAMETYPE_NULL_LAST) {
+ if (_ctx.frame_type == IVI4_FRAMETYPE_NULL_LAST) {
// Returning the previous frame, so exit wth success
return 0;
}
- if (!err && _ctx.gop_flags & IVI5_IS_PROTECTED) {
+ if (_ctx.gop_flags & IVI5_IS_PROTECTED) {
warning("Password-protected clip");
- err = -1;
+ return -1;
}
- if (!err && !_ctx.planes[0].bands) {
+ if (!_ctx.planes[0].bands) {
warning("Color planes not initialized yet");
- err = -1;
+ return -1;
+ }
+
+ switch_buffers();
+
+ //{ START_TIMER;
+
+ if (is_nonnull_frame()) {
+ _ctx.buf_invalid[_ctx.dst_buf] = 1;
+ for (p = 0; p < 3; p++) {
+ for (b = 0; b < _ctx.planes[p].num_bands; b++) {
+ result = decode_band(&_ctx.planes[p].bands[b]);
+ if (result < 0) {
+ warning("Error while decoding band: %d, plane: %d", b, p);
+ return result;
+ }
+ }
+ }
+ _ctx.buf_invalid[_ctx.dst_buf] = 0;
+ } else {
+ if (_ctx.is_scalable)
+ return -1;
+
+ for (p = 0; p < 3; p++) {
+ if (!_ctx.planes[p].bands[0].buf)
+ return -1;
+ }
+ }
+ if (_ctx.buf_invalid[_ctx.dst_buf])
+ return -1;
+
+ //STOP_TIMER("decode_planes"); }
+
+ if (!is_nonnull_frame())
+ return 0;
+
+ result = ff_set_dimensions(_ctx.planes[0].width, _ctx.planes[0].height);
+ if (result < 0)
+ return result;
+
+ if ((result = ff_get_buffer(frame, 0)) < 0)
+ return result;
+
+ if (_ctx.is_scalable) {
+ if (_ctx.is_indeo4)
+ ff_ivi_recompose_haar(&_ctx.planes[0], frame->data[0], frame->linesize[0]);
+ else
+ ff_ivi_recompose53(&_ctx.planes[0], frame->data[0], frame->linesize[0]);
+ } else {
+ ivi_output_plane(&_ctx.planes[0], frame->data[0], frame->linesize[0]);
+ }
+
+ ivi_output_plane(&_ctx.planes[2], frame->data[1], frame->linesize[1]);
+ ivi_output_plane(&_ctx.planes[1], frame->data[2], frame->linesize[2]);
+
+ // If the bidirectional mode is enabled, next I and the following P
+ // frame will be sent together. Unfortunately the approach below seems
+ // to be the only way to handle the B-frames mode.
+ // That's exactly the same Intel decoders do.
+ if (_ctx.is_indeo4 && _ctx.frame_type == IVI4_FRAMETYPE_INTRA) {
+ int left;
+
+ // skip version string
+ while (_ctx.gb->getBits(8)) {
+ if (_ctx.gb->getBitsLeft() < 8)
+ return -1;
+ }
+ left = _ctx.gb->getBitsCount() & 0x18;
+ _ctx.gb->skipBitsLong(64 - left);
+ if (_ctx.gb->getBitsLeft() > 18 &&
+ _ctx.gb->showBitsLong(21) == 0xBFFF8) { // syncheader + inter type
+ error("Indeo decoder: Mode not currently implemented in ScummVM");
+ }
+ }
+
+ return 0;
+}
+
+int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
+ int result, i, t, idx1, idx2, pos;
+ IVITile * tile;
+
+ band->buf = band->bufs[_ctx.dst_buf];
+ if (!band->buf) {
+ warning("Band buffer points to no data!");
+ return -1;
+ }
+ if (_ctx.is_indeo4 && _ctx.frame_type == IVI4_FRAMETYPE_BIDIR) {
+ band->ref_buf = band->bufs[_ctx.b_ref_buf];
+ band->b_ref_buf = band->bufs[_ctx.ref_buf];
+ }
+ else {
+ band->ref_buf = band->bufs[_ctx.ref_buf];
+ band->b_ref_buf = 0;
+ }
+ band->data_ptr = _ctx.frame_data + (_ctx.gb->getBitsCount() >> 3);
+
+ result = decode_band_hdr(band);
+ if (result) {
+ warning("Error while decoding band header: %d",
+ result);
+ return result;
+ }
+
+ if (band->is_empty) {
+ warning("Empty band encountered!");
+ return -1;
+ }
+
+ band->rv_map = &_ctx.rvmap_tabs[band->rvmap_sel];
+
+ /* apply corrections to the selected rvmap table if present */
+ for (i = 0; i < band->num_corr; i++) {
+ idx1 = band->corr[i * 2];
+ idx2 = band->corr[i * 2 + 1];
+ FFSWAP(uint8, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);
+ FFSWAP(int16, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
+ if (idx1 == band->rv_map->eob_sym || idx2 == band->rv_map->eob_sym)
+ band->rv_map->eob_sym ^= idx1 ^ idx2;
+ if (idx1 == band->rv_map->esc_sym || idx2 == band->rv_map->esc_sym)
+ band->rv_map->esc_sym ^= idx1 ^ idx2;
}
- // TODO
+ pos = _ctx.gb->getBitsCount();
+
+ for (t = 0; t < band->num_tiles; t++) {
+ tile = &band->tiles[t];
+
+ if (tile->mb_size != band->mb_size) {
+ warning("MB sizes mismatch: %d vs. %d",
+ band->mb_size, tile->mb_size);
+ return -1;
+ }
+ tile->is_empty = _ctx.gb->getBits1();
+ if (tile->is_empty) {
+ result = ivi_process_empty_tile(band, tile,
+ (_ctx.planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3));
+ if (result < 0)
+ break;
+ warning("Empty tile encountered!");
+ } else {
+ tile->data_size = ivi_dec_tile_data_size(_ctx.gb);
+ if (!tile->data_size) {
+ warning("Tile data size is zero!");
+ result = -1;
+ break;
+ }
+
+ result = decode_mb_info(band, tile);
+ if (result < 0)
+ break;
+
+ result = ivi_decode_blocks(_ctx.gb, band, tile);
+ if (result < 0) {
+ warning("Corrupted tile data encountered!");
+ break;
+ }
+
+ if ((((int)_ctx.gb->getBitsCount() - pos) >> 3) != tile->data_size) {
+ warning("Tile data_size mismatch!");
+ result = -1;
+ break;
+ }
+
+ pos += tile->data_size << 3; // skip to next tile
+ }
+ }
+
+ // restore the selected rvmap table by applying its corrections in
+ // reverse order
+ for (i = band->num_corr - 1; i >= 0; i--) {
+ idx1 = band->corr[i * 2];
+ idx2 = band->corr[i * 2 + 1];
+ FFSWAP(uint8, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);
+ FFSWAP(int16, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
+ if (idx1 == band->rv_map->eob_sym || idx2 == band->rv_map->eob_sym)
+ band->rv_map->eob_sym ^= idx1 ^ idx2;
+ if (idx1 == band->rv_map->esc_sym || idx2 == band->rv_map->esc_sym)
+ band->rv_map->esc_sym ^= idx1 ^ idx2;
+ }
+
+ _ctx.gb->alignGetBits();
+
+ return result;
+}
+
+int IndeoDecoderBase::ff_set_dimensions(uint16 width, uint16 height) {
+ if (_surface->w != width || _surface->h != height)
+ _surface->create(width, height);
+
+ return 0;
+}
+
+int IndeoDecoderBase::ff_get_buffer(AVFrame *frame, int flags) {
+ frame->data[0] = (uint8 *)_surface->getBasePtr(0, 0);
+ return 0;
+}
- return err;
+void IndeoDecoderBase::ff_ivi_recompose_haar(const IVIPlaneDesc *plane,
+ uint8 *dst, const int dst_pitch) {
+ int x, y, indx, b0, b1, b2, b3, p0, p1, p2, p3;
+ const short * b0_ptr, *b1_ptr, *b2_ptr, *b3_ptr;
+ int32 pitch;
+
+ // all bands should have the same pitch
+ pitch = plane->bands[0].pitch;
+
+ // get pointers to the wavelet bands
+ b0_ptr = plane->bands[0].buf;
+ b1_ptr = plane->bands[1].buf;
+ b2_ptr = plane->bands[2].buf;
+ b3_ptr = plane->bands[3].buf;
+
+ for (y = 0; y < plane->height; y += 2) {
+ for (x = 0, indx = 0; x < plane->width; x += 2, indx++) {
+ // load coefficients
+ b0 = b0_ptr[indx]; //should be: b0 = (num_bands > 0) ? b0_ptr[indx] : 0;
+ b1 = b1_ptr[indx]; //should be: b1 = (num_bands > 1) ? b1_ptr[indx] : 0;
+ b2 = b2_ptr[indx]; //should be: b2 = (num_bands > 2) ? b2_ptr[indx] : 0;
+ b3 = b3_ptr[indx]; //should be: b3 = (num_bands > 3) ? b3_ptr[indx] : 0;
+
+ // haar wavelet recomposition
+ p0 = (b0 + b1 + b2 + b3 + 2) >> 2;
+ p1 = (b0 + b1 - b2 - b3 + 2) >> 2;
+ p2 = (b0 - b1 + b2 - b3 + 2) >> 2;
+ p3 = (b0 - b1 - b2 + b3 + 2) >> 2;
+
+ // bias, convert and output four pixels
+ dst[x] = av_clip_uint8(p0 + 128);
+ dst[x + 1] = av_clip_uint8(p1 + 128);
+ dst[dst_pitch + x] = av_clip_uint8(p2 + 128);
+ dst[dst_pitch + x + 1] = av_clip_uint8(p3 + 128);
+ }// for x
+
+ dst += dst_pitch << 1;
+
+ b0_ptr += pitch;
+ b1_ptr += pitch;
+ b2_ptr += pitch;
+ b3_ptr += pitch;
+ }// for y
}
+
+void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *plane,
+ uint8 *dst, const int dst_pitch) {
+ int x, y, indx;
+ int32 p0, p1, p2, p3, tmp0, tmp1, tmp2;
+ int32 b0_1, b0_2, b1_1, b1_2, b1_3, b2_1, b2_2, b2_3, b2_4, b2_5, b2_6;
+ int32 b3_1, b3_2, b3_3, b3_4, b3_5, b3_6, b3_7, b3_8, b3_9;
+ int32 pitch, back_pitch;
+ const short * b0_ptr, *b1_ptr, *b2_ptr, *b3_ptr;
+ const int num_bands = 4;
+
+ // all bands should have the same pitch
+ pitch = plane->bands[0].pitch;
+
+ // pixels at the position "y-1" will be set to pixels at the "y" for the 1st iteration
+ back_pitch = 0;
+
+ // get pointers to the wavelet bands
+ b0_ptr = plane->bands[0].buf;
+ b1_ptr = plane->bands[1].buf;
+ b2_ptr = plane->bands[2].buf;
+ b3_ptr = plane->bands[3].buf;
+
+ for (y = 0; y < plane->height; y += 2) {
+
+ if (y + 2 >= plane->height)
+ pitch = 0;
+ // load storage variables with values
+ if (num_bands > 0) {
+ b0_1 = b0_ptr[0];
+ b0_2 = b0_ptr[pitch];
+ }
+
+ if (num_bands > 1) {
+ b1_1 = b1_ptr[back_pitch];
+ b1_2 = b1_ptr[0];
+ b1_3 = b1_1 - b1_2 * 6 + b1_ptr[pitch];
+ }
+
+ if (num_bands > 2) {
+ b2_2 = b2_ptr[0]; // b2[x, y ]
+ b2_3 = b2_2; // b2[x+1,y ] = b2[x,y]
+ b2_5 = b2_ptr[pitch]; // b2[x ,y+1]
+ b2_6 = b2_5; // b2[x+1,y+1] = b2[x,y+1]
+ }
+
+ if (num_bands > 3) {
+ b3_2 = b3_ptr[back_pitch]; // b3[x ,y-1]
+ b3_3 = b3_2; // b3[x+1,y-1] = b3[x ,y-1]
+ b3_5 = b3_ptr[0]; // b3[x ,y ]
+ b3_6 = b3_5; // b3[x+1,y ] = b3[x ,y ]
+ b3_8 = b3_2 - b3_5 * 6 + b3_ptr[pitch];
+ b3_9 = b3_8;
+ }
+
+ for (x = 0, indx = 0; x < plane->width; x += 2, indx++) {
+ if (x + 2 >= plane->width) {
+ b0_ptr--;
+ b1_ptr--;
+ b2_ptr--;
+ b3_ptr--;
+ }
+
+ // some values calculated in the previous iterations can
+ // be reused in the next ones, so do appropriate copying
+ b2_1 = b2_2; // b2[x-1,y ] = b2[x, y ]
+ b2_2 = b2_3; // b2[x ,y ] = b2[x+1,y ]
+ b2_4 = b2_5; // b2[x-1,y+1] = b2[x ,y+1]
+ b2_5 = b2_6; // b2[x ,y+1] = b2[x+1,y+1]
+ b3_1 = b3_2; // b3[x-1,y-1] = b3[x ,y-1]
+ b3_2 = b3_3; // b3[x ,y-1] = b3[x+1,y-1]
+ b3_4 = b3_5; // b3[x-1,y ] = b3[x ,y ]
+ b3_5 = b3_6; // b3[x ,y ] = b3[x+1,y ]
+ b3_7 = b3_8; // vert_HPF(x-1)
+ b3_8 = b3_9; // vert_HPF(x )
+
+ p0 = p1 = p2 = p3 = 0;
+
+ // process the LL-band by applying LPF both vertically and horizontally
+ if (num_bands > 0) {
+ tmp0 = b0_1;
+ tmp2 = b0_2;
+ b0_1 = b0_ptr[indx + 1];
+ b0_2 = b0_ptr[pitch + indx + 1];
+ tmp1 = tmp0 + b0_1;
+
+ p0 = tmp0 << 4;
+ p1 = tmp1 << 3;
+ p2 = (tmp0 + tmp2) << 3;
+ p3 = (tmp1 + tmp2 + b0_2) << 2;
+ }
+
+ // process the HL-band by applying HPF vertically and LPF horizontally
+ if (num_bands > 1) {
+ tmp0 = b1_2;
+ tmp1 = b1_1;
+ b1_2 = b1_ptr[indx + 1];
+ b1_1 = b1_ptr[back_pitch + indx + 1];
+
+ tmp2 = tmp1 - tmp0 * 6 + b1_3;
+ b1_3 = b1_1 - b1_2 * 6 + b1_ptr[pitch + indx + 1];
+
+ p0 += (tmp0 + tmp1) << 3;
+ p1 += (tmp0 + tmp1 + b1_1 + b1_2) << 2;
+ p2 += tmp2 << 2;
+ p3 += (tmp2 + b1_3) << 1;
+ }
+
+ // process the LH-band by applying LPF vertically and HPF horizontally
+ if (num_bands > 2) {
+ b2_3 = b2_ptr[indx + 1];
+ b2_6 = b2_ptr[pitch + indx + 1];
+
+ tmp0 = b2_1 + b2_2;
+ tmp1 = b2_1 - b2_2 * 6 + b2_3;
+
+ p0 += tmp0 << 3;
+ p1 += tmp1 << 2;
+ p2 += (tmp0 + b2_4 + b2_5) << 2;
+ p3 += (tmp1 + b2_4 - b2_5 * 6 + b2_6) << 1;
+ }
+
+ // process the HH-band by applying HPF both vertically and horizontally
+ if (num_bands > 3) {
+ b3_6 = b3_ptr[indx + 1]; // b3[x+1,y ]
+ b3_3 = b3_ptr[back_pitch + indx + 1]; // b3[x+1,y-1]
+
+ tmp0 = b3_1 + b3_4;
+ tmp1 = b3_2 + b3_5;
+ tmp2 = b3_3 + b3_6;
+
+ b3_9 = b3_3 - b3_6 * 6 + b3_ptr[pitch + indx + 1];
+
+ p0 += (tmp0 + tmp1) << 2;
+ p1 += (tmp0 - tmp1 * 6 + tmp2) << 1;
+ p2 += (b3_7 + b3_8) << 1;
+ p3 += b3_7 - b3_8 * 6 + b3_9;
+ }
+
+ // output four pixels
+ dst[x] = av_clip_uint8((p0 >> 6) + 128);
+ dst[x + 1] = av_clip_uint8((p1 >> 6) + 128);
+ dst[dst_pitch + x] = av_clip_uint8((p2 >> 6) + 128);
+ dst[dst_pitch + x + 1] = av_clip_uint8((p3 >> 6) + 128);
+ }// for x
+
+ dst += dst_pitch << 1;
+
+ back_pitch = -pitch;
+
+ b0_ptr += pitch + 1;
+ b1_ptr += pitch + 1;
+ b2_ptr += pitch + 1;
+ b3_ptr += pitch + 1;
+ }
+}
+
+void IndeoDecoderBase::ivi_output_plane(IVIPlaneDesc *plane, uint8 *dst, int dst_pitch) {
+ int x, y;
+ const int16 * src = plane->bands[0].buf;
+ uint32 pitch = plane->bands[0].pitch;
+
+ if (!src)
+ return;
+
+ for (y = 0; y < plane->height; y++) {
+ for (x = 0; x < plane->width; x++)
+ dst[x] = av_clip_uint8(src[x] + 128);
+ src += pitch;
+ dst += dst_pitch;
+ }
+}
+
+int IndeoDecoderBase::ivi_process_empty_tile(IVIBandDesc *band,
+ IVITile *tile, int32 mv_scale) {
+ int x, y, need_mc, mbn, blk, num_blocks, mv_x, mv_y, mc_type;
+ int offs, mb_offset, row_offset, ret;
+ IVIMbInfo *mb, *ref_mb;
+ const int16 *src;
+ int16 *dst;
+ ivi_mc_func mc_no_delta_func;
+
+ if (tile->num_MBs != IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size)) {
+ warning("Allocated tile size %d mismatches "
+ "parameters %d in ivi_process_empty_tile()",
+ tile->num_MBs, IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size));
+ return -1;
+ }
+
+ offs = tile->ypos * band->pitch + tile->xpos;
+ mb = tile->mbs;
+ ref_mb = tile->ref_mbs;
+ row_offset = band->mb_size * band->pitch;
+ need_mc = 0; /* reset the mc tracking flag */
+
+ for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
+ mb_offset = offs;
+
+ for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
+ mb->xpos = x;
+ mb->ypos = y;
+ mb->buf_offs = mb_offset;
+
+ mb->type = 1; /* set the macroblocks type = INTER */
+ mb->cbp = 0; /* all blocks are empty */
+
+ if (!band->qdelta_present && !band->plane && !band->band_num) {
+ mb->q_delta = band->glob_quant;
+ mb->mv_x = 0;
+ mb->mv_y = 0;
+ }
+
+ if (band->inherit_qdelta && ref_mb)
+ mb->q_delta = ref_mb->q_delta;
+
+ if (band->inherit_mv && ref_mb) {
+ /* motion vector inheritance */
+ if (mv_scale) {
+ mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
+ mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
+ } else {
+ mb->mv_x = ref_mb->mv_x;
+ mb->mv_y = ref_mb->mv_y;
+ }
+ need_mc |= mb->mv_x || mb->mv_y; /* tracking non-zero motion vectors */
+ {
+ int dmv_x, dmv_y, cx, cy;
+
+ dmv_x = mb->mv_x >> band->is_halfpel;
+ dmv_y = mb->mv_y >> band->is_halfpel;
+ cx = mb->mv_x & band->is_halfpel;
+ cy = mb->mv_y & band->is_halfpel;
+
+ if (mb->xpos + dmv_x < 0
+ || mb->xpos + dmv_x + band->mb_size + cx > band->pitch
+ || mb->ypos + dmv_y < 0
+ || mb->ypos + dmv_y + band->mb_size + cy > band->aheight) {
+ warning("MV out of bounds");
+ return -1;
+ }
+ }
+ }
+
+ mb++;
+ if (ref_mb)
+ ref_mb++;
+ mb_offset += band->mb_size;
+ } // for x
+ offs += row_offset;
+ } // for y
+
+ if (band->inherit_mv && need_mc) { // apply motion compensation if there is at least one non-zero motion vector
+ num_blocks = (band->mb_size != band->blk_size) ? 4 : 1; // number of blocks per mb
+ mc_no_delta_func = (band->blk_size == 8) ? IndeoDSP::ff_ivi_mc_8x8_no_delta
+ : IndeoDSP::ff_ivi_mc_4x4_no_delta;
+
+ for (mbn = 0, mb = tile->mbs; mbn < tile->num_MBs; mb++, mbn++) {
+ mv_x = mb->mv_x;
+ mv_y = mb->mv_y;
+ if (!band->is_halfpel) {
+ mc_type = 0; // we have only fullpel vectors
+ } else {
+ mc_type = ((mv_y & 1) << 1) | (mv_x & 1);
+ mv_x >>= 1;
+ mv_y >>= 1; // convert halfpel vectors into fullpel ones
+ }
+
+ for (blk = 0; blk < num_blocks; blk++) {
+ // adjust block position in the buffer according with its number
+ offs = mb->buf_offs + band->blk_size * ((blk & 1) + !!(blk & 2) * band->pitch);
+ ret = ivi_mc(band, mc_no_delta_func, nullptr, offs,
+ mv_x, mv_y, 0, 0, mc_type, -1);
+ if (ret < 0)
+ return ret;
+ }
+ }
+ } else {
+ // copy data from the reference tile into the current one
+ src = band->ref_buf + tile->ypos * band->pitch + tile->xpos;
+ dst = band->buf + tile->ypos * band->pitch + tile->xpos;
+ for (y = 0; y < tile->height; y++) {
+ memcpy(dst, src, tile->width*sizeof(band->buf[0]));
+ src += band->pitch;
+ dst += band->pitch;
+ }
+ }
+
+ return 0;
+}
+
+int IndeoDecoderBase::ivi_dec_tile_data_size(GetBits *gb) {
+ int len = 0;
+
+ if (gb->getBits1()) {
+ len = gb->getBits(8);
+ if (len == 255)
+ len = gb->getBitsLong(24);
+ }
+
+ // align the bitstream reader on the byte boundary
+ gb->alignGetBits();
+
+ return len;
+}
+
+int IndeoDecoderBase::ivi_decode_blocks(GetBits *gb, IVIBandDesc *band, IVITile *tile) {
+ int mbn, blk, num_blocks, blk_size, ret, is_intra;
+ int mc_type = 0, mc_type2 = -1;
+ int mv_x = 0, mv_y = 0, mv_x2 = 0, mv_y2 = 0;
+ int32 prev_dc;
+ uint32 cbp, quant, buf_offs;
+ IVIMbInfo *mb;
+ ivi_mc_func mc_with_delta_func, mc_no_delta_func;
+ ivi_mc_avg_func mc_avg_with_delta_func, mc_avg_no_delta_func;
+ const uint8 *scale_tab;
+
+ /* init intra prediction for the DC coefficient */
+ prev_dc = 0;
+ blk_size = band->blk_size;
+ /* number of blocks per mb */
+ num_blocks = (band->mb_size != blk_size) ? 4 : 1;
+ if (blk_size == 8) {
+ mc_with_delta_func = IndeoDSP::ff_ivi_mc_8x8_delta;
+ mc_no_delta_func = IndeoDSP::ff_ivi_mc_8x8_no_delta;
+ mc_avg_with_delta_func = IndeoDSP::ff_ivi_mc_avg_8x8_delta;
+ mc_avg_no_delta_func = IndeoDSP::ff_ivi_mc_avg_8x8_no_delta;
+ } else {
+ mc_with_delta_func = IndeoDSP::ff_ivi_mc_4x4_delta;
+ mc_no_delta_func = IndeoDSP::ff_ivi_mc_4x4_no_delta;
+ mc_avg_with_delta_func = IndeoDSP::ff_ivi_mc_avg_4x4_delta;
+ mc_avg_no_delta_func = IndeoDSP::ff_ivi_mc_avg_4x4_no_delta;
+ }
+
+ for (mbn = 0, mb = tile->mbs; mbn < tile->num_MBs; mb++, mbn++) {
+ is_intra = !mb->type;
+ cbp = mb->cbp;
+ buf_offs = mb->buf_offs;
+
+ quant = band->glob_quant + mb->q_delta;
+ if (_ctx.is_indeo4)
+ quant = av_clip_uintp2(quant, 5);
+ else
+ quant = av_clip((int)quant, 0, 23);
+
+ scale_tab = is_intra ? band->intra_scale : band->inter_scale;
+ if (scale_tab)
+ quant = scale_tab[quant];
+
+ if (!is_intra) {
+ mv_x = mb->mv_x;
+ mv_y = mb->mv_y;
+ mv_x2 = mb->b_mv_x;
+ mv_y2 = mb->b_mv_y;
+ if (band->is_halfpel) {
+ mc_type = ((mv_y & 1) << 1) | (mv_x & 1);
+ mc_type2 = ((mv_y2 & 1) << 1) | (mv_x2 & 1);
+ mv_x >>= 1;
+ mv_y >>= 1;
+ mv_x2 >>= 1;
+ mv_y2 >>= 1; /* convert halfpel vectors into fullpel ones */
+ }
+ if (mb->type == 2)
+ mc_type = -1;
+ if (mb->type != 2 && mb->type != 3)
+ mc_type2 = -1;
+ if (mb->type) {
+ int dmv_x, dmv_y, cx, cy;
+
+ dmv_x = mb->mv_x >> band->is_halfpel;
+ dmv_y = mb->mv_y >> band->is_halfpel;
+ cx = mb->mv_x & band->is_halfpel;
+ cy = mb->mv_y & band->is_halfpel;
+
+ if (mb->xpos + dmv_x < 0 ||
+ mb->xpos + dmv_x + band->mb_size + cx > band->pitch ||
+ mb->ypos + dmv_y < 0 ||
+ mb->ypos + dmv_y + band->mb_size + cy > band->aheight) {
+ return -1;
+ }
+ }
+ if (mb->type == 2 || mb->type == 3) {
+ int dmv_x, dmv_y, cx, cy;
+
+ dmv_x = mb->b_mv_x >> band->is_halfpel;
+ dmv_y = mb->b_mv_y >> band->is_halfpel;
+ cx = mb->b_mv_x & band->is_halfpel;
+ cy = mb->b_mv_y & band->is_halfpel;
+
+ if (mb->xpos + dmv_x < 0 ||
+ mb->xpos + dmv_x + band->mb_size + cx > band->pitch ||
+ mb->ypos + dmv_y < 0 ||
+ mb->ypos + dmv_y + band->mb_size + cy > band->aheight) {
+ return -1;
+ }
+ }
+ }
+
+ for (blk = 0; blk < num_blocks; blk++) {
+ // adjust block position in the buffer according to its number
+ if (blk & 1) {
+ buf_offs += blk_size;
+ } else if (blk == 2) {
+ buf_offs -= blk_size;
+ buf_offs += blk_size * band->pitch;
+ }
+
+ if (cbp & 1) { // block coded ?
+ ret = ivi_decode_coded_blocks(gb, band, mc_with_delta_func,
+ mc_avg_with_delta_func,
+ mv_x, mv_y, mv_x2, mv_y2,
+ &prev_dc, is_intra,
+ mc_type, mc_type2, quant,
+ buf_offs);
+ if (ret < 0)
+ return ret;
+ } else {
+ // block not coded
+ // for intra blocks apply the dc slant transform
+ // for inter - perform the motion compensation without delta
+ if (is_intra) {
+ ret = ivi_dc_transform(band, &prev_dc, buf_offs, blk_size);
+ if (ret < 0)
+ return ret;
+ } else {
+ ret = ivi_mc(band, mc_no_delta_func, mc_avg_no_delta_func,
+ buf_offs, mv_x, mv_y, mv_x2, mv_y2,
+ mc_type, mc_type2);
+ if (ret < 0)
+ return ret;
+ }
+ }
+
+ cbp >>= 1;
+ }// for blk
+ }// for mbn
+
+ gb->alignGetBits();
+ return 0;
+}
+
+int IndeoDecoderBase::ivi_scale_mv(int mv, int mv_scale){
+ return (mv + (mv > 0) + (mv_scale - 1)) >> mv_scale;
+}
+
+int IndeoDecoderBase::ivi_mc(IVIBandDesc *band, ivi_mc_func mc, ivi_mc_avg_func mc_avg,
+ int offs, int mv_x, int mv_y, int mv_x2, int mv_y2,
+ int mc_type, int mc_type2){
+ int ref_offs = offs + mv_y * band->pitch + mv_x;
+ int buf_size = band->pitch * band->aheight;
+ int min_size = band->pitch * (band->blk_size - 1) + band->blk_size;
+ int ref_size = (mc_type > 1) * band->pitch + (mc_type & 1);
+
+ if (mc_type != -1) {
+ assert(offs >= 0 && ref_offs >= 0 && band->ref_buf);
+ assert(buf_size - min_size >= offs);
+ assert(buf_size - min_size - ref_size >= ref_offs);
+ }
+
+ if (mc_type2 == -1) {
+ mc(band->buf + offs, band->ref_buf + ref_offs, band->pitch, mc_type);
+ } else {
+ int ref_offs2 = offs + mv_y2 * band->pitch + mv_x2;
+ int ref_size2 = (mc_type2 > 1) * band->pitch + (mc_type2 & 1);
+ if (offs < 0 || ref_offs2 < 0 || !band->b_ref_buf)
+ return -1;
+ if (buf_size - min_size - ref_size2 < ref_offs2)
+ return -1;
+
+ if (mc_type == -1)
+ mc(band->buf + offs, band->b_ref_buf + ref_offs2,
+ band->pitch, mc_type2);
+ else
+ mc_avg(band->buf + offs, band->ref_buf + ref_offs,
+ band->b_ref_buf + ref_offs2, band->pitch,
+ mc_type, mc_type2);
+ }
+
+ return 0;
+}
+
+int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
+ ivi_mc_func mc, ivi_mc_avg_func mc_avg, int mv_x, int mv_y,
+ int mv_x2, int mv_y2, int *prev_dc, int is_intra,
+ int mc_type, int mc_type2, uint32 quant, int offs) {
+ const uint16 *base_tab = is_intra ? band->intra_base : band->inter_base;
+ RVMapDesc *rvmap = band->rv_map;
+ uint8 col_flags[8];
+ int32 trvec[64];
+ uint32 sym = 0, lo, hi, q;
+ int pos, run, val;
+ int blk_size = band->blk_size;
+ int num_coeffs = blk_size * blk_size;
+ int col_mask = blk_size - 1;
+ int scan_pos = -1;
+ int min_size = band->pitch * (band->transform_size - 1) +
+ band->transform_size;
+ int buf_size = band->pitch * band->aheight - offs;
+
+ if (min_size > buf_size)
+ return -1;
+
+ if (!band->scan) {
+ warning("Scan pattern is not set.");
+ return -1;
+ }
+
+ // zero transform vector
+ memset(trvec, 0, num_coeffs * sizeof(trvec[0]));
+ // zero column flags
+ memset(col_flags, 0, sizeof(col_flags));
+ while (scan_pos <= num_coeffs) {
+ sym = gb->getVLC2(band->blk_vlc.tab->table,
+ IVI_VLC_BITS, 1);
+ if (sym == rvmap->eob_sym)
+ break; // End of block
+
+ // Escape - run/val explicitly coded using 3 vlc codes
+ if (sym == rvmap->esc_sym) {
+ run = gb->getVLC2(band->blk_vlc.tab->table, IVI_VLC_BITS, 1) + 1;
+ lo = gb->getVLC2(band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
+ hi = gb->getVLC2(band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
+ // merge them and convert into signed val
+ val = IVI_TOSIGNED((hi << 6) | lo);
+ }
+ else {
+ if (sym >= 256U) {
+ warning("Invalid sym encountered");
+ return -1;
+ }
+ run = rvmap->runtab[sym];
+ val = rvmap->valtab[sym];
+ }
+
+ // de-zigzag and dequantize
+ scan_pos += run;
+ if (scan_pos >= num_coeffs || scan_pos < 0)
+ break;
+ pos = band->scan[scan_pos];
+
+ if (!val)
+ warning("Val = 0 encountered!");
+
+ q = (base_tab[pos] * quant) >> 9;
+ if (q > 1)
+ val = val * q + FFSIGN(val) * (((q ^ 1) - 1) >> 1);
+ trvec[pos] = val;
+ // track columns containing non-zero coeffs
+ col_flags[pos & col_mask] |= !!val;
+ }
+
+ if (scan_pos < 0 || scan_pos >= num_coeffs && sym != rvmap->eob_sym)
+ return -1; // corrupt block data
+
+ // undoing DC coeff prediction for intra-blocks
+ if (is_intra && band->is_2d_trans) {
+ *prev_dc += trvec[0];
+ trvec[0] = *prev_dc;
+ col_flags[0] |= !!*prev_dc;
+ }
+
+ if (band->transform_size > band->blk_size) {
+ warning("Too large transform");
+ return -1;
+ }
+
+ // apply inverse transform
+ band->inv_transform(trvec, band->buf + offs,
+ band->pitch, col_flags);
+
+ // apply motion compensation
+ if (!is_intra)
+ return ivi_mc(band, mc, mc_avg, offs, mv_x, mv_y, mv_x2, mv_y2,
+ mc_type, mc_type2);
+
+ return 0;
+}
+
+int IndeoDecoderBase::ivi_dc_transform(IVIBandDesc *band, int *prev_dc,
+ int buf_offs, int blk_size) {
+ int buf_size = band->pitch * band->aheight - buf_offs;
+ int min_size = (blk_size - 1) * band->pitch + blk_size;
+
+ if (min_size > buf_size)
+ return -1;
+
+ band->dc_transform(prev_dc, band->buf + buf_offs,
+ band->pitch, blk_size);
+
+ return 0;
+}
+
+
+/**
+ * Scan patterns shared between indeo4 and indeo5
+ */
+const uint8 IndeoDecoderBase::_ff_ivi_vertical_scan_8x8[64] = {
+ 0, 8, 16, 24, 32, 40, 48, 56,
+ 1, 9, 17, 25, 33, 41, 49, 57,
+ 2, 10, 18, 26, 34, 42, 50, 58,
+ 3, 11, 19, 27, 35, 43, 51, 59,
+ 4, 12, 20, 28, 36, 44, 52, 60,
+ 5, 13, 21, 29, 37, 45, 53, 61,
+ 6, 14, 22, 30, 38, 46, 54, 62,
+ 7, 15, 23, 31, 39, 47, 55, 63
+};
+
+const uint8 IndeoDecoderBase::_ff_ivi_horizontal_scan_8x8[64] = {
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55,
+ 56, 57, 58, 59, 60, 61, 62, 63
+};
+
+const uint8 IndeoDecoderBase::_ff_ivi_direct_scan_4x4[16] = {
+ 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
+};
+
/*------------------------------------------------------------------------*/
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) {
diff --git a/image/codecs/indeo/indeo.h b/image/codecs/indeo/indeo.h
index c84f257..fa1bc2f 100644
--- a/image/codecs/indeo/indeo.h
+++ b/image/codecs/indeo/indeo.h
@@ -55,10 +55,21 @@ enum {
IVI4_FRAMETYPE_NULL_LAST = 6 ///< empty frame with no data
};
+typedef void(*ivi_mc_func) (int16 *buf, const int16 *ref_buf,
+ uint32 pitch, int mc_type);
+typedef void(*ivi_mc_avg_func) (int16 *buf, const int16 *ref_buf1,
+ const int16 *ref_buf2,
+ uint32 pitch, int mc_type, int mc_type2);
+
#define IVI_VLC_BITS 13 ///< max number of bits of the ivi's huffman codes
#define IVI5_IS_PROTECTED 0x20
/**
+ * convert unsigned values into signed ones (the sign is in the LSB)
+ */
+#define IVI_TOSIGNED(val) (-(((val) >> 1) ^ -((val) & 1)))
+
+/**
* huffman codebook descriptor
*/
struct IVIHuffDesc {
@@ -129,7 +140,6 @@ enum {
//extern const uint8 ff_ivi_horizontal_scan_8x8[64];
//extern const uint8 ff_ivi_direct_scan_4x4[16];
-
/**
* Declare inverse transform function types
*/
@@ -272,6 +282,40 @@ struct IVIPlaneDesc {
static void ivi_free_buffers(IVIPlaneDesc *planes);
};
+struct AVFrame {
+#define AV_NUM_DATA_POINTERS 8
+ /**
+ * pointer to the picture/channel planes.
+ * This might be different from the first allocated byte
+ *
+ * Some decoders access areas outside 0,0 - width,height, please
+ * see avcodec_align_dimensions2(). Some filters and swscale can read
+ * up to 16 bytes beyond the planes, if these filters are to be used,
+ * then 16 extra bytes must be allocated.
+ *
+ * NOTE: Except for hwaccel formats, pointers not needed by the format
+ * MUST be set to NULL.
+ */
+ uint8 *data[AV_NUM_DATA_POINTERS];
+
+ /**
+ * For video, size in bytes of each picture line.
+ * For audio, size in bytes of each plane.
+ *
+ * For audio, only linesize[0] may be set. For planar audio, each channel
+ * plane must be the same size.
+ *
+ * For video the linesizes should be multiples of the CPUs alignment
+ * preference, this is 16 or 32 for modern desktop CPUs.
+ * Some code requires such alignment other code can be slower without
+ * correct alignment, for yet other it makes no difference.
+ *
+ * @note The linesize may be larger than the size of usable data -- there
+ * may be extra padding present for performance reasons.
+ */
+ int linesize[AV_NUM_DATA_POINTERS];
+};
+
struct IVI45DecContext {
GetBits * gb;
RVMapDesc rvmap_tabs[9]; ///< local corrected copy of the static rvmap tables
@@ -310,33 +354,131 @@ struct IVI45DecContext {
uint8 gop_flags;
uint32 lock_word;
- int show_indeo4_info;
uint8 has_b_frames;
uint8 has_transp; ///< transparency mode status: 1 - enabled
uint8 uses_tiling;
uint8 uses_haar;
uint8 uses_fullpel;
-// int (*decode_pic_hdr) (struct IVI45DecContext *ctx, AVCodecContext *avctx);
-// int (*decode_band_hdr) (struct IVI45DecContext *ctx, IVIBandDesc *band, AVCodecContext *avctx);
-// int (*decode_mb_info) (struct IVI45DecContext *ctx, IVIBandDesc *band, IVITile *tile, AVCodecContext *avctx);
-// void (*switch_buffers) (struct IVI45DecContext *ctx);
-// int (*is_nonnull_frame)(struct IVI45DecContext *ctx);
-
int gop_invalid;
int buf_invalid[4];
int is_indeo4;
-// AVFrame * p_frame;
+ AVFrame * p_frame;
int got_p_frame;
};
class IndeoDecoderBase : public Codec {
+private:
+ /**
+ * Decode an Indeo 4 or 5 band.
+ *
+ * @param[in,out] band ptr to the band descriptor
+ * @returns result code: 0 = OK, -1 = error
+ */
+ int decode_band(IVIBandDesc *band);
+
+ /**
+ * Sets the frame dimensions
+ */
+ int ff_set_dimensions(uint16 width, uint16 height);
+
+ /**
+ * Get a buffer for a frame. This is a wrapper around
+ * AVCodecContext.get_buffer() and should be used instead calling get_buffer()
+ * directly.
+ */
+ int ff_get_buffer(AVFrame *frame, int flags);
+
+ /**
+ * Haar wavelet recomposition filter for Indeo 4
+ *
+ * @param[in] plane pointer to the descriptor of the plane being processed
+ * @param[out] dst pointer to the destination buffer
+ * @param[in] dst_pitch pitch of the destination buffer
+ */
+ void ff_ivi_recompose_haar(const IVIPlaneDesc *plane, uint8 *dst,
+ const int dst_pitch);
+
+ /**
+ * 5/3 wavelet recomposition filter for Indeo5
+ *
+ * @param[in] plane pointer to the descriptor of the plane being processed
+ * @param[out] dst pointer to the destination buffer
+ * @param[in] dst_pitch pitch of the destination buffer
+ */
+ void ff_ivi_recompose53(const IVIPlaneDesc *plane,
+ uint8 *dst, const int dst_pitch);
+
+ /*
+ * Convert and output the current plane.
+ * This conversion is done by adding back the bias value of 128
+ * (subtracted in the encoder) and clipping the result.
+ *
+ * @param[in] plane pointer to the descriptor of the plane being processed
+ * @param[out] dst pointer to the buffer receiving converted pixels
+ * @param[in] dst_pitch pitch for moving to the next y line
+ */
+ void ivi_output_plane(IVIPlaneDesc *plane, uint8 *dst, int dst_pitch);
+
+ /**
+ * Handle empty tiles by performing data copying and motion
+ * compensation respectively.
+ *
+ * @param[in] band pointer to the band descriptor
+ * @param[in] tile pointer to the tile descriptor
+ * @param[in] mv_scale scaling factor for motion vectors
+ */
+ int ivi_process_empty_tile(IVIBandDesc *band, IVITile *tile, int32 mv_scale);
+
+ /*
+ * Decode size of the tile data.
+ * The size is stored as a variable-length field having the following format:
+ * if (tile_data_size < 255) than this field is only one byte long
+ * if (tile_data_size >= 255) than this field four is byte long: 0xFF X1 X2 X3
+ * where X1-X3 is size of the tile data
+ *
+ * @param[in,out] gb the GetBit context
+ * @return size of the tile data in bytes
+ */
+ int ivi_dec_tile_data_size(GetBits *gb);
+
+ /*
+ * Decode block data:
+ * extract huffman-coded transform coefficients from the bitstream,
+ * dequantize them, apply inverse transform and motion compensation
+ * in order to reconstruct the picture.
+ *
+ * @param[in,out] gb the GetBit context
+ * @param[in] band pointer to the band descriptor
+ * @param[in] tile pointer to the tile descriptor
+ * @return result code: 0 - OK, -1 = error (corrupted blocks data)
+ */
+ int ivi_decode_blocks(GetBits *gb, IVIBandDesc *band, IVITile *tile);
+
+ int ivi_mc(IVIBandDesc *band, ivi_mc_func mc, ivi_mc_avg_func mc_avg,
+ int offs, int mv_x, int mv_y, int mv_x2, int mv_y2,
+ int mc_type, int mc_type2);
+
+ int ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
+ ivi_mc_func mc, ivi_mc_avg_func mc_avg, int mv_x, int mv_y,
+ int mv_x2, int mv_y2, int *prev_dc, int is_intra,
+ int mc_type, int mc_type2, uint32 quant, int offs);
+
+ int ivi_dc_transform(IVIBandDesc *band, int *prev_dc, int buf_offs,
+ int blk_size);
protected:
IVI45DecContext _ctx;
Graphics::PixelFormat _pixelFormat;
Graphics::ManagedSurface *_surface;
+
+ /**
+ * Scan patterns shared between indeo4 and indeo5
+ */
+ static const uint8 _ff_ivi_vertical_scan_8x8[64];
+ static const uint8 _ff_ivi_horizontal_scan_8x8[64];
+ static const uint8 _ff_ivi_direct_scan_4x4[16];
protected:
/**
* Returns the pixel format for the decoder's surface
@@ -350,10 +492,40 @@ protected:
virtual int decodePictureHeader() = 0;
/**
+ * Rearrange decoding and reference buffers.
+ */
+ virtual void switch_buffers() = 0;
+
+ virtual bool is_nonnull_frame() const = 0;
+
+ /**
+ * Decode Indeo band header.
+ *
+ * @param[in,out] band pointer to the band descriptor
+ * @return result code: 0 = OK, negative number = error
+ */
+ virtual int decode_band_hdr(IVIBandDesc *band) = 0;
+
+ /**
+ * Decode information (block type, cbp, quant delta, motion vector)
+ * for all macroblocks in the current tile.
+ *
+ * @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
+ */
+ virtual int decode_mb_info(IVIBandDesc *band, IVITile *tile)= 0;
+
+ /**
* Decodes the Indeo frame from the bit reader already
* loaded into the context
*/
int decodeIndeoFrame();
+
+ /**
+ * scale motion vector
+ */
+ int ivi_scale_mv(int mv, int mv_scale);
public:
IndeoDecoderBase(uint16 width, uint16 height);
virtual ~IndeoDecoderBase();
diff --git a/image/codecs/indeo/indeo_dsp.cpp b/image/codecs/indeo/indeo_dsp.cpp
new file mode 100644
index 0000000..88e078d
--- /dev/null
+++ b/image/codecs/indeo/indeo_dsp.cpp
@@ -0,0 +1,639 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/* VLC code
+ *
+ * Original copyright note: * Intel Indeo 4 (IV41, IV42, etc.) video decoder for ffmpeg
+ * written, produced, and directed by Alan Smithee
+ */
+
+#include "image/codecs/indeo/indeo_dsp.h"
+
+namespace Image {
+namespace Indeo {
+
+/**
+ * butterfly operation for the inverse Haar transform
+ */
+#define IVI_HAAR_BFLY(s1, s2, o1, o2, t) \
+ t = ((s1) - (s2)) >> 1;\
+ o1 = ((s1) + (s2)) >> 1;\
+ o2 = (t);\
+
+/**
+ * inverse 8-point Haar transform
+ */
+#define INV_HAAR8(s1, s5, s3, s7, s2, s4, s6, s8,\
+ d1, d2, d3, d4, d5, d6, d7, d8,\
+ t0, t1, t2, t3, t4, t5, t6, t7, t8) {\
+ t1 = (s1) << 1; t5 = (s5) << 1;\
+ IVI_HAAR_BFLY(t1, t5, t1, t5, t0); IVI_HAAR_BFLY(t1, s3, t1, t3, t0);\
+ IVI_HAAR_BFLY(t5, s7, t5, t7, t0); IVI_HAAR_BFLY(t1, s2, t1, t2, t0);\
+ IVI_HAAR_BFLY(t3, s4, t3, t4, t0); IVI_HAAR_BFLY(t5, s6, t5, t6, t0);\
+ IVI_HAAR_BFLY(t7, s8, t7, t8, t0);\
+ d1 = COMPENSATE(t1);\
+ d2 = COMPENSATE(t2);\
+ d3 = COMPENSATE(t3);\
+ d4 = COMPENSATE(t4);\
+ d5 = COMPENSATE(t5);\
+ d6 = COMPENSATE(t6);\
+ d7 = COMPENSATE(t7);\
+ d8 = COMPENSATE(t8); }
+
+/**
+ * inverse 4-point Haar transform
+ */
+#define INV_HAAR4(s1, s3, s5, s7, d1, d2, d3, d4, t0, t1, t2, t3, t4) {\
+ IVI_HAAR_BFLY(s1, s3, t0, t1, t4);\
+ IVI_HAAR_BFLY(t0, s5, t2, t3, t4);\
+ d1 = COMPENSATE(t2);\
+ d2 = COMPENSATE(t3);\
+ IVI_HAAR_BFLY(t1, s7, t2, t3, t4);\
+ d3 = COMPENSATE(t2);\
+ d4 = COMPENSATE(t3); }
+
+void IndeoDSP::ff_ivi_inverse_haar_8x8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags) {
+ int i, shift, sp1, sp2, sp3, sp4;
+ const int32 *src;
+ int32 *dst;
+ int tmp[64];
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+
+ // apply the InvHaar8 to all columns
+#define COMPENSATE(x) (x)
+ src = in;
+ dst = tmp;
+ for (i = 0; i < 8; i++) {
+ if (flags[i]) {
+ // pre-scaling
+ shift = !(i & 4);
+ sp1 = src[ 0] << shift;
+ sp2 = src[ 8] << shift;
+ sp3 = src[16] << shift;
+ sp4 = src[24] << shift;
+ INV_HAAR8( sp1, sp2, sp3, sp4,
+ src[32], src[40], src[48], src[56],
+ dst[ 0], dst[ 8], dst[16], dst[24],
+ dst[32], dst[40], dst[48], dst[56],
+ t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ } else
+ dst[ 0] = dst[ 8] = dst[16] = dst[24] =
+ dst[32] = dst[40] = dst[48] = dst[56] = 0;
+
+ src++;
+ dst++;
+ }
+#undef COMPENSATE
+
+ // apply the InvHaar8 to all rows
+#define COMPENSATE(x) (x)
+ src = tmp;
+ for (i = 0; i < 8; i++) {
+ if ( !src[0] && !src[1] && !src[2] && !src[3]
+ && !src[4] && !src[5] && !src[6] && !src[7]) {
+ memset(out, 0, 8 * sizeof(out[0]));
+ } else {
+ INV_HAAR8(src[0], src[1], src[2], src[3],
+ src[4], src[5], src[6], src[7],
+ out[0], out[1], out[2], out[3],
+ out[4], out[5], out[6], out[7],
+ t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ }
+ src += 8;
+ out += pitch;
+ }
+#undef COMPENSATE
+}
+
+void IndeoDSP::ff_ivi_row_haar8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags) {
+ int i;
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+
+ // apply the InvHaar8 to all rows
+#define COMPENSATE(x) (x)
+ for (i = 0; i < 8; i++) {
+ if ( !in[0] && !in[1] && !in[2] && !in[3]
+ && !in[4] && !in[5] && !in[6] && !in[7]) {
+ memset(out, 0, 8 * sizeof(out[0]));
+ } else {
+ INV_HAAR8(in[0], in[1], in[2], in[3],
+ in[4], in[5], in[6], in[7],
+ out[0], out[1], out[2], out[3],
+ out[4], out[5], out[6], out[7],
+ t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ }
+ in += 8;
+ out += pitch;
+ }
+#undef COMPENSATE
+}
+
+void IndeoDSP::ff_ivi_col_haar8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags) {
+ int i;
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+
+ // apply the InvHaar8 to all columns
+#define COMPENSATE(x) (x)
+ for (i = 0; i < 8; i++) {
+ if (flags[i]) {
+ INV_HAAR8(in[ 0], in[ 8], in[16], in[24],
+ in[32], in[40], in[48], in[56],
+ out[0 * pitch], out[1 * pitch],
+ out[2 * pitch], out[3 * pitch],
+ out[4 * pitch], out[5 * pitch],
+ out[6 * pitch], out[7 * pitch],
+ t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ } else
+ out[0 * pitch] = out[1 * pitch] =
+ out[2 * pitch] = out[3 * pitch] =
+ out[4 * pitch] = out[5 * pitch] =
+ out[6 * pitch] = out[7 * pitch] = 0;
+
+ in++;
+ out++;
+ }
+#undef COMPENSATE
+}
+
+void IndeoDSP::ff_ivi_inverse_haar_4x4(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags) {
+ int i, shift, sp1, sp2;
+ const int32 *src;
+ int32 *dst;
+ int tmp[16];
+ int t0, t1, t2, t3, t4;
+
+ // apply the InvHaar4 to all columns
+#define COMPENSATE(x) (x)
+ src = in;
+ dst = tmp;
+ for (i = 0; i < 4; i++) {
+ if (flags[i]) {
+ // pre-scaling
+ shift = !(i & 2);
+ sp1 = src[0] << shift;
+ sp2 = src[4] << shift;
+ INV_HAAR4( sp1, sp2, src[8], src[12],
+ dst[0], dst[4], dst[8], dst[12],
+ t0, t1, t2, t3, t4);
+ } else
+ dst[0] = dst[4] = dst[8] = dst[12] = 0;
+
+ src++;
+ dst++;
+ }
+#undef COMPENSATE
+
+ // apply the InvHaar8 to all rows
+#define COMPENSATE(x) (x)
+ src = tmp;
+ for (i = 0; i < 4; i++) {
+ if (!src[0] && !src[1] && !src[2] && !src[3]) {
+ memset(out, 0, 4 * sizeof(out[0]));
+ } else {
+ INV_HAAR4(src[0], src[1], src[2], src[3],
+ out[0], out[1], out[2], out[3],
+ t0, t1, t2, t3, t4);
+ }
+ src += 4;
+ out += pitch;
+ }
+#undef COMPENSATE
+}
+
+void IndeoDSP::ff_ivi_row_haar4(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags) {
+ int i;
+ int t0, t1, t2, t3, t4;
+
+ // apply the InvHaar4 to all rows
+#define COMPENSATE(x) (x)
+ for (i = 0; i < 4; i++) {
+ if (!in[0] && !in[1] && !in[2] && !in[3]) {
+ memset(out, 0, 4 * sizeof(out[0]));
+ } else {
+ INV_HAAR4(in[0], in[1], in[2], in[3],
+ out[0], out[1], out[2], out[3],
+ t0, t1, t2, t3, t4);
+ }
+ in += 4;
+ out += pitch;
+ }
+#undef COMPENSATE
+}
+
+void IndeoDSP::ff_ivi_col_haar4(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags) {
+ int i;
+ int t0, t1, t2, t3, t4;
+
+ // apply the InvHaar8 to all columns
+#define COMPENSATE(x) (x)
+ for (i = 0; i < 4; i++) {
+ if (flags[i]) {
+ INV_HAAR4(in[0], in[4], in[8], in[12],
+ out[0 * pitch], out[1 * pitch],
+ out[2 * pitch], out[3 * pitch],
+ t0, t1, t2, t3, t4);
+ } else
+ out[0 * pitch] = out[1 * pitch] =
+ out[2 * pitch] = out[3 * pitch] = 0;
+
+ in++;
+ out++;
+ }
+#undef COMPENSATE
+}
+
+void IndeoDSP::ff_ivi_dc_haar_2d(const int32 *in, int16 *out, uint32 pitch,
+ int blk_size) {
+ int x, y;
+ int16 dc_coeff;
+
+ dc_coeff = (*in + 0) >> 3;
+
+ for (y = 0; y < blk_size; out += pitch, y++) {
+ for (x = 0; x < blk_size; x++)
+ out[x] = dc_coeff;
+ }
+}
+
+//* butterfly operation for the inverse slant transform
+#define IVI_SLANT_BFLY(s1, s2, o1, o2, t) \
+ t = (s1) - (s2);\
+ o1 = (s1) + (s2);\
+ o2 = (t);\
+
+//* This is a reflection a,b = 1/2, 5/4 for the inverse slant transform
+#define IVI_IREFLECT(s1, s2, o1, o2, t) \
+ t = (((s1) + (s2)*2 + 2) >> 2) + (s1);\
+ o2 = (((s1)*2 - (s2) + 2) >> 2) - (s2);\
+ o1 = (t);\
+
+//* This is a reflection a,b = 1/2, 7/8 for the inverse slant transform
+#define IVI_SLANT_PART4(s1, s2, o1, o2, t) \
+ t = (s2) + (((s1)*4 - (s2) + 4) >> 3);\
+ o2 = (s1) + ((-(s1) - (s2)*4 + 4) >> 3);\
+ o1 = (t);\
+
+//* inverse slant8 transform
+#define IVI_INV_SLANT8(s1, s4, s8, s5, s2, s6, s3, s7,\
+ d1, d2, d3, d4, d5, d6, d7, d8,\
+ t0, t1, t2, t3, t4, t5, t6, t7, t8) {\
+ IVI_SLANT_PART4(s4, s5, t4, t5, t0);\
+\
+ IVI_SLANT_BFLY(s1, t5, t1, t5, t0); IVI_SLANT_BFLY(s2, s6, t2, t6, t0);\
+ IVI_SLANT_BFLY(s7, s3, t7, t3, t0); IVI_SLANT_BFLY(t4, s8, t4, t8, t0);\
+\
+ IVI_SLANT_BFLY(t1, t2, t1, t2, t0); IVI_IREFLECT (t4, t3, t4, t3, t0);\
+ IVI_SLANT_BFLY(t5, t6, t5, t6, t0); IVI_IREFLECT (t8, t7, t8, t7, t0);\
+ IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\
+ IVI_SLANT_BFLY(t5, t8, t5, t8, t0); IVI_SLANT_BFLY(t6, t7, t6, t7, t0);\
+ d1 = COMPENSATE(t1);\
+ d2 = COMPENSATE(t2);\
+ d3 = COMPENSATE(t3);\
+ d4 = COMPENSATE(t4);\
+ d5 = COMPENSATE(t5);\
+ d6 = COMPENSATE(t6);\
+ d7 = COMPENSATE(t7);\
+ d8 = COMPENSATE(t8);}
+
+//* inverse slant4 transform
+#define IVI_INV_SLANT4(s1, s4, s2, s3, d1, d2, d3, d4, t0, t1, t2, t3, t4) {\
+ IVI_SLANT_BFLY(s1, s2, t1, t2, t0); IVI_IREFLECT (s4, s3, t4, t3, t0);\
+\
+ IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\
+ d1 = COMPENSATE(t1);\
+ d2 = COMPENSATE(t2);\
+ d3 = COMPENSATE(t3);\
+ d4 = COMPENSATE(t4);}
+
+void IndeoDSP::ff_ivi_inverse_slant_8x8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) {
+ int i;
+ const int32 *src;
+ int32 *dst;
+ int tmp[64];
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+
+#define COMPENSATE(x) (x)
+ src = in;
+ dst = tmp;
+ for (i = 0; i < 8; i++) {
+ if (flags[i]) {
+ IVI_INV_SLANT8(src[0], src[8], src[16], src[24], src[32], src[40], src[48], src[56],
+ dst[0], dst[8], dst[16], dst[24], dst[32], dst[40], dst[48], dst[56],
+ t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ } else
+ dst[0] = dst[8] = dst[16] = dst[24] = dst[32] = dst[40] = dst[48] = dst[56] = 0;
+
+ src++;
+ dst++;
+ }
+#undef COMPENSATE
+
+#define COMPENSATE(x) (((x) + 1)>>1)
+ src = tmp;
+ for (i = 0; i < 8; i++) {
+ if (!src[0] && !src[1] && !src[2] && !src[3] && !src[4] && !src[5] && !src[6] && !src[7]) {
+ memset(out, 0, 8*sizeof(out[0]));
+ } else {
+ IVI_INV_SLANT8(src[0], src[1], src[2], src[3], src[4], src[5], src[6], src[7],
+ out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7],
+ t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ }
+ src += 8;
+ out += pitch;
+ }
+#undef COMPENSATE
+}
+
+void IndeoDSP::ff_ivi_inverse_slant_4x4(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) {
+ int i;
+ const int32 *src;
+ int32 *dst;
+ int tmp[16];
+ int t0, t1, t2, t3, t4;
+
+#define COMPENSATE(x) (x)
+ src = in;
+ dst = tmp;
+ for (i = 0; i < 4; i++) {
+ if (flags[i]) {
+ IVI_INV_SLANT4(src[0], src[4], src[8], src[12],
+ dst[0], dst[4], dst[8], dst[12],
+ t0, t1, t2, t3, t4);
+ } else
+ dst[0] = dst[4] = dst[8] = dst[12] = 0;
+
+ src++;
+ dst++;
+ }
+#undef COMPENSATE
+
+#define COMPENSATE(x) (((x) + 1)>>1)
+ src = tmp;
+ for (i = 0; i < 4; i++) {
+ if (!src[0] && !src[1] && !src[2] && !src[3]) {
+ out[0] = out[1] = out[2] = out[3] = 0;
+ } else {
+ IVI_INV_SLANT4(src[0], src[1], src[2], src[3],
+ out[0], out[1], out[2], out[3],
+ t0, t1, t2, t3, t4);
+ }
+ src += 4;
+ out += pitch;
+ }
+#undef COMPENSATE
+}
+
+void IndeoDSP::ff_ivi_dc_slant_2d(const int32 *in, int16 *out, uint32 pitch,
+ int blk_size) {
+ int x, y;
+ int16 dc_coeff;
+
+ dc_coeff = (*in + 1) >> 1;
+
+ for (y = 0; y < blk_size; out += pitch, y++) {
+ for (x = 0; x < blk_size; x++)
+ out[x] = dc_coeff;
+ }
+}
+
+void IndeoDSP::ff_ivi_row_slant8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags) {
+ int i;
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+
+#define COMPENSATE(x) (((x) + 1)>>1)
+ for (i = 0; i < 8; i++) {
+ if (!in[0] && !in[1] && !in[2] && !in[3] && !in[4] && !in[5] && !in[6] && !in[7]) {
+ memset(out, 0, 8*sizeof(out[0]));
+ } else {
+ IVI_INV_SLANT8( in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7],
+ out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7],
+ t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ }
+ in += 8;
+ out += pitch;
+ }
+#undef COMPENSATE
+}
+
+void IndeoDSP::ff_ivi_dc_row_slant(const int32 *in, int16 *out, uint32 pitch, int blk_size) {
+ int x, y;
+ int16 dc_coeff;
+
+ dc_coeff = (*in + 1) >> 1;
+
+ for (x = 0; x < blk_size; x++)
+ out[x] = dc_coeff;
+
+ out += pitch;
+
+ for (y = 1; y < blk_size; out += pitch, y++) {
+ for (x = 0; x < blk_size; x++)
+ out[x] = 0;
+ }
+}
+
+void IndeoDSP::ff_ivi_col_slant8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) {
+ int i, row2, row4, row8;
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+
+ row2 = pitch << 1;
+ row4 = pitch << 2;
+ row8 = pitch << 3;
+
+#define COMPENSATE(x) (((x) + 1)>>1)
+ for (i = 0; i < 8; i++) {
+ if (flags[i]) {
+ IVI_INV_SLANT8(in[0], in[8], in[16], in[24], in[32], in[40], in[48], in[56],
+ out[0], out[pitch], out[row2], out[row2 + pitch], out[row4],
+ out[row4 + pitch], out[row4 + row2], out[row8 - pitch],
+ t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ } else {
+ out[0] = out[pitch] = out[row2] = out[row2 + pitch] = out[row4] =
+ out[row4 + pitch] = out[row4 + row2] = out[row8 - pitch] = 0;
+ }
+
+ in++;
+ out++;
+ }
+#undef COMPENSATE
+}
+
+void IndeoDSP::ff_ivi_dc_col_slant(const int32 *in, int16 *out, uint32 pitch, int blk_size) {
+ int x, y;
+ int16 dc_coeff;
+
+ dc_coeff = (*in + 1) >> 1;
+
+ for (y = 0; y < blk_size; out += pitch, y++) {
+ out[0] = dc_coeff;
+ for (x = 1; x < blk_size; x++)
+ out[x] = 0;
+ }
+}
+
+void IndeoDSP::ff_ivi_row_slant4(const int32 *in, int16 *out,
+ uint32 pitch, const uint8 *flags) {
+ int i;
+ int t0, t1, t2, t3, t4;
+
+#define COMPENSATE(x) (((x) + 1)>>1)
+ for (i = 0; i < 4; i++) {
+ if (!in[0] && !in[1] && !in[2] && !in[3]) {
+ memset(out, 0, 4*sizeof(out[0]));
+ } else {
+ IVI_INV_SLANT4( in[0], in[1], in[2], in[3],
+ out[0], out[1], out[2], out[3],
+ t0, t1, t2, t3, t4);
+ }
+ in += 4;
+ out += pitch;
+ }
+#undef COMPENSATE
+}
+
+void IndeoDSP::ff_ivi_col_slant4(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags) {
+ int i, row2;
+ int t0, t1, t2, t3, t4;
+
+ row2 = pitch << 1;
+
+#define COMPENSATE(x) (((x) + 1)>>1)
+ for (i = 0; i < 4; i++) {
+ if (flags[i]) {
+ IVI_INV_SLANT4(in[0], in[4], in[8], in[12],
+ out[0], out[pitch], out[row2], out[row2 + pitch],
+ t0, t1, t2, t3, t4);
+ } else {
+ out[0] = out[pitch] = out[row2] = out[row2 + pitch] = 0;
+ }
+
+ in++;
+ out++;
+ }
+#undef COMPENSATE
+}
+
+void IndeoDSP::ff_ivi_put_pixels_8x8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags) {
+ int x, y;
+
+ for (y = 0; y < 8; out += pitch, in += 8, y++)
+ for (x = 0; x < 8; x++)
+ out[x] = in[x];
+}
+
+void IndeoDSP::ff_ivi_put_dc_pixel_8x8(const int32 *in, int16 *out, uint32 pitch,
+ int blk_size) {
+ int y;
+
+ out[0] = in[0];
+ memset(out + 1, 0, 7*sizeof(out[0]));
+ out += pitch;
+
+ for (y = 1; y < 8; out += pitch, y++)
+ memset(out, 0, 8*sizeof(out[0]));
+}
+
+#define IVI_MC_TEMPLATE(size, suffix, OP) \
+static void ivi_mc_ ## size ##x## size ## suffix(int16 *buf, \
+ uint32 dpitch, \
+ const int16 *ref_buf, \
+ uint32 pitch, int mc_type) \
+{ \
+ int i, j; \
+ const int16 *wptr; \
+\
+ switch (mc_type) { \
+ case 0: /* fullpel (no interpolation) */ \
+ for (i = 0; i < size; i++, buf += dpitch, ref_buf += pitch) { \
+ for (j = 0; j < size; j++) {\
+ OP(buf[j], ref_buf[j]); \
+ } \
+ } \
+ break; \
+ case 1: /* horizontal halfpel interpolation */ \
+ for (i = 0; i < size; i++, buf += dpitch, ref_buf += pitch) \
+ for (j = 0; j < size; j++) \
+ OP(buf[j], (ref_buf[j] + ref_buf[j+1]) >> 1); \
+ break; \
+ case 2: /* vertical halfpel interpolation */ \
+ wptr = ref_buf + pitch; \
+ for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, ref_buf += pitch) \
+ for (j = 0; j < size; j++) \
+ OP(buf[j], (ref_buf[j] + wptr[j]) >> 1); \
+ break; \
+ case 3: /* vertical and horizontal halfpel interpolation */ \
+ wptr = ref_buf + pitch; \
+ for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, ref_buf += pitch) \
+ for (j = 0; j < size; j++) \
+ OP(buf[j], (ref_buf[j] + ref_buf[j+1] + wptr[j] + wptr[j+1]) >> 2); \
+ break; \
+ } \
+} \
+\
+void IndeoDSP::ff_ivi_mc_ ## size ##x## size ## suffix(int16 *buf, const int16 *ref_buf, \
+ uint32 pitch, int mc_type) \
+{ \
+ ivi_mc_ ## size ##x## size ## suffix(buf, pitch, ref_buf, pitch, mc_type); \
+}
+
+#define IVI_MC_AVG_TEMPLATE(size, suffix, OP) \
+void IndeoDSP::ff_ivi_mc_avg_ ## size ##x## size ## suffix(int16 *buf, \
+ const int16 *ref_buf, \
+ const int16 *ref_buf2, \
+ uint32 pitch, \
+ int mc_type, int mc_type2) \
+{ \
+ int16 tmp[size * size]; \
+ int i, j; \
+\
+ ivi_mc_ ## size ##x## size ## _no_delta(tmp, size, ref_buf, pitch, mc_type); \
+ ivi_mc_ ## size ##x## size ## _delta(tmp, size, ref_buf2, pitch, mc_type2); \
+ for (i = 0; i < size; i++, buf += pitch) { \
+ for (j = 0; j < size; j++) {\
+ OP(buf[j], tmp[i * size + j] >> 1); \
+ } \
+ } \
+}
+
+#define OP_PUT(a, b) (a) = (b)
+#define OP_ADD(a, b) (a) += (b)
+
+IVI_MC_TEMPLATE(8, _no_delta, OP_PUT)
+IVI_MC_TEMPLATE(8, _delta, OP_ADD)
+IVI_MC_TEMPLATE(4, _no_delta, OP_PUT)
+IVI_MC_TEMPLATE(4, _delta, OP_ADD)
+IVI_MC_AVG_TEMPLATE(8, _no_delta, OP_PUT)
+IVI_MC_AVG_TEMPLATE(8, _delta, OP_ADD)
+IVI_MC_AVG_TEMPLATE(4, _no_delta, OP_PUT)
+IVI_MC_AVG_TEMPLATE(4, _delta, OP_ADD)
+
+} // End of namespace Indeo
+} // End of namespace Image
diff --git a/image/codecs/indeo/indeo_dsp.h b/image/codecs/indeo/indeo_dsp.h
new file mode 100644
index 0000000..fc50339
--- /dev/null
+++ b/image/codecs/indeo/indeo_dsp.h
@@ -0,0 +1,338 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+/* VLC code
+ *
+ * Original copyright note:
+ * DSP functions (inverse transforms, motion compensation, wavelet recompositions)
+ * for Indeo Video Interactive codecs.
+ */
+
+#ifndef IMAGE_CODECS_INDEO_INDEO_DSP_H
+#define IMAGE_CODECS_INDEO_INDEO_DSP_H
+
+#include "image/codecs/indeo/mem.h"
+#include "image/codecs/indeo/indeo.h"
+
+namespace Image {
+namespace Indeo {
+
+class IndeoDSP {
+public:
+ /**
+ * two-dimensional inverse Haar 8x8 transform for Indeo 4
+ *
+ * @param[in] in pointer to the vector of transform coefficients
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] flags pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
+ */
+ static void ff_ivi_inverse_haar_8x8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
+ static void ff_ivi_inverse_haar_8x1(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
+ static void ff_ivi_inverse_haar_1x8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
+
+ /**
+ * one-dimensional inverse 8-point Haar transform on rows for Indeo 4
+ *
+ * @param[in] in pointer to the vector of transform coefficients
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] flags pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
+ */
+ static void ff_ivi_row_haar8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
+
+ /**
+ * one-dimensional inverse 8-point Haar transform on columns for Indeo 4
+ *
+ * @param[in] in pointer to the vector of transform coefficients
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] flags pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
+ */
+ static void ff_ivi_col_haar8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
+
+ /**
+ * two-dimensional inverse Haar 4x4 transform for Indeo 4
+ *
+ * @param[in] in pointer to the vector of transform coefficients
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] flags pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
+ */
+ static void ff_ivi_inverse_haar_4x4(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
+
+ /**
+ * one-dimensional inverse 4-point Haar transform on rows for Indeo 4
+ *
+ * @param[in] in pointer to the vector of transform coefficients
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] flags pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
+ */
+ static void ff_ivi_row_haar4(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
+
+ /**
+ * one-dimensional inverse 4-point Haar transform on columns for Indeo 4
+ *
+ * @param[in] in pointer to the vector of transform coefficients
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] flags pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
+ */
+ static void ff_ivi_col_haar4(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
+
+ /**
+ * DC-only two-dimensional inverse Haar transform for Indeo 4.
+ * Performing the inverse transform in this case is equivalent to
+ * spreading DC_coeff >> 3 over the whole block.
+ *
+ * @param[in] in pointer to the dc coefficient
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] blk_size transform block size
+ */
+ static void ff_ivi_dc_haar_2d(const int32 *in, int16 *out, uint32 pitch,
+ int blk_size);
+
+ /**
+ * two-dimensional inverse slant 8x8 transform
+ *
+ * @param[in] in pointer to the vector of transform coefficients
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] flags pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
+ */
+ static void ff_ivi_inverse_slant_8x8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
+
+ /**
+ * two-dimensional inverse slant 4x4 transform
+ *
+ * @param[in] in pointer to the vector of transform coefficients
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] flags pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
+ */
+ static void ff_ivi_inverse_slant_4x4(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
+
+ /**
+ * DC-only two-dimensional inverse slant transform.
+ * Performing the inverse slant transform in this case is equivalent to
+ * spreading (DC_coeff + 1)/2 over the whole block.
+ * It works much faster than performing the slant transform on a vector of zeroes.
+ *
+ * @param[in] in pointer to the dc coefficient
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] blk_size transform block size
+ */
+ static void ff_ivi_dc_slant_2d(const int32 *in, int16 *out, uint32 pitch, int blk_size);
+
+ /**
+ * inverse 1D row slant transform
+ *
+ * @param[in] in pointer to the vector of transform coefficients
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] flags pointer to the array of column flags (unused here)
+ */
+ static void ff_ivi_row_slant8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
+
+ /**
+ * inverse 1D column slant transform
+ *
+ * @param[in] in pointer to the vector of transform coefficients
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] flags pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
+ */
+ static void ff_ivi_col_slant8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
+
+ /**
+ * inverse 1D row slant transform
+ *
+ * @param[in] in pointer to the vector of transform coefficients
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] flags pointer to the array of column flags (unused here)
+ */
+ static void ff_ivi_row_slant4(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
+
+ /**
+ * inverse 1D column slant transform
+ *
+ * @param[in] in pointer to the vector of transform coefficients
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] flags pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
+ */
+ static void ff_ivi_col_slant4(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
+
+ /**
+ * DC-only inverse row slant transform
+ */
+ static void ff_ivi_dc_row_slant(const int32 *in, int16 *out, uint32 pitch, int blk_size);
+
+ /**
+ * DC-only inverse column slant transform
+ */
+ static void ff_ivi_dc_col_slant(const int32 *in, int16 *out, uint32 pitch, int blk_size);
+
+ /**
+ * Copy the pixels into the frame buffer.
+ */
+ static void ff_ivi_put_pixels_8x8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags);
+
+ /**
+ * Copy the DC coefficient into the first pixel of the block and
+ * zero all others.
+ */
+ static void ff_ivi_put_dc_pixel_8x8(const int32 *in, int16 *out, uint32 pitch, int blk_size);
+
+ /**
+ * 8x8 block motion compensation with adding delta
+ *
+ * @param[in,out] buf pointer to the block in the current frame buffer containing delta
+ * @param[in] ref_buf pointer to the corresponding block in the reference frame
+ * @param[in] pitch pitch for moving to the next y line
+ * @param[in] mc_type interpolation type
+ */
+ static void ff_ivi_mc_8x8_delta(int16 *buf, const int16 *ref_buf, uint32 pitch, int mc_type);
+
+ /**
+ * 4x4 block motion compensation with adding delta
+ *
+ * @param[in,out] buf pointer to the block in the current frame buffer containing delta
+ * @param[in] ref_buf pointer to the corresponding block in the reference frame
+ * @param[in] pitch pitch for moving to the next y line
+ * @param[in] mc_type interpolation type
+ */
+ static void ff_ivi_mc_4x4_delta(int16 *buf, const int16 *ref_buf, uint32 pitch, int mc_type);
+
+ /**
+ * motion compensation without adding delta
+ *
+ * @param[in,out] buf pointer to the block in the current frame receiving the result
+ * @param[in] ref_buf pointer to the corresponding block in the reference frame
+ * @param[in] pitch pitch for moving to the next y line
+ * @param[in] mc_type interpolation type
+ */
+ static void ff_ivi_mc_8x8_no_delta(int16 *buf, const int16 *ref_buf, uint32 pitch, int mc_type);
+
+ /**
+ * 4x4 block motion compensation without adding delta
+ *
+ * @param[in,out] buf pointer to the block in the current frame receiving the result
+ * @param[in] ref_buf pointer to the corresponding block in the reference frame
+ * @param[in] pitch pitch for moving to the next y line
+ * @param[in] mc_type interpolation type
+ */
+ static void ff_ivi_mc_4x4_no_delta(int16 *buf, const int16 *ref_buf, uint32 pitch, int mc_type);
+
+ /**
+ * 8x8 block motion compensation with adding delta
+ *
+ * @param[in,out] buf pointer to the block in the current frame buffer containing delta
+ * @param[in] ref_buf pointer to the corresponding block in the backward reference frame
+ * @param[in] ref_buf2 pointer to the corresponding block in the forward reference frame
+ * @param[in] pitch pitch for moving to the next y line
+ * @param[in] mc_type interpolation type for backward reference
+ * @param[in] mc_type2 interpolation type for forward reference
+ */
+ static void ff_ivi_mc_avg_8x8_delta(int16 *buf, const int16 *ref_buf, const int16 *ref_buf2, uint32 pitch, int mc_type, int mc_type2);
+
+ /**
+ * 4x4 block motion compensation with adding delta
+ *
+ * @param[in,out] buf pointer to the block in the current frame buffer containing delta
+ * @param[in] ref_buf pointer to the corresponding block in the backward reference frame
+ * @param[in] ref_buf2 pointer to the corresponding block in the forward reference frame
+ * @param[in] pitch pitch for moving to the next y line
+ * @param[in] mc_type interpolation type for backward reference
+ * @param[in] mc_type2 interpolation type for forward reference
+ */
+ static void ff_ivi_mc_avg_4x4_delta(int16 *buf, const int16 *ref_buf, const int16 *ref_buf2, uint32 pitch, int mc_type, int mc_type2);
+
+ /**
+ * motion compensation without adding delta for B-frames
+ *
+ * @param[in,out] buf pointer to the block in the current frame receiving the result
+ * @param[in] ref_buf pointer to the corresponding block in the backward reference frame
+ * @param[in] ref_buf2 pointer to the corresponding block in the forward reference frame
+ * @param[in] pitch pitch for moving to the next y line
+ * @param[in] mc_type interpolation type for backward reference
+ * @param[in] mc_type2 interpolation type for forward reference
+ */
+ static void ff_ivi_mc_avg_8x8_no_delta(int16 *buf, const int16 *ref_buf, const int16 *ref_buf2, uint32 pitch, int mc_type, int mc_type2);
+
+ /**
+ * 4x4 block motion compensation without adding delta for B-frames
+ *
+ * @param[in,out] buf pointer to the block in the current frame receiving the result
+ * @param[in] ref_buf pointer to the corresponding block in the backward reference frame
+ * @param[in] ref_buf2 pointer to the corresponding block in the forward reference frame
+ * @param[in] pitch pitch for moving to the next y line
+ * @param[in] mc_type interpolation type for backward reference
+ * @param[in] mc_type2 interpolation type for forward reference
+ */
+ static void ff_ivi_mc_avg_4x4_no_delta(int16 *buf, const int16 *ref_buf, const int16 *ref_buf2, uint32 pitch, int mc_type, int mc_type2);
+};
+
+} // End of namespace Indeo
+} // End of namespace Image
+
+#endif
diff --git a/image/codecs/indeo/mem.cpp b/image/codecs/indeo/mem.cpp
index 03a39ca..53a3236 100644
--- a/image/codecs/indeo/mem.cpp
+++ b/image/codecs/indeo/mem.cpp
@@ -153,5 +153,29 @@ uint16 inv_bits(uint16 val, int nbits) {
return res;
}
+uint8 av_clip_uint8(int a) {
+ if (a&(~0xFF)) return (-a) >> 31;
+ else return a;
+}
+
+unsigned av_clip_uintp2(int a, int p) {
+ if (a & ~((1 << p) - 1)) return -a >> 31 & ((1 << p) - 1);
+ else return a;
+}
+
+
+/*------------------------------------------------------------------------*/
+
+const uint8 ff_zigzag_direct[64] = {
+ 0, 1, 8, 16, 9, 2, 3, 10,
+ 17, 24, 32, 25, 18, 11, 4, 5,
+ 12, 19, 26, 33, 40, 48, 41, 34,
+ 27, 20, 13, 6, 7, 14, 21, 28,
+ 35, 42, 49, 56, 57, 50, 43, 36,
+ 29, 22, 15, 23, 30, 37, 44, 51,
+ 58, 59, 52, 45, 38, 31, 39, 46,
+ 53, 60, 61, 54, 47, 55, 62, 63
+};
+
} // End of namespace Indeo
} // End of namespace Image
diff --git a/image/codecs/indeo/mem.h b/image/codecs/indeo/mem.h
index 4f9ebf0..d3755d6 100644
--- a/image/codecs/indeo/mem.h
+++ b/image/codecs/indeo/mem.h
@@ -37,6 +37,7 @@ 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)
/**
* Allocate a memory block with alignment suitable for all memory accesses
@@ -139,6 +140,34 @@ extern uint16 inv_bits(uint16 val, int nbits);
*/
extern uint32 bitswap_32(uint32 x);
+/**
+ * Clip a signed integer value into the 0-255 range.
+ * @param a value to clip
+ * @return clipped value
+ */
+extern uint8 av_clip_uint8(int a);
+
+/**
+ * Clip a signed integer to an unsigned power of two range.
+ * @param a value to clip
+ * @param p bit position to clip at
+ * @return clipped value
+ */
+extern unsigned av_clip_uintp2(int a, int p);
+
+/**
+* Clip a signed integer value into the amin-amax range.
+* @param a value to clip
+* @param amin minimum value of the clip range
+* @param amax maximum value of the clip range
+* @return clipped value
+*/
+#define av_clip CLIP
+
+/*------------------------------------------------------------------------*/
+
+extern const uint8 ff_zigzag_direct[64];
+
} // End of namespace Indeo
} // End of namespace Image
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index 29616e9..af521b3 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -34,6 +34,7 @@
#include "common/util.h"
#include "graphics/yuv_to_rgb.h"
#include "image/codecs/indeo4.h"
+#include "image/codecs/indeo/mem.h"
namespace Image {
@@ -223,6 +224,373 @@ int Indeo4Decoder::decodePictureHeader() {
return 0;
}
+void Indeo4Decoder::switch_buffers() {
+ int is_prev_ref = 0, is_ref = 0;
+
+ switch (_ctx.prev_frame_type) {
+ case IVI4_FRAMETYPE_INTRA:
+ case IVI4_FRAMETYPE_INTRA1:
+ case IVI4_FRAMETYPE_INTER:
+ is_prev_ref = 1;
+ break;
+ }
+
+ switch (_ctx.frame_type) {
+ case IVI4_FRAMETYPE_INTRA:
+ case IVI4_FRAMETYPE_INTRA1:
+ case IVI4_FRAMETYPE_INTER:
+ is_ref = 1;
+ break;
+
+ default:
+ break;
+ }
+
+ if (is_prev_ref && is_ref) {
+ FFSWAP(int, _ctx.dst_buf, _ctx.ref_buf);
+ }
+ else if (is_prev_ref) {
+ FFSWAP(int, _ctx.ref_buf, _ctx.b_ref_buf);
+ FFSWAP(int, _ctx.dst_buf, _ctx.ref_buf);
+ }
+}
+
+bool Indeo4Decoder::is_nonnull_frame() const {
+ return _ctx.frame_type < IVI4_FRAMETYPE_NULL_FIRST;
+}
+
+int Indeo4Decoder::decode_band_hdr(IVIBandDesc *band) {
+ int plane, band_num, indx, transform_id, scan_indx;
+ int i;
+ int quant_mat;
+
+ plane = _ctx.gb->getBits(2);
+ band_num = _ctx.gb->getBits(4);
+ if (band->plane != plane || band->band_num != band_num) {
+ warning("Invalid band header sequence!");
+ return -1;
+ }
+
+ band->is_empty = _ctx.gb->getBits1();
+ if (!band->is_empty) {
+ int old_blk_size = band->blk_size;
+ // skip header size
+ // If header size is not given, header size is 4 bytes.
+ if (_ctx.gb->getBits1())
+ _ctx.gb->skipBits(16);
+
+ band->is_halfpel = _ctx.gb->getBits(2);
+ if (band->is_halfpel >= 2) {
+ warning("Invalid/unsupported mv resolution: %d!",
+ band->is_halfpel);
+ return -1;
+ }
+ if (!band->is_halfpel)
+ _ctx.uses_fullpel = 1;
+
+ band->checksum_present = _ctx.gb->getBits1();
+ if (band->checksum_present)
+ band->checksum = _ctx.gb->getBits(16);
+
+ indx = _ctx.gb->getBits(2);
+ if (indx == 3) {
+ warning("Invalid block size!");
+ return -1;
+ }
+ band->mb_size = 16 >> indx;
+ band->blk_size = 8 >> (indx >> 1);
+
+ band->inherit_mv = _ctx.gb->getBits1();
+ band->inherit_qdelta = _ctx.gb->getBits1();
+
+ band->glob_quant = _ctx.gb->getBits(5);
+
+ if (!_ctx.gb->getBits1() || _ctx.frame_type == IVI4_FRAMETYPE_INTRA) {
+ transform_id = _ctx.gb->getBits(5);
+ if (transform_id >= FF_ARRAY_ELEMS(_transforms) ||
+ !_transforms[transform_id].inv_trans) {
+ warning("Transform %d", transform_id);
+ return -3;
+ }
+ if ((transform_id >= 7 && transform_id <= 9) ||
+ transform_id == 17) {
+ warning("DCT transform");
+ return -3;
+ }
+
+ if (transform_id < 10 && band->blk_size < 8) {
+ warning("wrong transform size!");
+ return -1;
+ }
+ if ((transform_id >= 0 && transform_id <= 2) || transform_id == 10)
+ _ctx.uses_haar = 1;
+
+ band->inv_transform = _transforms[transform_id].inv_trans;
+ band->dc_transform = _transforms[transform_id].dc_trans;
+ band->is_2d_trans = _transforms[transform_id].is_2d_trans;
+
+ if (transform_id < 10)
+ band->transform_size = 8;
+ else
+ band->transform_size = 4;
+
+ if (band->blk_size != band->transform_size) {
+ warning("transform and block size mismatch (%d != %d)", band->transform_size, band->blk_size);
+ return -1;
+ }
+
+ scan_indx = _ctx.gb->getBits(4);
+ if (scan_indx == 15) {
+ warning("Custom scan pattern encountered!");
+ return -1;
+ }
+ if (scan_indx > 4 && scan_indx < 10) {
+ if (band->blk_size != 4) {
+ warning("mismatching scan table!");
+ return -1;
+ }
+ } else if (band->blk_size != 8) {
+ warning("mismatching scan table!");
+ return -1;
+ }
+
+ band->scan = _scan_index_to_tab[scan_indx];
+ band->scan_size = band->blk_size;
+
+ quant_mat = _ctx.gb->getBits(5);
+ if (quant_mat == 31) {
+ warning("Custom quant matrix encountered!");
+ return -1;
+ }
+ if (quant_mat >= FF_ARRAY_ELEMS(_quant_index_to_tab)) {
+ warning("Quantization matrix %d", quant_mat);
+ return -1;
+ }
+ band->quant_mat = quant_mat;
+ } else {
+ if (old_blk_size != band->blk_size) {
+ warning("The band block size does not match the configuration inherited");
+ return -1;
+ }
+ }
+ if (_quant_index_to_tab[band->quant_mat] > 4 && band->blk_size == 4) {
+ warning("Invalid quant matrix for 4x4 block encountered!");
+ band->quant_mat = 0;
+ return -1;
+ }
+ if (band->scan_size != band->blk_size) {
+ warning("mismatching scan table!");
+ return -1;
+ }
+ if (band->transform_size == 8 && band->blk_size < 8) {
+ warning("mismatching transform_size!");
+ return -1;
+ }
+
+ // decode block huffman codebook
+ 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))
+ return -1;
+
+ // select appropriate rvmap table for this band
+ band->rvmap_sel = _ctx.gb->getBits1() ? _ctx.gb->getBits(3) : 8;
+
+ // decode rvmap probability corrections if any
+ band->num_corr = 0; // there is no corrections
+ if (_ctx.gb->getBits1()) {
+ band->num_corr = _ctx.gb->getBits(8); // get number of correction pairs
+ if (band->num_corr > 61) {
+ warning("Too many corrections: %d",
+ band->num_corr);
+ return -1;
+ }
+
+ // read correction pairs
+ for (i = 0; i < band->num_corr * 2; i++)
+ band->corr[i] = _ctx.gb->getBits(8);
+ }
+ }
+
+ if (band->blk_size == 8) {
+ band->intra_base = &_ivi4_quant_8x8_intra[_quant_index_to_tab[band->quant_mat]][0];
+ band->inter_base = &_ivi4_quant_8x8_inter[_quant_index_to_tab[band->quant_mat]][0];
+ } else {
+ band->intra_base = &_ivi4_quant_4x4_intra[_quant_index_to_tab[band->quant_mat]][0];
+ band->inter_base = &_ivi4_quant_4x4_inter[_quant_index_to_tab[band->quant_mat]][0];
+ }
+
+ // Indeo 4 doesn't use scale tables
+ band->intra_scale = NULL;
+ band->inter_scale = NULL;
+
+ _ctx.gb->alignGetBits();
+
+ if (!band->scan) {
+ warning("band->scan not set");
+ return -1;
+ }
+
+ return 0;
+}
+
+int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
+ int x, y, mv_x, mv_y, mv_delta, offs, mb_offset, blks_per_mb,
+ mv_scale, mb_type_bits, s;
+ IVIMbInfo *mb, *ref_mb;
+ int row_offset = band->mb_size * band->pitch;
+
+ mb = tile->mbs;
+ ref_mb = tile->ref_mbs;
+ offs = tile->ypos * band->pitch + tile->xpos;
+
+ blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
+ mb_type_bits = _ctx.frame_type == IVI4_FRAMETYPE_BIDIR ? 2 : 1;
+
+ /* scale factor for motion vectors */
+ mv_scale = (_ctx.planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
+ mv_x = mv_y = 0;
+
+ if (((tile->width + band->mb_size - 1) / band->mb_size) * ((tile->height + band->mb_size - 1) / band->mb_size) != tile->num_MBs) {
+ warning("num_MBs mismatch %d %d %d %d", tile->width, tile->height, band->mb_size, tile->num_MBs);
+ return -1;
+ }
+
+ for (y = tile->ypos; y < tile->ypos + tile->height; y += band->mb_size) {
+ mb_offset = offs;
+
+ for (x = tile->xpos; x < tile->xpos + tile->width; x += band->mb_size) {
+ mb->xpos = x;
+ mb->ypos = y;
+ mb->buf_offs = mb_offset;
+ mb->b_mv_x =
+ mb->b_mv_y = 0;
+
+ if (_ctx.gb->getBits1()) {
+ if (_ctx.frame_type == IVI4_FRAMETYPE_INTRA) {
+ warning("Empty macroblock in an INTRA picture!");
+ return -1;
+ }
+ mb->type = 1; // empty macroblocks are always INTER
+ mb->cbp = 0; // all blocks are empty
+
+ mb->q_delta = 0;
+ if (!band->plane && !band->band_num && _ctx.in_q) {
+ mb->q_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->table,
+ IVI_VLC_BITS, 1);
+ mb->q_delta = IVI_TOSIGNED(mb->q_delta);
+ }
+
+ mb->mv_x = mb->mv_y = 0; /* no motion vector coded */
+ if (band->inherit_mv && ref_mb) {
+ /* motion vector inheritance */
+ if (mv_scale) {
+ mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
+ mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
+ }
+ else {
+ mb->mv_x = ref_mb->mv_x;
+ mb->mv_y = ref_mb->mv_y;
+ }
+ }
+ } else {
+ if (band->inherit_mv) {
+ /* copy mb_type from corresponding reference mb */
+ if (!ref_mb) {
+ warning("ref_mb unavailable");
+ return -1;
+ }
+ mb->type = ref_mb->type;
+ }
+ else if (_ctx.frame_type == IVI4_FRAMETYPE_INTRA ||
+ _ctx.frame_type == IVI4_FRAMETYPE_INTRA1) {
+ mb->type = 0; /* mb_type is always INTRA for intra-frames */
+ } else {
+ mb->type = _ctx.gb->getBits(mb_type_bits);
+ }
+
+ mb->cbp = _ctx.gb->getBits(blks_per_mb);
+
+ mb->q_delta = 0;
+ if (band->inherit_qdelta) {
+ if (ref_mb) mb->q_delta = ref_mb->q_delta;
+ }
+ else if (mb->cbp || (!band->plane && !band->band_num &&
+ _ctx.in_q)) {
+ mb->q_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->table,
+ IVI_VLC_BITS, 1);
+ mb->q_delta = IVI_TOSIGNED(mb->q_delta);
+ }
+
+ if (!mb->type) {
+ mb->mv_x = mb->mv_y = 0; /* there is no motion vector in intra-macroblocks */
+ } else {
+ if (band->inherit_mv) {
+ if (ref_mb)
+ /* motion vector inheritance */
+ if (mv_scale) {
+ mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
+ mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
+ }
+ else {
+ mb->mv_x = ref_mb->mv_x;
+ mb->mv_y = ref_mb->mv_y;
+ }
+ } else {
+ /* decode motion vector deltas */
+ mv_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->table,
+ IVI_VLC_BITS, 1);
+ mv_y += IVI_TOSIGNED(mv_delta);
+ mv_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->table,
+ IVI_VLC_BITS, 1);
+ mv_x += IVI_TOSIGNED(mv_delta);
+ mb->mv_x = mv_x;
+ mb->mv_y = mv_y;
+ if (mb->type == 3) {
+ mv_delta = _ctx.gb->getVLC2(
+ _ctx.mb_vlc.tab->table,
+ IVI_VLC_BITS, 1);
+ mv_y += IVI_TOSIGNED(mv_delta);
+ mv_delta = _ctx.gb->getVLC2(
+ _ctx.mb_vlc.tab->table,
+ IVI_VLC_BITS, 1);
+ mv_x += IVI_TOSIGNED(mv_delta);
+ mb->b_mv_x = -mv_x;
+ mb->b_mv_y = -mv_y;
+ }
+ }
+ if (mb->type == 2) {
+ mb->b_mv_x = -mb->mv_x;
+ mb->b_mv_y = -mb->mv_y;
+ mb->mv_x = 0;
+ mb->mv_y = 0;
+ }
+ }
+ }
+
+ s = band->is_halfpel;
+ if (mb->type)
+ if (x + (mb->mv_x >> s) + (y + (mb->mv_y >> s))*band->pitch < 0 ||
+ x + ((mb->mv_x + s) >> s) + band->mb_size - 1
+ + (y + band->mb_size - 1 + ((mb->mv_y + s) >> s))*band->pitch > band->bufsize - 1) {
+ warning("motion vector %d %d outside reference", x*s + mb->mv_x, y*s + mb->mv_y);
+ return -1;
+ }
+
+ mb++;
+ if (ref_mb)
+ ref_mb++;
+ mb_offset += band->mb_size;
+ }
+
+ offs += row_offset;
+ }
+
+ _ctx.gb->alignGetBits();
+ return 0;
+}
+
int Indeo4Decoder::scaleTileSize(int def_size, int size_factor) {
return size_factor == 15 ? def_size : (size_factor + 1) << 5;
}
@@ -245,8 +613,334 @@ int Indeo4Decoder::decodePlaneSubdivision() {
/*------------------------------------------------------------------------*/
+/**
+ * Indeo 4 8x8 scan (zigzag) patterns
+ */
+static const uint8 ivi4_alternate_scan_8x8[64] = {
+ 0, 8, 1, 9, 16, 24, 2, 3, 17, 25, 10, 11, 32, 40, 48, 56,
+ 4, 5, 6, 7, 33, 41, 49, 57, 18, 19, 26, 27, 12, 13, 14, 15,
+ 34, 35, 43, 42, 50, 51, 59, 58, 20, 21, 22, 23, 31, 30, 29, 28,
+ 36, 37, 38, 39, 47, 46, 45, 44, 52, 53, 54, 55, 63, 62, 61, 60
+};
+
+static const uint8 ivi4_alternate_scan_4x4[16] = {
+ 0, 1, 4, 5, 8, 12, 2, 3, 9, 13, 6, 7, 10, 11, 14, 15
+};
+
+static const uint8 ivi4_vertical_scan_4x4[16] = {
+ 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15
+};
+
+static const uint8 ivi4_horizontal_scan_4x4[16] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
+};
+
const uint Indeo4Decoder::_ivi4_common_pic_sizes[14] = {
640, 480, 320, 240, 160, 120, 704, 480, 352, 240, 352, 288, 176, 144
};
+Indeo4Decoder::Transform Indeo4Decoder::_transforms[18] = {
+ { IndeoDSP::ff_ivi_inverse_haar_8x8, IndeoDSP::ff_ivi_dc_haar_2d, 1 },
+ { IndeoDSP::ff_ivi_row_haar8, IndeoDSP::ff_ivi_dc_haar_2d, 0 },
+ { IndeoDSP::ff_ivi_col_haar8, IndeoDSP::ff_ivi_dc_haar_2d, 0 },
+ { IndeoDSP::ff_ivi_put_pixels_8x8, IndeoDSP::ff_ivi_put_dc_pixel_8x8, 1 },
+ { IndeoDSP::ff_ivi_inverse_slant_8x8, IndeoDSP::ff_ivi_dc_slant_2d, 1 },
+ { IndeoDSP::ff_ivi_row_slant8, IndeoDSP::ff_ivi_dc_row_slant, 1 },
+ { IndeoDSP::ff_ivi_col_slant8, IndeoDSP::ff_ivi_dc_col_slant, 1 },
+ { NULL, NULL, 0 }, // inverse DCT 8x8
+ { NULL, NULL, 0 }, // inverse DCT 8x1
+ { NULL, NULL, 0 }, // inverse DCT 1x8
+ { IndeoDSP::ff_ivi_inverse_haar_4x4, IndeoDSP::ff_ivi_dc_haar_2d, 1 },
+ { IndeoDSP::ff_ivi_inverse_slant_4x4, IndeoDSP::ff_ivi_dc_slant_2d, 1 },
+ { NULL, NULL, 0 }, // no transform 4x4
+ { IndeoDSP::ff_ivi_row_haar4, IndeoDSP::ff_ivi_dc_haar_2d, 0 },
+ { IndeoDSP::ff_ivi_col_haar4, IndeoDSP::ff_ivi_dc_haar_2d, 0 },
+ { IndeoDSP::ff_ivi_row_slant4, IndeoDSP::ff_ivi_dc_row_slant, 0 },
+ { IndeoDSP::ff_ivi_col_slant4, IndeoDSP::ff_ivi_dc_col_slant, 0 },
+ { NULL, NULL, 0 }, // inverse DCT 4x4
+};
+
+const uint8 *const Indeo4Decoder::_scan_index_to_tab[15] = {
+ // for 8x8 transforms
+ ff_zigzag_direct,
+ ivi4_alternate_scan_8x8,
+ _ff_ivi_horizontal_scan_8x8,
+ _ff_ivi_vertical_scan_8x8,
+ ff_zigzag_direct,
+
+ // for 4x4 transforms
+ _ff_ivi_direct_scan_4x4,
+ ivi4_alternate_scan_4x4,
+ ivi4_vertical_scan_4x4,
+ ivi4_horizontal_scan_4x4,
+ _ff_ivi_direct_scan_4x4,
+
+ // TODO: check if those are needed
+ _ff_ivi_horizontal_scan_8x8,
+ _ff_ivi_horizontal_scan_8x8,
+ _ff_ivi_horizontal_scan_8x8,
+ _ff_ivi_horizontal_scan_8x8,
+ _ff_ivi_horizontal_scan_8x8
+};
+
+/**
+ * Indeo 4 dequant tables
+ */
+const uint16 Indeo4Decoder::_ivi4_quant_8x8_intra[9][64] = {
+ {
+ 43, 342, 385, 470, 555, 555, 598, 726,
+ 342, 342, 470, 513, 555, 598, 726, 769,
+ 385, 470, 555, 555, 598, 726, 726, 811,
+ 470, 470, 555, 555, 598, 726, 769, 854,
+ 470, 555, 555, 598, 683, 726, 854, 1025,
+ 555, 555, 598, 683, 726, 854, 1025, 1153,
+ 555, 555, 598, 726, 811, 982, 1195, 1451,
+ 555, 598, 726, 811, 982, 1195, 1451, 1793
+ },
+ {
+ 86, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
+ 1195, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
+ 2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
+ 2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
+ 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
+ 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
+ 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
+ 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827
+ },
+ {
+ 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
+ 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
+ 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
+ 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
+ 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
+ 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
+ 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
+ 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835
+ },
+ {
+ 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
+ 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
+ 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
+ 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
+ 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
+ 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
+ 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
+ 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414
+ },
+ {
+ 897, 897, 897, 897, 897, 897, 897, 897,
+ 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067,
+ 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
+ 1409, 1409, 1409, 1409, 1409, 1409, 1409, 1409,
+ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579,
+ 1750, 1750, 1750, 1750, 1750, 1750, 1750, 1750,
+ 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921,
+ 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091
+ },
+ {
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
+ 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
+ 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
+ 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
+ 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
+ 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414
+ },
+ {
+ 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
+ 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
+ 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
+ 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
+ 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
+ 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
+ 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
+ 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390
+ },
+ {
+ 22, 171, 214, 257, 257, 299, 299, 342,
+ 171, 171, 257, 257, 299, 299, 342, 385,
+ 214, 257, 257, 299, 299, 342, 342, 385,
+ 257, 257, 257, 299, 299, 342, 385, 427,
+ 257, 257, 299, 299, 342, 385, 427, 513,
+ 257, 299, 299, 342, 385, 427, 513, 598,
+ 299, 299, 299, 385, 385, 470, 598, 726,
+ 299, 299, 385, 385, 470, 598, 726, 897
+ },
+ {
+ 86, 598, 1195, 1195, 2390, 2390, 2390, 2390,
+ 598, 598, 1195, 1195, 2390, 2390, 2390, 2390,
+ 1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
+ 1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
+ 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
+ 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
+ 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
+ 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414
+ }
+};
+
+const uint16 Indeo4Decoder::_ivi4_quant_8x8_inter[9][64] = {
+ {
+ 427, 427, 470, 427, 427, 427, 470, 470,
+ 427, 427, 470, 427, 427, 427, 470, 470,
+ 470, 470, 470, 470, 470, 470, 470, 470,
+ 427, 427, 470, 470, 427, 427, 470, 470,
+ 427, 427, 470, 427, 427, 427, 470, 470,
+ 427, 427, 470, 427, 427, 427, 470, 470,
+ 470, 470, 470, 470, 470, 470, 470, 470,
+ 470, 470, 470, 470, 470, 470, 470, 470
+ },
+ {
+ 1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
+ 1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
+ 2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
+ 2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
+ 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
+ 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
+ 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
+ 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414
+ },
+ {
+ 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
+ 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
+ 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
+ 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
+ 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
+ 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
+ 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
+ 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281
+ },
+ {
+ 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
+ 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
+ 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
+ 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
+ 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
+ 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
+ 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
+ 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433
+ },
+ {
+ 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
+ 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
+ 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
+ 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
+ 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
+ 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
+ 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
+ 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281
+ },
+ {
+ 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
+ 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
+ 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
+ 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
+ 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
+ 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
+ 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
+ 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433
+ },
+ {
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707
+ },
+ {
+ 86, 171, 171, 214, 214, 214, 214, 257,
+ 171, 171, 214, 214, 214, 214, 257, 257,
+ 171, 214, 214, 214, 214, 257, 257, 257,
+ 214, 214, 214, 214, 257, 257, 257, 299,
+ 214, 214, 214, 257, 257, 257, 299, 299,
+ 214, 214, 257, 257, 257, 299, 299, 299,
+ 214, 257, 257, 257, 299, 299, 299, 342,
+ 257, 257, 257, 299, 299, 299, 342, 342
+ },
+ {
+ 854, 854, 1195, 1195, 1707, 1707, 1707, 1707,
+ 854, 854, 1195, 1195, 1707, 1707, 1707, 1707,
+ 1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
+ 1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
+ 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
+ 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
+ 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
+ 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707
+ }
+};
+
+const uint16 Indeo4Decoder::_ivi4_quant_4x4_intra[5][16] = {
+ {
+ 22, 214, 257, 299,
+ 214, 257, 299, 342,
+ 257, 299, 342, 427,
+ 299, 342, 427, 513
+ },
+ {
+ 129, 1025, 1451, 1451,
+ 1025, 1025, 1451, 1451,
+ 1451, 1451, 2049, 2049,
+ 1451, 1451, 2049, 2049
+ },
+ {
+ 43, 171, 171, 171,
+ 43, 171, 171, 171,
+ 43, 171, 171, 171,
+ 43, 171, 171, 171
+ },
+ {
+ 43, 43, 43, 43,
+ 171, 171, 171, 171,
+ 171, 171, 171, 171,
+ 171, 171, 171, 171
+ },
+ {
+ 43, 43, 43, 43,
+ 43, 43, 43, 43,
+ 43, 43, 43, 43,
+ 43, 43, 43, 43
+ }
+};
+
+const uint16 Indeo4Decoder::_ivi4_quant_4x4_inter[5][16] = {
+ {
+ 107, 214, 257, 299,
+ 214, 257, 299, 299,
+ 257, 299, 299, 342,
+ 299, 299, 342, 342
+ },
+ {
+ 513, 1025, 1238, 1238,
+ 1025, 1025, 1238, 1238,
+ 1238, 1238, 1451, 1451,
+ 1238, 1238, 1451, 1451
+ },
+ {
+ 43, 171, 171, 171,
+ 43, 171, 171, 171,
+ 43, 171, 171, 171,
+ 43, 171, 171, 171
+ },
+ {
+ 43, 43, 43, 43,
+ 171, 171, 171, 171,
+ 171, 171, 171, 171,
+ 171, 171, 171, 171
+ },
+ {
+ 43, 43, 43, 43,
+ 43, 43, 43, 43,
+ 43, 43, 43, 43,
+ 43, 43, 43, 43
+ }
+};
+
+const uint8 Indeo4Decoder::_quant_index_to_tab[22] = {
+ 0, 1, 0, 2, 1, 3, 0, 4, 1, 5, 0, 1, 6, 7, 8, // for 8x8 quant matrixes
+ 0, 1, 2, 2, 3, 3, 4 // for 4x4 quant matrixes
+};
+
} // End of namespace Image
diff --git a/image/codecs/indeo4.h b/image/codecs/indeo4.h
index b2d89d5..1034f18 100644
--- a/image/codecs/indeo4.h
+++ b/image/codecs/indeo4.h
@@ -35,6 +35,7 @@
#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 {
@@ -50,6 +51,11 @@ using namespace Indeo;
* - AVIDecoder
*/
class Indeo4Decoder : public IndeoDecoderBase {
+ struct Transform {
+ InvTransformPtr *inv_trans;
+ DCTransformPtr *dc_trans;
+ int is_2d_trans;
+ };
public:
Indeo4Decoder(uint16 width, uint16 height);
virtual ~Indeo4Decoder() {}
@@ -63,6 +69,31 @@ protected:
* @returns 0 = Ok, negative number = error
*/
virtual int decodePictureHeader();
+
+ /**
+ * Rearrange decoding and reference buffers.
+ */
+ virtual void switch_buffers();
+
+ virtual bool is_nonnull_frame() const;
+
+ /**
+ * Decode Indeo 4 band header.
+ *
+ * @param[in,out] band pointer to the band descriptor
+ * @return result code: 0 = OK, negative number = error
+ */
+ virtual int decode_band_hdr(IVIBandDesc *band);
+
+ /**
+ * Decode information (block type, cbp, quant delta, motion vector)
+ * for all macroblocks in the current tile.
+ *
+ * @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
+ */
+ virtual int decode_mb_info(IVIBandDesc *band, IVITile *tile);
private:
int scaleTileSize(int def_size, int size_factor);
@@ -83,6 +114,30 @@ private:
* Standard picture dimensions
*/
static const uint _ivi4_common_pic_sizes[14];
+
+ /**
+ * Transformations list
+ */
+ static Transform _transforms[18];
+
+ static const uint8 *const _scan_index_to_tab[15];
+
+ /**
+ * Indeo 4 dequant tables
+ */
+ static const uint16 _ivi4_quant_8x8_intra[9][64];
+
+ static const uint16 _ivi4_quant_8x8_inter[9][64];
+
+ static const uint16 _ivi4_quant_4x4_intra[5][16];
+
+ static const uint16 _ivi4_quant_4x4_inter[5][16];
+
+ /**
+ * Table for mapping quant matrix index from the bitstream
+ * into internal quant table number.
+ */
+ static const uint8 _quant_index_to_tab[22];
};
} // End of namespace Image
diff --git a/image/module.mk b/image/module.mk
index 6d55b17..03ba4d1 100644
--- a/image/module.mk
+++ b/image/module.mk
@@ -25,6 +25,7 @@ MODULE_OBJS := \
codecs/truemotion1.o \
codecs/indeo/get_bits.o \
codecs/indeo/indeo.o \
+ codecs/indeo/indeo_dsp.o \
codecs/indeo/mem.o \
codecs/indeo/vlc.o
Commit: c60a03019cb00649e19fa2c9baf289688237b90f
https://github.com/scummvm/scummvm/commit/c60a03019cb00649e19fa2c9baf289688237b90f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T10:08:15-04:00
Commit Message:
IMAGE: Cleanup and warning fixes for Indeo decoder
Changed paths:
image/codecs/indeo/indeo.cpp
image/codecs/indeo/indeo_dsp.cpp
image/codecs/indeo/mem.cpp
image/codecs/indeo4.cpp
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index e530c57..f68609d 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -396,6 +396,11 @@ IndeoDecoderBase::IndeoDecoderBase(uint16 width, uint16 height) : Codec() {
IndeoDecoderBase::~IndeoDecoderBase() {
delete _surface;
+ IVIPlaneDesc::ivi_free_buffers(_ctx.planes);
+ if (_ctx.mb_vlc.cust_tab.table)
+ _ctx.mb_vlc.cust_tab.ff_free_vlc();
+
+ delete _ctx.p_frame;
}
int IndeoDecoderBase::decodeIndeoFrame() {
@@ -512,8 +517,7 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
if (_ctx.is_indeo4 && _ctx.frame_type == IVI4_FRAMETYPE_BIDIR) {
band->ref_buf = band->bufs[_ctx.b_ref_buf];
band->b_ref_buf = band->bufs[_ctx.ref_buf];
- }
- else {
+ } else {
band->ref_buf = band->bufs[_ctx.ref_buf];
band->b_ref_buf = 0;
}
@@ -533,7 +537,7 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
band->rv_map = &_ctx.rvmap_tabs[band->rvmap_sel];
- /* apply corrections to the selected rvmap table if present */
+ // apply corrections to the selected rvmap table if present
for (i = 0; i < band->num_corr; i++) {
idx1 = band->corr[i * 2];
idx2 = band->corr[i * 2 + 1];
@@ -858,7 +862,7 @@ int IndeoDecoderBase::ivi_process_empty_tile(IVIBandDesc *band,
mb = tile->mbs;
ref_mb = tile->ref_mbs;
row_offset = band->mb_size * band->pitch;
- need_mc = 0; /* reset the mc tracking flag */
+ need_mc = 0; // reset the mc tracking flag
for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
mb_offset = offs;
@@ -868,8 +872,8 @@ int IndeoDecoderBase::ivi_process_empty_tile(IVIBandDesc *band,
mb->ypos = y;
mb->buf_offs = mb_offset;
- mb->type = 1; /* set the macroblocks type = INTER */
- mb->cbp = 0; /* all blocks are empty */
+ mb->type = 1; // set the macroblocks type = INTER
+ mb->cbp = 0; // all blocks are empty
if (!band->qdelta_present && !band->plane && !band->band_num) {
mb->q_delta = band->glob_quant;
@@ -881,7 +885,7 @@ int IndeoDecoderBase::ivi_process_empty_tile(IVIBandDesc *band,
mb->q_delta = ref_mb->q_delta;
if (band->inherit_mv && ref_mb) {
- /* motion vector inheritance */
+ // motion vector inheritance
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
@@ -889,7 +893,7 @@ int IndeoDecoderBase::ivi_process_empty_tile(IVIBandDesc *band,
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
}
- need_mc |= mb->mv_x || mb->mv_y; /* tracking non-zero motion vectors */
+ need_mc |= mb->mv_x || mb->mv_y; // tracking non-zero motion vectors
{
int dmv_x, dmv_y, cx, cy;
@@ -981,10 +985,10 @@ int IndeoDecoderBase::ivi_decode_blocks(GetBits *gb, IVIBandDesc *band, IVITile
ivi_mc_avg_func mc_avg_with_delta_func, mc_avg_no_delta_func;
const uint8 *scale_tab;
- /* init intra prediction for the DC coefficient */
+ // init intra prediction for the DC coefficient
prev_dc = 0;
blk_size = band->blk_size;
- /* number of blocks per mb */
+ // number of blocks per mb
num_blocks = (band->mb_size != blk_size) ? 4 : 1;
if (blk_size == 8) {
mc_with_delta_func = IndeoDSP::ff_ivi_mc_8x8_delta;
@@ -1024,7 +1028,7 @@ int IndeoDecoderBase::ivi_decode_blocks(GetBits *gb, IVIBandDesc *band, IVITile
mv_x >>= 1;
mv_y >>= 1;
mv_x2 >>= 1;
- mv_y2 >>= 1; /* convert halfpel vectors into fullpel ones */
+ mv_y2 >>= 1; // convert halfpel vectors into fullpel ones
}
if (mb->type == 2)
mc_type = -1;
@@ -1153,7 +1157,8 @@ int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
RVMapDesc *rvmap = band->rv_map;
uint8 col_flags[8];
int32 trvec[64];
- uint32 sym = 0, lo, hi, q;
+ uint32 sym = 0, q;
+ int lo, hi;
int pos, run, val;
int blk_size = band->blk_size;
int num_coeffs = blk_size * blk_size;
@@ -1188,8 +1193,7 @@ int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
hi = gb->getVLC2(band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
// merge them and convert into signed val
val = IVI_TOSIGNED((hi << 6) | lo);
- }
- else {
+ } else {
if (sym >= 256U) {
warning("Invalid sym encountered");
return -1;
diff --git a/image/codecs/indeo/indeo_dsp.cpp b/image/codecs/indeo/indeo_dsp.cpp
index 88e078d..f13ce91 100644
--- a/image/codecs/indeo/indeo_dsp.cpp
+++ b/image/codecs/indeo/indeo_dsp.cpp
@@ -96,9 +96,10 @@ void IndeoDSP::ff_ivi_inverse_haar_8x8(const int32 *in, int16 *out, uint32 pitch
dst[ 0], dst[ 8], dst[16], dst[24],
dst[32], dst[40], dst[48], dst[56],
t0, t1, t2, t3, t4, t5, t6, t7, t8);
- } else
+ } else {
dst[ 0] = dst[ 8] = dst[16] = dst[24] =
dst[32] = dst[40] = dst[48] = dst[56] = 0;
+ }
src++;
dst++;
@@ -165,11 +166,12 @@ void IndeoDSP::ff_ivi_col_haar8(const int32 *in, int16 *out, uint32 pitch,
out[4 * pitch], out[5 * pitch],
out[6 * pitch], out[7 * pitch],
t0, t1, t2, t3, t4, t5, t6, t7, t8);
- } else
+ } else {
out[0 * pitch] = out[1 * pitch] =
out[2 * pitch] = out[3 * pitch] =
out[4 * pitch] = out[5 * pitch] =
out[6 * pitch] = out[7 * pitch] = 0;
+ }
in++;
out++;
@@ -198,8 +200,9 @@ void IndeoDSP::ff_ivi_inverse_haar_4x4(const int32 *in, int16 *out, uint32 pitch
INV_HAAR4( sp1, sp2, src[8], src[12],
dst[0], dst[4], dst[8], dst[12],
t0, t1, t2, t3, t4);
- } else
+ } else {
dst[0] = dst[4] = dst[8] = dst[12] = 0;
+ }
src++;
dst++;
@@ -257,9 +260,10 @@ void IndeoDSP::ff_ivi_col_haar4(const int32 *in, int16 *out, uint32 pitch,
out[0 * pitch], out[1 * pitch],
out[2 * pitch], out[3 * pitch],
t0, t1, t2, t3, t4);
- } else
+ } else {
out[0 * pitch] = out[1 * pitch] =
out[2 * pitch] = out[3 * pitch] = 0;
+ }
in++;
out++;
@@ -345,11 +349,12 @@ void IndeoDSP::ff_ivi_inverse_slant_8x8(const int32 *in, int16 *out, uint32 pitc
IVI_INV_SLANT8(src[0], src[8], src[16], src[24], src[32], src[40], src[48], src[56],
dst[0], dst[8], dst[16], dst[24], dst[32], dst[40], dst[48], dst[56],
t0, t1, t2, t3, t4, t5, t6, t7, t8);
- } else
+ } else {
dst[0] = dst[8] = dst[16] = dst[24] = dst[32] = dst[40] = dst[48] = dst[56] = 0;
+ }
- src++;
- dst++;
+ src++;
+ dst++;
}
#undef COMPENSATE
@@ -384,11 +389,11 @@ void IndeoDSP::ff_ivi_inverse_slant_4x4(const int32 *in, int16 *out, uint32 pitc
IVI_INV_SLANT4(src[0], src[4], src[8], src[12],
dst[0], dst[4], dst[8], dst[12],
t0, t1, t2, t3, t4);
- } else
+ } else {
dst[0] = dst[4] = dst[8] = dst[12] = 0;
-
- src++;
- dst++;
+ }
+ src++;
+ dst++;
}
#undef COMPENSATE
diff --git a/image/codecs/indeo/mem.cpp b/image/codecs/indeo/mem.cpp
index 53a3236..88085ae 100644
--- a/image/codecs/indeo/mem.cpp
+++ b/image/codecs/indeo/mem.cpp
@@ -146,9 +146,10 @@ uint16 inv_bits(uint16 val, int nbits) {
if (nbits <= 8) {
res = ff_reverse[val] >> (8 - nbits);
- } else
+ } else {
res = ((ff_reverse[val & 0xFF] << 8) +
(ff_reverse[val >> 8])) >> (16 - nbits);
+ }
return res;
}
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index af521b3..bedc2d9 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -248,8 +248,7 @@ void Indeo4Decoder::switch_buffers() {
if (is_prev_ref && is_ref) {
FFSWAP(int, _ctx.dst_buf, _ctx.ref_buf);
- }
- else if (is_prev_ref) {
+ } else if (is_prev_ref) {
FFSWAP(int, _ctx.ref_buf, _ctx.b_ref_buf);
FFSWAP(int, _ctx.dst_buf, _ctx.ref_buf);
}
@@ -488,24 +487,22 @@ int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
- }
- else {
+ } else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
}
}
} else {
if (band->inherit_mv) {
- /* copy mb_type from corresponding reference mb */
+ // copy mb_type from corresponding reference mb
if (!ref_mb) {
warning("ref_mb unavailable");
return -1;
}
mb->type = ref_mb->type;
- }
- else if (_ctx.frame_type == IVI4_FRAMETYPE_INTRA ||
+ } else if (_ctx.frame_type == IVI4_FRAMETYPE_INTRA ||
_ctx.frame_type == IVI4_FRAMETYPE_INTRA1) {
- mb->type = 0; /* mb_type is always INTRA for intra-frames */
+ mb->type = 0; // mb_type is always INTRA for intra-frames
} else {
mb->type = _ctx.gb->getBits(mb_type_bits);
}
@@ -524,11 +521,11 @@ int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
}
if (!mb->type) {
- mb->mv_x = mb->mv_y = 0; /* there is no motion vector in intra-macroblocks */
+ mb->mv_x = mb->mv_y = 0; // there is no motion vector in intra-macroblocks
} else {
if (band->inherit_mv) {
if (ref_mb)
- /* motion vector inheritance */
+ // motion vector inheritance
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
@@ -538,7 +535,7 @@ int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
mb->mv_y = ref_mb->mv_y;
}
} else {
- /* decode motion vector deltas */
+ // decode motion vector deltas
mv_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_y += IVI_TOSIGNED(mv_delta);
Commit: 400661182efae9659e664fec0e81c7ed8c3a10ec
https://github.com/scummvm/scummvm/commit/400661182efae9659e664fec0e81c7ed8c3a10ec
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T10:08:17-04:00
Commit Message:
IMAGE: Indeo4 header now being successfully loaded
Changed paths:
image/codecs/indeo/indeo.cpp
image/codecs/indeo/indeo.h
image/codecs/indeo/vlc.cpp
image/codecs/indeo/vlc.h
image/codecs/indeo4.cpp
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index f68609d..e58b4c6 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -33,6 +33,7 @@
#include "image/codecs/indeo/indeo_dsp.h"
#include "image/codecs/indeo/mem.h"
#include "common/system.h"
+#include "common/algorithm.h"
#include "common/textconsole.h"
#include "common/util.h"
@@ -139,13 +140,15 @@ 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_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_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);
}
}
@@ -174,10 +177,10 @@ int IVIHuffTab::ff_ivi_dec_huff_desc(GetBits *gb, int desc_coded, int which_tab)
new_huff.xbits[i] = 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) {
+ if (new_huff.ivi_huff_desc_cmp(&cust_desc) || !cust_tab._table) {
cust_desc.ivi_huff_desc_copy(&new_huff);
- if (cust_tab.table)
+ if (cust_tab._table)
cust_tab.ff_free_vlc();
result = cust_desc.ivi_create_huff_from_desc(&cust_tab, 0);
if (result) {
@@ -199,6 +202,83 @@ int IVIHuffTab::ff_ivi_dec_huff_desc(GetBits *gb, int desc_coded, int which_tab)
/*------------------------------------------------------------------------*/
+RVMapDesc::RVMapDesc() {
+ eob_sym = esc_sym = 0;
+ Common::fill(&runtab[0], &runtab[256], 0);
+ Common::fill(&valtab[0], &valtab[256], 0);
+}
+
+/*------------------------------------------------------------------------*/
+
+IVIMbInfo::IVIMbInfo() : xpos(0), ypos(0), buf_offs(0), type(0), cbp(0),
+ q_delta(0), mv_x(0), mv_y(0), b_mv_x(0), b_mv_y(0) {
+}
+
+/*------------------------------------------------------------------------*/
+
+IVITile::IVITile() : xpos(0), ypos(0), width(0), height(0), mb_size(0),
+ is_empty(0), data_size(0), num_MBs(0), mbs(nullptr), ref_mbs(nullptr) {
+}
+
+/*------------------------------------------------------------------------*/
+
+IVIBandDesc::IVIBandDesc() : plane(0), band_num(0), width(0), height(0),
+ aheight(0), data_ptr(nullptr), data_size(0), buf(nullptr),
+ ref_buf(nullptr), b_ref_buf(nullptr), pitch(0), is_empty(0),
+ mb_size(0), blk_size(0), is_halfpel(0), inherit_mv(0), bufsize(0),
+ inherit_qdelta(0), qdelta_present(0), quant_mat(0), glob_quant(0),
+ scan(nullptr), scan_size(0), num_corr(0), rvmap_sel(0), rv_map(nullptr),
+ num_tiles(0), tiles(nullptr), inv_transform(nullptr), transform_size(0),
+ dc_transform(nullptr), is_2d_trans(0), checksum(0), checksum_present(0),
+ intra_base(nullptr), inter_base(nullptr), intra_scale(nullptr),
+ inter_scale(nullptr) {
+ Common::fill(&bufs[0], &bufs[4], (int16 *)nullptr);
+ Common::fill(&corr[0], &corr[61 * 2], 0);
+}
+
+int IVIBandDesc::ivi_init_tiles(IVITile *ref_tile, int p, int b, int t_height, int t_width) {
+ int x, y;
+ IVITile *tile = tiles;
+
+ for (y = 0; y < height; y += t_height) {
+ for (x = 0; x < width; x += t_width) {
+ tile->xpos = x;
+ tile->ypos = y;
+ tile->mb_size = mb_size;
+ tile->width = MIN(width - x, t_width);
+ tile->height = MIN(height - y, t_height);
+ tile->is_empty = tile->data_size = 0;
+ // calculate number of macroblocks
+ tile->num_MBs = IVI_MBs_PER_TILE(tile->width, tile->height,
+ mb_size);
+
+ av_freep(&tile->mbs);
+ tile->mbs = (IVIMbInfo *)av_mallocz_array(tile->num_MBs, sizeof(IVIMbInfo));
+ if (!tile->mbs)
+ return -2;
+
+ tile->ref_mbs = 0;
+ if (p || b) {
+ if (tile->num_MBs != ref_tile->num_MBs) {
+ warning("ref_tile mismatch");
+ return -1;
+ }
+ tile->ref_mbs = ref_tile->mbs;
+ ref_tile++;
+ }
+ tile++;
+ }
+ }
+
+ return 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+IVIPicConfig::IVIPicConfig() : pic_width(0), pic_height(0), chroma_width(0),
+ chroma_height(0), tile_width(0), tile_height(0), luma_bands(0), chroma_bands(0) {
+}
+
bool IVIPicConfig::ivi_pic_config_cmp(const IVIPicConfig &cfg2) {
return pic_width != cfg2.pic_width || pic_height != cfg2.pic_height ||
chroma_width != cfg2.chroma_width || chroma_height != cfg2.chroma_height ||
@@ -208,6 +288,9 @@ bool IVIPicConfig::ivi_pic_config_cmp(const IVIPicConfig &cfg2) {
/*------------------------------------------------------------------------*/
+IVIPlaneDesc::IVIPlaneDesc() : width(0), height(0), num_bands(0), bands(nullptr) {
+}
+
int IVIPlaneDesc::ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg, bool is_indeo4) {
int p, b;
uint32 b_width, b_height, align_fac, width_aligned,
@@ -333,7 +416,7 @@ void IVIPlaneDesc::ivi_free_buffers(IVIPlaneDesc *planes) {
av_freep(&planes[p].bands[b].bufs[2]);
av_freep(&planes[p].bands[b].bufs[3]);
- if (planes[p].bands[b].blk_vlc.cust_tab.table)
+ if (planes[p].bands[b].blk_vlc.cust_tab._table)
planes[p].bands[b].blk_vlc.cust_tab.ff_free_vlc();
for (t = 0; t < planes[p].bands[b].num_tiles; t++)
av_freep(&planes[p].bands[b].tiles[t].mbs);
@@ -346,41 +429,22 @@ void IVIPlaneDesc::ivi_free_buffers(IVIPlaneDesc *planes) {
/*------------------------------------------------------------------------*/
-int IVIBandDesc::ivi_init_tiles(IVITile *ref_tile, int p, int b, int t_height, int t_width) {
- int x, y;
- IVITile *tile = tiles;
-
- for (y = 0; y < height; y += t_height) {
- for (x = 0; x < width; x += t_width) {
- tile->xpos = x;
- tile->ypos = y;
- tile->mb_size = mb_size;
- tile->width = MIN(width - x, t_width);
- tile->height = MIN(height - y, t_height);
- tile->is_empty = tile->data_size = 0;
- // calculate number of macroblocks
- tile->num_MBs = IVI_MBs_PER_TILE(tile->width, tile->height,
- mb_size);
-
- av_freep(&tile->mbs);
- tile->mbs = (IVIMbInfo *)av_mallocz_array(tile->num_MBs, sizeof(IVIMbInfo));
- if (!tile->mbs)
- return -2;
+AVFrame::AVFrame() {
+ Common::fill(&data[0], &data[AV_NUM_DATA_POINTERS], (uint8 *)nullptr);
+ Common::fill(&linesize[0], &linesize[AV_NUM_DATA_POINTERS], 0);
+}
- tile->ref_mbs = 0;
- if (p || b) {
- if (tile->num_MBs != ref_tile->num_MBs) {
- warning("ref_tile mismatch");
- return -1;
- }
- tile->ref_mbs = ref_tile->mbs;
- ref_tile++;
- }
- tile++;
- }
- }
+/*------------------------------------------------------------------------*/
- return 0;
+IVI45DecContext::IVI45DecContext() : gb(nullptr), frame_num(0), frame_type(0),
+ prev_frame_type(0), data_size(0), is_scalable(0), frame_data(0),
+ inter_scal(0), frame_size(0), pic_hdr_size(0), frame_flags(0),
+ checksum(0), buf_switch(0), dst_buf(0), ref_buf(0), ref2_buf(0),
+ b_ref_buf(0), rvmap_sel(0), in_imf(0), in_q(0), pic_glob_quant(0),
+ unknown1(0), gop_hdr_size(0), gop_flags(0), lock_word(0), has_b_frames(0),
+ has_transp(0), uses_tiling(0), uses_haar(0), uses_fullpel(0), gop_invalid(0),
+ is_indeo4(0), p_frame(nullptr), got_p_frame(0) {
+ Common::fill(&buf_invalid[0], &buf_invalid[4], 0);
}
/*------------------------------------------------------------------------*/
@@ -389,15 +453,13 @@ IndeoDecoderBase::IndeoDecoderBase(uint16 width, uint16 height) : Codec() {
_pixelFormat = g_system->getScreenFormat();
_surface = new Graphics::ManagedSurface();
_surface->create(width, height, _pixelFormat);
- _ctx.gb = nullptr;
- _ctx.pic_conf.pic_width = _ctx.pic_conf.pic_height = 0;
_ctx.b_ref_buf = 3; // buffer 2 is used for scalability mode
}
IndeoDecoderBase::~IndeoDecoderBase() {
delete _surface;
IVIPlaneDesc::ivi_free_buffers(_ctx.planes);
- if (_ctx.mb_vlc.cust_tab.table)
+ if (_ctx.mb_vlc.cust_tab._table)
_ctx.mb_vlc.cust_tab.ff_free_vlc();
delete _ctx.p_frame;
@@ -1181,16 +1243,16 @@ int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
// zero column flags
memset(col_flags, 0, sizeof(col_flags));
while (scan_pos <= num_coeffs) {
- sym = gb->getVLC2(band->blk_vlc.tab->table,
+ sym = gb->getVLC2(band->blk_vlc.tab->_table,
IVI_VLC_BITS, 1);
if (sym == rvmap->eob_sym)
break; // End of block
// Escape - run/val explicitly coded using 3 vlc codes
if (sym == rvmap->esc_sym) {
- run = gb->getVLC2(band->blk_vlc.tab->table, IVI_VLC_BITS, 1) + 1;
- lo = gb->getVLC2(band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
- hi = gb->getVLC2(band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
+ run = gb->getVLC2(band->blk_vlc.tab->_table, IVI_VLC_BITS, 1) + 1;
+ lo = gb->getVLC2(band->blk_vlc.tab->_table, IVI_VLC_BITS, 1);
+ hi = gb->getVLC2(band->blk_vlc.tab->_table, IVI_VLC_BITS, 1);
// merge them and convert into signed val
val = IVI_TOSIGNED((hi << 6) | lo);
} else {
diff --git a/image/codecs/indeo/indeo.h b/image/codecs/indeo/indeo.h
index fa1bc2f..2103ebe 100644
--- a/image/codecs/indeo/indeo.h
+++ b/image/codecs/indeo/indeo.h
@@ -55,6 +55,17 @@ enum {
IVI4_FRAMETYPE_NULL_LAST = 6 ///< empty frame with no data
};
+enum {
+ IVI_MB_HUFF = 0, /// Huffman table is used for coding macroblocks
+ IVI_BLK_HUFF = 1 /// Huffman table is used for coding blocks
+};
+
+/**
+ * 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 blk_size);
+
typedef void(*ivi_mc_func) (int16 *buf, const int16 *ref_buf,
uint32 pitch, int mc_type);
typedef void(*ivi_mc_avg_func) (int16 *buf, const int16 *ref_buf1,
@@ -127,26 +138,6 @@ public:
int ff_ivi_dec_huff_desc(GetBits *gb, int desc_coded, int which_tab);
};
-enum {
- IVI_MB_HUFF = 0, /// Huffman table is used for coding macroblocks
- IVI_BLK_HUFF = 1 /// Huffman table is used for coding blocks
-};
-
-
-/**
- * Common scan patterns (defined in ivi_common.c)
- */
-//extern const uint8 ff_ivi_vertical_scan_8x8[64];
-//extern const uint8 ff_ivi_horizontal_scan_8x8[64];
-//extern const uint8 ff_ivi_direct_scan_4x4[16];
-
-/**
- * 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 blk_size);
-
-
/**
* run-value (RLE) table descriptor
*/
@@ -155,10 +146,9 @@ struct RVMapDesc {
uint8 esc_sym; ///< escape symbol
uint8 runtab[256];
int8 valtab[256];
-};
-
-extern const RVMapDesc ff_ivi_rvmap_tabs[9];
+ RVMapDesc();
+};
/**
* information for Indeo macroblock (16x16, 8x8 or 4x4)
@@ -174,8 +164,9 @@ struct IVIMbInfo {
int8 mv_y; ///< motion vector (y component)
int8 b_mv_x; ///< second motion vector (x component)
int8 b_mv_y; ///< second motion vector (y component)
-};
+ IVIMbInfo();
+};
/**
* information for Indeo tile
@@ -191,8 +182,9 @@ struct IVITile {
int num_MBs; ///< number of macroblocks in this tile
IVIMbInfo * mbs; ///< array of macroblock descriptors
IVIMbInfo * ref_mbs; ///< ptr to the macroblock descriptors of the reference tile
-};
+ IVITile();
+};
/**
* information for Indeo wavelet band
@@ -242,6 +234,8 @@ struct IVIBandDesc {
const uint8 * intra_scale; ///< quantization coefficient for intra blocks
const uint8 * inter_scale; ///< quantization coefficient for inter blocks
+ IVIBandDesc();
+
int ivi_init_tiles(IVITile *ref_tile, int p, int b, int t_height, int t_width);
};
@@ -255,6 +249,8 @@ struct IVIPicConfig {
uint8 luma_bands;
uint8 chroma_bands;
+ IVIPicConfig();
+
/**
* Compare some properties of two pictures
*/
@@ -270,6 +266,8 @@ struct IVIPlaneDesc {
uint8 num_bands; ///< number of bands this plane subdivided into
IVIBandDesc *bands; ///< array of band descriptors
+ IVIPlaneDesc();
+
static int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg, bool is_indeo4);
static int ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height);
@@ -314,6 +312,8 @@ struct AVFrame {
* may be extra padding present for performance reasons.
*/
int linesize[AV_NUM_DATA_POINTERS];
+
+ AVFrame();
};
struct IVI45DecContext {
@@ -367,6 +367,8 @@ struct IVI45DecContext {
AVFrame * p_frame;
int got_p_frame;
+
+ IVI45DecContext();
};
class IndeoDecoderBase : public Codec {
@@ -541,10 +543,9 @@ public:
* @param h the height of the picture
* @param log_offset the offset to sum to the log level for logging with log_ctx
* @returns >= 0 if valid, a negative error code otherwise
-*/
+ */
extern int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
-
} // End of namespace Indeo
} // End of namespace Image
diff --git a/image/codecs/indeo/vlc.cpp b/image/codecs/indeo/vlc.cpp
index 4415965..485acfb 100644
--- a/image/codecs/indeo/vlc.cpp
+++ b/image/codecs/indeo/vlc.cpp
@@ -32,14 +32,14 @@
#include "common/util.h"
namespace Image {
-namespace Indeo {
+ namespace Indeo {
/**
* Quicksort
* This sort is fast, and fully inplace but not stable and it is possible
* to construct input that requires O(n^2) time but this is very unlikely to
* happen with non constructed input.
-*/
+ */
#define AV_QSORT(p, num, type, cmp) do {\
void *stack[64][2];\
int sp= 1;\
@@ -104,28 +104,38 @@ namespace Indeo {
}\
} while (0)
-/**
- * VLC decoding
- */
-#define GET_DATA(v, table, i, wrap, size) \
-{ \
- const uint8 *ptr = (const uint8 *)table + i * wrap; \
- switch(size) { \
- case 1: \
- v = *(const uint8 *)ptr; \
- break; \
- case 2: \
- v = *(const uint16 *)ptr; \
- break; \
- default: \
- v = *(const uint32 *)ptr; \
- break; \
- } \
-}
+#define COPY(condition)\
+ for (i = 0; i < nb_codes; i++) { \
+ buf[j].bits = getData(p_bits, i, bits_wrap, bits_size); \
+ if (!(condition)) \
+ continue; \
+ if (buf[j].bits > 3*nb_bits || 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)) { \
+ 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 = bitswap_32(buf[j].code); \
+ else \
+ buf[j].code <<= 32 - buf[j].bits; \
+ if (symbols) \
+ buf[j].symbol = getData(symbols, i, symbols_wrap, symbols_size); \
+ else \
+ buf[j].symbol = i; \
+ j++; \
+ }
/*------------------------------------------------------------------------*/
-VLC::VLC() : bits(0), table_size(0), table_allocated(0), table(nullptr) {
+VLC::VLC() : _bits(0), _table_size(0), _table_allocated(0), _table(nullptr) {
}
int VLC::init_vlc(int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size,
@@ -143,17 +153,17 @@ int VLC::init_vlc(int nb_bits, int nb_codes, const void *p_bits, int bits_wrap,
VLC localvlc, *vlc;
vlc = this;
- vlc->bits = nb_bits;
+ vlc->_bits = nb_bits;
if (flags & INIT_VLC_USE_NEW_STATIC) {
assert((nb_codes + 1) <= FF_ARRAY_ELEMS(localbuf));
buf = localbuf;
localvlc = *this;
vlc = &localvlc;
- vlc->table_size = 0;
+ vlc->_table_size = 0;
} else {
- vlc->table = NULL;
- vlc->table_allocated = 0;
- vlc->table_size = 0;
+ vlc->_table = NULL;
+ vlc->_table_allocated = 0;
+ vlc->_table_size = 0;
buf = (VLCcode *)av_malloc_array((nb_codes + 1), sizeof(VLCcode));
assert(buf);
@@ -161,34 +171,7 @@ int VLC::init_vlc(int nb_bits, int nb_codes, const void *p_bits, int bits_wrap,
assert(symbols_size <= 2 || !symbols);
j = 0;
-#define COPY(condition)\
- for (i = 0; i < nb_codes; i++) { \
- GET_DATA(buf[j].bits, p_bits, i, bits_wrap, bits_size); \
- if (!(condition)) \
- continue; \
- if (buf[j].bits > 3*nb_bits || 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; \
- } \
- GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size); \
- 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 = bitswap_32(buf[j].code); \
- else \
- buf[j].code <<= 32 - buf[j].bits; \
- if (symbols) \
- GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size) \
- else \
- buf[j].symbol = i; \
- j++; \
- }
+
COPY(buf[j].bits > nb_bits);
// qsort is the slowest part of init_vlc, and could probably be improved or avoided
@@ -199,15 +182,15 @@ int VLC::init_vlc(int nb_bits, int nb_codes, const void *p_bits, int bits_wrap,
ret = vlc->build_table(nb_bits, nb_codes, buf, flags);
if (flags & INIT_VLC_USE_NEW_STATIC) {
- if (vlc->table_size != vlc->table_allocated)
- warning("needed %d had %d", table_size, table_allocated);
+ if (vlc->_table_size != vlc->_table_allocated)
+ warning("needed %d had %d", vlc->_table_size, vlc->_table_allocated);
assert(ret >= 0);
*this = *vlc;
} else {
free(buf);
if (ret < 0) {
- av_freep(&vlc->table);
+ av_freep(&vlc->_table);
return -1;
}
}
@@ -216,7 +199,7 @@ int VLC::init_vlc(int nb_bits, int nb_codes, const void *p_bits, int bits_wrap,
}
void VLC::ff_free_vlc() {
- free(table);
+ free(_table);
}
int VLC::compare_vlcspec(const void *a, const void *b) {
@@ -230,27 +213,26 @@ int VLC::build_table(int table_nb_bits, int nb_codes,
int table_size, table_index, index, code_prefix, symbol, subtable_bits;
int i, j, k, n, nb, inc;
uint32 code;
- // the double volatile is needed to prevent an internal compiler error in gcc 4.2
- volatile VLC_TYPE(*volatile table)[2];
-
+ VLC_TYPE (*table)[2];
table_size = 1 << table_nb_bits;
if (table_nb_bits > 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);
+ //warning("new table index=%d size=%d", table_index, table_size);
if (table_index < 0)
return table_index;
- table = (volatile VLC_TYPE(*)[2])&vlc->table[table_index];
+ table = &vlc->_table[table_index];
- /* first pass: map codes and compute auxiliary table sizes */
+ // first pass: map codes and compute auxiliary table sizes
for (i = 0; i < nb_codes; i++) {
n = codes[i].bits;
code = codes[i].code;
symbol = codes[i].symbol;
- warning("i=%d n=%d code=0x%x", i, n, code);
+ //warning("i=%d n=%d code=0x%x", i, n, code);
+
if (n <= table_nb_bits) {
- /* no need to add another table */
+ // no need to add another table
j = code >> (32 - table_nb_bits);
nb = 1 << (table_nb_bits - n);
inc = 1;
@@ -260,18 +242,19 @@ int VLC::build_table(int table_nb_bits, int nb_codes,
}
for (k = 0; k < nb; k++) {
int bits = table[j][1];
- warning("%4x: code=%d n=%d", j, i, n);
+ //warning("%4x: code=%d n=%d", j, i, n);
+
if (bits != 0 && bits != n) {
warning("incorrect codes");
return -1;
}
+
table[j][1] = n; //bits
table[j][0] = symbol;
j += inc;
}
- }
- else {
- /* fill auxiliary table recursively */
+ } else {
+ // fill auxiliary table recursively
n -= table_nb_bits;
code_prefix = code >> (32 - table_nb_bits);
subtable_bits = n;
@@ -282,7 +265,7 @@ int VLC::build_table(int table_nb_bits, int nb_codes,
if (n <= 0)
break;
code = codes[k].code;
- if (code >> (32 - table_nb_bits) != code_prefix)
+ if (code >> (32 - table_nb_bits) != (uint)code_prefix)
break;
codes[k].bits = n;
codes[k].code = code << table_nb_bits;
@@ -291,12 +274,13 @@ int VLC::build_table(int table_nb_bits, int nb_codes,
subtable_bits = MIN(subtable_bits, table_nb_bits);
j = (flags & INIT_VLC_LE) ? bitswap_32(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);
+ //warning("%4x: n=%d (subtable)", j, codes[i].bits + table_nb_bits);
index = vlc->build_table(subtable_bits, k - i, codes + i, flags);
if (index < 0)
return index;
- /* note: realloc has been done, so reload tables */
- table = (volatile VLC_TYPE(*)[2])&vlc->table[table_index];
+
+ // note: realloc has been done, so reload tables
+ table = (VLC_TYPE (*)[2])&vlc->_table[table_index];
table[j][0] = index; //code
i = k - 1;
}
@@ -312,25 +296,41 @@ int VLC::build_table(int table_nb_bits, int nb_codes,
int VLC::alloc_table(int size, int use_static) {
VLC *vlc = this;
- int index = vlc->table_size;
+ int index = vlc->_table_size;
- vlc->table_size += size;
- if (vlc->table_size > vlc->table_allocated) {
+ vlc->_table_size += size;
+ if (vlc->_table_size > vlc->_table_allocated) {
// cannot do anything, init_vlc() is used with too little memory
assert(!use_static);
- vlc->table_allocated += (1 << vlc->bits);
- vlc->table = (int16(*)[2])av_realloc_f(vlc->table, vlc->table_allocated, sizeof(VLC_TYPE) * 2);
- if (!vlc->table) {
- vlc->table_allocated = 0;
- vlc->table_size = 0;
+ vlc->_table_allocated += (1 << vlc->_bits);
+ vlc->_table = (int16(*)[2])av_realloc_f(vlc->_table, vlc->_table_allocated, sizeof(VLC_TYPE) * 2);
+ if (!vlc->_table) {
+ vlc->_table_allocated = 0;
+ vlc->_table_size = 0;
return -2;
}
- memset(vlc->table + vlc->table_allocated - (1 << vlc->bits), 0, sizeof(VLC_TYPE) * 2 << vlc->bits);
+ memset(vlc->_table + vlc->_table_allocated - (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;
+
+ switch(size) {
+ case 1:
+ return *(const uint8 *)ptr;
+ case 2:
+ return *(const uint16 *)ptr;
+ default:
+ return *(const uint32 *)ptr;
+ }
+}
+
} // End of namespace Indeo
} // End of namespace Image
diff --git a/image/codecs/indeo/vlc.h b/image/codecs/indeo/vlc.h
index 682be66..01c7b11 100644
--- a/image/codecs/indeo/vlc.h
+++ b/image/codecs/indeo/vlc.h
@@ -37,8 +37,11 @@ namespace Image {
namespace Indeo {
#define VLC_TYPE int16
-#define INIT_VLC_LE 2
-#define INIT_VLC_USE_NEW_STATIC 4
+
+enum VLCFlag {
+ INIT_VLC_LE = 2,
+ INIT_VLC_USE_NEW_STATIC = 4
+};
struct VLCcode {
uint8 bits;
@@ -54,14 +57,21 @@ struct VLCcode {
struct VLC {
private:
static int compare_vlcspec(const void *a, const void *b);
+
+ /**
+ * Gets a value of a given size from a table
+ * @param table Table to get data from
+ * @param idx Index of value to retrieve
+ * @param wrap Size of elements with alignment
+ * @param size Size of elements
+ */
+ static uint getData(const void *table, uint idx, uint wrap, uint size);
public:
- int bits;
- VLC_TYPE (*table)[2]; ///< code, bits
- int table_size, table_allocated;
+ int _bits;
+ VLC_TYPE (*_table)[2]; ///< code, bits
+ int _table_size, _table_allocated;
VLC();
- ~VLC() { ff_free_vlc(); }
-
/* Build VLC decoding tables suitable for use with get_vlc().
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index bedc2d9..936d4b0 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -476,7 +476,7 @@ int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
mb->q_delta = 0;
if (!band->plane && !band->band_num && _ctx.in_q) {
- mb->q_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->table,
+ mb->q_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
}
@@ -515,7 +515,7 @@ int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
}
else if (mb->cbp || (!band->plane && !band->band_num &&
_ctx.in_q)) {
- mb->q_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->table,
+ mb->q_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
}
@@ -536,21 +536,21 @@ int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
}
} else {
// decode motion vector deltas
- mv_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->table,
+ mv_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table,
IVI_VLC_BITS, 1);
mv_y += IVI_TOSIGNED(mv_delta);
- mv_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->table,
+ mv_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table,
IVI_VLC_BITS, 1);
mv_x += IVI_TOSIGNED(mv_delta);
mb->mv_x = mv_x;
mb->mv_y = mv_y;
if (mb->type == 3) {
mv_delta = _ctx.gb->getVLC2(
- _ctx.mb_vlc.tab->table,
+ _ctx.mb_vlc.tab->_table,
IVI_VLC_BITS, 1);
mv_y += IVI_TOSIGNED(mv_delta);
mv_delta = _ctx.gb->getVLC2(
- _ctx.mb_vlc.tab->table,
+ _ctx.mb_vlc.tab->_table,
IVI_VLC_BITS, 1);
mv_x += IVI_TOSIGNED(mv_delta);
mb->b_mv_x = -mv_x;
Commit: 3a2ee8ea23247f72628294b48b43716c1b84d8a8
https://github.com/scummvm/scummvm/commit/3a2ee8ea23247f72628294b48b43716c1b84d8a8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T10:08:19-04:00
Commit Message:
IMAGE: Fixes for setup of Indeo4 decoder
Changed paths:
image/codecs/indeo/get_bits.cpp
image/codecs/indeo/get_bits.h
image/codecs/indeo/indeo.cpp
image/codecs/indeo/indeo.h
image/codecs/indeo4.cpp
diff --git a/image/codecs/indeo/get_bits.cpp b/image/codecs/indeo/get_bits.cpp
index fce773d..f165329 100644
--- a/image/codecs/indeo/get_bits.cpp
+++ b/image/codecs/indeo/get_bits.cpp
@@ -161,35 +161,13 @@ 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),
- _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;
+ _sizeInBits(src._sizeInBits), _sizeInBitsPlus8(src._sizeInBitsPlus8){
}
int GetBits::getXbits(int n) {
diff --git a/image/codecs/indeo/get_bits.h b/image/codecs/indeo/get_bits.h
index f9f577c..336cfa3 100644
--- a/image/codecs/indeo/get_bits.h
+++ b/image/codecs/indeo/get_bits.h
@@ -46,7 +46,6 @@ namespace Indeo {
class GetBits {
private:
const byte *_buffer;
- DisposeAfterUse::Flag _disposeAfterUse;
uint _index;
uint _sizeInBits;
uint _sizeInBitsPlus8;
@@ -60,22 +59,11 @@ public:
* @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
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index e58b4c6..83cd9fd 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -202,14 +202,6 @@ int IVIHuffTab::ff_ivi_dec_huff_desc(GetBits *gb, int desc_coded, int which_tab)
/*------------------------------------------------------------------------*/
-RVMapDesc::RVMapDesc() {
- eob_sym = esc_sym = 0;
- Common::fill(&runtab[0], &runtab[256], 0);
- Common::fill(&valtab[0], &valtab[256], 0);
-}
-
-/*------------------------------------------------------------------------*/
-
IVIMbInfo::IVIMbInfo() : xpos(0), ypos(0), buf_offs(0), type(0), cbp(0),
q_delta(0), mv_x(0), mv_y(0), b_mv_x(0), b_mv_y(0) {
}
@@ -445,6 +437,7 @@ IVI45DecContext::IVI45DecContext() : gb(nullptr), frame_num(0), frame_type(0),
has_transp(0), uses_tiling(0), uses_haar(0), uses_fullpel(0), gop_invalid(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]);
}
/*------------------------------------------------------------------------*/
@@ -1322,10 +1315,17 @@ int IndeoDecoderBase::ivi_dc_transform(IVIBandDesc *band, int *prev_dc,
return 0;
}
+/*------------------------------------------------------------------------*/
+
+int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) {
+ if (((w + 128) * (uint64)(h + 128)) < (INT_MAX / 8))
+ return 0;
+
+ error("Picture size %ux%u is invalid", w, h);
+}
+
+/*------------------------------------------------------------------------*/
-/**
- * Scan patterns shared between indeo4 and indeo5
- */
const uint8 IndeoDecoderBase::_ff_ivi_vertical_scan_8x8[64] = {
0, 8, 16, 24, 32, 40, 48, 56,
1, 9, 17, 25, 33, 41, 49, 57,
@@ -1352,14 +1352,360 @@ const uint8 IndeoDecoderBase::_ff_ivi_direct_scan_4x4[16] = {
0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
};
-/*------------------------------------------------------------------------*/
-
-int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) {
- if (((w + 128) * (uint64)(h + 128)) < (INT_MAX / 8))
- return 0;
-
- error("Picture size %ux%u is invalid", w, h);
+const RVMapDesc IVI45DecContext::_ff_ivi_rvmap_tabs[9] = {
+{ // MapTab0
+ 5, // eob_sym
+ 2, // esc_sym
+ // run table
+ {1, 1, 0, 1, 1, 0, 1, 1, 2, 2, 1, 1, 1, 1, 3, 3,
+ 1, 1, 2, 2, 1, 1, 4, 4, 1, 1, 1, 1, 2, 2, 5, 5,
+ 1, 1, 3, 3, 1, 1, 6, 6, 1, 2, 1, 2, 7, 7, 1, 1,
+ 8, 8, 1, 1, 4, 2, 1, 4, 2, 1, 3, 3, 1, 1, 1, 9,
+ 9, 1, 2, 1, 2, 1, 5, 5, 1, 1, 10, 10, 1, 1, 3, 3,
+ 2, 2, 1, 1, 11, 11, 6, 4, 4, 1, 6, 1, 2, 1, 2, 12,
+ 8, 1, 12, 7, 8, 7, 1, 16, 1, 16, 1, 3, 3, 13, 1, 13,
+ 2, 2, 1, 15, 1, 5, 14, 15, 1, 5, 14, 1, 17, 8, 17, 8,
+ 1, 4, 4, 2, 2, 1, 25, 25, 24, 24, 1, 3, 1, 3, 1, 8,
+ 6, 7, 6, 1, 18, 8, 18, 1, 7, 23, 2, 2, 23, 1, 1, 21,
+ 22, 9, 9, 22, 19, 1, 21, 5, 19, 5, 1, 33, 20, 33, 20, 8,
+ 4, 4, 1, 32, 2, 2, 8, 3, 32, 26, 3, 1, 7, 7, 26, 6,
+ 1, 6, 1, 1, 16, 1, 10, 1, 10, 2, 16, 29, 28, 2, 29, 28,
+ 1, 27, 5, 8, 5, 27, 1, 8, 3, 7, 3, 31, 41, 31, 1, 41,
+ 6, 1, 6, 7, 4, 4, 1, 1, 2, 1, 2, 11, 34, 30, 11, 1,
+ 30, 15, 15, 34, 36, 40, 36, 40, 35, 35, 37, 37, 39, 39, 38, 38},
+
+ // value table
+ { 1, -1, 0, 2, -2, 0, 3, -3, 1, -1, 4, -4, 5, -5, 1, -1,
+ 6, -6, 2, -2, 7, -7, 1, -1, 8, -8, 9, -9, 3, -3, 1, -1,
+ 10, -10, 2, -2, 11, -11, 1, -1, 12, 4, -12, -4, 1, -1, 13, -13,
+ 1, -1, 14, -14, 2, 5, 15, -2, -5, -15, -3, 3, 16, -16, 17, 1,
+ -1, -17, 6, 18, -6, -18, 2, -2, 19, -19, 1, -1, 20, -20, 4, -4,
+ 7, -7, 21, -21, 1, -1, 2, 3, -3, 22, -2, -22, 8, 23, -8, 1,
+ 2, -23, -1, 2, -2, -2, 24, 1, -24, -1, 25, 5, -5, 1, -25, -1,
+ 9, -9, 26, 1, -26, 3, 1, -1, 27, -3, -1, -27, 1, 3, -1, -3,
+ 28, -4, 4, 10, -10, -28, 1, -1, 1, -1, 29, 6, -29, -6, 30, -4,
+ 3, 3, -3, -30, 1, 4, -1, 31, -3, 1, 11, -11, -1, -31, 32, -1,
+ -1, 2, -2, 1, 1, -32, 1, 4, -1, -4, 33, -1, 1, 1, -1, 5,
+ 5, -5, -33, -1, -12, 12, -5, -7, 1, 1, 7, 34, 4, -4, -1, 4,
+ -34, -4, 35, 36, -2, -35, -2, -36, 2, 13, 2, -1, 1, -13, 1, -1,
+ 37, 1, -5, 6, 5, -1, 38, -6, -8, 5, 8, -1, 1, 1, -37, -1,
+ 5, 39, -5, -5, 6, -6, -38, -39, -14, 40, 14, 2, 1, 1, -2, -40,
+ -1, -2, 2, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1}
+},{
+ // MapTab1
+ 0, // eob_sym
+ 38, // esc_sym
+ // run table
+ {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 8, 6, 8, 7,
+ 7, 9, 9, 10, 10, 11, 11, 1, 12, 1, 12, 13, 13, 16, 14, 16,
+ 14, 15, 15, 17, 17, 18, 0, 18, 19, 20, 21, 19, 22, 21, 20, 22,
+ 25, 24, 2, 25, 24, 23, 23, 2, 26, 28, 26, 28, 29, 27, 29, 27,
+ 33, 33, 1, 32, 1, 3, 32, 30, 36, 3, 36, 30, 31, 31, 35, 34,
+ 37, 41, 34, 35, 37, 4, 41, 4, 49, 8, 8, 49, 40, 38, 5, 38,
+ 40, 39, 5, 39, 42, 43, 42, 7, 57, 6, 43, 44, 6, 50, 7, 44,
+ 57, 48, 50, 48, 45, 45, 46, 47, 51, 46, 47, 58, 1, 51, 58, 1,
+ 52, 59, 53, 9, 52, 55, 55, 59, 53, 56, 54, 56, 54, 9, 64, 64,
+ 60, 63, 60, 63, 61, 62, 61, 62, 2, 10, 2, 10, 11, 1, 11, 13,
+ 12, 1, 12, 13, 16, 16, 8, 8, 14, 3, 3, 15, 14, 15, 4, 4,
+ 1, 17, 17, 5, 1, 7, 7, 5, 6, 1, 2, 2, 6, 22, 1, 25,
+ 21, 22, 8, 24, 1, 21, 25, 24, 8, 18, 18, 23, 9, 20, 23, 33,
+ 29, 33, 20, 1, 19, 1, 29, 36, 9, 36, 19, 41, 28, 57, 32, 3,
+ 28, 3, 1, 27, 49, 49, 1, 32, 26, 26, 2, 4, 4, 7, 57, 41,
+ 2, 7, 10, 5, 37, 16, 10, 27, 8, 8, 13, 16, 37, 13, 1, 5},
+
+ // value table
+ {0, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1,
+ -1, 1, -1, 1, -1, 1, -1, 2, 1, -2, -1, 1, -1, 1, 1, -1,
+ -1, 1, -1, 1, -1, 1, 0, -1, 1, 1, 1, -1, 1, -1, -1, -1,
+ 1, 1, 2, -1, -1, 1, -1, -2, 1, 1, -1, -1, 1, 1, -1, -1,
+ 1, -1, 3, 1, -3, 2, -1, 1, 1, -2, -1, -1, -1, 1, 1, 1,
+ 1, 1, -1, -1, -1, 2, -1, -2, 1, 2, -2, -1, 1, 1, 2, -1,
+ -1, 1, -2, -1, 1, 1, -1, 2, 1, 2, -1, 1, -2, -1, -2, -1,
+ -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 4, -1, -1, -4,
+ 1, 1, 1, 2, -1, -1, 1, -1, -1, 1, -1, -1, 1, -2, 1, -1,
+ 1, 1, -1, -1, 1, 1, -1, -1, 3, 2, -3, -2, 2, 5, -2, 2,
+ 2, -5, -2, -2, -2, 2, -3, 3, 2, 3, -3, 2, -2, -2, 3, -3,
+ 6, 2, -2, 3, -6, 3, -3, -3, 3, 7, -4, 4, -3, 2, -7, 2,
+ 2, -2, -4, 2, 8, -2, -2, -2, 4, 2, -2, 2, 3, 2, -2, -2,
+ 2, 2, -2, -8, -2, 9, -2, 2, -3, -2, 2, -2, 2, 2, 2, 4,
+ -2, -4, 10, 2, 2, -2, -9, -2, 2, -2, 5, 4, -4, 4, -2, 2,
+ -5, -4, -3, 4, 2, -3, 3, -2, -5, 5, 3, 3, -2, -3, -10, -4}
+},{
+ // MapTab2
+ 2, // eob_sym
+ 11, // esc_sym
+ // run table
+ {1, 1, 0, 2, 2, 1, 1, 3, 3, 4, 4, 0, 1, 1, 5, 5,
+ 2, 2, 6, 6, 7, 7, 1, 8, 1, 8, 3, 3, 9, 9, 1, 2,
+ 2, 1, 4, 10, 4, 10, 11, 11, 1, 5, 12, 12, 1, 5, 13, 13,
+ 3, 3, 6, 6, 2, 2, 14, 14, 16, 16, 15, 7, 15, 8, 8, 7,
+ 1, 1, 17, 17, 4, 4, 1, 1, 18, 18, 2, 2, 5, 5, 25, 3,
+ 9, 3, 25, 9, 19, 24, 19, 24, 1, 21, 20, 1, 21, 22, 20, 22,
+ 23, 23, 8, 6, 33, 6, 8, 33, 7, 7, 26, 26, 1, 32, 1, 32,
+ 28, 4, 28, 10, 29, 27, 27, 10, 41, 4, 29, 2, 2, 41, 36, 31,
+ 49, 31, 34, 30, 34, 36, 30, 35, 1, 49, 11, 5, 35, 11, 1, 3,
+ 3, 5, 37, 37, 8, 40, 8, 40, 12, 12, 42, 42, 1, 38, 16, 57,
+ 1, 6, 16, 39, 38, 6, 7, 7, 13, 13, 39, 43, 2, 43, 57, 2,
+ 50, 9, 44, 9, 50, 4, 15, 48, 44, 4, 1, 15, 48, 14, 14, 1,
+ 45, 45, 8, 3, 5, 8, 51, 47, 3, 46, 46, 47, 5, 51, 1, 17,
+ 17, 58, 1, 58, 2, 52, 52, 2, 53, 7, 59, 6, 6, 56, 53, 55,
+ 7, 55, 1, 54, 59, 56, 54, 10, 1, 10, 4, 60, 1, 60, 8, 4,
+ 8, 64, 64, 61, 1, 63, 3, 63, 62, 61, 5, 11, 5, 3, 11, 62},
+
+ // value table
+ { 1, -1, 0, 1, -1, 2, -2, 1, -1, 1, -1, 0, 3, -3, 1, -1,
+ 2, -2, 1, -1, 1, -1, 4, 1, -4, -1, 2, -2, 1, -1, 5, 3,
+ -3, -5, 2, 1, -2, -1, 1, -1, 6, 2, 1, -1, -6, -2, 1, -1,
+ 3, -3, 2, -2, 4, -4, 1, -1, 1, -1, 1, 2, -1, 2, -2, -2,
+ 7, -7, 1, -1, 3, -3, 8, -8, 1, -1, 5, -5, 3, -3, 1, 4,
+ 2, -4, -1, -2, 1, 1, -1, -1, 9, 1, 1, -9, -1, 1, -1, -1,
+ 1, -1, 3, -3, 1, 3, -3, -1, 3, -3, 1, -1, 10, 1, -10, -1,
+ 1, 4, -1, 2, 1, -1, 1, -2, 1, -4, -1, 6, -6, -1, 1, 1,
+ 1, -1, 1, 1, -1, -1, -1, 1, 11, -1, -2, 4, -1, 2, -11, 5,
+ -5, -4, -1, 1, 4, 1, -4, -1, -2, 2, 1, -1, 12, 1, -2, 1,
+ -12, 4, 2, 1, -1, -4, 4, -4, 2, -2, -1, 1, 7, -1, -1, -7,
+ -1, -3, 1, 3, 1, 5, 2, 1, -1, -5, 13, -2, -1, 2, -2, -13,
+ 1, -1, 5, 6, 5, -5, 1, 1, -6, 1, -1, -1, -5, -1, 14, 2,
+ -2, 1, -14, -1, 8, 1, -1, -8, 1, 5, 1, 5, -5, 1, -1, 1,
+ -5, -1, 15, 1, -1, -1, -1, 3, -15, -3, 6, 1, 16, -1, 6, -6,
+ -6, 1, -1, 1, -16, 1, 7, -1, 1, -1, -6, -3, 6, -7, 3, -1}
+},{
+ // MapTab3
+ 0, // eob_sym
+ 35, // esc_sym
+ // run table
+ {0, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 5, 5, 6, 6, 7,
+ 7, 8, 8, 9, 9, 2, 2, 10, 10, 1, 1, 11, 11, 12, 12, 3,
+ 3, 13, 13, 0, 14, 14, 16, 15, 16, 15, 4, 4, 17, 1, 17, 1,
+ 5, 5, 18, 18, 2, 2, 6, 6, 8, 19, 7, 8, 7, 19, 20, 20,
+ 21, 21, 22, 24, 22, 24, 23, 23, 1, 1, 25, 25, 3, 3, 26, 26,
+ 9, 9, 27, 27, 28, 28, 33, 29, 4, 33, 29, 1, 4, 1, 32, 32,
+ 2, 2, 31, 10, 30, 10, 30, 31, 34, 34, 5, 5, 36, 36, 35, 41,
+ 35, 11, 41, 11, 37, 1, 8, 8, 37, 6, 1, 6, 40, 7, 7, 40,
+ 12, 38, 12, 39, 39, 38, 49, 13, 49, 13, 3, 42, 3, 42, 16, 16,
+ 43, 43, 14, 14, 1, 1, 44, 15, 44, 15, 2, 2, 57, 48, 50, 48,
+ 57, 50, 4, 45, 45, 4, 46, 47, 47, 46, 1, 51, 1, 17, 17, 51,
+ 8, 9, 9, 5, 58, 8, 58, 5, 52, 52, 55, 56, 53, 56, 55, 59,
+ 59, 53, 54, 1, 6, 54, 7, 7, 6, 1, 2, 3, 2, 3, 64, 60,
+ 60, 10, 10, 64, 61, 62, 61, 63, 1, 63, 62, 1, 18, 24, 18, 4,
+ 25, 4, 8, 21, 21, 1, 24, 22, 25, 22, 8, 11, 19, 11, 23, 1,
+ 20, 23, 19, 20, 5, 12, 5, 1, 16, 2, 12, 13, 2, 13, 1, 16},
+
+ // value table
+ { 0, 1, -1, 1, -1, 1, -1, 1, -1, 2, -2, 1, -1, 1, -1, 1,
+ -1, 1, -1, 1, -1, 2, -2, 1, -1, 3, -3, 1, -1, 1, -1, 2,
+ -2, 1, -1, 0, 1, -1, 1, 1, -1, -1, 2, -2, 1, 4, -1, -4,
+ 2, -2, 1, -1, -3, 3, 2, -2, 2, 1, 2, -2, -2, -1, 1, -1,
+ 1, -1, 1, 1, -1, -1, 1, -1, 5, -5, 1, -1, 3, -3, 1, -1,
+ 2, -2, 1, -1, 1, -1, 1, 1, 3, -1, -1, 6, -3, -6, -1, 1,
+ 4, -4, 1, 2, 1, -2, -1, -1, 1, -1, 3, -3, 1, -1, 1, 1,
+ -1, 2, -1, -2, 1, 7, -3, 3, -1, 3, -7, -3, 1, -3, 3, -1,
+ 2, 1, -2, 1, -1, -1, 1, 2, -1, -2, -4, -1, 4, 1, 2, -2,
+ 1, -1, -2, 2, 8, -8, -1, 2, 1, -2, -5, 5, 1, -1, -1, 1,
+ -1, 1, 4, -1, 1, -4, -1, -1, 1, 1, 9, 1, -9, 2, -2, -1,
+ -4, 3, -3, -4, -1, 4, 1, 4, 1, -1, 1, -1, 1, 1, -1, 1,
+ -1, -1, -1, 10, 4, 1, 4, -4, -4, -10, 6, 5, -6, -5, 1, -1,
+ 1, 3, -3, -1, 1, -1, -1, -1, 11, 1, 1, -11, -2, -2, 2, 5,
+ -2, -5, -5, 2, -2, 12, 2, -2, 2, 2, 5, -3, -2, 3, -2, -12,
+ -2, 2, 2, 2, -5, 3, 5, 13, -3, 7, -3, -3, -7, 3, -13, 3}
+},{
+ // MapTab4
+ 0, // eob_sym
+ 34, // esc_sym
+ // run table
+ {0, 1, 1, 1, 2, 2, 1, 3, 3, 1, 1, 1, 4, 4, 1, 5,
+ 2, 1, 5, 2, 1, 1, 6, 6, 1, 1, 1, 1, 1, 7, 3, 1,
+ 2, 3, 0, 1, 2, 7, 1, 1, 1, 8, 1, 1, 8, 1, 1, 1,
+ 9, 1, 9, 1, 2, 1, 1, 2, 1, 1, 10, 4, 1, 10, 1, 4,
+ 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 2, 1, 5, 1, 1, 1,
+ 2, 5, 1, 11, 1, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 2, 1, 6, 1, 6, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 12,
+ 3, 1, 12, 1, 1, 1, 2, 1, 1, 3, 1, 1, 1, 1, 1, 1,
+ 4, 1, 1, 1, 2, 1, 1, 4, 1, 1, 1, 1, 1, 1, 2, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, 5,
+ 1, 1, 1, 1, 1, 7, 1, 7, 1, 1, 2, 3, 1, 1, 1, 1,
+ 5, 1, 1, 1, 1, 1, 1, 2, 13, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 13, 2, 1, 1, 4, 1, 1, 1,
+ 3, 1, 6, 1, 1, 1, 14, 1, 1, 1, 1, 1, 14, 6, 1, 1,
+ 1, 1, 15, 2, 4, 1, 2, 3, 15, 1, 1, 1, 8, 1, 1, 8,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1},
+
+ // value table
+ { 0, 1, -1, 2, 1, -1, -2, 1, -1, 3, -3, 4, 1, -1, -4, 1,
+ 2, 5, -1, -2, -5, 6, 1, -1, -6, 7, -7, 8, -8, 1, 2, 9,
+ 3, -2, 0, -9, -3, -1, 10, -10, 11, 1, -11, 12, -1, -12, 13, -13,
+ 1, 14, -1, -14, 4, 15, -15, -4, 16, -16, 1, 2, 17, -1, -17, -2,
+ 18, -18, 19, -19, 20, 3, -20, 21, -21, -3, 5, 22, 2, -22, -23, 23,
+ -5, -2, 24, 1, -24, -1, 25, -25, 26, -26, -27, 27, 28, 29, -28, -29,
+ 6, 30, 2, -31, -2, -30, 31, -6, -32, 32, 33, -33, 34, -35, -34, 1,
+ 4, -36, -1, 35, 37, 36, 7, -37, 38, -4, -38, 39, 41, 40, -40, -39,
+ 3, 42, -43, -41, -7, -42, 43, -3, 44, -44, 45, -45, 46, 47, 8, -47,
+ -48, -46, 50, -50, 48, 49, 51, -49, 52, -52, 5, -51, -8, -53, 53, 3,
+ -56, 56, 55, 54, -54, 2, 60, -2, -55, 58, 9, -5, 59, 57, -57, -63,
+ -3, -58, -60, -61, 61, -59, -62, -9, 1, 64, 62, 69, -64, 63, 65, -67,
+ -68, 66, -65, 68, -66, -69, 67, -70, -1, 10, 71, -71, 4, 73, 72, 70,
+ 6, -76, -3, 74, -78, -74, 1, 78, 80, -72, -75, 76, -1, 3, -73, 79,
+ 75, 77, 1, 11, -4, -79, -10, -6, -1, -77, -83, -80, 2, 81, -84, -2,
+ 83, -81, 82, -82, 84, -87, -86, 85, -11, -85, 86, -89, 87, -88, 88, 89}
+},{
+ // MapTab5
+ 2, // eob_sym
+ 33, // esc_sym
+ // run table
+ {1, 1, 0, 2, 1, 2, 1, 3, 3, 1, 1, 4, 4, 2, 2, 1,
+ 1, 5, 5, 6, 1, 6, 1, 7, 7, 3, 3, 2, 8, 2, 8, 1,
+ 1, 0, 9, 9, 1, 1, 10, 4, 10, 4, 11, 11, 2, 1, 2, 1,
+ 12, 12, 3, 3, 1, 1, 13, 5, 5, 13, 14, 1, 1, 14, 2, 2,
+ 6, 6, 15, 1, 1, 15, 16, 4, 7, 16, 4, 7, 1, 1, 3, 3,
+ 8, 8, 2, 2, 1, 1, 17, 17, 1, 1, 18, 18, 5, 5, 2, 2,
+ 1, 1, 9, 19, 9, 19, 20, 3, 3, 20, 1, 10, 21, 1, 10, 4,
+ 4, 21, 22, 6, 6, 22, 1, 1, 23, 24, 2, 2, 23, 24, 11, 1,
+ 1, 11, 7, 25, 7, 1, 1, 25, 8, 8, 3, 26, 3, 1, 12, 2,
+ 2, 26, 1, 12, 5, 5, 27, 4, 1, 4, 1, 27, 28, 1, 28, 13,
+ 1, 13, 2, 29, 2, 1, 32, 6, 1, 30, 14, 29, 14, 6, 3, 31,
+ 3, 1, 30, 1, 32, 31, 33, 9, 33, 1, 1, 7, 9, 7, 2, 2,
+ 1, 1, 4, 36, 34, 4, 5, 10, 10, 5, 34, 1, 1, 35, 8, 8,
+ 36, 3, 35, 1, 15, 3, 2, 1, 16, 15, 16, 2, 37, 1, 37, 1,
+ 1, 1, 6, 6, 38, 1, 38, 11, 1, 39, 39, 40, 11, 2, 41, 4,
+ 40, 1, 2, 4, 1, 1, 1, 41, 3, 1, 3, 1, 5, 7, 5, 7},
+
+ // value table
+ { 1, -1, 0, 1, 2, -1, -2, 1, -1, 3, -3, 1, -1, 2, -2, 4,
+ -4, 1, -1, 1, 5, -1, -5, 1, -1, 2, -2, 3, 1, -3, -1, 6,
+ -6, 0, 1, -1, 7, -7, 1, 2, -1, -2, 1, -1, 4, 8, -4, -8,
+ 1, -1, 3, -3, 9, -9, 1, 2, -2, -1, 1, 10, -10, -1, 5, -5,
+ 2, -2, 1, 11, -11, -1, 1, 3, 2, -1, -3, -2, 12, -12, 4, -4,
+ 2, -2, -6, 6, 13, -13, 1, -1, 14, -14, 1, -1, 3, -3, 7, -7,
+ 15, -15, 2, 1, -2, -1, 1, 5, -5, -1, -16, 2, 1, 16, -2, 4,
+ -4, -1, 1, 3, -3, -1, 17, -17, 1, 1, -8, 8, -1, -1, 2, 18,
+ -18, -2, 3, 1, -3, 19, -19, -1, 3, -3, 6, 1, -6, 20, 2, 9,
+ -9, -1, -20, -2, 4, -4, 1, -5, 21, 5, -21, -1, 1, -22, -1, 2,
+ 22, -2, 10, 1, -10, 23, 1, 4, -23, 1, 2, -1, -2, -4, -7, 1,
+ 7, -24, -1, 24, -1, -1, 1, 3, -1, -25, 25, 4, -3, -4, 11, -11,
+ 26, -26, 6, 1, 1, -6, -5, -3, 3, 5, -1, -27, 27, 1, 4, -4,
+ -1, -8, -1, 28, 2, 8, -12, -28, -2, -2, 2, 12, -1, 29, 1, -29,
+ 30, -30, 5, -5, 1, -31, -1, 3, 31, -1, 1, 1, -3, -13, 1, -7,
+ -1, -32, 13, 7, 32, 33, -33, -1, -9, -34, 9, 34, -6, 5, 6, -5}
+},{
+ // MapTab6
+ 2, // eob_sym
+ 13, // esc_sym
+ // run table
+ {1, 1, 0, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 0, 2, 2,
+ 4, 1, 4, 1, 1, 1, 5, 5, 1, 1, 6, 6, 2, 2, 1, 1,
+ 3, 3, 7, 7, 1, 1, 8, 8, 1, 1, 2, 2, 1, 9, 1, 9,
+ 4, 4, 10, 1, 1, 10, 1, 1, 11, 11, 3, 3, 1, 2, 1, 2,
+ 1, 1, 12, 12, 5, 5, 1, 1, 13, 1, 1, 13, 2, 2, 1, 1,
+ 6, 6, 1, 1, 4, 14, 4, 14, 3, 1, 3, 1, 1, 1, 15, 7,
+ 15, 2, 2, 7, 1, 1, 1, 8, 1, 8, 16, 16, 1, 1, 1, 1,
+ 2, 1, 1, 2, 1, 1, 3, 5, 5, 3, 4, 1, 1, 4, 1, 1,
+ 17, 17, 9, 1, 1, 9, 2, 2, 1, 1, 10, 10, 1, 6, 1, 1,
+ 6, 18, 1, 1, 18, 1, 1, 1, 2, 2, 3, 1, 3, 1, 1, 1,
+ 4, 1, 19, 1, 19, 7, 1, 1, 20, 1, 4, 20, 1, 7, 11, 2,
+ 1, 11, 21, 2, 8, 5, 1, 8, 1, 5, 21, 1, 1, 1, 22, 1,
+ 1, 22, 1, 1, 3, 3, 1, 23, 2, 12, 24, 1, 1, 2, 1, 1,
+ 12, 23, 1, 1, 24, 1, 1, 1, 4, 1, 1, 1, 2, 1, 6, 6,
+ 4, 2, 1, 1, 1, 1, 1, 1, 1, 14, 13, 3, 1, 25, 9, 25,
+ 14, 1, 9, 3, 13, 1, 1, 1, 1, 1, 10, 1, 1, 2, 10, 2},
+
+ // value table
+ {-20, -1, 0, 2, -2, 1, -1, 3, -3, 1, -1, 4, -4, 0, 2, -2,
+ 1, 5, -1, -5, 6, -6, 1, -1, 7, -7, 1, -1, 3, -3, 8, -8,
+ 2, -2, 1, -1, 9, -9, 1, -1, 10, -10, 4, -4, 11, 1, -11, -1,
+ 2, -2, 1, 12, -12, -1, 13, -13, 1, -1, 3, -3, 14, 5, -14, -5,
+ -15, 15, -1, 1, 2, -2, 16, -16, 1, 17, -17, -1, 6, -6, 18, -18,
+ 2, -2, -19, 19, -3, 1, 3, -1, 4, 20, -4, 1, -21, 21, 1, 2,
+ -1, -7, 7, -2, 22, -22, 23, 2, -23, -2, 1, -1, -24, 24, -25, 25,
+ -8, -26, 26, 8, -27, 27, 5, 3, -3, -5, -4, 28, -28, 4, 29, -29,
+ 1, -1, -2, -30, 30, 2, 9, -9, -31, 31, 2, -2, -32, 3, 32, -33,
+ -3, 1, 33, -34, -1, 34, -35, 35, -10, 10, -6, 36, 6, -36, 37, -37,
+ -5, 38, 1, -38, -1, 3, 39, -39, -1, 40, 5, 1, -40, -3, 2, -11,
+ -41, -2, 1, 11, -3, -4, 41, 3, 42, 4, -1, -43, -42, 43, 1, -44,
+ 45, -1, 44, -45, -7, 7, -46, 1, -12, 2, 1, -47, 46, 12, 47, 48,
+ -2, -1, -48, 49, -1, -50, -49, 50, -6, -51, 51, 52, -13, 53, -4, 4,
+ 6, 13, -53, -52, -54, 55, 54, -55, -56, -2, 2, -8, 56, 1, -3, -1,
+ 2, 58, 3, 8, -2, 57, -58, -60, -59, -57, -3, 60, 59, -14, 3, 14}
+},{
+ // MapTab7
+ 2, // eob_sym
+ 38, // esc_sym
+ // run table
+ {1, 1, 0, 2, 2, 1, 1, 3, 3, 4, 4, 5, 5, 1, 1, 6,
+ 6, 2, 2, 7, 7, 8, 8, 1, 1, 3, 3, 9, 9, 10, 10, 1,
+ 1, 2, 2, 4, 4, 11, 0, 11, 12, 12, 13, 13, 1, 1, 5, 5,
+ 14, 14, 15, 16, 15, 16, 3, 3, 1, 6, 1, 6, 2, 2, 7, 7,
+ 8, 8, 17, 17, 1, 1, 4, 4, 18, 18, 2, 2, 1, 19, 1, 20,
+ 19, 20, 21, 21, 3, 3, 22, 22, 5, 5, 24, 1, 1, 23, 9, 23,
+ 24, 9, 2, 2, 10, 1, 1, 10, 6, 6, 25, 4, 4, 25, 7, 7,
+ 26, 8, 1, 8, 3, 1, 26, 3, 11, 11, 27, 27, 2, 28, 1, 2,
+ 28, 1, 12, 12, 5, 5, 29, 13, 13, 29, 32, 1, 1, 33, 31, 30,
+ 32, 4, 30, 33, 4, 31, 3, 14, 1, 1, 3, 34, 34, 2, 2, 14,
+ 6, 6, 35, 36, 35, 36, 1, 15, 1, 16, 16, 15, 7, 9, 7, 9,
+ 37, 8, 8, 37, 1, 1, 39, 2, 38, 39, 2, 40, 5, 38, 40, 5,
+ 3, 3, 4, 4, 10, 10, 1, 1, 1, 1, 41, 2, 41, 2, 6, 6,
+ 1, 1, 11, 42, 11, 43, 3, 42, 3, 17, 4, 43, 1, 17, 7, 1,
+ 8, 44, 4, 7, 44, 5, 8, 2, 5, 1, 2, 48, 45, 1, 12, 45,
+ 12, 48, 13, 13, 1, 9, 9, 46, 1, 46, 47, 47, 49, 18, 18, 49},
+
+ // value table
+ { 1, -1, 0, 1, -1, 2, -2, 1, -1, 1, -1, 1, -1, 3, -3, 1,
+ -1, -2, 2, 1, -1, 1, -1, 4, -4, -2, 2, 1, -1, 1, -1, 5,
+ -5, -3, 3, 2, -2, 1, 0, -1, 1, -1, 1, -1, 6, -6, 2, -2,
+ 1, -1, 1, 1, -1, -1, -3, 3, 7, 2, -7, -2, -4, 4, 2, -2,
+ 2, -2, 1, -1, 8, -8, 3, -3, 1, -1, -5, 5, 9, 1, -9, 1,
+ -1, -1, 1, -1, -4, 4, 1, -1, 3, -3, 1, -10, 10, 1, 2, -1,
+ -1, -2, 6, -6, 2, 11, -11, -2, 3, -3, 1, -4, 4, -1, 3, -3,
+ 1, 3, 12, -3, -5, -12, -1, 5, 2, -2, 1, -1, -7, 1, 13, 7,
+ -1, -13, 2, -2, 4, -4, 1, 2, -2, -1, 1, 14, -14, 1, 1, 1,
+ -1, -5, -1, -1, 5, -1, -6, 2, -15, 15, 6, 1, -1, -8, 8, -2,
+ -4, 4, 1, 1, -1, -1, 16, 2, -16, -2, 2, -2, 4, 3, -4, -3,
+ -1, -4, 4, 1, -17, 17, -1, -9, 1, 1, 9, 1, -5, -1, -1, 5,
+ -7, 7, 6, -6, 3, -3, 18, -18, 19, -19, 1, -10, -1, 10, -5, 5,
+ 20, -20, -3, 1, 3, 1, 8, -1, -8, 2, 7, -1, -21, -2, 5, 21,
+ 5, -1, -7, -5, 1, -6, -5, -11, 6, 22, 11, 1, 1, -22, -3, -1,
+ 3, -1, 3, -3, -23, 4, -4, 1, 23, -1, 1, -1, 1, -2, 2, -1}
+},{
+ // MapTab8
+ 4, // eob_sym
+ 11, // esc_sym
+ // run table
+ {1, 1, 1, 1, 0, 2, 2, 1, 1, 3, 3, 0, 1, 1, 2, 2,
+ 4, 4, 1, 1, 5, 5, 1, 1, 2, 2, 3, 3, 6, 6, 1, 1,
+ 7, 7, 8, 1, 8, 2, 2, 1, 4, 4, 1, 3, 1, 3, 9, 9,
+ 2, 2, 1, 5, 1, 5, 10, 10, 1, 1, 11, 11, 3, 6, 3, 4,
+ 4, 6, 2, 2, 1, 12, 1, 12, 7, 13, 7, 13, 1, 1, 8, 8,
+ 2, 2, 14, 14, 16, 15, 16, 5, 5, 1, 3, 15, 1, 3, 4, 4,
+ 1, 1, 17, 17, 2, 2, 6, 6, 1, 18, 1, 18, 22, 21, 22, 21,
+ 25, 24, 25, 19, 9, 20, 9, 23, 19, 24, 20, 3, 23, 7, 3, 1,
+ 1, 7, 28, 26, 29, 5, 28, 26, 5, 8, 29, 4, 8, 27, 2, 2,
+ 4, 27, 1, 1, 10, 36, 10, 33, 33, 36, 30, 1, 32, 32, 1, 30,
+ 6, 31, 31, 35, 3, 6, 11, 11, 3, 2, 35, 2, 34, 1, 34, 1,
+ 37, 37, 12, 7, 12, 5, 41, 5, 4, 7, 1, 8, 13, 4, 1, 41,
+ 13, 38, 8, 38, 9, 1, 40, 40, 9, 1, 39, 2, 2, 49, 39, 42,
+ 3, 3, 14, 16, 49, 14, 16, 42, 43, 43, 6, 6, 15, 1, 1, 15,
+ 44, 44, 1, 1, 50, 48, 4, 5, 4, 7, 5, 2, 10, 10, 48, 7,
+ 50, 45, 2, 1, 45, 8, 8, 1, 46, 46, 3, 47, 47, 3, 1, 1},
+
+ // value table
+ { 1, -1, 2, -2, 0, 1, -1, 3, -3, 1, -1, 0, 4, -4, 2, -2,
+ 1, -1, 5, -5, 1, -1, 6, -6, 3, -3, 2, -2, 1, -1, 7, -7,
+ 1, -1, 1, 8, -1, 4, -4, -8, 2, -2, 9, 3, -9, -3, 1, -1,
+ 5, -5, 10, 2, -10, -2, 1, -1, 11, -11, 1, -1, -4, 2, 4, 3,
+ -3, -2, 6, -6, 12, 1, -12, -1, 2, 1, -2, -1, 13, -13, 2, -2,
+ 7, -7, 1, -1, 1, 1, -1, 3, -3, 14, 5, -1, -14, -5, 4, -4,
+ 15, -15, 1, -1, 8, -8, -3, 3, 16, 1, -16, -1, 1, 1, -1, -1,
+ 1, 1, -1, 1, 2, 1, -2, 1, -1, -1, -1, 6, -1, 3, -6, 17,
+ -17, -3, 1, 1, 1, 4, -1, -1, -4, 3, -1, 5, -3, -1, -9, 9,
+ -5, 1, 18, -18, 2, 1, -2, 1, -1, -1, 1, 19, -1, 1, -19, -1,
+ 4, 1, -1, 1, 7, -4, -2, 2, -7, 10, -1, -10, 1, 20, -1, -20,
+ 1, -1, 2, 4, -2, 5, 1, -5, 6, -4, 21, 4, 2, -6, -21, -1,
+ -2, 1, -4, -1, -3, 22, -1, 1, 3, -22, -1, 11, -11, 1, 1, 1,
+ 8, -8, 2, 2, -1, -2, -2, -1, 1, -1, -5, 5, 2, 23, -23, -2,
+ 1, -1, 24, -24, -1, -1, 7, 6, -7, 5, -6, 12, -3, 3, 1, -5,
+ 1, 1, -12, 25, -1, -5, 5, -25, -1, 1, 9, 1, -1, -9, 26, -26}
}
+};
+
} // End of namespace Indeo
} // End of namespace Image
diff --git a/image/codecs/indeo/indeo.h b/image/codecs/indeo/indeo.h
index 2103ebe..f49a9b7 100644
--- a/image/codecs/indeo/indeo.h
+++ b/image/codecs/indeo/indeo.h
@@ -146,8 +146,6 @@ struct RVMapDesc {
uint8 esc_sym; ///< escape symbol
uint8 runtab[256];
int8 valtab[256];
-
- RVMapDesc();
};
/**
@@ -369,6 +367,11 @@ struct IVI45DecContext {
int got_p_frame;
IVI45DecContext();
+private:
+ /**
+ * Initial Run-value (RLE) tables.
+ */
+ static const RVMapDesc _ff_ivi_rvmap_tabs[9];
};
class IndeoDecoderBase : public Codec {
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index 936d4b0..11a6577 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -42,6 +42,9 @@ namespace Image {
Indeo4Decoder::Indeo4Decoder(uint16 width, uint16 height) : IndeoDecoderBase(width, height) {
_ctx.is_indeo4 = true;
+ _ctx.ref_buf = 1;
+ _ctx.b_ref_buf = 3;
+ _ctx.p_frame = new AVFrame();
}
bool Indeo4Decoder::isIndeo4(Common::SeekableReadStream &stream) {
@@ -66,15 +69,24 @@ const Graphics::Surface *Indeo4Decoder::decodeFrame(Common::SeekableReadStream &
if (!isIndeo4(stream))
return nullptr;
- // Set up the GetBits instance for reading the stream
- _ctx.gb = new GetBits(stream);
+ // Set up the frame data buffer
+ byte *frameData = new byte[stream.size()];
+ stream.read(frameData, stream.size());
+ _ctx.frame_data = frameData;
+ _ctx.frame_size = stream.size();
+
+ // Set up the GetBits instance for reading the data
+ _ctx.gb = new GetBits(_ctx.frame_data, _ctx.frame_size * 8);
// Decode the frame
int err = decodeIndeoFrame();
- // Free the bit reader
+ // Free the bit reader and frame buffer
delete _ctx.gb;
_ctx.gb = nullptr;
+ delete[] frameData;
+ _ctx.frame_data = nullptr;
+ _ctx.frame_size = 0;
return (err < 0) ? nullptr : &_surface->rawSurface();
}
Commit: 0910e642a229d8f477f35943c6845f3b5a4dea42
https://github.com/scummvm/scummvm/commit/0910e642a229d8f477f35943c6845f3b5a4dea42
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T10:08:20-04:00
Commit Message:
IMAGE: Fix decoding tile data in Indeo4 decoder
Changed paths:
image/codecs/indeo/get_bits.cpp
image/codecs/indeo/indeo.cpp
image/codecs/indeo/indeo.h
image/codecs/indeo4.cpp
diff --git a/image/codecs/indeo/get_bits.cpp b/image/codecs/indeo/get_bits.cpp
index f165329..60c82c4 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 83cd9fd..31e8e98 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 f49a9b7..cd6920d 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 11a6577..79874cd 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
Commit: 4e9933d3c99d6367b04f07d2bd7499f1de999b57
https://github.com/scummvm/scummvm/commit/4e9933d3c99d6367b04f07d2bd7499f1de999b57
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T10:08:22-04:00
Commit Message:
IMAGE: Indeo4 decoder is now working
Changed paths:
image/codecs/indeo/indeo.cpp
image/codecs/indeo/indeo.h
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index 31e8e98..d6fdfd1 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -32,6 +32,7 @@
#include "image/codecs/indeo/indeo.h"
#include "image/codecs/indeo/indeo_dsp.h"
#include "image/codecs/indeo/mem.h"
+#include "graphics/yuv_to_rgb.h"
#include "common/system.h"
#include "common/algorithm.h"
#include "common/textconsole.h"
@@ -410,8 +411,31 @@ void IVIPlaneDesc::ivi_free_buffers(IVIPlaneDesc *planes) {
/*------------------------------------------------------------------------*/
AVFrame::AVFrame() {
- Common::fill(&data[0], &data[AV_NUM_DATA_POINTERS], (uint8 *)nullptr);
- Common::fill(&linesize[0], &linesize[AV_NUM_DATA_POINTERS], 0);
+ Common::fill(&_data[0], &_data[AV_NUM_DATA_POINTERS], (uint8 *)nullptr);
+ Common::fill(&_linesize[0], &_linesize[AV_NUM_DATA_POINTERS], 0);
+}
+
+int AVFrame::ff_set_dimensions(uint16 width, uint16 height) {
+ _width = width;
+ _height = height;
+ _linesize[0] = _linesize[1] = _linesize[2] = width;
+
+ return 0;
+}
+
+int AVFrame::ff_get_buffer(int flags) {
+ av_frame_free();
+ _data[0] = (uint8 *)av_mallocz(_width * _height);
+ _data[1] = (uint8 *)av_mallocz(_width * _height);
+ _data[2] = (uint8 *)av_mallocz(_width * _height);
+
+ return 0;
+}
+
+void AVFrame::av_frame_free() {
+ av_freep(&_data[0]);
+ av_freep(&_data[1]);
+ av_freep(&_data[2]);
}
/*------------------------------------------------------------------------*/
@@ -444,8 +468,10 @@ IVI45DecContext::IVI45DecContext() : gb(nullptr), frame_num(0), frame_type(0),
IndeoDecoderBase::IndeoDecoderBase(uint16 width, uint16 height) : Codec() {
_pixelFormat = g_system->getScreenFormat();
+ assert(_pixelFormat.bytesPerPixel > 1);
_surface = new Graphics::ManagedSurface();
_surface->create(width, height, _pixelFormat);
+ _surface->fillRect(Common::Rect(0, 0, width, height), 0);
_ctx.b_ref_buf = 3; // buffer 2 is used for scalability mode
}
@@ -518,24 +544,25 @@ int IndeoDecoderBase::decodeIndeoFrame() {
if (!is_nonnull_frame())
return 0;
- result = ff_set_dimensions(_ctx.planes[0].width, _ctx.planes[0].height);
+ assert(_ctx.planes[0].width <= _surface->w && _ctx.planes[0].height <= _surface->h);
+ result = frame->ff_set_dimensions(_ctx.planes[0].width, _ctx.planes[0].height);
if (result < 0)
return result;
- if ((result = ff_get_buffer(frame, 0)) < 0)
+ if ((result = frame->ff_get_buffer(0)) < 0)
return result;
if (_ctx.is_scalable) {
if (_ctx.is_indeo4)
- ff_ivi_recompose_haar(&_ctx.planes[0], frame->data[0], frame->linesize[0]);
+ ff_ivi_recompose_haar(&_ctx.planes[0], frame->_data[0], frame->_linesize[0]);
else
- ff_ivi_recompose53(&_ctx.planes[0], frame->data[0], frame->linesize[0]);
+ ff_ivi_recompose53(&_ctx.planes[0], frame->_data[0], frame->_linesize[0]);
} else {
- ivi_output_plane(&_ctx.planes[0], frame->data[0], frame->linesize[0]);
+ ivi_output_plane(&_ctx.planes[0], frame->_data[0], frame->_linesize[0]);
}
- ivi_output_plane(&_ctx.planes[2], frame->data[1], frame->linesize[1]);
- ivi_output_plane(&_ctx.planes[1], frame->data[2], frame->linesize[2]);
+ ivi_output_plane(&_ctx.planes[2], frame->_data[1], frame->_linesize[1]);
+ ivi_output_plane(&_ctx.planes[1], frame->_data[2], frame->_linesize[2]);
// If the bidirectional mode is enabled, next I and the following P
// frame will be sent together. Unfortunately the approach below seems
@@ -557,6 +584,15 @@ int IndeoDecoderBase::decodeIndeoFrame() {
}
}
+ // Merge the planes into the final surface
+ Graphics::Surface s = _surface->getSubArea(Common::Rect(0, 0, _surface->w, _surface->h));
+ YUVToRGBMan.convert410(&s, Graphics::YUVToRGBManager::kScaleITU,
+ frame->_data[0], frame->_data[1], frame->_data[2], frame->_width, frame->_height,
+ frame->_width, frame->_width);
+
+ // Free the now un-needed frame data
+ frame->av_frame_free();
+
return 0;
}
@@ -667,20 +703,6 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
return result;
}
-int IndeoDecoderBase::ff_set_dimensions(uint16 width, uint16 height) {
- if (_surface->w != width || _surface->h != height)
- _surface->create(width, height);
-
- return 0;
-}
-
-int IndeoDecoderBase::ff_get_buffer(AVFrame *frame, int flags) {
- frame->data[0] = (uint8 *)_surface->getBasePtr(0, 0);
- frame->linesize[0] = _surface->pitch;
-
- return 0;
-}
-
void IndeoDecoderBase::ff_ivi_recompose_haar(const IVIPlaneDesc *plane,
uint8 *dst, const int dst_pitch) {
int x, y, indx, b0, b1, b2, b3, p0, p1, p2, p3;
diff --git a/image/codecs/indeo/indeo.h b/image/codecs/indeo/indeo.h
index cd6920d..d980120 100644
--- a/image/codecs/indeo/indeo.h
+++ b/image/codecs/indeo/indeo.h
@@ -277,7 +277,12 @@ struct IVIPlaneDesc {
};
struct AVFrame {
-#define AV_NUM_DATA_POINTERS 8
+ /**
+ * Dimensions
+ */
+ int _width, _height;
+
+#define AV_NUM_DATA_POINTERS 3
/**
* pointer to the picture/channel planes.
* This might be different from the first allocated byte
@@ -290,7 +295,7 @@ struct AVFrame {
* NOTE: Except for hwaccel formats, pointers not needed by the format
* MUST be set to NULL.
*/
- uint8 *data[AV_NUM_DATA_POINTERS];
+ uint8 *_data[AV_NUM_DATA_POINTERS];
/**
* For video, size in bytes of each picture line.
@@ -307,9 +312,32 @@ struct AVFrame {
* @note The linesize may be larger than the size of usable data -- there
* may be extra padding present for performance reasons.
*/
- int linesize[AV_NUM_DATA_POINTERS];
+ int _linesize[AV_NUM_DATA_POINTERS];
+ /**
+ * Constructor
+ */
AVFrame();
+
+ /**
+ * Destructor
+ */
+ ~AVFrame() { av_frame_free(); }
+
+ /**
+ * Sets the frame dimensions
+ */
+ int ff_set_dimensions(uint16 width, uint16 height);
+
+ /**
+ * Get a buffer for a frame
+ */
+ int ff_get_buffer(int flags);
+
+ /**
+ * Frees any data loaded for the frame
+ */
+ void av_frame_free();
};
struct IVI45DecContext {
@@ -389,18 +417,6 @@ private:
int decode_band(IVIBandDesc *band);
/**
- * Sets the frame dimensions
- */
- int ff_set_dimensions(uint16 width, uint16 height);
-
- /**
- * Get a buffer for a frame. This is a wrapper around
- * AVCodecContext.get_buffer() and should be used instead calling get_buffer()
- * directly.
- */
- int ff_get_buffer(AVFrame *frame, int flags);
-
- /**
* Haar wavelet recomposition filter for Indeo 4
*
* @param[in] plane pointer to the descriptor of the plane being processed
Commit: a6ffef9e26a10ddd23965fe2f6b5a7e7965fb22e
https://github.com/scummvm/scummvm/commit/a6ffef9e26a10ddd23965fe2f6b5a7e7965fb22e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T10:08:24-04:00
Commit Message:
IMAGE: Remove green lines from Indeo4 decoder
Changed paths:
image/codecs/indeo/indeo.cpp
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index d6fdfd1..69b9f42 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -425,9 +425,15 @@ int AVFrame::ff_set_dimensions(uint16 width, uint16 height) {
int AVFrame::ff_get_buffer(int flags) {
av_frame_free();
+
+ // Luminance channel
_data[0] = (uint8 *)av_mallocz(_width * _height);
- _data[1] = (uint8 *)av_mallocz(_width * _height);
- _data[2] = (uint8 *)av_mallocz(_width * _height);
+
+ // UV Chroma Channels
+ _data[1] = (uint8 *)av_malloc(_width * _height);
+ _data[2] = (uint8 *)av_malloc(_width * _height);
+ Common::fill(_data[1], _data[1] + _width * _height, 0x80);
+ Common::fill(_data[2], _data[2] + _width * _height, 0x80);
return 0;
}
Commit: 9c7b9e166746a903dc0b7e87967ec257967e1359
https://github.com/scummvm/scummvm/commit/9c7b9e166746a903dc0b7e87967ec257967e1359
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T10:43:23-04:00
Commit Message:
IMAGE: Compilation fixes for Indeo4 decoder
Changed paths:
image/codecs/indeo/get_bits.cpp
image/codecs/indeo/indeo.cpp
image/codecs/indeo/indeo.h
image/codecs/indeo/mem.cpp
image/codecs/indeo/mem.h
image/codecs/indeo4.cpp
diff --git a/image/codecs/indeo/get_bits.cpp b/image/codecs/indeo/get_bits.cpp
index 60c82c4..ade4baa 100644
--- a/image/codecs/indeo/get_bits.cpp
+++ b/image/codecs/indeo/get_bits.cpp
@@ -21,6 +21,7 @@
*/
#include "image/codecs/indeo/get_bits.h"
+#include "image/codecs/indeo/mem.h"
#include "common/algorithm.h"
#include "common/endian.h"
#include "common/textconsole.h"
@@ -158,7 +159,7 @@ static uint zeroExtend(uint val, uint bits) {
}
GetBits::GetBits(const byte *buffer, size_t totalBits) {
- assert(buffer && totalBits < (INT_MAX - 7));
+ assert(buffer && totalBits < (MAX_INTEGER - 7));
_buffer = buffer;
_sizeInBits = totalBits;
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index 69b9f42..2c11a09 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -1304,7 +1304,7 @@ int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
col_flags[pos & col_mask] |= !!val;
}
- if (scan_pos < 0 || scan_pos >= num_coeffs && sym != rvmap->eob_sym)
+ if (scan_pos < 0 || (scan_pos >= num_coeffs && sym != rvmap->eob_sym))
return -1; // corrupt block data
// undoing DC coeff prediction for intra-blocks
@@ -1348,7 +1348,7 @@ int IndeoDecoderBase::ivi_dc_transform(IVIBandDesc *band, int *prev_dc,
/*------------------------------------------------------------------------*/
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) {
- if (((w + 128) * (uint64)(h + 128)) < (INT_MAX / 8))
+ if (((w + 128) * (uint64)(h + 128)) < (MAX_INTEGER / 8))
return 0;
error("Picture size %ux%u is invalid", w, h);
diff --git a/image/codecs/indeo/indeo.h b/image/codecs/indeo/indeo.h
index d980120..a786995 100644
--- a/image/codecs/indeo/indeo.h
+++ b/image/codecs/indeo/indeo.h
@@ -113,7 +113,7 @@ struct IVIHuffDesc {
void ivi_huff_desc_copy(const IVIHuffDesc *src);
};
-class IVI45DecContext;
+struct IVI45DecContext;
/**
* macroblock/block huffman table descriptor
@@ -341,7 +341,7 @@ struct AVFrame {
};
struct IVI45DecContext {
- friend class IVIHuffTab;
+ friend struct IVIHuffTab;
private:
VLC_TYPE table_data[8192 * 16][2];
VLC ivi_mb_vlc_tabs[8]; ///< static macroblock Huffman tables
diff --git a/image/codecs/indeo/mem.cpp b/image/codecs/indeo/mem.cpp
index 88085ae..9987415 100644
--- a/image/codecs/indeo/mem.cpp
+++ b/image/codecs/indeo/mem.cpp
@@ -85,13 +85,13 @@ void *av_mallocz(size_t size) {
}
void *av_malloc_array(size_t nmemb, size_t size) {
- if (!size || nmemb >= INT_MAX / size)
+ if (!size || nmemb >= MAX_INTEGER / size)
return nullptr;
return malloc(nmemb * size);
}
void *av_mallocz_array(size_t nmemb, size_t size) {
- if (!size || nmemb >= INT_MAX / size)
+ if (!size || nmemb >= MAX_INTEGER / size)
return NULL;
return av_mallocz(nmemb * size);
diff --git a/image/codecs/indeo/mem.h b/image/codecs/indeo/mem.h
index d3755d6..cc927e6 100644
--- a/image/codecs/indeo/mem.h
+++ b/image/codecs/indeo/mem.h
@@ -38,6 +38,7 @@ namespace Indeo {
#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
/**
* Allocate a memory block with alignment suitable for all memory accesses
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index 79874cd..7e0a451 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -317,7 +317,7 @@ int Indeo4Decoder::decode_band_hdr(IVIBandDesc *band) {
if (!_ctx.gb->getBits1() || _ctx.frame_type == IVI4_FRAMETYPE_INTRA) {
transform_id = _ctx.gb->getBits(5);
- if (transform_id >= FF_ARRAY_ELEMS(_transforms) ||
+ if ((uint)transform_id >= FF_ARRAY_ELEMS(_transforms) ||
!_transforms[transform_id].inv_trans) {
warning("Transform %d", transform_id);
return -3;
@@ -372,7 +372,7 @@ int Indeo4Decoder::decode_band_hdr(IVIBandDesc *band) {
warning("Custom quant matrix encountered!");
return -1;
}
- if (quant_mat >= FF_ARRAY_ELEMS(_quant_index_to_tab)) {
+ if ((uint)quant_mat >= FF_ARRAY_ELEMS(_quant_index_to_tab)) {
warning("Quantization matrix %d", quant_mat);
return -1;
}
@@ -523,8 +523,7 @@ int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
mb->q_delta = 0;
if (band->inherit_qdelta) {
if (ref_mb) mb->q_delta = ref_mb->q_delta;
- }
- else if (mb->cbp || (!band->plane && !band->band_num &&
+ } else if (mb->cbp || (!band->plane && !band->band_num &&
_ctx.in_q)) {
mb->q_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table,
IVI_VLC_BITS, 1);
@@ -535,16 +534,16 @@ int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
mb->mv_x = mb->mv_y = 0; // there is no motion vector in intra-macroblocks
} else {
if (band->inherit_mv) {
- if (ref_mb)
+ if (ref_mb) {
// motion vector inheritance
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
- }
- else {
+ } else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
}
+ }
} else {
// decode motion vector deltas
mv_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table,
Commit: bd010bc79f6a56b51c1414a8cafc64bc248496fe
https://github.com/scummvm/scummvm/commit/bd010bc79f6a56b51c1414a8cafc64bc248496fe
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T11:16:07-04:00
Commit Message:
COMMON: Converted Common::BitStream to use DisposeAfterUse
Changed paths:
common/bitstream.h
engines/macventure/text.cpp
video/bink_decoder.cpp
video/smk_decoder.cpp
diff --git a/common/bitstream.h b/common/bitstream.h
index b789f2a..325118b 100644
--- a/common/bitstream.h
+++ b/common/bitstream.h
@@ -28,6 +28,7 @@
#include "common/scummsys.h"
#include "common/textconsole.h"
#include "common/stream.h"
+#include "common/types.h"
namespace Common {
@@ -88,8 +89,8 @@ protected:
template<int valueBits, bool isLE, bool isMSB2LSB>
class BitStreamImpl : public BitStream {
private:
- SeekableReadStream *_stream; ///< The input stream.
- bool _disposeAfterUse; ///< Should we delete the stream on destruction?
+ SeekableReadStream *_stream; ///< The input stream.
+ DisposeAfterUse::Flag _disposeAfterUse; ///< Should we delete the stream on destruction?
uint32 _value; ///< Current value.
uint8 _inValue; ///< Position within the current value.
@@ -132,7 +133,7 @@ private:
public:
/** Create a bit stream using this input data stream and optionally delete it on destruction. */
- BitStreamImpl(SeekableReadStream *stream, bool disposeAfterUse = false) :
+ BitStreamImpl(SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::NO) :
_stream(stream), _disposeAfterUse(disposeAfterUse), _value(0), _inValue(0) {
if ((valueBits != 8) && (valueBits != 16) && (valueBits != 32))
@@ -141,14 +142,14 @@ public:
/** Create a bit stream using this input data stream. */
BitStreamImpl(SeekableReadStream &stream) :
- _stream(&stream), _disposeAfterUse(false), _value(0), _inValue(0) {
+ _stream(&stream), _disposeAfterUse(DisposeAfterUse::NO), _value(0), _inValue(0) {
if ((valueBits != 8) && (valueBits != 16) && (valueBits != 32))
error("BitStreamImpl: Invalid memory layout %d, %d, %d", valueBits, isLE, isMSB2LSB);
}
~BitStreamImpl() {
- if (_disposeAfterUse)
+ if (_disposeAfterUse == DisposeAfterUse::YES)
delete _stream;
}
diff --git a/engines/macventure/text.cpp b/engines/macventure/text.cpp
index b4d67a1..d8e18ff 100644
--- a/engines/macventure/text.cpp
+++ b/engines/macventure/text.cpp
@@ -50,7 +50,7 @@ TextAsset::TextAsset(MacVentureEngine *engine, ObjID objid, ObjID source, ObjID
void TextAsset::decodeOld() {
Common::SeekableReadStream *res = _container->getItem(_id);
uint16 strLen = res->readUint16BE();
- Common::BitStream32BELSB stream(res, true);
+ Common::BitStream32BELSB stream(res, DisposeAfterUse::YES);
char *str = new char[strLen + 1];
bool lowercase = false;
char c;
@@ -114,7 +114,7 @@ void TextAsset::decodeOld() {
void TextAsset::decodeHuffman() {
_decoded = Common::String("");
Common::SeekableReadStream *res = _container->getItem(_id);
- Common::BitStream8MSB stream(res, true);
+ Common::BitStream8MSB stream(res, DisposeAfterUse::YES);
uint16 strLen = 0;
if (stream.getBit()) {
strLen = stream.getBits(15);
diff --git a/video/bink_decoder.cpp b/video/bink_decoder.cpp
index a228377..cf37e0f 100644
--- a/video/bink_decoder.cpp
+++ b/video/bink_decoder.cpp
@@ -187,7 +187,7 @@ void BinkDecoder::readNextPacket() {
audio.sampleCount = _bink->readUint32LE() / (2 * audio.channels);
audio.bits = new Common::BitStream32LELSB(new Common::SeekableSubReadStream(_bink,
- audioPacketStart + 4, audioPacketEnd), true);
+ audioPacketStart + 4, audioPacketEnd), DisposeAfterUse::YES);
audioTrack->decodePacket();
@@ -204,7 +204,7 @@ void BinkDecoder::readNextPacket() {
uint32 videoPacketEnd = _bink->pos() + frameSize;
frame.bits = new Common::BitStream32LELSB(new Common::SeekableSubReadStream(_bink,
- videoPacketStart, videoPacketEnd), true);
+ videoPacketStart, videoPacketEnd), DisposeAfterUse::YES);
videoTrack->decodePacket(frame);
diff --git a/video/smk_decoder.cpp b/video/smk_decoder.cpp
index ee7a4ce..4a2ada0 100644
--- a/video/smk_decoder.cpp
+++ b/video/smk_decoder.cpp
@@ -386,7 +386,7 @@ bool SmackerDecoder::loadStream(Common::SeekableReadStream *stream) {
byte *huffmanTrees = (byte *) malloc(_header.treesSize);
_fileStream->read(huffmanTrees, _header.treesSize);
- Common::BitStream8LSB bs(new Common::MemoryReadStream(huffmanTrees, _header.treesSize, DisposeAfterUse::YES), true);
+ Common::BitStream8LSB bs(new Common::MemoryReadStream(huffmanTrees, _header.treesSize, DisposeAfterUse::YES), DisposeAfterUse::YES);
videoTrack->readTrees(bs, _header.mMapSize, _header.mClrSize, _header.fullSize, _header.typeSize);
_firstFrameStart = _fileStream->pos();
@@ -469,7 +469,7 @@ void SmackerDecoder::readNextPacket() {
_fileStream->read(frameData, frameDataSize);
- Common::BitStream8LSB bs(new Common::MemoryReadStream(frameData, frameDataSize + 1, DisposeAfterUse::YES), true);
+ Common::BitStream8LSB bs(new Common::MemoryReadStream(frameData, frameDataSize + 1, DisposeAfterUse::YES), DisposeAfterUse::YES);
videoTrack->decodeFrame(bs);
_fileStream->seek(startPos + frameSize);
@@ -773,7 +773,7 @@ Audio::AudioStream *SmackerDecoder::SmackerAudioTrack::getAudioStream() const {
}
void SmackerDecoder::SmackerAudioTrack::queueCompressedBuffer(byte *buffer, uint32 bufferSize, uint32 unpackedSize) {
- Common::BitStream8LSB audioBS(new Common::MemoryReadStream(buffer, bufferSize), true);
+ Common::BitStream8LSB audioBS(new Common::MemoryReadStream(buffer, bufferSize), DisposeAfterUse::YES);
bool dataPresent = audioBS.getBit();
if (!dataPresent)
Commit: fe6d624277412e7a9b32126da2586d6e663c9e91
https://github.com/scummvm/scummvm/commit/fe6d624277412e7a9b32126da2586d6e663c9e91
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T14:31:19-04:00
Commit Message:
IMAGE: Implemented Indeo5 decoder
Changed paths:
A image/codecs/indeo5.cpp
A image/codecs/indeo5.h
image/codecs/codec.cpp
image/codecs/indeo/get_bits.h
image/codecs/indeo/indeo.cpp
image/codecs/indeo/indeo.h
image/module.mk
diff --git a/image/codecs/codec.cpp b/image/codecs/codec.cpp
index 105e41e..913b7af 100644
--- a/image/codecs/codec.cpp
+++ b/image/codecs/codec.cpp
@@ -31,6 +31,7 @@
#include "image/codecs/cinepak.h"
#include "image/codecs/indeo3.h"
#include "image/codecs/indeo4.h"
+#include "image/codecs/indeo5.h"
#include "image/codecs/mjpeg.h"
#include "image/codecs/mpeg.h"
#include "image/codecs/msvideo1.h"
@@ -213,6 +214,8 @@ Codec *createBitmapCodec(uint32 tag, int width, int height, int bitsPerPixel) {
case MKTAG('I', 'V', '4', '1'):
case MKTAG('I', 'V', '4', '2'):
return new Indeo4Decoder(width, height);
+ case MKTAG('I', 'V', '5', '0'):
+ return new Indeo5Decoder(width, height);
#ifdef IMAGE_CODECS_TRUEMOTION1_H
case MKTAG('D','U','C','K'):
case MKTAG('d','u','c','k'):
diff --git a/image/codecs/indeo/get_bits.h b/image/codecs/indeo/get_bits.h
index 336cfa3..986bfc8 100644
--- a/image/codecs/indeo/get_bits.h
+++ b/image/codecs/indeo/get_bits.h
@@ -22,7 +22,7 @@
#include "common/scummsys.h"
-/* Intel Indeo 4 bitstream reader
+/* Indeo 4 & 5 bitstream reader
*
* Original copyright note:
* Copyright (c) 2004 Michael Niedermayer
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index 2c11a09..1968638 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -83,13 +83,6 @@ static const IVIHuffDesc ivi_blk_huff_desc[8] = {
*/
#define IVI_NUM_TILES(stride, tile_size) (((stride) + (tile_size) - 1) / (tile_size))
-
-/**
- * calculate number of macroblocks in a tile
- */
-#define IVI_MBs_PER_TILE(tile_width, tile_height, mb_size) \
- ((((tile_width) + (mb_size) - 1) / (mb_size)) * (((tile_height) + (mb_size) - 1) / (mb_size)))
-
/*------------------------------------------------------------------------*/
int IVIHuffDesc::ivi_create_huff_from_desc(VLC *vlc, int flag) const {
diff --git a/image/codecs/indeo/indeo.h b/image/codecs/indeo/indeo.h
index a786995..c9d556a 100644
--- a/image/codecs/indeo/indeo.h
+++ b/image/codecs/indeo/indeo.h
@@ -81,6 +81,12 @@ typedef void(*ivi_mc_avg_func) (int16 *buf, const int16 *ref_buf1,
#define IVI_TOSIGNED(val) (-(((val) >> 1) ^ -((val) & 1)))
/**
+ * calculate number of macroblocks in a tile
+ */
+#define IVI_MBs_PER_TILE(tile_width, tile_height, mb_size) \
+ ((((tile_width) + (mb_size) - 1) / (mb_size)) * (((tile_height) + (mb_size) - 1) / (mb_size)))
+
+/**
* huffman codebook descriptor
*/
struct IVIHuffDesc {
diff --git a/image/codecs/indeo5.cpp b/image/codecs/indeo5.cpp
new file mode 100644
index 0000000..b2aebe9
--- /dev/null
+++ b/image/codecs/indeo5.cpp
@@ -0,0 +1,750 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+/* Intel Indeo 5 decompressor, derived from ffmpeg.
+ *
+ * Original copyright note: * Intel Indeo 3 (IV41, IV42, etc.) video decoder for ffmpeg
+ * written, produced, and directed by Alan Smithee
+ */
+
+#include "common/endian.h"
+#include "common/stream.h"
+#include "common/textconsole.h"
+#include "common/util.h"
+#include "graphics/yuv_to_rgb.h"
+#include "image/codecs/indeo5.h"
+#include "image/codecs/indeo/mem.h"
+
+namespace Image {
+
+/**
+ * Indeo5 frame types.
+ */
+enum {
+ FRAMETYPE_INTRA = 0,
+ FRAMETYPE_INTER = 1, ///< non-droppable P-frame
+ FRAMETYPE_INTER_SCAL = 2, ///< droppable P-frame used in the scalability mode
+ FRAMETYPE_INTER_NOREF = 3, ///< droppable P-frame
+ FRAMETYPE_NULL = 4 ///< empty frame with no data
+};
+
+#define IVI5_PIC_SIZE_ESC 15
+
+Indeo5Decoder::Indeo5Decoder(uint16 width, uint16 height) : IndeoDecoderBase(width, height) {
+ _ctx.is_indeo4 = true;
+ _ctx.ref_buf = 1;
+ _ctx.b_ref_buf = 3;
+ _ctx.p_frame = new AVFrame();
+}
+
+bool Indeo5Decoder::isIndeo5(Common::SeekableReadStream &stream) {
+ // Less than 16 bytes? This can't be right
+ if (stream.size() < 16)
+ return false;
+
+ // Read in the start of the data
+ byte buffer[16];
+ stream.read(buffer, 16);
+ stream.seek(-16, SEEK_CUR);
+
+ // Validate the first 5-bit word has the correct identifier
+ Indeo::GetBits gb(buffer, 16 * 8);
+ bool isIndeo5 = gb.getBits(5) == 0x1F;
+
+ return isIndeo5;
+}
+
+const Graphics::Surface *Indeo5Decoder::decodeFrame(Common::SeekableReadStream &stream) {
+ // Not Indeo 5? Fail
+ if (!isIndeo5(stream))
+ return nullptr;
+
+ // Set up the frame data buffer
+ byte *frameData = new byte[stream.size()];
+ stream.read(frameData, stream.size());
+ _ctx.frame_data = frameData;
+ _ctx.frame_size = stream.size();
+
+ // Set up the GetBits instance for reading the data
+ _ctx.gb = new GetBits(_ctx.frame_data, _ctx.frame_size * 8);
+
+ // Decode the frame
+ int err = decodeIndeoFrame();
+
+ // Free the bit reader and frame buffer
+ delete _ctx.gb;
+ _ctx.gb = nullptr;
+ delete[] frameData;
+ _ctx.frame_data = nullptr;
+ _ctx.frame_size = 0;
+
+ return (err < 0) ? nullptr : &_surface->rawSurface();
+}
+
+int Indeo5Decoder::decodePictureHeader() {
+ int pic_size_indx, i, p;
+ IVIPicConfig pic_conf;
+
+ int ret;
+
+ if (_ctx.gb->getBits(5) != 0x1F) {
+ warning("Invalid picture start code!");
+ return -1;
+ }
+
+ _ctx.prev_frame_type = _ctx.frame_type;
+ _ctx.frame_type = _ctx.gb->getBits(3);
+ if (_ctx.frame_type >= 5) {
+ warning("Invalid frame type: %d", _ctx.frame_type);
+ return -1;
+ }
+
+ _ctx.frame_num = _ctx.gb->getBits(8);
+
+ if (_ctx.frame_type == FRAMETYPE_INTRA) {
+ if ((ret = decode_gop_header()) < 0) {
+ warning("Invalid GOP header, skipping frames.");
+ _ctx.gop_invalid = 1;
+ return ret;
+ }
+ _ctx.gop_invalid = 0;
+ }
+
+ if (_ctx.frame_type == FRAMETYPE_INTER_SCAL && !_ctx.is_scalable) {
+ warning("Scalable inter frame in non scalable stream");
+ _ctx.frame_type = FRAMETYPE_INTER;
+ return -1;
+ }
+
+ if (_ctx.frame_type != FRAMETYPE_NULL) {
+ _ctx.frame_flags = _ctx.gb->getBits(8);
+
+ _ctx.pic_hdr_size = (_ctx.frame_flags & 1) ? _ctx.gb->getBitsLong(24) : 0;
+
+ _ctx.checksum = (_ctx.frame_flags & 0x10) ? _ctx.gb->getBits(16) : 0;
+
+ // skip unknown extension if any
+ if (_ctx.frame_flags & 0x20)
+ skip_hdr_extension(); // XXX: untested
+
+ // decode macroblock huffman codebook
+ ret = _ctx.mb_vlc.ff_ivi_dec_huff_desc(&_ctx, _ctx.frame_flags & 0x40,
+ IVI_MB_HUFF);
+ if (ret < 0)
+ return ret;
+
+ _ctx.gb->skipBits(3); // FIXME: unknown meaning!
+ }
+
+ _ctx.gb->alignGetBits();
+ return 0;
+}
+
+void Indeo5Decoder::switch_buffers() {
+ switch (_ctx.prev_frame_type) {
+ case FRAMETYPE_INTRA:
+ case FRAMETYPE_INTER:
+ _ctx.buf_switch ^= 1;
+ _ctx.dst_buf = _ctx.buf_switch;
+ _ctx.ref_buf = _ctx.buf_switch ^ 1;
+ break;
+ case FRAMETYPE_INTER_SCAL:
+ if (!_ctx.inter_scal) {
+ _ctx.ref2_buf = 2;
+ _ctx.inter_scal = 1;
+ }
+ FFSWAP(int, _ctx.dst_buf, _ctx.ref2_buf);
+ _ctx.ref_buf = _ctx.ref2_buf;
+ break;
+ case FRAMETYPE_INTER_NOREF:
+ break;
+ }
+
+ switch (_ctx.frame_type) {
+ case FRAMETYPE_INTRA:
+ _ctx.buf_switch = 0;
+ // FALLTHROUGH
+ case FRAMETYPE_INTER:
+ _ctx.inter_scal = 0;
+ _ctx.dst_buf = _ctx.buf_switch;
+ _ctx.ref_buf = _ctx.buf_switch ^ 1;
+ break;
+ case FRAMETYPE_INTER_SCAL:
+ case FRAMETYPE_INTER_NOREF:
+ case FRAMETYPE_NULL:
+ break;
+ }
+}
+
+bool Indeo5Decoder::is_nonnull_frame() const {
+ return _ctx.frame_type != FRAMETYPE_NULL;
+}
+
+int Indeo5Decoder::decode_band_hdr(IVIBandDesc *band) {
+ int i, ret;
+ uint8 band_flags;
+
+ band_flags = _ctx.gb->getBits(8);
+
+ if (band_flags & 1) {
+ band->is_empty = 1;
+ return 0;
+ }
+
+ band->data_size = (_ctx.frame_flags & 0x80) ? _ctx.gb->getBitsLong(24) : 0;
+
+ band->inherit_mv = band_flags & 2;
+ band->inherit_qdelta = band_flags & 8;
+ band->qdelta_present = band_flags & 4;
+ if (!band->qdelta_present) band->inherit_qdelta = 1;
+
+ // decode rvmap probability corrections if any
+ band->num_corr = 0; // there are no corrections
+ if (band_flags & 0x10) {
+ band->num_corr = _ctx.gb->getBits(8); // get number of correction pairs
+ if (band->num_corr > 61) {
+ warning("Too many corrections: %d", band->num_corr);
+ return -1;
+ }
+
+ // read correction pairs
+ for (i = 0; i < band->num_corr * 2; i++)
+ band->corr[i] = _ctx.gb->getBits(8);
+ }
+
+ // select appropriate rvmap table for this band
+ band->rvmap_sel = (band_flags & 0x40) ? _ctx.gb->getBits(3) : 8;
+
+ // decode block huffman codebook
+ ret = band->blk_vlc.ff_ivi_dec_huff_desc(&_ctx, band_flags & 0x80, IVI_BLK_HUFF);
+ if (ret < 0)
+ return ret;
+
+ band->checksum_present = _ctx.gb->getBits1();
+ if (band->checksum_present)
+ band->checksum = _ctx.gb->getBits(16);
+
+ band->glob_quant = _ctx.gb->getBits(5);
+
+ // skip unknown extension if any
+ if (band_flags & 0x20) { // XXX: untested
+ _ctx.gb->alignGetBits();
+ skip_hdr_extension();
+ }
+
+ _ctx.gb->alignGetBits();
+
+ return 0;
+}
+
+int Indeo5Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
+ int x, y, mv_x, mv_y, mv_delta, offs, mb_offset,
+ mv_scale, blks_per_mb, s;
+ IVIMbInfo *mb, *ref_mb;
+ int row_offset = band->mb_size * band->pitch;
+
+ mb = tile->mbs;
+ ref_mb = tile->ref_mbs;
+ offs = tile->ypos * band->pitch + tile->xpos;
+
+ if (!ref_mb &&
+ ((band->qdelta_present && band->inherit_qdelta) || band->inherit_mv))
+ return -1;
+
+ if (tile->num_MBs != IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size)) {
+ warning("Allocated tile size %d mismatches parameters %d",
+ tile->num_MBs, IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size));
+ return -1;
+ }
+
+ // scale factor for motion vectors
+ mv_scale = (_ctx.planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
+ mv_x = mv_y = 0;
+
+ for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
+ mb_offset = offs;
+
+ for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
+ mb->xpos = x;
+ mb->ypos = y;
+ mb->buf_offs = mb_offset;
+
+ if (_ctx.gb->getBits1()) {
+ if (_ctx.frame_type == FRAMETYPE_INTRA) {
+ warning("Empty macroblock in an INTRA picture!");
+ return -1;
+ }
+ mb->type = 1; // empty macroblocks are always INTER
+ mb->cbp = 0; // all blocks are empty
+
+ mb->q_delta = 0;
+ if (!band->plane && !band->band_num && (_ctx.frame_flags & 8)) {
+ mb->q_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table, IVI_VLC_BITS, 1);
+ mb->q_delta = IVI_TOSIGNED(mb->q_delta);
+ }
+
+ mb->mv_x = mb->mv_y = 0; // no motion vector coded
+ if (band->inherit_mv && ref_mb) {
+ // motion vector inheritance
+ if (mv_scale) {
+ mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
+ mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
+ } else {
+ mb->mv_x = ref_mb->mv_x;
+ mb->mv_y = ref_mb->mv_y;
+ }
+ }
+ } else {
+ if (band->inherit_mv && ref_mb) {
+ mb->type = ref_mb->type; // copy mb_type from corresponding reference mb
+ } else if (_ctx.frame_type == FRAMETYPE_INTRA) {
+ mb->type = 0; // mb_type is always INTRA for intra-frames
+ } else {
+ mb->type = _ctx.gb->getBits1();
+ }
+
+ blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
+ mb->cbp = _ctx.gb->getBits(blks_per_mb);
+
+ mb->q_delta = 0;
+ if (band->qdelta_present) {
+ if (band->inherit_qdelta) {
+ if (ref_mb) mb->q_delta = ref_mb->q_delta;
+ } else if (mb->cbp || (!band->plane && !band->band_num &&
+ (_ctx.frame_flags & 8))) {
+ mb->q_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table, IVI_VLC_BITS, 1);
+ mb->q_delta = IVI_TOSIGNED(mb->q_delta);
+ }
+ }
+
+ if (!mb->type) {
+ mb->mv_x = mb->mv_y = 0; // there is no motion vector in intra-macroblocks
+ } else {
+ if (band->inherit_mv && ref_mb) {
+ // motion vector inheritance
+ if (mv_scale) {
+ mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
+ mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
+ } else {
+ mb->mv_x = ref_mb->mv_x;
+ mb->mv_y = ref_mb->mv_y;
+ }
+ } else {
+ // decode motion vector deltas
+ mv_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table, IVI_VLC_BITS, 1);
+ mv_y += IVI_TOSIGNED(mv_delta);
+ mv_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table, IVI_VLC_BITS, 1);
+ mv_x += IVI_TOSIGNED(mv_delta);
+ mb->mv_x = mv_x;
+ mb->mv_y = mv_y;
+ }
+ }
+ }
+
+ s = band->is_halfpel;
+ if (mb->type)
+ if (x + (mb->mv_x >> s) + (y + (mb->mv_y >> s))*band->pitch < 0 ||
+ x + ((mb->mv_x + s) >> s) + band->mb_size - 1
+ + (y + band->mb_size - 1 + ((mb->mv_y + s) >> s))*band->pitch > band->bufsize - 1) {
+ warning("motion vector %d %d outside reference", x*s + mb->mv_x, y*s + mb->mv_y);
+ return -1;
+ }
+
+ mb++;
+ if (ref_mb)
+ ref_mb++;
+ mb_offset += band->mb_size;
+ }
+
+ offs += row_offset;
+ }
+
+ _ctx.gb->alignGetBits();
+
+ return 0;
+}
+
+int Indeo5Decoder::decode_gop_header() {
+ int result, i, p, tile_size, pic_size_indx, mb_size, blk_size, is_scalable;
+ int quant_mat, blk_size_changed = 0;
+ IVIBandDesc *band, *band1, *band2;
+ IVIPicConfig pic_conf;
+
+ _ctx.gop_flags = _ctx.gb->getBits(8);
+
+ _ctx.gop_hdr_size = (_ctx.gop_flags & 1) ? _ctx.gb->getBits(16) : 0;
+
+ if (_ctx.gop_flags & IVI5_IS_PROTECTED)
+ _ctx.lock_word = _ctx.gb->getBitsLong(32);
+
+ tile_size = (_ctx.gop_flags & 0x40) ? 64 << _ctx.gb->getBits(2) : 0;
+ if (tile_size > 256) {
+ warning("Invalid tile size: %d", tile_size);
+ return -1;
+ }
+
+ // decode number of wavelet bands
+ // num_levels * 3 + 1
+ pic_conf.luma_bands = _ctx.gb->getBits(2) * 3 + 1;
+ pic_conf.chroma_bands = _ctx.gb->getBits1() * 3 + 1;
+ is_scalable = pic_conf.luma_bands != 1 || pic_conf.chroma_bands != 1;
+ if (is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) {
+ warning("Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d",
+ pic_conf.luma_bands, pic_conf.chroma_bands);
+ return -1;
+ }
+
+ pic_size_indx = _ctx.gb->getBits(4);
+ if (pic_size_indx == IVI5_PIC_SIZE_ESC) {
+ pic_conf.pic_height = _ctx.gb->getBits(13);
+ pic_conf.pic_width = _ctx.gb->getBits(13);
+ } else {
+ pic_conf.pic_height = _ivi5_common_pic_sizes[pic_size_indx * 2 + 1] << 2;
+ pic_conf.pic_width = _ivi5_common_pic_sizes[pic_size_indx * 2] << 2;
+ }
+
+ if (_ctx.gop_flags & 2) {
+ warning("YV12 picture format");
+ return -2;
+ }
+
+ pic_conf.chroma_height = (pic_conf.pic_height + 3) >> 2;
+ pic_conf.chroma_width = (pic_conf.pic_width + 3) >> 2;
+
+ if (!tile_size) {
+ pic_conf.tile_height = pic_conf.pic_height;
+ pic_conf.tile_width = pic_conf.pic_width;
+ } else {
+ pic_conf.tile_height = pic_conf.tile_width = tile_size;
+ }
+
+ // check if picture layout was changed and reallocate buffers
+ if (pic_conf.ivi_pic_config_cmp(_ctx.pic_conf) || _ctx.gop_invalid) {
+ result = IVIPlaneDesc::ff_ivi_init_planes(_ctx.planes, &pic_conf, 0);
+ if (result < 0) {
+ warning("Couldn't reallocate color planes!");
+ return result;
+ }
+ _ctx.pic_conf = pic_conf;
+ _ctx.is_scalable = is_scalable;
+ blk_size_changed = 1; // force reallocation of the internal structures
+ }
+
+ for (p = 0; p <= 1; p++) {
+ for (i = 0; i < (!p ? pic_conf.luma_bands : pic_conf.chroma_bands); i++) {
+ band = &_ctx.planes[p].bands[i];
+
+ band->is_halfpel = _ctx.gb->getBits1();
+
+ mb_size = _ctx.gb->getBits1();
+ blk_size = 8 >> _ctx.gb->getBits1();
+ mb_size = blk_size << !mb_size;
+
+ if (p == 0 && blk_size == 4) {
+ warning("4x4 luma blocks are unsupported!");
+ return -2;
+ }
+
+ blk_size_changed = mb_size != band->mb_size || blk_size != band->blk_size;
+ if (blk_size_changed) {
+ band->mb_size = mb_size;
+ band->blk_size = blk_size;
+ }
+
+ if (_ctx.gb->getBits1()) {
+ warning("Extended transform info");
+ return -2;
+ }
+
+ // select transform function and scan pattern according to plane and band number
+ switch ((p << 2) + i) {
+ case 0:
+ band->inv_transform = IndeoDSP::ff_ivi_inverse_slant_8x8;
+ band->dc_transform = IndeoDSP::ff_ivi_dc_slant_2d;
+ band->scan = ff_zigzag_direct;
+ band->transform_size = 8;
+ break;
+
+ case 1:
+ band->inv_transform = IndeoDSP::ff_ivi_row_slant8;
+ band->dc_transform = IndeoDSP::ff_ivi_dc_row_slant;
+ band->scan = _ff_ivi_vertical_scan_8x8;
+ band->transform_size = 8;
+ break;
+
+ case 2:
+ band->inv_transform = IndeoDSP::ff_ivi_col_slant8;
+ band->dc_transform = IndeoDSP::ff_ivi_dc_col_slant;
+ band->scan = _ff_ivi_horizontal_scan_8x8;
+ band->transform_size = 8;
+ break;
+
+ case 3:
+ band->inv_transform = IndeoDSP::ff_ivi_put_pixels_8x8;
+ band->dc_transform = IndeoDSP::ff_ivi_put_dc_pixel_8x8;
+ band->scan = _ff_ivi_horizontal_scan_8x8;
+ band->transform_size = 8;
+ break;
+
+ case 4:
+ band->inv_transform = IndeoDSP::ff_ivi_inverse_slant_4x4;
+ band->dc_transform = IndeoDSP::ff_ivi_dc_slant_2d;
+ band->scan = _ff_ivi_direct_scan_4x4;
+ band->transform_size = 4;
+ break;
+ }
+
+ band->is_2d_trans = band->inv_transform == IndeoDSP::ff_ivi_inverse_slant_8x8 ||
+ band->inv_transform == IndeoDSP::ff_ivi_inverse_slant_4x4;
+
+ if (band->transform_size != band->blk_size) {
+ warning("transform and block size mismatch (%d != %d)", band->transform_size, band->blk_size);
+ return -1;
+ }
+
+ // select dequant matrix according to plane and band number
+ if (!p) {
+ quant_mat = (pic_conf.luma_bands > 1) ? i + 1 : 0;
+ } else {
+ quant_mat = 5;
+ }
+
+ if (band->blk_size == 8) {
+ if (quant_mat >= 5) {
+ warning("quant_mat %d too large!", quant_mat);
+ return -1;
+ }
+ band->intra_base = &_ivi5_base_quant_8x8_intra[quant_mat][0];
+ band->inter_base = &_ivi5_base_quant_8x8_inter[quant_mat][0];
+ band->intra_scale = &_ivi5_scale_quant_8x8_intra[quant_mat][0];
+ band->inter_scale = &_ivi5_scale_quant_8x8_inter[quant_mat][0];
+ } else {
+ band->intra_base = _ivi5_base_quant_4x4_intra;
+ band->inter_base = _ivi5_base_quant_4x4_inter;
+ band->intra_scale = _ivi5_scale_quant_4x4_intra;
+ band->inter_scale = _ivi5_scale_quant_4x4_inter;
+ }
+
+ if (_ctx.gb->getBits(2)) {
+ warning("End marker missing!");
+ return -1;
+ }
+ }
+ }
+
+ // copy chroma parameters into the 2nd chroma plane
+ for (i = 0; i < pic_conf.chroma_bands; i++) {
+ band1 = &_ctx.planes[1].bands[i];
+ band2 = &_ctx.planes[2].bands[i];
+
+ band2->width = band1->width;
+ band2->height = band1->height;
+ band2->mb_size = band1->mb_size;
+ band2->blk_size = band1->blk_size;
+ band2->is_halfpel = band1->is_halfpel;
+ band2->intra_base = band1->intra_base;
+ band2->inter_base = band1->inter_base;
+ band2->intra_scale = band1->intra_scale;
+ band2->inter_scale = band1->inter_scale;
+ band2->scan = band1->scan;
+ band2->inv_transform = band1->inv_transform;
+ band2->dc_transform = band1->dc_transform;
+ band2->is_2d_trans = band1->is_2d_trans;
+ band2->transform_size = band1->transform_size;
+ }
+
+ // reallocate internal structures if needed
+ if (blk_size_changed) {
+ result = IVIPlaneDesc::ff_ivi_init_tiles(_ctx.planes, pic_conf.tile_width,
+ pic_conf.tile_height);
+ if (result < 0) {
+ warning("Couldn't reallocate internal structures!");
+ return result;
+ }
+ }
+
+ if (_ctx.gop_flags & 8) {
+ if (_ctx.gb->getBits(3)) {
+ warning("Alignment bits are not zero!");
+ return -1;
+ }
+
+ if (_ctx.gb->getBits1())
+ _ctx.gb->skipBitsLong(24); // skip transparency fill color
+ }
+
+ _ctx.gb->alignGetBits();
+
+ _ctx.gb->skipBits(23); // FIXME: unknown meaning
+
+ // skip GOP extension if any
+ if (_ctx.gb->getBits1()) {
+ do {
+ i = _ctx.gb->getBits(16);
+ } while (i & 0x8000);
+ }
+
+ _ctx.gb->alignGetBits();
+
+ return 0;
+}
+
+int Indeo5Decoder::skip_hdr_extension() {
+ int i, len;
+
+ do {
+ len = _ctx.gb->getBits(8);
+ if (8 * len > _ctx.gb->getBitsLeft())
+ return -1;
+ for (i = 0; i < len; i++)
+ _ctx.gb->skipBits(8);
+ } while (len);
+
+ return 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+const uint8 Indeo5Decoder::_ivi5_common_pic_sizes[30] = {
+ 160, 120, 80, 60, 40, 30, 176, 120, 88, 60, 88, 72, 44, 36, 60, 45, 160, 60,
+ 176, 60, 20, 15, 22, 18, 0, 0, 0, 0, 0, 0
+};
+
+const uint8 Indeo5Decoder::ivi5_common_pic_sizes[30] = {
+ 160, 120, 80, 60, 40, 30, 176, 120, 88, 60, 88, 72, 44, 36, 60, 45, 160, 60,
+ 176, 60, 20, 15, 22, 18, 0, 0, 0, 0, 0, 0
+};
+
+const uint16 Indeo5Decoder::_ivi5_base_quant_8x8_inter[5][64] = {
+ {0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a, 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e,
+ 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62, 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66,
+ 0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a, 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e,
+ 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x72, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76,
+ },
+ {0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a, 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e,
+ 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62, 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66,
+ 0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a, 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e,
+ 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x72, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76,
+ },
+ {0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
+ 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
+ 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
+ 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
+ },
+ {0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4,
+ 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2,
+ 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2,
+ },
+ {0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
+ 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
+ 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
+ 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
+ }
+};
+
+const uint16 Indeo5Decoder::_ivi5_base_quant_8x8_intra[5][64] = {
+ {0x1a, 0x2e, 0x36, 0x42, 0x46, 0x4a, 0x4e, 0x5a, 0x2e, 0x32, 0x3e, 0x42, 0x46, 0x4e, 0x56, 0x6a,
+ 0x36, 0x3e, 0x3e, 0x44, 0x4a, 0x54, 0x66, 0x72, 0x42, 0x42, 0x44, 0x4a, 0x52, 0x62, 0x6c, 0x7a,
+ 0x46, 0x46, 0x4a, 0x52, 0x5e, 0x66, 0x72, 0x8e, 0x4a, 0x4e, 0x54, 0x62, 0x66, 0x6e, 0x86, 0xa6,
+ 0x4e, 0x56, 0x66, 0x6c, 0x72, 0x86, 0x9a, 0xca, 0x5a, 0x6a, 0x72, 0x7a, 0x8e, 0xa6, 0xca, 0xfe,
+ },
+ {0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a, 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e,
+ 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62, 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66,
+ 0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a, 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e,
+ 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x72, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76,
+ },
+ {0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
+ 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
+ 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
+ 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
+ },
+ {0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4,
+ 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2,
+ 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2,
+ },
+ {0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
+ 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
+ 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
+ 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
+ }
+};
+
+const uint16 Indeo5Decoder::_ivi5_base_quant_4x4_inter[16] = {
+ 0x1e, 0x3e, 0x4a, 0x52, 0x3e, 0x4a, 0x52, 0x56, 0x4a, 0x52, 0x56, 0x5e, 0x52, 0x56, 0x5e, 0x66
+};
+
+const uint16 Indeo5Decoder::_ivi5_base_quant_4x4_intra[16] = {
+ 0x1e, 0x3e, 0x4a, 0x52, 0x3e, 0x4a, 0x52, 0x5e, 0x4a, 0x52, 0x5e, 0x7a, 0x52, 0x5e, 0x7a, 0x92
+};
+
+
+const uint8 Indeo5Decoder::_ivi5_scale_quant_8x8_inter[5][24] = {
+ {0x0b, 0x11, 0x13, 0x14, 0x15, 0x16, 0x18, 0x1a, 0x1b, 0x1d, 0x20, 0x22,
+ 0x23, 0x25, 0x28, 0x2a, 0x2e, 0x32, 0x35, 0x39, 0x3d, 0x41, 0x44, 0x4a,
+ },
+ {0x07, 0x14, 0x16, 0x18, 0x1b, 0x1e, 0x22, 0x25, 0x29, 0x2d, 0x31, 0x35,
+ 0x3a, 0x3f, 0x44, 0x4a, 0x50, 0x56, 0x5c, 0x63, 0x6a, 0x71, 0x78, 0x7e,
+ },
+ {0x15, 0x25, 0x28, 0x2d, 0x30, 0x34, 0x3a, 0x3d, 0x42, 0x48, 0x4c, 0x51,
+ 0x56, 0x5b, 0x60, 0x65, 0x6b, 0x70, 0x76, 0x7c, 0x82, 0x88, 0x8f, 0x97,
+ },
+ {0x13, 0x1f, 0x20, 0x22, 0x25, 0x28, 0x2b, 0x2d, 0x30, 0x33, 0x36, 0x39,
+ 0x3c, 0x3f, 0x42, 0x45, 0x48, 0x4b, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x62,
+ },
+ {0x3c, 0x52, 0x58, 0x5d, 0x63, 0x68, 0x68, 0x6d, 0x73, 0x78, 0x7c, 0x80,
+ 0x84, 0x89, 0x8e, 0x93, 0x98, 0x9d, 0xa3, 0xa9, 0xad, 0xb1, 0xb5, 0xba,
+ },
+};
+
+const uint8 Indeo5Decoder::_ivi5_scale_quant_8x8_intra[5][24] = {
+ {0x0b, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x17, 0x18, 0x1a, 0x1c, 0x1e, 0x20,
+ 0x22, 0x24, 0x27, 0x28, 0x2a, 0x2d, 0x2f, 0x31, 0x34, 0x37, 0x39, 0x3c,
+ },
+ {0x01, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1b, 0x1e, 0x22, 0x25, 0x28, 0x2c,
+ 0x30, 0x34, 0x38, 0x3d, 0x42, 0x47, 0x4c, 0x52, 0x58, 0x5e, 0x65, 0x6c,
+ },
+ {0x13, 0x22, 0x27, 0x2a, 0x2d, 0x33, 0x36, 0x3c, 0x41, 0x45, 0x49, 0x4e,
+ 0x53, 0x58, 0x5d, 0x63, 0x69, 0x6f, 0x75, 0x7c, 0x82, 0x88, 0x8e, 0x95,
+ },
+ {0x13, 0x1f, 0x21, 0x24, 0x27, 0x29, 0x2d, 0x2f, 0x34, 0x37, 0x3a, 0x3d,
+ 0x40, 0x44, 0x48, 0x4c, 0x4f, 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6b,
+ },
+ {0x31, 0x42, 0x47, 0x47, 0x4d, 0x52, 0x58, 0x58, 0x5d, 0x63, 0x67, 0x6b,
+ 0x6f, 0x73, 0x78, 0x7c, 0x80, 0x84, 0x89, 0x8e, 0x93, 0x98, 0x9d, 0xa4,
+ }
+};
+
+const uint8 Indeo5Decoder::_ivi5_scale_quant_4x4_inter[24] = {
+ 0x0b, 0x0d, 0x0d, 0x0e, 0x11, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
+};
+
+const uint8 Indeo5Decoder::_ivi5_scale_quant_4x4_intra[24] = {
+ 0x01, 0x0b, 0x0b, 0x0d, 0x0d, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x13, 0x14,
+ 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20
+};
+
+} // End of namespace Image
diff --git a/image/codecs/indeo5.h b/image/codecs/indeo5.h
new file mode 100644
index 0000000..102c610
--- /dev/null
+++ b/image/codecs/indeo5.h
@@ -0,0 +1,146 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+#include "image/codecs/indeo/get_bits.h"
+
+/* Intel Indeo 4 decompressor, derived from ffmpeg.
+ *
+ * Original copyright note:
+ * Intel Indeo 4 (IV31, IV32, etc.) video decoder for ffmpeg
+ * written, produced, and directed by Alan Smithee
+ */
+
+#ifndef IMAGE_CODECS_INDEO5_H
+#define IMAGE_CODECS_INDEO5_H
+
+#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 {
+
+using namespace Indeo;
+
+/**
+ * Intel Indeo 5 decoder.
+ *
+ * Used by AVI.
+ *
+ * Used in video:
+ * - AVIDecoder
+ */
+class Indeo5Decoder : public IndeoDecoderBase {
+ struct Transform {
+ InvTransformPtr *inv_trans;
+ DCTransformPtr *dc_trans;
+ int is_2d_trans;
+ };
+public:
+ Indeo5Decoder(uint16 width, uint16 height);
+ virtual ~Indeo5Decoder() {}
+
+ virtual const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream);
+
+ static bool isIndeo5(Common::SeekableReadStream &stream);
+protected:
+ /**
+ * Decode the Indeo 5 picture header.
+ * @returns 0 = Ok, negative number = error
+ */
+ virtual int decodePictureHeader();
+
+ /**
+ * Rearrange decoding and reference buffers.
+ */
+ virtual void switch_buffers();
+
+ virtual bool is_nonnull_frame() const;
+
+ /**
+ * Decode Indeo 4 band header.
+ *
+ * @param[in,out] band pointer to the band descriptor
+ * @return result code: 0 = OK, negative number = error
+ */
+ virtual int decode_band_hdr(IVIBandDesc *band);
+
+ /**
+ * Decode information (block type, cbp, quant delta, motion vector)
+ * for all macroblocks in the current tile.
+ *
+ * @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
+ */
+ virtual int decode_mb_info(IVIBandDesc *band, IVITile *tile);
+private:
+ /**
+ * Decode Indeo5 GOP (Group of pictures) header.
+ * This header is present in key frames only.
+ * It defines parameters for all frames in a GOP.
+ * @returns result code: 0 = OK, -1 = error
+ */
+ int decode_gop_header();
+
+ /**
+ * Skip a header extension.
+ */
+ int skip_hdr_extension();
+
+private:
+ /**
+ * standard picture dimensions (width, height divided by 4)
+ */
+ static const uint8 _ivi5_common_pic_sizes[30];
+
+ /**
+ * standard picture dimensions (width, height divided by 4)
+ */
+ static const uint8 ivi5_common_pic_sizes[30];
+
+ /**
+ * Indeo5 dequantization matrixes consist of two tables: base table
+ * and scale table. The base table defines the dequantization matrix
+ * itself and the scale table tells how this matrix should be scaled
+ * for a particular quant level (0...24).
+ *
+ * ivi5_base_quant_bbb_ttt - base tables for block size 'bbb' of type 'ttt'
+ * ivi5_scale_quant_bbb_ttt - scale tables for block size 'bbb' of type 'ttt'
+ */
+ static const uint16 _ivi5_base_quant_8x8_inter[5][64];
+ static const uint16 _ivi5_base_quant_8x8_intra[5][64];
+
+ static const uint16 _ivi5_base_quant_4x4_inter[16];
+ static const uint16 _ivi5_base_quant_4x4_intra[16];
+
+ static const uint8 _ivi5_scale_quant_8x8_inter[5][24];
+ static const uint8 _ivi5_scale_quant_8x8_intra[5][24];
+
+ static const uint8 _ivi5_scale_quant_4x4_inter[24];
+ static const uint8 _ivi5_scale_quant_4x4_intra[24];
+};
+
+} // End of namespace Image
+
+#endif
diff --git a/image/module.mk b/image/module.mk
index 03ba4d1..2ede7c3 100644
--- a/image/module.mk
+++ b/image/module.mk
@@ -14,6 +14,7 @@ MODULE_OBJS := \
codecs/codec.o \
codecs/indeo3.o \
codecs/indeo4.o \
+ codecs/indeo5.o \
codecs/mjpeg.o \
codecs/msrle.o \
codecs/msrle4.o \
Commit: 58ad70f351caa6f7791bf5ff62b0166e37dadf47
https://github.com/scummvm/scummvm/commit/58ad70f351caa6f7791bf5ff62b0166e37dadf47
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T16:04:22-04:00
Commit Message:
IMAGE: Renaming structure fields for Indeo decoders
Changed paths:
image/codecs/indeo/indeo.cpp
image/codecs/indeo/indeo.h
image/codecs/indeo4.cpp
image/codecs/indeo4.h
image/codecs/indeo5.cpp
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index 1968638..632e39e 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -79,7 +79,7 @@ static const IVIHuffDesc ivi_blk_huff_desc[8] = {
/*------------------------------------------------------------------------*/
/**
- * calculate number of tiles in a stride
+ * calculate number of _tiles in a stride
*/
#define IVI_NUM_TILES(stride, tile_size) (((stride) + (tile_size) - 1) / (tile_size))
@@ -92,16 +92,16 @@ int IVIHuffDesc::ivi_create_huff_from_desc(VLC *vlc, int flag) const {
pos = 0; // current position = 0
- for (i = 0; i < num_rows; i++) {
- codes_per_row = 1 << xbits[i];
- not_last_row = (i != num_rows - 1);
- prefix = ((1 << i) - 1) << (xbits[i] + not_last_row);
+ for (i = 0; i < _numRows; i++) {
+ codes_per_row = 1 << _xBits[i];
+ not_last_row = (i != _numRows - 1);
+ prefix = ((1 << i) - 1) << (_xBits[i] + not_last_row);
for (j = 0; j < codes_per_row; j++) {
if (pos >= 256) // Some Indeo5 codebooks can have more than 256
break; // elements, but only 256 codes are allowed!
- bits[pos] = i + xbits[i] + not_last_row;
+ bits[pos] = i + _xBits[i] + not_last_row;
if (bits[pos] > IVI_VLC_BITS)
return -1; // invalid descriptor
@@ -121,18 +121,18 @@ int IVIHuffDesc::ivi_create_huff_from_desc(VLC *vlc, int flag) const {
/*------------------------------------------------------------------------*/
bool IVIHuffDesc::ivi_huff_desc_cmp(const IVIHuffDesc *desc2) const {
- return num_rows != desc2->num_rows ||
- memcmp(xbits, desc2->xbits, num_rows);
+ return _numRows != desc2->_numRows ||
+ memcmp(_xBits, desc2->_xBits, _numRows);
}
void IVIHuffDesc::ivi_huff_desc_copy(const IVIHuffDesc *src) {
- num_rows = src->num_rows;
- memcpy(xbits, src->xbits, src->num_rows);
+ _numRows = src->_numRows;
+ memcpy(_xBits, src->_xBits, src->_numRows);
}
/*------------------------------------------------------------------------*/
-IVIHuffTab::IVIHuffTab() : tab(nullptr) {
+IVIHuffTab::IVIHuffTab() : _tab(nullptr) {
}
int IVIHuffTab::ff_ivi_dec_huff_desc(IVI45DecContext *ctx, int desc_coded, int which_tab) {
@@ -141,42 +141,42 @@ int IVIHuffTab::ff_ivi_dec_huff_desc(IVI45DecContext *ctx, int desc_coded, int w
if (!desc_coded) {
// select default table
- tab = (which_tab) ? &ctx->ivi_blk_vlc_tabs[7]
- : &ctx->ivi_mb_vlc_tabs[7];
+ _tab = (which_tab) ? &ctx->_iviBlkVlcTabs[7]
+ : &ctx->_iviMbVlcTabs[7];
return 0;
}
- tab_sel = ctx->gb->getBits(3);
- if (tab_sel == 7) {
+ _tabSel = ctx->_gb->getBits(3);
+ if (_tabSel == 7) {
// custom huffman table (explicitly encoded)
- new_huff.num_rows = ctx->gb->getBits(4);
- if (!new_huff.num_rows) {
+ new_huff._numRows = ctx->_gb->getBits(4);
+ if (!new_huff._numRows) {
warning("Empty custom Huffman table!");
return -1;
}
- for (i = 0; i < new_huff.num_rows; i++)
- new_huff.xbits[i] = ctx->gb->getBits(4);
+ for (i = 0; i < new_huff._numRows; i++)
+ 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) {
- cust_desc.ivi_huff_desc_copy(&new_huff);
+ if (new_huff.ivi_huff_desc_cmp(&_custDesc) || !_custTab._table) {
+ _custDesc.ivi_huff_desc_copy(&new_huff);
- if (cust_tab._table)
- cust_tab.ff_free_vlc();
- result = cust_desc.ivi_create_huff_from_desc(&cust_tab, 0);
+ if (_custTab._table)
+ _custTab.ff_free_vlc();
+ result = _custDesc.ivi_create_huff_from_desc(&_custTab, 0);
if (result) {
// reset faulty description
- cust_desc.num_rows = 0;
+ _custDesc._numRows = 0;
warning("Error while initializing custom vlc table!");
return result;
}
}
- tab = &cust_tab;
+ _tab = &_custTab;
} else {
// select one of predefined tables
- tab = (which_tab) ? &ctx->ivi_blk_vlc_tabs[tab_sel]
- : &ctx->ivi_mb_vlc_tabs[tab_sel];
+ _tab = (which_tab) ? &ctx->_iviBlkVlcTabs[_tabSel]
+ : &ctx->_iviMbVlcTabs[_tabSel];
}
return 0;
@@ -184,60 +184,62 @@ int IVIHuffTab::ff_ivi_dec_huff_desc(IVI45DecContext *ctx, int desc_coded, int w
/*------------------------------------------------------------------------*/
-IVIMbInfo::IVIMbInfo() : xpos(0), ypos(0), buf_offs(0), type(0), cbp(0),
- q_delta(0), mv_x(0), mv_y(0), b_mv_x(0), b_mv_y(0) {
+IVIMbInfo::IVIMbInfo() : _xPos(0), _yPos(0), _bufOffs(0), _type(0), _cbp(0),
+ _qDelta(0), _mvX(0), _mvY(0), _bMvX(0), _bMvY(0) {
}
/*------------------------------------------------------------------------*/
-IVITile::IVITile() : xpos(0), ypos(0), width(0), height(0), mb_size(0),
- is_empty(0), data_size(0), num_MBs(0), mbs(nullptr), ref_mbs(nullptr) {
+IVITile::IVITile() : _xPos(0), _yPos(0), _width(0), _height(0), _mbSize(0),
+ _isEmpty(false), _dataSize(0), _numMBs(0), _mbs(nullptr), _refMbs(nullptr) {
}
/*------------------------------------------------------------------------*/
-IVIBandDesc::IVIBandDesc() : plane(0), band_num(0), width(0), height(0),
- aheight(0), data_ptr(nullptr), data_size(0), buf(nullptr),
- ref_buf(nullptr), b_ref_buf(nullptr), pitch(0), is_empty(0),
- mb_size(0), blk_size(0), is_halfpel(0), inherit_mv(0), bufsize(0),
- inherit_qdelta(0), qdelta_present(0), quant_mat(0), glob_quant(0),
- scan(nullptr), scan_size(0), num_corr(0), rvmap_sel(0), rv_map(nullptr),
- num_tiles(0), tiles(nullptr), inv_transform(nullptr), transform_size(0),
- dc_transform(nullptr), is_2d_trans(0), checksum(0), checksum_present(0),
- intra_base(nullptr), inter_base(nullptr), intra_scale(nullptr),
- inter_scale(nullptr) {
- Common::fill(&bufs[0], &bufs[4], (int16 *)nullptr);
- Common::fill(&corr[0], &corr[61 * 2], 0);
+IVIBandDesc::IVIBandDesc() : _plane(0), _bandNum(0), _width(0), _height(0),
+ _aHeight(0), _dataPtr(nullptr), _dataSize(0), _buf(nullptr),
+ _refBuf(nullptr), _bRefBuf(nullptr), _pitch(0), _isEmpty(false),
+ _mbSize(0), _blkSize(0), _isHalfpel(false), _inheritMv(false), _bufSize(0),
+ _inheritQDelta(false), _qdeltaPresent(false), _quantMat(0), _globQuant(0),
+ _scan(nullptr), _scanSize(0), _numCorr(0), _rvmapSel(0), _rvMap(nullptr),
+ _numTiles(0), _tiles(nullptr), _invTransform(nullptr), _transformSize(0),
+ _dcTransform(nullptr), _is2dTrans(0), _checksum(0), _checksumPresent(false),
+ _intraBase(nullptr), _interBase(nullptr), _intraScale(nullptr),
+ _interScale(nullptr) {
+ Common::fill(&_bufs[0], &_bufs[4], (int16 *)nullptr);
+ Common::fill(&_corr[0], &_corr[61 * 2], 0);
}
int IVIBandDesc::ivi_init_tiles(IVITile *ref_tile, int p, int b, int t_height, int t_width) {
int x, y;
- IVITile *tile = tiles;
-
- for (y = 0; y < height; y += t_height) {
- for (x = 0; x < width; x += t_width) {
- tile->xpos = x;
- tile->ypos = y;
- tile->mb_size = mb_size;
- tile->width = MIN(width - x, t_width);
- tile->height = MIN(height - y, t_height);
- tile->is_empty = tile->data_size = 0;
+ IVITile *tile = _tiles;
+
+ for (y = 0; y < _height; y += t_height) {
+ for (x = 0; x < _width; x += t_width) {
+ tile->_xPos = x;
+ tile->_yPos = y;
+ tile->_mbSize = _mbSize;
+ tile->_width = MIN(_width - x, t_width);
+ tile->_height = MIN(_height - y, t_height);
+ tile->_dataSize = 0;
+ tile->_isEmpty = false;
+
// calculate number of macroblocks
- tile->num_MBs = IVI_MBs_PER_TILE(tile->width, tile->height,
- mb_size);
+ tile->_numMBs = IVI_MBs_PER_TILE(tile->_width, tile->_height,
+ _mbSize);
- av_freep(&tile->mbs);
- tile->mbs = (IVIMbInfo *)av_mallocz_array(tile->num_MBs, sizeof(IVIMbInfo));
- if (!tile->mbs)
+ av_freep(&tile->_mbs);
+ tile->_mbs = (IVIMbInfo *)av_mallocz_array(tile->_numMBs, sizeof(IVIMbInfo));
+ if (!tile->_mbs)
return -2;
- tile->ref_mbs = 0;
+ tile->_refMbs = 0;
if (p || b) {
- if (tile->num_MBs != ref_tile->num_MBs) {
+ if (tile->_numMBs != ref_tile->_numMBs) {
warning("ref_tile mismatch");
return -1;
}
- tile->ref_mbs = ref_tile->mbs;
+ tile->_refMbs = ref_tile->_mbs;
ref_tile++;
}
tile++;
@@ -249,23 +251,23 @@ int IVIBandDesc::ivi_init_tiles(IVITile *ref_tile, int p, int b, int t_height, i
/*------------------------------------------------------------------------*/
-IVIPicConfig::IVIPicConfig() : pic_width(0), pic_height(0), chroma_width(0),
- chroma_height(0), tile_width(0), tile_height(0), luma_bands(0), chroma_bands(0) {
+IVIPicConfig::IVIPicConfig() : _picWidth(0), _picHeight(0), _chromaWidth(0),
+ _chromaHeight(0), _tileWidth(0), _tileHeight(0), _lumaBands(0), _chromaBands(0) {
}
bool IVIPicConfig::ivi_pic_config_cmp(const IVIPicConfig &cfg2) {
- return pic_width != cfg2.pic_width || pic_height != cfg2.pic_height ||
- chroma_width != cfg2.chroma_width || chroma_height != cfg2.chroma_height ||
- tile_width != cfg2.tile_width || tile_height != cfg2.tile_height ||
- luma_bands != cfg2.luma_bands || chroma_bands != cfg2.chroma_bands;
+ return _picWidth != cfg2._picWidth || _picHeight != cfg2._picHeight ||
+ _chromaWidth != cfg2._chromaWidth || _chromaHeight != cfg2._chromaHeight ||
+ _tileWidth != cfg2._tileWidth || _tileHeight != cfg2._tileHeight ||
+ _lumaBands != cfg2._lumaBands || _chromaBands != cfg2._chromaBands;
}
/*------------------------------------------------------------------------*/
-IVIPlaneDesc::IVIPlaneDesc() : width(0), height(0), num_bands(0), bands(nullptr) {
+IVIPlaneDesc::IVIPlaneDesc() : _width(0), _height(0), _numBands(0), _bands(nullptr) {
}
-int IVIPlaneDesc::ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg, bool is_indeo4) {
+int IVIPlaneDesc::ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg, bool _isIndeo4) {
int p, b;
uint32 b_width, b_height, align_fac, width_aligned,
height_aligned, buf_size;
@@ -273,32 +275,32 @@ int IVIPlaneDesc::ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *c
ivi_free_buffers(planes);
- if (av_image_check_size(cfg->pic_width, cfg->pic_height, 0, NULL) < 0 ||
- cfg->luma_bands < 1 || cfg->chroma_bands < 1)
+ if (av_image_check_size(cfg->_picWidth, cfg->_picHeight, 0, NULL) < 0 ||
+ cfg->_lumaBands < 1 || cfg->_chromaBands < 1)
return -1;
- // fill in the descriptor of the luminance plane
- planes[0].width = cfg->pic_width;
- planes[0].height = cfg->pic_height;
- planes[0].num_bands = cfg->luma_bands;
+ // fill in the descriptor of the luminance _plane
+ planes[0]._width = cfg->_picWidth;
+ planes[0]._height = cfg->_picHeight;
+ planes[0]._numBands = cfg->_lumaBands;
// fill in the descriptors of the chrominance planes
- planes[1].width = planes[2].width = (cfg->pic_width + 3) >> 2;
- planes[1].height = planes[2].height = (cfg->pic_height + 3) >> 2;
- planes[1].num_bands = planes[2].num_bands = cfg->chroma_bands;
+ planes[1]._width = planes[2]._width = (cfg->_picWidth + 3) >> 2;
+ planes[1]._height = planes[2]._height = (cfg->_picHeight + 3) >> 2;
+ planes[1]._numBands = planes[2]._numBands = cfg->_chromaBands;
for (p = 0; p < 3; p++) {
- planes[p].bands = (IVIBandDesc *)av_mallocz_array(planes[p].num_bands, sizeof(IVIBandDesc));
- if (!planes[p].bands)
+ planes[p]._bands = (IVIBandDesc *)av_mallocz_array(planes[p]._numBands, sizeof(IVIBandDesc));
+ if (!planes[p]._bands)
return -2;
// select band dimensions: if there is only one band then it
// has the full size, if there are several bands each of them
// has only half size
- b_width = planes[p].num_bands == 1 ? planes[p].width
- : (planes[p].width + 1) >> 1;
- b_height = planes[p].num_bands == 1 ? planes[p].height
- : (planes[p].height + 1) >> 1;
+ b_width = planes[p]._numBands == 1 ? planes[p]._width
+ : (planes[p]._width + 1) >> 1;
+ b_height = planes[p]._numBands == 1 ? planes[p]._height
+ : (planes[p]._height + 1) >> 1;
// luma band buffers will be aligned on 16x16 (max macroblock size)
// chroma band buffers will be aligned on 8x8 (max macroblock size)
@@ -307,33 +309,33 @@ int IVIPlaneDesc::ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *c
height_aligned = FFALIGN(b_height, align_fac);
buf_size = width_aligned * height_aligned * sizeof(int16);
- for (b = 0; b < planes[p].num_bands; b++) {
- band = &planes[p].bands[b]; // select appropriate plane/band
- band->plane = p;
- band->band_num = b;
- band->width = b_width;
- band->height = b_height;
- band->pitch = width_aligned;
- band->aheight = height_aligned;
- band->bufs[0] = (int16 *)av_mallocz(buf_size);
- band->bufs[1] = (int16 *)av_mallocz(buf_size);
- band->bufsize = buf_size / 2;
- if (!band->bufs[0] || !band->bufs[1])
+ for (b = 0; b < planes[p]._numBands; b++) {
+ band = &planes[p]._bands[b]; // select appropriate _plane/band
+ band->_plane = p;
+ band->_bandNum = b;
+ band->_width = b_width;
+ band->_height = b_height;
+ band->_pitch = width_aligned;
+ band->_aHeight = height_aligned;
+ band->_bufs[0] = (int16 *)av_mallocz(buf_size);
+ band->_bufs[1] = (int16 *)av_mallocz(buf_size);
+ band->_bufSize = buf_size / 2;
+ if (!band->_bufs[0] || !band->_bufs[1])
return -2;
// allocate the 3rd band buffer for scalability mode
- if (cfg->luma_bands > 1) {
- band->bufs[2] = (int16 *)av_mallocz(buf_size);
- if (!band->bufs[2])
+ if (cfg->_lumaBands > 1) {
+ band->_bufs[2] = (int16 *)av_mallocz(buf_size);
+ if (!band->_bufs[2])
return -2;
}
- if (is_indeo4) {
- band->bufs[3] = (int16 *)av_mallocz(buf_size);
- if (!band->bufs[3])
+ if (_isIndeo4) {
+ band->_bufs[3] = (int16 *)av_mallocz(buf_size);
+ if (!band->_bufs[3])
return -2;
}
// reset custom vlc
- planes[p].bands[0].blk_vlc.cust_desc.num_rows = 0;
+ planes[p]._bands[0]._blkVlc._custDesc._numRows = 0;
}
}
@@ -341,35 +343,35 @@ int IVIPlaneDesc::ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *c
}
int IVIPlaneDesc::ff_ivi_init_tiles(IVIPlaneDesc *planes,
- int tile_width, int tile_height) {
+ int _tileWidth, int _tileHeight) {
int p, b, x_tiles, y_tiles, t_width, t_height, ret;
IVIBandDesc *band;
for (p = 0; p < 3; p++) {
- t_width = !p ? tile_width : (tile_width + 3) >> 2;
- t_height = !p ? tile_height : (tile_height + 3) >> 2;
+ t_width = !p ? _tileWidth : (_tileWidth + 3) >> 2;
+ t_height = !p ? _tileHeight : (_tileHeight + 3) >> 2;
- if (!p && planes[0].num_bands == 4) {
+ if (!p && planes[0]._numBands == 4) {
t_width >>= 1;
t_height >>= 1;
}
if (t_width <= 0 || t_height <= 0)
return -3;
- for (b = 0; b < planes[p].num_bands; b++) {
- band = &planes[p].bands[b];
- x_tiles = IVI_NUM_TILES(band->width, t_width);
- y_tiles = IVI_NUM_TILES(band->height, t_height);
- band->num_tiles = x_tiles * y_tiles;
+ for (b = 0; b < planes[p]._numBands; b++) {
+ band = &planes[p]._bands[b];
+ x_tiles = IVI_NUM_TILES(band->_width, t_width);
+ y_tiles = IVI_NUM_TILES(band->_height, t_height);
+ band->_numTiles = x_tiles * y_tiles;
- av_freep(&band->tiles);
- band->tiles = (IVITile *)av_mallocz_array(band->num_tiles, sizeof(IVITile));
- if (!band->tiles)
+ av_freep(&band->_tiles);
+ band->_tiles = (IVITile *)av_mallocz_array(band->_numTiles, sizeof(IVITile));
+ if (!band->_tiles)
return -2;
// use the first luma band as reference for motion vectors
// and quant
- ret = band->ivi_init_tiles(planes[0].bands[0].tiles,
+ ret = band->ivi_init_tiles(planes[0]._bands[0]._tiles,
p, b, t_height, t_width);
if (ret < 0)
return ret;
@@ -383,21 +385,21 @@ void IVIPlaneDesc::ivi_free_buffers(IVIPlaneDesc *planes) {
int p, b, t;
for (p = 0; p < 3; p++) {
- if (planes[p].bands)
- for (b = 0; b < planes[p].num_bands; b++) {
- av_freep(&planes[p].bands[b].bufs[0]);
- av_freep(&planes[p].bands[b].bufs[1]);
- av_freep(&planes[p].bands[b].bufs[2]);
- av_freep(&planes[p].bands[b].bufs[3]);
-
- if (planes[p].bands[b].blk_vlc.cust_tab._table)
- planes[p].bands[b].blk_vlc.cust_tab.ff_free_vlc();
- for (t = 0; t < planes[p].bands[b].num_tiles; t++)
- av_freep(&planes[p].bands[b].tiles[t].mbs);
- av_freep(&planes[p].bands[b].tiles);
+ if (planes[p]._bands)
+ for (b = 0; b < planes[p]._numBands; b++) {
+ av_freep(&planes[p]._bands[b]._bufs[0]);
+ av_freep(&planes[p]._bands[b]._bufs[1]);
+ av_freep(&planes[p]._bands[b]._bufs[2]);
+ av_freep(&planes[p]._bands[b]._bufs[3]);
+
+ if (planes[p]._bands[b]._blkVlc._custTab._table)
+ planes[p]._bands[b]._blkVlc._custTab.ff_free_vlc();
+ for (t = 0; t < planes[p]._bands[b]._numTiles; t++)
+ av_freep(&planes[p]._bands[b]._tiles[t]._mbs);
+ av_freep(&planes[p]._bands[b]._tiles);
}
- av_freep(&planes[p].bands);
- planes[p].num_bands = 0;
+ av_freep(&planes[p]._bands);
+ planes[p]._numBands = 0;
}
}
@@ -439,48 +441,48 @@ void AVFrame::av_frame_free() {
/*------------------------------------------------------------------------*/
-IVI45DecContext::IVI45DecContext() : gb(nullptr), frame_num(0), frame_type(0),
- prev_frame_type(0), data_size(0), is_scalable(0), frame_data(0),
- inter_scal(0), frame_size(0), pic_hdr_size(0), frame_flags(0),
- checksum(0), buf_switch(0), dst_buf(0), ref_buf(0), ref2_buf(0),
- b_ref_buf(0), rvmap_sel(0), in_imf(0), in_q(0), pic_glob_quant(0),
- unknown1(0), gop_hdr_size(0), gop_flags(0), lock_word(0), has_b_frames(0),
- has_transp(0), uses_tiling(0), uses_haar(0), uses_fullpel(0), gop_invalid(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]);
+IVI45DecContext::IVI45DecContext() : _gb(nullptr), _frameNum(0), _frameType(0),
+ _prevFrameType(0), _dataSize(0), _isScalable(0), _frameData(0),
+ _interScal(0), _frameSize(0), _picHdrSize(0), _frameFlags(0),
+ _checksum(0), _bufSwitch(0), _dstBuf(0), _refBuf(0), _ref2Buf(0),
+ _bRefBuf(0), _rvmapSel(0), _inImf(false), _inQ(false), _picGlobQuant(0),
+ _unknown1(0), _gopHdrSize(0), _gopFlags(0), _lockWord(0), _hasBFrames(false),
+ _hasTransp(false), _usesTiling(false), _usesHaar(false), _usesFullpel(false),
+ _gopInvalid(false), _isIndeo4(false), _pFrame(nullptr), _gotPFrame(false) {
+ Common::fill(&_bufInvalid[0], &_bufInvalid[4], 0);
+ Common::copy(&_ff_ivi_rvmap_tabs[0], &_ff_ivi_rvmap_tabs[9], &_rvmapTabs[0]);
for (int idx = 0; idx < (8192 * 16); ++idx)
- table_data[idx][0] = table_data[idx][1] = 0;
+ _tableData[idx][0] = _tableData[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);
+ _iviMbVlcTabs[i]._table = _tableData + i * 2 * 8192;
+ _iviMbVlcTabs[i]._table_allocated = 8192;
+ ivi_mb_huff_desc[i].ivi_create_huff_from_desc(&_iviMbVlcTabs[i], 1);
+ _iviBlkVlcTabs[i]._table = _tableData + (i * 2 + 1) * 8192;
+ _iviBlkVlcTabs[i]._table_allocated = 8192;
+ ivi_blk_huff_desc[i].ivi_create_huff_from_desc(&_iviBlkVlcTabs[i], 1);
}
}
/*------------------------------------------------------------------------*/
-IndeoDecoderBase::IndeoDecoderBase(uint16 width, uint16 height) : Codec() {
+IndeoDecoderBase::IndeoDecoderBase(uint16 _width, uint16 _height) : Codec() {
_pixelFormat = g_system->getScreenFormat();
assert(_pixelFormat.bytesPerPixel > 1);
_surface = new Graphics::ManagedSurface();
- _surface->create(width, height, _pixelFormat);
- _surface->fillRect(Common::Rect(0, 0, width, height), 0);
- _ctx.b_ref_buf = 3; // buffer 2 is used for scalability mode
+ _surface->create(_width, _height, _pixelFormat);
+ _surface->fillRect(Common::Rect(0, 0, _width, _height), 0);
+ _ctx._bRefBuf = 3; // buffer 2 is used for scalability mode
}
IndeoDecoderBase::~IndeoDecoderBase() {
delete _surface;
- IVIPlaneDesc::ivi_free_buffers(_ctx.planes);
- if (_ctx.mb_vlc.cust_tab._table)
- _ctx.mb_vlc.cust_tab.ff_free_vlc();
+ IVIPlaneDesc::ivi_free_buffers(_ctx._planes);
+ if (_ctx._mbVlc._custTab._table)
+ _ctx._mbVlc._custTab.ff_free_vlc();
- delete _ctx.p_frame;
+ delete _ctx._pFrame;
}
int IndeoDecoderBase::decodeIndeoFrame() {
@@ -492,20 +494,20 @@ int IndeoDecoderBase::decodeIndeoFrame() {
if (decodePictureHeader() < 0)
return -1;
- if (_ctx.gop_invalid)
+ if (_ctx._gopInvalid)
return -1;
- if (_ctx.frame_type == IVI4_FRAMETYPE_NULL_LAST) {
+ if (_ctx._frameType == IVI4_FRAMETYPE_NULL_LAST) {
// Returning the previous frame, so exit wth success
return 0;
}
- if (_ctx.gop_flags & IVI5_IS_PROTECTED) {
+ if (_ctx._gopFlags & IVI5_IS_PROTECTED) {
warning("Password-protected clip");
return -1;
}
- if (!_ctx.planes[0].bands) {
+ if (!_ctx._planes[0]._bands) {
warning("Color planes not initialized yet");
return -1;
}
@@ -515,27 +517,27 @@ int IndeoDecoderBase::decodeIndeoFrame() {
//{ START_TIMER;
if (is_nonnull_frame()) {
- _ctx.buf_invalid[_ctx.dst_buf] = 1;
+ _ctx._bufInvalid[_ctx._dstBuf] = 1;
for (p = 0; p < 3; p++) {
- for (b = 0; b < _ctx.planes[p].num_bands; b++) {
- result = decode_band(&_ctx.planes[p].bands[b]);
+ for (b = 0; b < _ctx._planes[p]._numBands; b++) {
+ result = decode_band(&_ctx._planes[p]._bands[b]);
if (result < 0) {
- warning("Error while decoding band: %d, plane: %d", b, p);
+ warning("Error while decoding band: %d, _plane: %d", b, p);
return result;
}
}
}
- _ctx.buf_invalid[_ctx.dst_buf] = 0;
+ _ctx._bufInvalid[_ctx._dstBuf] = 0;
} else {
- if (_ctx.is_scalable)
+ if (_ctx._isScalable)
return -1;
for (p = 0; p < 3; p++) {
- if (!_ctx.planes[p].bands[0].buf)
+ if (!_ctx._planes[p]._bands[0]._buf)
return -1;
}
}
- if (_ctx.buf_invalid[_ctx.dst_buf])
+ if (_ctx._bufInvalid[_ctx._dstBuf])
return -1;
//STOP_TIMER("decode_planes"); }
@@ -543,42 +545,42 @@ int IndeoDecoderBase::decodeIndeoFrame() {
if (!is_nonnull_frame())
return 0;
- assert(_ctx.planes[0].width <= _surface->w && _ctx.planes[0].height <= _surface->h);
- result = frame->ff_set_dimensions(_ctx.planes[0].width, _ctx.planes[0].height);
+ assert(_ctx._planes[0]._width <= _surface->w && _ctx._planes[0]._height <= _surface->h);
+ result = frame->ff_set_dimensions(_ctx._planes[0]._width, _ctx._planes[0]._height);
if (result < 0)
return result;
if ((result = frame->ff_get_buffer(0)) < 0)
return result;
- if (_ctx.is_scalable) {
- if (_ctx.is_indeo4)
- ff_ivi_recompose_haar(&_ctx.planes[0], frame->_data[0], frame->_linesize[0]);
+ if (_ctx._isScalable) {
+ if (_ctx._isIndeo4)
+ ff_ivi_recompose_haar(&_ctx._planes[0], frame->_data[0], frame->_linesize[0]);
else
- ff_ivi_recompose53(&_ctx.planes[0], frame->_data[0], frame->_linesize[0]);
+ ff_ivi_recompose53(&_ctx._planes[0], frame->_data[0], frame->_linesize[0]);
} else {
- ivi_output_plane(&_ctx.planes[0], frame->_data[0], frame->_linesize[0]);
+ ivi_output_plane(&_ctx._planes[0], frame->_data[0], frame->_linesize[0]);
}
- ivi_output_plane(&_ctx.planes[2], frame->_data[1], frame->_linesize[1]);
- ivi_output_plane(&_ctx.planes[1], frame->_data[2], frame->_linesize[2]);
+ ivi_output_plane(&_ctx._planes[2], frame->_data[1], frame->_linesize[1]);
+ ivi_output_plane(&_ctx._planes[1], frame->_data[2], frame->_linesize[2]);
// If the bidirectional mode is enabled, next I and the following P
// frame will be sent together. Unfortunately the approach below seems
// to be the only way to handle the B-frames mode.
// That's exactly the same Intel decoders do.
- if (_ctx.is_indeo4 && _ctx.frame_type == IVI4_FRAMETYPE_INTRA) {
+ if (_ctx._isIndeo4 && _ctx._frameType == IVI4_FRAMETYPE_INTRA) {
int left;
// skip version string
- while (_ctx.gb->getBits(8)) {
- if (_ctx.gb->getBitsLeft() < 8)
+ while (_ctx._gb->getBits(8)) {
+ if (_ctx._gb->getBitsLeft() < 8)
return -1;
}
- left = _ctx.gb->getBitsCount() & 0x18;
- _ctx.gb->skipBitsLong(64 - left);
- if (_ctx.gb->getBitsLeft() > 18 &&
- _ctx.gb->showBitsLong(21) == 0xBFFF8) { // syncheader + inter type
+ left = _ctx._gb->getBitsCount() & 0x18;
+ _ctx._gb->skipBitsLong(64 - left);
+ if (_ctx._gb->getBitsLeft() > 18 &&
+ _ctx._gb->showBitsLong(21) == 0xBFFF8) { // syncheader + inter _type
error("Indeo decoder: Mode not currently implemented in ScummVM");
}
}
@@ -599,19 +601,19 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
int result, i, t, idx1, idx2, pos;
IVITile * tile;
- band->buf = band->bufs[_ctx.dst_buf];
- if (!band->buf) {
+ band->_buf = band->_bufs[_ctx._dstBuf];
+ if (!band->_buf) {
warning("Band buffer points to no data!");
return -1;
}
- if (_ctx.is_indeo4 && _ctx.frame_type == IVI4_FRAMETYPE_BIDIR) {
- band->ref_buf = band->bufs[_ctx.b_ref_buf];
- band->b_ref_buf = band->bufs[_ctx.ref_buf];
+ if (_ctx._isIndeo4 && _ctx._frameType == IVI4_FRAMETYPE_BIDIR) {
+ band->_refBuf = band->_bufs[_ctx._bRefBuf];
+ band->_bRefBuf = band->_bufs[_ctx._refBuf];
} else {
- band->ref_buf = band->bufs[_ctx.ref_buf];
- band->b_ref_buf = 0;
+ band->_refBuf = band->_bufs[_ctx._refBuf];
+ band->_bRefBuf = 0;
}
- band->data_ptr = _ctx.frame_data + (_ctx.gb->getBitsCount() >> 3);
+ band->_dataPtr = _ctx._frameData + (_ctx._gb->getBitsCount() >> 3);
result = decode_band_hdr(band);
if (result) {
@@ -620,45 +622,45 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
return result;
}
- if (band->is_empty) {
+ if (band->_isEmpty) {
warning("Empty band encountered!");
return -1;
}
- band->rv_map = &_ctx.rvmap_tabs[band->rvmap_sel];
+ band->_rvMap = &_ctx._rvmapTabs[band->_rvmapSel];
// apply corrections to the selected rvmap table if present
- for (i = 0; i < band->num_corr; i++) {
- idx1 = band->corr[i * 2];
- idx2 = band->corr[i * 2 + 1];
- FFSWAP(uint8, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);
- FFSWAP(int16, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
- if (idx1 == band->rv_map->eob_sym || idx2 == band->rv_map->eob_sym)
- band->rv_map->eob_sym ^= idx1 ^ idx2;
- if (idx1 == band->rv_map->esc_sym || idx2 == band->rv_map->esc_sym)
- band->rv_map->esc_sym ^= idx1 ^ idx2;
+ 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]);
+ if (idx1 == band->_rvMap->_eobSym || idx2 == band->_rvMap->_eobSym)
+ band->_rvMap->_eobSym ^= idx1 ^ idx2;
+ if (idx1 == band->_rvMap->_escSym || idx2 == band->_rvMap->_escSym)
+ band->_rvMap->_escSym ^= idx1 ^ idx2;
}
- pos = _ctx.gb->getBitsCount();
+ pos = _ctx._gb->getBitsCount();
- for (t = 0; t < band->num_tiles; t++) {
- tile = &band->tiles[t];
+ for (t = 0; t < band->_numTiles; t++) {
+ tile = &band->_tiles[t];
- if (tile->mb_size != band->mb_size) {
+ if (tile->_mbSize != band->_mbSize) {
warning("MB sizes mismatch: %d vs. %d",
- band->mb_size, tile->mb_size);
+ band->_mbSize, tile->_mbSize);
return -1;
}
- tile->is_empty = _ctx.gb->getBits1();
- if (tile->is_empty) {
+ tile->_isEmpty = _ctx._gb->getBits1();
+ if (tile->_isEmpty) {
result = ivi_process_empty_tile(band, tile,
- (_ctx.planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3));
+ (_ctx._planes[0]._bands[0]._mbSize >> 3) - (band->_mbSize >> 3));
if (result < 0)
break;
warning("Empty tile encountered!");
} else {
- tile->data_size = ivi_dec_tile_data_size(_ctx.gb);
- if (!tile->data_size) {
+ tile->_dataSize = ivi_dec_tile_data_size(_ctx._gb);
+ if (!tile->_dataSize) {
warning("Tile data size is zero!");
result = -1;
break;
@@ -668,62 +670,62 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
if (result < 0)
break;
- result = ivi_decode_blocks(_ctx.gb, band, tile);
+ result = ivi_decode_blocks(_ctx._gb, band, tile);
if (result < 0) {
warning("Corrupted tile data encountered!");
break;
}
- if ((((int)_ctx.gb->getBitsCount() - pos) >> 3) != tile->data_size) {
- warning("Tile data_size mismatch!");
+ if ((((int)_ctx._gb->getBitsCount() - pos) >> 3) != tile->_dataSize) {
+ warning("Tile _dataSize mismatch!");
result = -1;
break;
}
- pos += tile->data_size << 3; // skip to next tile
+ pos += tile->_dataSize << 3; // skip to next tile
}
}
// restore the selected rvmap table by applying its corrections in
// reverse order
- for (i = band->num_corr - 1; i >= 0; i--) {
- idx1 = band->corr[i * 2];
- idx2 = band->corr[i * 2 + 1];
- FFSWAP(uint8, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);
- FFSWAP(int16, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
- if (idx1 == band->rv_map->eob_sym || idx2 == band->rv_map->eob_sym)
- band->rv_map->eob_sym ^= idx1 ^ idx2;
- if (idx1 == band->rv_map->esc_sym || idx2 == band->rv_map->esc_sym)
- band->rv_map->esc_sym ^= idx1 ^ idx2;
+ 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]);
+ if (idx1 == band->_rvMap->_eobSym || idx2 == band->_rvMap->_eobSym)
+ band->_rvMap->_eobSym ^= idx1 ^ idx2;
+ if (idx1 == band->_rvMap->_escSym || idx2 == band->_rvMap->_escSym)
+ band->_rvMap->_escSym ^= idx1 ^ idx2;
}
- _ctx.gb->alignGetBits();
+ _ctx._gb->alignGetBits();
return result;
}
-void IndeoDecoderBase::ff_ivi_recompose_haar(const IVIPlaneDesc *plane,
+void IndeoDecoderBase::ff_ivi_recompose_haar(const IVIPlaneDesc *_plane,
uint8 *dst, const int dst_pitch) {
int x, y, indx, b0, b1, b2, b3, p0, p1, p2, p3;
const short * b0_ptr, *b1_ptr, *b2_ptr, *b3_ptr;
- int32 pitch;
+ int32 _pitch;
- // all bands should have the same pitch
- pitch = plane->bands[0].pitch;
+ // all bands should have the same _pitch
+ _pitch = _plane->_bands[0]._pitch;
// get pointers to the wavelet bands
- b0_ptr = plane->bands[0].buf;
- b1_ptr = plane->bands[1].buf;
- b2_ptr = plane->bands[2].buf;
- b3_ptr = plane->bands[3].buf;
+ b0_ptr = _plane->_bands[0]._buf;
+ b1_ptr = _plane->_bands[1]._buf;
+ b2_ptr = _plane->_bands[2]._buf;
+ b3_ptr = _plane->_bands[3]._buf;
- for (y = 0; y < plane->height; y += 2) {
- for (x = 0, indx = 0; x < plane->width; x += 2, indx++) {
+ for (y = 0; y < _plane->_height; y += 2) {
+ for (x = 0, indx = 0; x < _plane->_width; x += 2, indx++) {
// load coefficients
- b0 = b0_ptr[indx]; //should be: b0 = (num_bands > 0) ? b0_ptr[indx] : 0;
- b1 = b1_ptr[indx]; //should be: b1 = (num_bands > 1) ? b1_ptr[indx] : 0;
- b2 = b2_ptr[indx]; //should be: b2 = (num_bands > 2) ? b2_ptr[indx] : 0;
- b3 = b3_ptr[indx]; //should be: b3 = (num_bands > 3) ? b3_ptr[indx] : 0;
+ b0 = b0_ptr[indx]; //should be: b0 = (_numBands > 0) ? b0_ptr[indx] : 0;
+ b1 = b1_ptr[indx]; //should be: b1 = (_numBands > 1) ? b1_ptr[indx] : 0;
+ b2 = b2_ptr[indx]; //should be: b2 = (_numBands > 2) ? b2_ptr[indx] : 0;
+ b3 = b3_ptr[indx]; //should be: b3 = (_numBands > 3) ? b3_ptr[indx] : 0;
// haar wavelet recomposition
p0 = (b0 + b1 + b2 + b3 + 2) >> 2;
@@ -740,70 +742,70 @@ void IndeoDecoderBase::ff_ivi_recompose_haar(const IVIPlaneDesc *plane,
dst += dst_pitch << 1;
- b0_ptr += pitch;
- b1_ptr += pitch;
- b2_ptr += pitch;
- b3_ptr += pitch;
+ b0_ptr += _pitch;
+ b1_ptr += _pitch;
+ b2_ptr += _pitch;
+ b3_ptr += _pitch;
}// for y
}
-void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *plane,
+void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *_plane,
uint8 *dst, const int dst_pitch) {
int x, y, indx;
int32 p0, p1, p2, p3, tmp0, tmp1, tmp2;
int32 b0_1, b0_2, b1_1, b1_2, b1_3, b2_1, b2_2, b2_3, b2_4, b2_5, b2_6;
int32 b3_1, b3_2, b3_3, b3_4, b3_5, b3_6, b3_7, b3_8, b3_9;
- int32 pitch, back_pitch;
+ int32 _pitch, back_pitch;
const short * b0_ptr, *b1_ptr, *b2_ptr, *b3_ptr;
- const int num_bands = 4;
+ const int _numBands = 4;
- // all bands should have the same pitch
- pitch = plane->bands[0].pitch;
+ // all bands should have the same _pitch
+ _pitch = _plane->_bands[0]._pitch;
// pixels at the position "y-1" will be set to pixels at the "y" for the 1st iteration
back_pitch = 0;
// get pointers to the wavelet bands
- b0_ptr = plane->bands[0].buf;
- b1_ptr = plane->bands[1].buf;
- b2_ptr = plane->bands[2].buf;
- b3_ptr = plane->bands[3].buf;
+ b0_ptr = _plane->_bands[0]._buf;
+ b1_ptr = _plane->_bands[1]._buf;
+ b2_ptr = _plane->_bands[2]._buf;
+ b3_ptr = _plane->_bands[3]._buf;
- for (y = 0; y < plane->height; y += 2) {
+ for (y = 0; y < _plane->_height; y += 2) {
- if (y + 2 >= plane->height)
- pitch = 0;
+ if (y + 2 >= _plane->_height)
+ _pitch = 0;
// load storage variables with values
- if (num_bands > 0) {
+ if (_numBands > 0) {
b0_1 = b0_ptr[0];
- b0_2 = b0_ptr[pitch];
+ b0_2 = b0_ptr[_pitch];
}
- if (num_bands > 1) {
+ if (_numBands > 1) {
b1_1 = b1_ptr[back_pitch];
b1_2 = b1_ptr[0];
- b1_3 = b1_1 - b1_2 * 6 + b1_ptr[pitch];
+ b1_3 = b1_1 - b1_2 * 6 + b1_ptr[_pitch];
}
- if (num_bands > 2) {
+ if (_numBands > 2) {
b2_2 = b2_ptr[0]; // b2[x, y ]
b2_3 = b2_2; // b2[x+1,y ] = b2[x,y]
- b2_5 = b2_ptr[pitch]; // b2[x ,y+1]
+ b2_5 = b2_ptr[_pitch]; // b2[x ,y+1]
b2_6 = b2_5; // b2[x+1,y+1] = b2[x,y+1]
}
- if (num_bands > 3) {
+ if (_numBands > 3) {
b3_2 = b3_ptr[back_pitch]; // b3[x ,y-1]
b3_3 = b3_2; // b3[x+1,y-1] = b3[x ,y-1]
b3_5 = b3_ptr[0]; // b3[x ,y ]
b3_6 = b3_5; // b3[x+1,y ] = b3[x ,y ]
- b3_8 = b3_2 - b3_5 * 6 + b3_ptr[pitch];
+ b3_8 = b3_2 - b3_5 * 6 + b3_ptr[_pitch];
b3_9 = b3_8;
}
- for (x = 0, indx = 0; x < plane->width; x += 2, indx++) {
- if (x + 2 >= plane->width) {
+ for (x = 0, indx = 0; x < _plane->_width; x += 2, indx++) {
+ if (x + 2 >= _plane->_width) {
b0_ptr--;
b1_ptr--;
b2_ptr--;
@@ -826,11 +828,11 @@ void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *plane,
p0 = p1 = p2 = p3 = 0;
// process the LL-band by applying LPF both vertically and horizontally
- if (num_bands > 0) {
+ if (_numBands > 0) {
tmp0 = b0_1;
tmp2 = b0_2;
b0_1 = b0_ptr[indx + 1];
- b0_2 = b0_ptr[pitch + indx + 1];
+ b0_2 = b0_ptr[_pitch + indx + 1];
tmp1 = tmp0 + b0_1;
p0 = tmp0 << 4;
@@ -840,14 +842,14 @@ void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *plane,
}
// process the HL-band by applying HPF vertically and LPF horizontally
- if (num_bands > 1) {
+ if (_numBands > 1) {
tmp0 = b1_2;
tmp1 = b1_1;
b1_2 = b1_ptr[indx + 1];
b1_1 = b1_ptr[back_pitch + indx + 1];
tmp2 = tmp1 - tmp0 * 6 + b1_3;
- b1_3 = b1_1 - b1_2 * 6 + b1_ptr[pitch + indx + 1];
+ b1_3 = b1_1 - b1_2 * 6 + b1_ptr[_pitch + indx + 1];
p0 += (tmp0 + tmp1) << 3;
p1 += (tmp0 + tmp1 + b1_1 + b1_2) << 2;
@@ -856,9 +858,9 @@ void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *plane,
}
// process the LH-band by applying LPF vertically and HPF horizontally
- if (num_bands > 2) {
+ if (_numBands > 2) {
b2_3 = b2_ptr[indx + 1];
- b2_6 = b2_ptr[pitch + indx + 1];
+ b2_6 = b2_ptr[_pitch + indx + 1];
tmp0 = b2_1 + b2_2;
tmp1 = b2_1 - b2_2 * 6 + b2_3;
@@ -870,7 +872,7 @@ void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *plane,
}
// process the HH-band by applying HPF both vertically and horizontally
- if (num_bands > 3) {
+ if (_numBands > 3) {
b3_6 = b3_ptr[indx + 1]; // b3[x+1,y ]
b3_3 = b3_ptr[back_pitch + indx + 1]; // b3[x+1,y-1]
@@ -878,7 +880,7 @@ void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *plane,
tmp1 = b3_2 + b3_5;
tmp2 = b3_3 + b3_6;
- b3_9 = b3_3 - b3_6 * 6 + b3_ptr[pitch + indx + 1];
+ b3_9 = b3_3 - b3_6 * 6 + b3_ptr[_pitch + indx + 1];
p0 += (tmp0 + tmp1) << 2;
p1 += (tmp0 - tmp1 * 6 + tmp2) << 1;
@@ -895,95 +897,95 @@ void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *plane,
dst += dst_pitch << 1;
- back_pitch = -pitch;
+ back_pitch = -_pitch;
- b0_ptr += pitch + 1;
- b1_ptr += pitch + 1;
- b2_ptr += pitch + 1;
- b3_ptr += pitch + 1;
+ b0_ptr += _pitch + 1;
+ b1_ptr += _pitch + 1;
+ b2_ptr += _pitch + 1;
+ b3_ptr += _pitch + 1;
}
}
-void IndeoDecoderBase::ivi_output_plane(IVIPlaneDesc *plane, uint8 *dst, int dst_pitch) {
+void IndeoDecoderBase::ivi_output_plane(IVIPlaneDesc *_plane, uint8 *dst, int dst_pitch) {
int x, y;
- const int16 * src = plane->bands[0].buf;
- uint32 pitch = plane->bands[0].pitch;
+ const int16 * src = _plane->_bands[0]._buf;
+ uint32 _pitch = _plane->_bands[0]._pitch;
if (!src)
return;
- for (y = 0; y < plane->height; y++) {
- for (x = 0; x < plane->width; x++)
+ for (y = 0; y < _plane->_height; y++) {
+ for (x = 0; x < _plane->_width; x++)
dst[x] = av_clip_uint8(src[x] + 128);
- src += pitch;
+ src += _pitch;
dst += dst_pitch;
}
}
int IndeoDecoderBase::ivi_process_empty_tile(IVIBandDesc *band,
IVITile *tile, int32 mv_scale) {
- int x, y, need_mc, mbn, blk, num_blocks, mv_x, mv_y, mc_type;
+ int x, y, need_mc, mbn, blk, num_blocks, _mvX, _mvY, mc_type;
int offs, mb_offset, row_offset, ret;
IVIMbInfo *mb, *ref_mb;
- const int16 *src;
- int16 *dst;
- ivi_mc_func mc_no_delta_func;
+ const int16 * src;
+ int16 * dst;
+ IviMCFunc mc_no_delta_func;
- if (tile->num_MBs != IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size)) {
+ if (tile->_numMBs != IVI_MBs_PER_TILE(tile->_width, tile->_height, band->_mbSize)) {
warning("Allocated tile size %d mismatches "
"parameters %d in ivi_process_empty_tile()",
- tile->num_MBs, IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size));
+ tile->_numMBs, IVI_MBs_PER_TILE(tile->_width, tile->_height, band->_mbSize));
return -1;
}
- offs = tile->ypos * band->pitch + tile->xpos;
- mb = tile->mbs;
- ref_mb = tile->ref_mbs;
- row_offset = band->mb_size * band->pitch;
+ offs = tile->_yPos * band->_pitch + tile->_xPos;
+ mb = tile->_mbs;
+ ref_mb = tile->_refMbs;
+ row_offset = band->_mbSize * band->_pitch;
need_mc = 0; // reset the mc tracking flag
- for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
+ for (y = tile->_yPos; y < (tile->_yPos + tile->_height); y += band->_mbSize) {
mb_offset = offs;
- for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
- mb->xpos = x;
- mb->ypos = y;
- mb->buf_offs = mb_offset;
+ for (x = tile->_xPos; x < (tile->_xPos + tile->_width); x += band->_mbSize) {
+ mb->_xPos = x;
+ mb->_yPos = y;
+ mb->_bufOffs = mb_offset;
- mb->type = 1; // set the macroblocks type = INTER
- mb->cbp = 0; // all blocks are empty
+ mb->_type = 1; // set the macroblocks _type = INTER
+ mb->_cbp = 0; // all blocks are empty
- if (!band->qdelta_present && !band->plane && !band->band_num) {
- mb->q_delta = band->glob_quant;
- mb->mv_x = 0;
- mb->mv_y = 0;
+ if (!band->_qdeltaPresent && !band->_plane && !band->_bandNum) {
+ mb->_qDelta = band->_globQuant;
+ mb->_mvX = 0;
+ mb->_mvY = 0;
}
- if (band->inherit_qdelta && ref_mb)
- mb->q_delta = ref_mb->q_delta;
+ if (band->_inheritQDelta && ref_mb)
+ mb->_qDelta = ref_mb->_qDelta;
- if (band->inherit_mv && ref_mb) {
+ if (band->_inheritMv && ref_mb) {
// motion vector inheritance
if (mv_scale) {
- mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
- mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
+ mb->_mvX = ivi_scale_mv(ref_mb->_mvX, mv_scale);
+ mb->_mvY = ivi_scale_mv(ref_mb->_mvY, mv_scale);
} else {
- mb->mv_x = ref_mb->mv_x;
- mb->mv_y = ref_mb->mv_y;
+ mb->_mvX = ref_mb->_mvX;
+ mb->_mvY = ref_mb->_mvY;
}
- need_mc |= mb->mv_x || mb->mv_y; // tracking non-zero motion vectors
+ need_mc |= mb->_mvX || mb->_mvY; // tracking non-zero motion vectors
{
int dmv_x, dmv_y, cx, cy;
- dmv_x = mb->mv_x >> band->is_halfpel;
- dmv_y = mb->mv_y >> band->is_halfpel;
- cx = mb->mv_x & band->is_halfpel;
- cy = mb->mv_y & band->is_halfpel;
+ dmv_x = mb->_mvX >> band->_isHalfpel;
+ dmv_y = mb->_mvY >> band->_isHalfpel;
+ cx = mb->_mvX & band->_isHalfpel;
+ cy = mb->_mvY & band->_isHalfpel;
- if (mb->xpos + dmv_x < 0
- || mb->xpos + dmv_x + band->mb_size + cx > band->pitch
- || mb->ypos + dmv_y < 0
- || mb->ypos + dmv_y + band->mb_size + cy > band->aheight) {
+ if (mb->_xPos + dmv_x < 0
+ || mb->_xPos + dmv_x + band->_mbSize + cx > band->_pitch
+ || mb->_yPos + dmv_y < 0
+ || mb->_yPos + dmv_y + band->_mbSize + cy > band->_aHeight) {
warning("MV out of bounds");
return -1;
}
@@ -993,82 +995,82 @@ int IndeoDecoderBase::ivi_process_empty_tile(IVIBandDesc *band,
mb++;
if (ref_mb)
ref_mb++;
- mb_offset += band->mb_size;
+ mb_offset += band->_mbSize;
} // for x
offs += row_offset;
} // for y
- if (band->inherit_mv && need_mc) { // apply motion compensation if there is at least one non-zero motion vector
- num_blocks = (band->mb_size != band->blk_size) ? 4 : 1; // number of blocks per mb
- mc_no_delta_func = (band->blk_size == 8) ? IndeoDSP::ff_ivi_mc_8x8_no_delta
+ if (band->_inheritMv && need_mc) { // apply motion compensation if there is at least one non-zero motion vector
+ num_blocks = (band->_mbSize != band->_blkSize) ? 4 : 1; // number of blocks per mb
+ mc_no_delta_func = (band->_blkSize == 8) ? IndeoDSP::ff_ivi_mc_8x8_no_delta
: IndeoDSP::ff_ivi_mc_4x4_no_delta;
- for (mbn = 0, mb = tile->mbs; mbn < tile->num_MBs; mb++, mbn++) {
- mv_x = mb->mv_x;
- mv_y = mb->mv_y;
- if (!band->is_halfpel) {
+ for (mbn = 0, mb = tile->_mbs; mbn < tile->_numMBs; mb++, mbn++) {
+ _mvX = mb->_mvX;
+ _mvY = mb->_mvY;
+ if (!band->_isHalfpel) {
mc_type = 0; // we have only fullpel vectors
} else {
- mc_type = ((mv_y & 1) << 1) | (mv_x & 1);
- mv_x >>= 1;
- mv_y >>= 1; // convert halfpel vectors into fullpel ones
+ mc_type = ((_mvY & 1) << 1) | (_mvX & 1);
+ _mvX >>= 1;
+ _mvY >>= 1; // convert halfpel vectors into fullpel ones
}
for (blk = 0; blk < num_blocks; blk++) {
// adjust block position in the buffer according with its number
- offs = mb->buf_offs + band->blk_size * ((blk & 1) + !!(blk & 2) * band->pitch);
+ offs = mb->_bufOffs + band->_blkSize * ((blk & 1) + !!(blk & 2) * band->_pitch);
ret = ivi_mc(band, mc_no_delta_func, nullptr, offs,
- mv_x, mv_y, 0, 0, mc_type, -1);
+ _mvX, _mvY, 0, 0, mc_type, -1);
if (ret < 0)
return ret;
}
}
} else {
// copy data from the reference tile into the current one
- src = band->ref_buf + tile->ypos * band->pitch + tile->xpos;
- dst = band->buf + tile->ypos * band->pitch + tile->xpos;
- for (y = 0; y < tile->height; y++) {
- memcpy(dst, src, tile->width*sizeof(band->buf[0]));
- src += band->pitch;
- dst += band->pitch;
+ src = band->_refBuf + tile->_yPos * band->_pitch + tile->_xPos;
+ dst = band->_buf + tile->_yPos * band->_pitch + tile->_xPos;
+ for (y = 0; y < tile->_height; y++) {
+ memcpy(dst, src, tile->_width*sizeof(band->_buf[0]));
+ src += band->_pitch;
+ dst += band->_pitch;
}
}
return 0;
}
-int IndeoDecoderBase::ivi_dec_tile_data_size(GetBits *gb) {
+int IndeoDecoderBase::ivi_dec_tile_data_size(GetBits *_gb) {
int len = 0;
- if (gb->getBits1()) {
- len = gb->getBits(8);
+ if (_gb->getBits1()) {
+ len = _gb->getBits(8);
if (len == 255)
- len = gb->getBitsLong(24);
+ len = _gb->getBitsLong(24);
}
// align the bitstream reader on the byte boundary
- gb->alignGetBits();
+ _gb->alignGetBits();
return len;
}
-int IndeoDecoderBase::ivi_decode_blocks(GetBits *gb, IVIBandDesc *band, IVITile *tile) {
- int mbn, blk, num_blocks, blk_size, ret, is_intra;
+int IndeoDecoderBase::ivi_decode_blocks(GetBits *_gb, IVIBandDesc *band, IVITile *tile) {
+ int mbn, blk, num_blocks, _blkSize, ret, is_intra;
int mc_type = 0, mc_type2 = -1;
- int mv_x = 0, mv_y = 0, mv_x2 = 0, mv_y2 = 0;
+ int _mvX = 0, _mvY = 0, mv_x2 = 0, mv_y2 = 0;
int32 prev_dc;
- uint32 cbp, quant, buf_offs;
+ uint32 _cbp, quant, _bufOffs;
IVIMbInfo *mb;
- ivi_mc_func mc_with_delta_func, mc_no_delta_func;
- ivi_mc_avg_func mc_avg_with_delta_func, mc_avg_no_delta_func;
+ IviMCFunc mc_with_delta_func, mc_no_delta_func;
+ IviMCAvgFunc mc_avg_with_delta_func, mc_avg_no_delta_func;
const uint8 *scale_tab;
// init intra prediction for the DC coefficient
prev_dc = 0;
- blk_size = band->blk_size;
+ _blkSize = band->_blkSize;
// number of blocks per mb
- num_blocks = (band->mb_size != blk_size) ? 4 : 1;
- if (blk_size == 8) {
+ num_blocks = (band->_mbSize != _blkSize) ? 4 : 1;
+ if (_blkSize == 8) {
mc_with_delta_func = IndeoDSP::ff_ivi_mc_8x8_delta;
mc_no_delta_func = IndeoDSP::ff_ivi_mc_8x8_no_delta;
mc_avg_with_delta_func = IndeoDSP::ff_ivi_mc_avg_8x8_delta;
@@ -1080,65 +1082,65 @@ int IndeoDecoderBase::ivi_decode_blocks(GetBits *gb, IVIBandDesc *band, IVITile
mc_avg_no_delta_func = IndeoDSP::ff_ivi_mc_avg_4x4_no_delta;
}
- for (mbn = 0, mb = tile->mbs; mbn < tile->num_MBs; mb++, mbn++) {
- is_intra = !mb->type;
- cbp = mb->cbp;
- buf_offs = mb->buf_offs;
+ for (mbn = 0, mb = tile->_mbs; mbn < tile->_numMBs; mb++, mbn++) {
+ is_intra = !mb->_type;
+ _cbp = mb->_cbp;
+ _bufOffs = mb->_bufOffs;
- quant = band->glob_quant + mb->q_delta;
- if (_ctx.is_indeo4)
+ quant = band->_globQuant + mb->_qDelta;
+ if (_ctx._isIndeo4)
quant = av_clip_uintp2(quant, 5);
else
quant = av_clip((int)quant, 0, 23);
- scale_tab = is_intra ? band->intra_scale : band->inter_scale;
+ scale_tab = is_intra ? band->_intraScale : band->_interScale;
if (scale_tab)
quant = scale_tab[quant];
if (!is_intra) {
- mv_x = mb->mv_x;
- mv_y = mb->mv_y;
- mv_x2 = mb->b_mv_x;
- mv_y2 = mb->b_mv_y;
- if (band->is_halfpel) {
- mc_type = ((mv_y & 1) << 1) | (mv_x & 1);
+ _mvX = mb->_mvX;
+ _mvY = mb->_mvY;
+ mv_x2 = mb->_bMvX;
+ mv_y2 = mb->_bMvY;
+ if (band->_isHalfpel) {
+ mc_type = ((_mvY & 1) << 1) | (_mvX & 1);
mc_type2 = ((mv_y2 & 1) << 1) | (mv_x2 & 1);
- mv_x >>= 1;
- mv_y >>= 1;
+ _mvX >>= 1;
+ _mvY >>= 1;
mv_x2 >>= 1;
mv_y2 >>= 1; // convert halfpel vectors into fullpel ones
}
- if (mb->type == 2)
+ if (mb->_type == 2)
mc_type = -1;
- if (mb->type != 2 && mb->type != 3)
+ if (mb->_type != 2 && mb->_type != 3)
mc_type2 = -1;
- if (mb->type) {
+ if (mb->_type) {
int dmv_x, dmv_y, cx, cy;
- dmv_x = mb->mv_x >> band->is_halfpel;
- dmv_y = mb->mv_y >> band->is_halfpel;
- cx = mb->mv_x & band->is_halfpel;
- cy = mb->mv_y & band->is_halfpel;
+ dmv_x = mb->_mvX >> band->_isHalfpel;
+ dmv_y = mb->_mvY >> band->_isHalfpel;
+ cx = mb->_mvX & band->_isHalfpel;
+ cy = mb->_mvY & band->_isHalfpel;
- if (mb->xpos + dmv_x < 0 ||
- mb->xpos + dmv_x + band->mb_size + cx > band->pitch ||
- mb->ypos + dmv_y < 0 ||
- mb->ypos + dmv_y + band->mb_size + cy > band->aheight) {
+ if (mb->_xPos + dmv_x < 0 ||
+ mb->_xPos + dmv_x + band->_mbSize + cx > band->_pitch ||
+ mb->_yPos + dmv_y < 0 ||
+ mb->_yPos + dmv_y + band->_mbSize + cy > band->_aHeight) {
return -1;
}
}
- if (mb->type == 2 || mb->type == 3) {
+ if (mb->_type == 2 || mb->_type == 3) {
int dmv_x, dmv_y, cx, cy;
- dmv_x = mb->b_mv_x >> band->is_halfpel;
- dmv_y = mb->b_mv_y >> band->is_halfpel;
- cx = mb->b_mv_x & band->is_halfpel;
- cy = mb->b_mv_y & band->is_halfpel;
+ dmv_x = mb->_bMvX >> band->_isHalfpel;
+ dmv_y = mb->_bMvY >> band->_isHalfpel;
+ cx = mb->_bMvX & band->_isHalfpel;
+ cy = mb->_bMvY & band->_isHalfpel;
- if (mb->xpos + dmv_x < 0 ||
- mb->xpos + dmv_x + band->mb_size + cx > band->pitch ||
- mb->ypos + dmv_y < 0 ||
- mb->ypos + dmv_y + band->mb_size + cy > band->aheight) {
+ if (mb->_xPos + dmv_x < 0 ||
+ mb->_xPos + dmv_x + band->_mbSize + cx > band->_pitch ||
+ mb->_yPos + dmv_y < 0 ||
+ mb->_yPos + dmv_y + band->_mbSize + cy > band->_aHeight) {
return -1;
}
}
@@ -1147,19 +1149,19 @@ int IndeoDecoderBase::ivi_decode_blocks(GetBits *gb, IVIBandDesc *band, IVITile
for (blk = 0; blk < num_blocks; blk++) {
// adjust block position in the buffer according to its number
if (blk & 1) {
- buf_offs += blk_size;
+ _bufOffs += _blkSize;
} else if (blk == 2) {
- buf_offs -= blk_size;
- buf_offs += blk_size * band->pitch;
+ _bufOffs -= _blkSize;
+ _bufOffs += _blkSize * band->_pitch;
}
- if (cbp & 1) { // block coded ?
- ret = ivi_decode_coded_blocks(gb, band, mc_with_delta_func,
+ if (_cbp & 1) { // block coded ?
+ ret = ivi_decode_coded_blocks(_gb, band, mc_with_delta_func,
mc_avg_with_delta_func,
- mv_x, mv_y, mv_x2, mv_y2,
+ _mvX, _mvY, mv_x2, mv_y2,
&prev_dc, is_intra,
mc_type, mc_type2, quant,
- buf_offs);
+ _bufOffs);
if (ret < 0)
return ret;
} else {
@@ -1167,23 +1169,23 @@ int IndeoDecoderBase::ivi_decode_blocks(GetBits *gb, IVIBandDesc *band, IVITile
// for intra blocks apply the dc slant transform
// for inter - perform the motion compensation without delta
if (is_intra) {
- ret = ivi_dc_transform(band, &prev_dc, buf_offs, blk_size);
+ ret = ivi_dc_transform(band, &prev_dc, _bufOffs, _blkSize);
if (ret < 0)
return ret;
} else {
ret = ivi_mc(band, mc_no_delta_func, mc_avg_no_delta_func,
- buf_offs, mv_x, mv_y, mv_x2, mv_y2,
+ _bufOffs, _mvX, _mvY, mv_x2, mv_y2,
mc_type, mc_type2);
if (ret < 0)
return ret;
}
}
- cbp >>= 1;
+ _cbp >>= 1;
}// for blk
}// for mbn
- gb->alignGetBits();
+ _gb->alignGetBits();
return 0;
}
@@ -1191,65 +1193,65 @@ int IndeoDecoderBase::ivi_scale_mv(int mv, int mv_scale){
return (mv + (mv > 0) + (mv_scale - 1)) >> mv_scale;
}
-int IndeoDecoderBase::ivi_mc(IVIBandDesc *band, ivi_mc_func mc, ivi_mc_avg_func mc_avg,
- int offs, int mv_x, int mv_y, int mv_x2, int mv_y2,
+int IndeoDecoderBase::ivi_mc(IVIBandDesc *band, IviMCFunc mc, IviMCAvgFunc mc_avg,
+ int offs, int _mvX, int _mvY, int mv_x2, int mv_y2,
int mc_type, int mc_type2){
- int ref_offs = offs + mv_y * band->pitch + mv_x;
- int buf_size = band->pitch * band->aheight;
- int min_size = band->pitch * (band->blk_size - 1) + band->blk_size;
- int ref_size = (mc_type > 1) * band->pitch + (mc_type & 1);
+ int ref_offs = offs + _mvY * band->_pitch + _mvX;
+ int buf_size = band->_pitch * band->_aHeight;
+ int min_size = band->_pitch * (band->_blkSize - 1) + band->_blkSize;
+ int ref_size = (mc_type > 1) * band->_pitch + (mc_type & 1);
if (mc_type != -1) {
- assert(offs >= 0 && ref_offs >= 0 && band->ref_buf);
+ assert(offs >= 0 && ref_offs >= 0 && band->_refBuf);
assert(buf_size - min_size >= offs);
assert(buf_size - min_size - ref_size >= ref_offs);
}
if (mc_type2 == -1) {
- mc(band->buf + offs, band->ref_buf + ref_offs, band->pitch, mc_type);
+ mc(band->_buf + offs, band->_refBuf + ref_offs, band->_pitch, mc_type);
} else {
- int ref_offs2 = offs + mv_y2 * band->pitch + mv_x2;
- int ref_size2 = (mc_type2 > 1) * band->pitch + (mc_type2 & 1);
- if (offs < 0 || ref_offs2 < 0 || !band->b_ref_buf)
+ int ref_offs2 = offs + mv_y2 * band->_pitch + mv_x2;
+ int ref_size2 = (mc_type2 > 1) * band->_pitch + (mc_type2 & 1);
+ if (offs < 0 || ref_offs2 < 0 || !band->_bRefBuf)
return -1;
if (buf_size - min_size - ref_size2 < ref_offs2)
return -1;
if (mc_type == -1)
- mc(band->buf + offs, band->b_ref_buf + ref_offs2,
- band->pitch, mc_type2);
+ mc(band->_buf + offs, band->_bRefBuf + ref_offs2,
+ band->_pitch, mc_type2);
else
- mc_avg(band->buf + offs, band->ref_buf + ref_offs,
- band->b_ref_buf + ref_offs2, band->pitch,
+ mc_avg(band->_buf + offs, band->_refBuf + ref_offs,
+ band->_bRefBuf + ref_offs2, band->_pitch,
mc_type, mc_type2);
}
return 0;
}
-int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
- ivi_mc_func mc, ivi_mc_avg_func mc_avg, int mv_x, int mv_y,
+int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *_gb, IVIBandDesc *band,
+ IviMCFunc mc, IviMCAvgFunc mc_avg, int _mvX, int _mvY,
int mv_x2, int mv_y2, int *prev_dc, int is_intra,
int mc_type, int mc_type2, uint32 quant, int offs) {
- const uint16 *base_tab = is_intra ? band->intra_base : band->inter_base;
- RVMapDesc *rvmap = band->rv_map;
+ const uint16 *base_tab = is_intra ? band->_intraBase : band->_interBase;
+ RVMapDesc *rvmap = band->_rvMap;
uint8 col_flags[8];
int32 trvec[64];
uint32 sym = 0, q;
int lo, hi;
int pos, run, val;
- int blk_size = band->blk_size;
- int num_coeffs = blk_size * blk_size;
- int col_mask = blk_size - 1;
+ int _blkSize = band->_blkSize;
+ int num_coeffs = _blkSize * _blkSize;
+ int col_mask = _blkSize - 1;
int scan_pos = -1;
- int min_size = band->pitch * (band->transform_size - 1) +
- band->transform_size;
- int buf_size = band->pitch * band->aheight - offs;
+ int min_size = band->_pitch * (band->_transformSize - 1) +
+ band->_transformSize;
+ int buf_size = band->_pitch * band->_aHeight - offs;
if (min_size > buf_size)
return -1;
- if (!band->scan) {
+ if (!band->_scan) {
warning("Scan pattern is not set.");
return -1;
}
@@ -1259,16 +1261,16 @@ int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
// zero column flags
memset(col_flags, 0, sizeof(col_flags));
while (scan_pos <= num_coeffs) {
- sym = gb->getVLC2(band->blk_vlc.tab->_table,
+ sym = _gb->getVLC2(band->_blkVlc._tab->_table,
IVI_VLC_BITS, 1);
- if (sym == rvmap->eob_sym)
+ if (sym == rvmap->_eobSym)
break; // End of block
// Escape - run/val explicitly coded using 3 vlc codes
- if (sym == rvmap->esc_sym) {
- run = gb->getVLC2(band->blk_vlc.tab->_table, IVI_VLC_BITS, 1) + 1;
- lo = gb->getVLC2(band->blk_vlc.tab->_table, IVI_VLC_BITS, 1);
- hi = gb->getVLC2(band->blk_vlc.tab->_table, IVI_VLC_BITS, 1);
+ if (sym == rvmap->_escSym) {
+ run = _gb->getVLC2(band->_blkVlc._tab->_table, IVI_VLC_BITS, 1) + 1;
+ lo = _gb->getVLC2(band->_blkVlc._tab->_table, IVI_VLC_BITS, 1);
+ hi = _gb->getVLC2(band->_blkVlc._tab->_table, IVI_VLC_BITS, 1);
// merge them and convert into signed val
val = IVI_TOSIGNED((hi << 6) | lo);
} else {
@@ -1276,15 +1278,15 @@ int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
warning("Invalid sym encountered");
return -1;
}
- run = rvmap->runtab[sym];
- val = rvmap->valtab[sym];
+ run = rvmap->_runtab[sym];
+ val = rvmap->_valtab[sym];
}
// de-zigzag and dequantize
scan_pos += run;
if (scan_pos >= num_coeffs || scan_pos < 0)
break;
- pos = band->scan[scan_pos];
+ pos = band->_scan[scan_pos];
if (!val)
warning("Val = 0 encountered!");
@@ -1297,43 +1299,43 @@ int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
col_flags[pos & col_mask] |= !!val;
}
- if (scan_pos < 0 || (scan_pos >= num_coeffs && sym != rvmap->eob_sym))
+ if (scan_pos < 0 || (scan_pos >= num_coeffs && sym != rvmap->_eobSym))
return -1; // corrupt block data
// undoing DC coeff prediction for intra-blocks
- if (is_intra && band->is_2d_trans) {
+ if (is_intra && band->_is2dTrans) {
*prev_dc += trvec[0];
trvec[0] = *prev_dc;
col_flags[0] |= !!*prev_dc;
}
- if (band->transform_size > band->blk_size) {
+ if (band->_transformSize > band->_blkSize) {
warning("Too large transform");
return -1;
}
// apply inverse transform
- band->inv_transform(trvec, band->buf + offs,
- band->pitch, col_flags);
+ band->_invTransform(trvec, band->_buf + offs,
+ band->_pitch, col_flags);
// apply motion compensation
if (!is_intra)
- return ivi_mc(band, mc, mc_avg, offs, mv_x, mv_y, mv_x2, mv_y2,
+ return ivi_mc(band, mc, mc_avg, offs, _mvX, _mvY, mv_x2, mv_y2,
mc_type, mc_type2);
return 0;
}
int IndeoDecoderBase::ivi_dc_transform(IVIBandDesc *band, int *prev_dc,
- int buf_offs, int blk_size) {
- int buf_size = band->pitch * band->aheight - buf_offs;
- int min_size = (blk_size - 1) * band->pitch + blk_size;
+ int bufOffs, int blkSize) {
+ int buf_size = band->_pitch * band->_aHeight - bufOffs;
+ int min_size = (blkSize - 1) * band->_pitch + blkSize;
if (min_size > buf_size)
return -1;
- band->dc_transform(prev_dc, band->buf + buf_offs,
- band->pitch, blk_size);
+ band->_dcTransform(prev_dc, band->_buf + bufOffs,
+ band->_pitch, blkSize);
return 0;
}
@@ -1377,8 +1379,8 @@ const uint8 IndeoDecoderBase::_ff_ivi_direct_scan_4x4[16] = {
const RVMapDesc IVI45DecContext::_ff_ivi_rvmap_tabs[9] = {
{ // MapTab0
- 5, // eob_sym
- 2, // esc_sym
+ 5, // _eobSym
+ 2, // _escSym
// run table
{1, 1, 0, 1, 1, 0, 1, 1, 2, 2, 1, 1, 1, 1, 3, 3,
1, 1, 2, 2, 1, 1, 4, 4, 1, 1, 1, 1, 2, 2, 5, 5,
@@ -1416,8 +1418,8 @@ const RVMapDesc IVI45DecContext::_ff_ivi_rvmap_tabs[9] = {
-1, -2, 2, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1}
},{
// MapTab1
- 0, // eob_sym
- 38, // esc_sym
+ 0, // _eobSym
+ 38, // _escSym
// run table
{0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 8, 6, 8, 7,
7, 9, 9, 10, 10, 11, 11, 1, 12, 1, 12, 13, 13, 16, 14, 16,
@@ -1455,8 +1457,8 @@ const RVMapDesc IVI45DecContext::_ff_ivi_rvmap_tabs[9] = {
-5, -4, -3, 4, 2, -3, 3, -2, -5, 5, 3, 3, -2, -3, -10, -4}
},{
// MapTab2
- 2, // eob_sym
- 11, // esc_sym
+ 2, // _eobSym
+ 11, // _escSym
// run table
{1, 1, 0, 2, 2, 1, 1, 3, 3, 4, 4, 0, 1, 1, 5, 5,
2, 2, 6, 6, 7, 7, 1, 8, 1, 8, 3, 3, 9, 9, 1, 2,
@@ -1494,8 +1496,8 @@ const RVMapDesc IVI45DecContext::_ff_ivi_rvmap_tabs[9] = {
-6, 1, -1, 1, -16, 1, 7, -1, 1, -1, -6, -3, 6, -7, 3, -1}
},{
// MapTab3
- 0, // eob_sym
- 35, // esc_sym
+ 0, // _eobSym
+ 35, // _escSym
// run table
{0, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 5, 5, 6, 6, 7,
7, 8, 8, 9, 9, 2, 2, 10, 10, 1, 1, 11, 11, 12, 12, 3,
@@ -1533,8 +1535,8 @@ const RVMapDesc IVI45DecContext::_ff_ivi_rvmap_tabs[9] = {
-2, 2, 2, 2, -5, 3, 5, 13, -3, 7, -3, -3, -7, 3, -13, 3}
},{
// MapTab4
- 0, // eob_sym
- 34, // esc_sym
+ 0, // _eobSym
+ 34, // _escSym
// run table
{0, 1, 1, 1, 2, 2, 1, 3, 3, 1, 1, 1, 4, 4, 1, 5,
2, 1, 5, 2, 1, 1, 6, 6, 1, 1, 1, 1, 1, 7, 3, 1,
@@ -1572,8 +1574,8 @@ const RVMapDesc IVI45DecContext::_ff_ivi_rvmap_tabs[9] = {
83, -81, 82, -82, 84, -87, -86, 85, -11, -85, 86, -89, 87, -88, 88, 89}
},{
// MapTab5
- 2, // eob_sym
- 33, // esc_sym
+ 2, // _eobSym
+ 33, // _escSym
// run table
{1, 1, 0, 2, 1, 2, 1, 3, 3, 1, 1, 4, 4, 2, 2, 1,
1, 5, 5, 6, 1, 6, 1, 7, 7, 3, 3, 2, 8, 2, 8, 1,
@@ -1611,8 +1613,8 @@ const RVMapDesc IVI45DecContext::_ff_ivi_rvmap_tabs[9] = {
-1, -32, 13, 7, 32, 33, -33, -1, -9, -34, 9, 34, -6, 5, 6, -5}
},{
// MapTab6
- 2, // eob_sym
- 13, // esc_sym
+ 2, // _eobSym
+ 13, // _escSym
// run table
{1, 1, 0, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 0, 2, 2,
4, 1, 4, 1, 1, 1, 5, 5, 1, 1, 6, 6, 2, 2, 1, 1,
@@ -1650,8 +1652,8 @@ const RVMapDesc IVI45DecContext::_ff_ivi_rvmap_tabs[9] = {
2, 58, 3, 8, -2, 57, -58, -60, -59, -57, -3, 60, 59, -14, 3, 14}
},{
// MapTab7
- 2, // eob_sym
- 38, // esc_sym
+ 2, // _eobSym
+ 38, // _escSym
// run table
{1, 1, 0, 2, 2, 1, 1, 3, 3, 4, 4, 5, 5, 1, 1, 6,
6, 2, 2, 7, 7, 8, 8, 1, 1, 3, 3, 9, 9, 10, 10, 1,
@@ -1689,8 +1691,8 @@ const RVMapDesc IVI45DecContext::_ff_ivi_rvmap_tabs[9] = {
3, -1, 3, -3, -23, 4, -4, 1, 23, -1, 1, -1, 1, -2, 2, -1}
},{
// MapTab8
- 4, // eob_sym
- 11, // esc_sym
+ 4, // _eobSym
+ 11, // _escSym
// run table
{1, 1, 1, 1, 0, 2, 2, 1, 1, 3, 3, 0, 1, 1, 2, 2,
4, 4, 1, 1, 5, 5, 1, 1, 2, 2, 3, 3, 6, 6, 1, 1,
diff --git a/image/codecs/indeo/indeo.h b/image/codecs/indeo/indeo.h
index c9d556a..b9e4693 100644
--- a/image/codecs/indeo/indeo.h
+++ b/image/codecs/indeo/indeo.h
@@ -64,15 +64,14 @@ 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 blk_size);
+typedef void (DCTransformPtr) (const int32 *in, int16 *out, uint32 pitch, int blkSize);
-typedef void(*ivi_mc_func) (int16 *buf, const int16 *ref_buf,
- uint32 pitch, int mc_type);
-typedef void(*ivi_mc_avg_func) (int16 *buf, const int16 *ref_buf1,
- const int16 *ref_buf2,
- uint32 pitch, int mc_type, int mc_type2);
+typedef void(*IviMCFunc) (int16 *buf, const int16 *refBuf, uint32 pitch, int mc_type);
+typedef void(*IviMCAvgFunc) (int16 *buf, const int16 *refBuf1, const int16 *refBuf2,
+ uint32 pitch, int mcType, int mcType2);
-#define IVI_VLC_BITS 13 ///< max number of bits of the ivi's huffman codes
+///< max number of bits of the ivi's huffman codes
+#define IVI_VLC_BITS 13
#define IVI5_IS_PROTECTED 0x20
/**
@@ -83,15 +82,15 @@ typedef void(*ivi_mc_avg_func) (int16 *buf, const int16 *ref_buf1,
/**
* calculate number of macroblocks in a tile
*/
-#define IVI_MBs_PER_TILE(tile_width, tile_height, mb_size) \
- ((((tile_width) + (mb_size) - 1) / (mb_size)) * (((tile_height) + (mb_size) - 1) / (mb_size)))
+#define IVI_MBs_PER_TILE(_tileWidth, _tileHeight, _mbSize) \
+ ((((_tileWidth) + (_mbSize) - 1) / (_mbSize)) * (((_tileHeight) + (_mbSize) - 1) / (_mbSize)))
/**
* huffman codebook descriptor
*/
struct IVIHuffDesc {
- int32 num_rows;
- uint8 xbits[16];
+ int32 _numRows;
+ uint8 _xBits[16];
/*
* Generate a huffman codebook from the given descriptor
@@ -126,13 +125,13 @@ struct IVI45DecContext;
*/
struct IVIHuffTab {
public:
- int32 tab_sel; /// index of one of the predefined tables
+ int32 _tabSel; /// index of one of the predefined tables
/// or "7" for custom one
- VLC *tab; /// pointer to the table associated with tab_sel
+ VLC * _tab; /// pointer to the table associated with tab_sel
/// the following are used only when tab_sel == 7
- IVIHuffDesc cust_desc; /// custom Huffman codebook descriptor
- VLC cust_tab; /// vlc table for custom codebook
+ IVIHuffDesc _custDesc; /// custom Huffman codebook descriptor
+ VLC _custTab; /// vlc table for custom codebook
/**
* Constructor
@@ -146,26 +145,26 @@ public:
* run-value (RLE) table descriptor
*/
struct RVMapDesc {
- uint8 eob_sym; ///< end of block symbol
- uint8 esc_sym; ///< escape symbol
- uint8 runtab[256];
- int8 valtab[256];
+ uint8 _eobSym; ///< end of block symbol
+ uint8 _escSym; ///< escape symbol
+ uint8 _runtab[256];
+ int8 _valtab[256];
};
/**
* information for Indeo macroblock (16x16, 8x8 or 4x4)
*/
struct IVIMbInfo {
- int16 xpos;
- int16 ypos;
- uint32 buf_offs; ///< address in the output buffer for this mb
- uint8 type; ///< macroblock type: 0 - INTRA, 1 - INTER
- uint8 cbp; ///< coded block pattern
- int8 q_delta; ///< quant delta
- int8 mv_x; ///< motion vector (x component)
- int8 mv_y; ///< motion vector (y component)
- int8 b_mv_x; ///< second motion vector (x component)
- int8 b_mv_y; ///< second motion vector (y component)
+ int16 _xPos;
+ int16 _yPos;
+ uint32 _bufOffs; ///< address in the output buffer for this mb
+ uint8 _type; ///< macroblock type: 0 - INTRA, 1 - INTER
+ uint8 _cbp; ///< coded block pattern
+ int8 _qDelta; ///< quant delta
+ int8 _mvX; ///< motion vector (x component)
+ int8 _mvY; ///< motion vector (y component)
+ int8 _bMvX; ///< second motion vector (x component)
+ int8 _bMvY; ///< second motion vector (y component)
IVIMbInfo();
};
@@ -174,16 +173,16 @@ struct IVIMbInfo {
* information for Indeo tile
*/
struct IVITile {
- int xpos;
- int ypos;
- int width;
- int height;
- int mb_size;
- int is_empty; ///< = 1 if this tile doesn't contain any data
- int data_size; ///< size of the data in bytes
- int num_MBs; ///< number of macroblocks in this tile
- IVIMbInfo * mbs; ///< array of macroblock descriptors
- IVIMbInfo * ref_mbs; ///< ptr to the macroblock descriptors of the reference tile
+ int _xPos;
+ int _yPos;
+ int _width;
+ int _height;
+ int _mbSize;
+ bool _isEmpty;
+ int _dataSize; ///< size of the data in bytes
+ int _numMBs; ///< number of macroblocks in this tile
+ IVIMbInfo * _mbs; ///< array of macroblock descriptors
+ IVIMbInfo * _refMbs; ///< ptr to the macroblock descriptors of the reference tile
IVITile();
};
@@ -192,49 +191,49 @@ struct IVITile {
* information for Indeo wavelet band
*/
struct IVIBandDesc {
- int plane; ///< plane number this band belongs to
- int band_num; ///< band number
- int width;
- int height;
- int aheight; ///< aligned band height
- const uint8 * data_ptr; ///< ptr to the first byte of the band data
- int data_size; ///< size of the band data
- int16 * buf; ///< pointer to the output buffer for this band
- int16 * ref_buf; ///< pointer to the reference frame buffer (for motion compensation)
- int16 * b_ref_buf; ///< pointer to the second reference frame buffer (for motion compensation)
- int16 * bufs[4]; ///< array of pointers to the band buffers
- int pitch; ///< pitch associated with the buffers above
- int is_empty; ///< = 1 if this band doesn't contain any data
- int mb_size; ///< macroblock size
- int blk_size; ///< block size
- int is_halfpel; ///< precision of the motion compensation: 0 - fullpel, 1 - halfpel
- int inherit_mv; ///< tells if motion vector is inherited from reference macroblock
- int inherit_qdelta; ///< tells if quantiser delta is inherited from reference macroblock
- int qdelta_present; ///< tells if Qdelta signal is present in the bitstream (Indeo5 only)
- int quant_mat; ///< dequant matrix index
- int glob_quant; ///< quant base for this band
- const uint8 * scan; ///< ptr to the scan pattern
- int scan_size; ///< size of the scantable
-
- IVIHuffTab blk_vlc; ///< vlc table for decoding block data
-
- int num_corr; ///< number of correction entries
- uint8 corr[61 * 2]; ///< rvmap correction pairs
- int rvmap_sel; ///< rvmap table selector
- RVMapDesc * rv_map; ///< ptr to the RLE table for this band
- int num_tiles; ///< number of tiles in this band
- IVITile * tiles; ///< array of tile descriptors
- InvTransformPtr *inv_transform;
- int transform_size;
- DCTransformPtr *dc_transform;
- int is_2d_trans; ///< 1 indicates that the two-dimensional inverse transform is used
- int32 checksum; ///< for debug purposes
- int checksum_present;
- int bufsize; ///< band buffer size in bytes
- const uint16 * intra_base; ///< quantization matrix for intra blocks
- const uint16 * inter_base; ///< quantization matrix for inter blocks
- const uint8 * intra_scale; ///< quantization coefficient for intra blocks
- const uint8 * inter_scale; ///< quantization coefficient for inter blocks
+ int _plane; ///< plane number this band belongs to
+ int _bandNum; ///< band number
+ int _width;
+ int _height;
+ int _aHeight; ///< aligned band height
+ const uint8 * _dataPtr; ///< ptr to the first byte of the band data
+ int _dataSize; ///< size of the band data
+ int16 * _buf; ///< pointer to the output buffer for this band
+ int16 * _refBuf; ///< pointer to the reference frame buffer (for motion compensation)
+ int16 * _bRefBuf; ///< pointer to the second reference frame buffer (for motion compensation)
+ int16 * _bufs[4]; ///< array of pointers to the band buffers
+ int _pitch; ///< _pitch associated with the buffers above
+ bool _isEmpty;
+ int _mbSize; ///< macroblock size
+ int _blkSize; ///< block size
+ uint8 _isHalfpel; ///< precision of the motion compensation: 0 - fullpel, 1 - halfpel
+ bool _inheritMv; ///< tells if motion vector is inherited from reference macroblock
+ bool _inheritQDelta; ///< tells if quantiser delta is inherited from reference macroblock
+ bool _qdeltaPresent; ///< tells if Qdelta signal is present in the bitstream (Indeo5 only)
+ int _quantMat; ///< dequant matrix index
+ int _globQuant; ///< quant base for this band
+ const uint8 * _scan; ///< ptr to the scan pattern
+ int _scanSize; ///< size of the scantable
+
+ IVIHuffTab _blkVlc; ///< vlc table for decoding block data
+
+ int _numCorr; ///< number of correction entries
+ uint8 _corr[61 * 2]; ///< rvmap correction pairs
+ int _rvmapSel; ///< rvmap table selector
+ RVMapDesc * _rvMap; ///< ptr to the RLE table for this band
+ int _numTiles; ///< number of tiles in this band
+ IVITile * _tiles; ///< array of tile descriptors
+ InvTransformPtr *_invTransform;
+ int _transformSize;
+ DCTransformPtr *_dcTransform;
+ bool _is2dTrans;
+ int32 _checksum; ///< for debug purposes
+ int _checksumPresent;
+ int _bufSize; ///< band buffer size in bytes
+ const uint16 * _intraBase; ///< quantization matrix for intra blocks
+ const uint16 * _interBase; ///< quantization matrix for inter blocks
+ const uint8 * _intraScale; ///< quantization coefficient for intra blocks
+ const uint8 * _interScale; ///< quantization coefficient for inter blocks
IVIBandDesc();
@@ -242,14 +241,14 @@ struct IVIBandDesc {
};
struct IVIPicConfig {
- uint16 pic_width;
- uint16 pic_height;
- uint16 chroma_width;
- uint16 chroma_height;
- uint16 tile_width;
- uint16 tile_height;
- uint8 luma_bands;
- uint8 chroma_bands;
+ uint16 _picWidth;
+ uint16 _picHeight;
+ uint16 _chromaWidth;
+ uint16 _chromaHeight;
+ uint16 _tileWidth;
+ uint16 _tileHeight;
+ uint8 _lumaBands;
+ uint8 _chromaBands;
IVIPicConfig();
@@ -263,16 +262,16 @@ struct IVIPicConfig {
* color plane (luma or chroma) information
*/
struct IVIPlaneDesc {
- uint16 width;
- uint16 height;
- uint8 num_bands; ///< number of bands this plane subdivided into
- IVIBandDesc *bands; ///< array of band descriptors
+ uint16 _width;
+ uint16 _height;
+ uint8 _numBands; ///< number of bands this plane subdivided into
+ IVIBandDesc * _bands; ///< array of band descriptors
IVIPlaneDesc();
- static int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg, bool is_indeo4);
+ static int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg, bool _isIndeo4);
- static int ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height);
+ static int ff_ivi_init_tiles(IVIPlaneDesc *planes, int _tileWidth, int _tileHeight);
/*
* Free planes, bands and macroblocks buffers.
@@ -349,60 +348,60 @@ struct AVFrame {
struct IVI45DecContext {
friend 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
+ VLC_TYPE _tableData[8192 * 16][2];
+ VLC _iviMbVlcTabs[8]; ///< static macroblock Huffman tables
+ VLC _iviBlkVlcTabs[8]; ///< static block Huffman tables
public:
- GetBits * gb;
- RVMapDesc rvmap_tabs[9]; ///< local corrected copy of the static rvmap tables
-
- uint32 frame_num;
- int frame_type;
- int prev_frame_type; ///< frame type of the previous frame
- uint32 data_size; ///< size of the frame data in bytes from picture header
- int is_scalable;
- const uint8 * frame_data; ///< input frame data pointer
- int inter_scal; ///< signals a sequence of scalable inter frames
- uint32 frame_size; ///< frame size in bytes
- uint32 pic_hdr_size; ///< picture header size in bytes
- uint8 frame_flags;
- uint16 checksum; ///< frame checksum
-
- IVIPicConfig pic_conf;
- IVIPlaneDesc planes[3]; ///< color planes
-
- int buf_switch; ///< used to switch between three buffers
- int dst_buf; ///< buffer index for the currently decoded frame
- int ref_buf; ///< inter frame reference buffer index
- int ref2_buf; ///< temporal storage for switching buffers
- int b_ref_buf; ///< second reference frame buffer index
-
- IVIHuffTab mb_vlc; ///< current macroblock table descriptor
- IVIHuffTab blk_vlc; ///< current block table descriptor
-
- uint8 rvmap_sel;
- uint8 in_imf;
- uint8 in_q; ///< flag for explicitly stored quantiser delta
- uint8 pic_glob_quant;
- uint8 unknown1;
-
- uint16 gop_hdr_size;
- uint8 gop_flags;
- uint32 lock_word;
-
- uint8 has_b_frames;
- uint8 has_transp; ///< transparency mode status: 1 - enabled
- uint8 uses_tiling;
- uint8 uses_haar;
- uint8 uses_fullpel;
-
- int gop_invalid;
- int buf_invalid[4];
-
- int is_indeo4;
-
- AVFrame * p_frame;
- int got_p_frame;
+ GetBits * _gb;
+ RVMapDesc _rvmapTabs[9]; ///< local corrected copy of the static rvmap tables
+
+ uint32 _frameNum;
+ int _frameType;
+ int _prevFrameType; ///< frame type of the previous frame
+ uint32 _dataSize; ///< size of the frame data in bytes from picture header
+ int _isScalable;
+ const uint8 * _frameData; ///< input frame data pointer
+ int _interScal; ///< signals a sequence of scalable inter frames
+ uint32 _frameSize; ///< frame size in bytes
+ uint32 _picHdrSize; ///< picture header size in bytes
+ uint8 _frameFlags;
+ uint16 _checksum; ///< frame _checksum
+
+ IVIPicConfig _picConf;
+ IVIPlaneDesc _planes[3]; ///< color planes
+
+ int _bufSwitch; ///< used to switch between three buffers
+ int _dstBuf; ///< buffer index for the currently decoded frame
+ int _refBuf; ///< inter frame reference buffer index
+ int _ref2Buf; ///< temporal storage for switching buffers
+ int _bRefBuf; ///< second reference frame buffer index
+
+ IVIHuffTab _mbVlc; ///< current macroblock table descriptor
+ IVIHuffTab _blkVlc; ///< current block table descriptor
+
+ uint8 _rvmapSel;
+ bool _inImf;
+ bool _inQ; ///< flag for explicitly stored quantiser delta
+ uint8 _picGlobQuant;
+ uint8 _unknown1;
+
+ uint16 _gopHdrSize;
+ uint8 _gopFlags;
+ uint32 _lockWord;
+
+ bool _hasBFrames;
+ bool _hasTransp; ///< transparency mode enabled
+ bool _usesTiling;
+ bool _usesHaar;
+ bool _usesFullpel;
+
+ bool _gopInvalid;
+ int _bufInvalid[4];
+
+ bool _isIndeo4;
+
+ AVFrame * _pFrame;
+ bool _gotPFrame;
IVI45DecContext();
private:
@@ -427,7 +426,7 @@ private:
*
* @param[in] plane pointer to the descriptor of the plane being processed
* @param[out] dst pointer to the destination buffer
- * @param[in] dst_pitch pitch of the destination buffer
+ * @param[in] dst_pitch _pitch of the destination buffer
*/
void ff_ivi_recompose_haar(const IVIPlaneDesc *plane, uint8 *dst,
const int dst_pitch);
@@ -437,7 +436,7 @@ private:
*
* @param[in] plane pointer to the descriptor of the plane being processed
* @param[out] dst pointer to the destination buffer
- * @param[in] dst_pitch pitch of the destination buffer
+ * @param[in] dst_pitch _pitch of the destination buffer
*/
void ff_ivi_recompose53(const IVIPlaneDesc *plane,
uint8 *dst, const int dst_pitch);
@@ -449,7 +448,7 @@ private:
*
* @param[in] plane pointer to the descriptor of the plane being processed
* @param[out] dst pointer to the buffer receiving converted pixels
- * @param[in] dst_pitch pitch for moving to the next y line
+ * @param[in] dst_pitch _pitch for moving to the next y line
*/
void ivi_output_plane(IVIPlaneDesc *plane, uint8 *dst, int dst_pitch);
@@ -488,17 +487,17 @@ private:
*/
int ivi_decode_blocks(GetBits *gb, IVIBandDesc *band, IVITile *tile);
- int ivi_mc(IVIBandDesc *band, ivi_mc_func mc, ivi_mc_avg_func mc_avg,
- int offs, int mv_x, int mv_y, int mv_x2, int mv_y2,
+ int ivi_mc(IVIBandDesc *band, IviMCFunc mc, IviMCAvgFunc mc_avg,
+ int offs, int _mvX, int _mvY, int mv_x2, int mv_y2,
int mc_type, int mc_type2);
int ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
- ivi_mc_func mc, ivi_mc_avg_func mc_avg, int mv_x, int mv_y,
+ IviMCFunc mc, IviMCAvgFunc mc_avg, int _mvX, int _mvY,
int mv_x2, int mv_y2, int *prev_dc, int is_intra,
int mc_type, int mc_type2, uint32 quant, int offs);
- int ivi_dc_transform(IVIBandDesc *band, int *prev_dc, int buf_offs,
- int blk_size);
+ int ivi_dc_transform(IVIBandDesc *band, int *prevDc, int bufOffs,
+ int blkSize);
protected:
IVI45DecContext _ctx;
Graphics::PixelFormat _pixelFormat;
@@ -538,7 +537,7 @@ protected:
virtual int decode_band_hdr(IVIBandDesc *band) = 0;
/**
- * Decode information (block type, cbp, quant delta, motion vector)
+ * Decode information (block type, _cbp, quant delta, motion vector)
* for all macroblocks in the current tile.
*
* @param[in,out] band pointer to the band descriptor
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index 7e0a451..12ab988 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -41,10 +41,10 @@ namespace Image {
#define IVI4_PIC_SIZE_ESC 7
Indeo4Decoder::Indeo4Decoder(uint16 width, uint16 height) : IndeoDecoderBase(width, height) {
- _ctx.is_indeo4 = true;
- _ctx.ref_buf = 1;
- _ctx.b_ref_buf = 3;
- _ctx.p_frame = new AVFrame();
+ _ctx._isIndeo4 = true;
+ _ctx._refBuf = 1;
+ _ctx._bRefBuf = 3;
+ _ctx._pFrame = new AVFrame();
}
bool Indeo4Decoder::isIndeo4(Common::SeekableReadStream &stream) {
@@ -72,56 +72,56 @@ const Graphics::Surface *Indeo4Decoder::decodeFrame(Common::SeekableReadStream &
// Set up the frame data buffer
byte *frameData = new byte[stream.size()];
stream.read(frameData, stream.size());
- _ctx.frame_data = frameData;
- _ctx.frame_size = stream.size();
+ _ctx._frameData = frameData;
+ _ctx._frameSize = stream.size();
// Set up the GetBits instance for reading the data
- _ctx.gb = new GetBits(_ctx.frame_data, _ctx.frame_size * 8);
+ _ctx._gb = new GetBits(_ctx._frameData, _ctx._frameSize * 8);
// Decode the frame
int err = decodeIndeoFrame();
// Free the bit reader and frame buffer
- delete _ctx.gb;
- _ctx.gb = nullptr;
+ delete _ctx._gb;
+ _ctx._gb = nullptr;
delete[] frameData;
- _ctx.frame_data = nullptr;
- _ctx.frame_size = 0;
+ _ctx._frameData = nullptr;
+ _ctx._frameSize = 0;
return (err < 0) ? nullptr : &_surface->rawSurface();
}
int Indeo4Decoder::decodePictureHeader() {
int pic_size_indx, i, p;
- IVIPicConfig pic_conf;
+ IVIPicConfig _picConf;
- if (_ctx.gb->getBits(18) != 0x3FFF8) {
+ if (_ctx._gb->getBits(18) != 0x3FFF8) {
warning("Invalid picture start code!");
return -1;
}
- _ctx.prev_frame_type = _ctx.frame_type;
- _ctx.frame_type = _ctx.gb->getBits(3);
- if (_ctx.frame_type == 7) {
- warning("Invalid frame type: %d", _ctx.frame_type);
+ _ctx._prevFrameType = _ctx._frameType;
+ _ctx._frameType = _ctx._gb->getBits(3);
+ if (_ctx._frameType == 7) {
+ warning("Invalid frame type: %d", _ctx._frameType);
return -1;
}
- if (_ctx.frame_type == IVI4_FRAMETYPE_BIDIR)
- _ctx.has_b_frames = 1;
+ if (_ctx._frameType == IVI4_FRAMETYPE_BIDIR)
+ _ctx._hasBFrames = true;
- _ctx.has_transp = _ctx.gb->getBits1();
+ _ctx._hasTransp = _ctx._gb->getBits1();
// unknown bit: Mac decoder ignores this bit, XANIM returns error
- if (_ctx.gb->getBits1()) {
+ if (_ctx._gb->getBits1()) {
warning("Sync bit is set!");
return -1;
}
- _ctx.data_size = _ctx.gb->getBits1() ? _ctx.gb->getBits(24) : 0;
+ _ctx._dataSize = _ctx._gb->getBits1() ? _ctx._gb->getBits(24) : 0;
// null frames don't contain anything else so we just return
- if (_ctx.frame_type >= IVI4_FRAMETYPE_NULL_FIRST) {
+ if (_ctx._frameType >= IVI4_FRAMETYPE_NULL_FIRST) {
warning("Null frame encountered!");
return 0;
}
@@ -129,108 +129,108 @@ int Indeo4Decoder::decodePictureHeader() {
// Check key lock status. If enabled - ignore lock word.
// Usually we have to prompt the user for the password, but
// we don't do that because Indeo 4 videos can be decoded anyway
- if (_ctx.gb->getBits1()) {
- _ctx.gb->skipBitsLong(32);
+ if (_ctx._gb->getBits1()) {
+ _ctx._gb->skipBitsLong(32);
warning("Password-protected clip!");
}
- pic_size_indx = _ctx.gb->getBits(3);
+ pic_size_indx = _ctx._gb->getBits(3);
if (pic_size_indx == IVI4_PIC_SIZE_ESC) {
- pic_conf.pic_height = _ctx.gb->getBits(16);
- pic_conf.pic_width = _ctx.gb->getBits(16);
+ _picConf._picHeight = _ctx._gb->getBits(16);
+ _picConf._picWidth = _ctx._gb->getBits(16);
} else {
- pic_conf.pic_height = _ivi4_common_pic_sizes[pic_size_indx * 2 + 1];
- pic_conf.pic_width = _ivi4_common_pic_sizes[pic_size_indx * 2];
+ _picConf._picHeight = _ivi4_common_pic_sizes[pic_size_indx * 2 + 1];
+ _picConf._picWidth = _ivi4_common_pic_sizes[pic_size_indx * 2];
}
// Decode tile dimensions.
- _ctx.uses_tiling = _ctx.gb->getBits1();
- if (_ctx.uses_tiling) {
- pic_conf.tile_height = scaleTileSize(pic_conf.pic_height, _ctx.gb->getBits(4));
- pic_conf.tile_width = scaleTileSize(pic_conf.pic_width, _ctx.gb->getBits(4));
+ _ctx._usesTiling = _ctx._gb->getBits1();
+ if (_ctx._usesTiling) {
+ _picConf._tileHeight = scaleTileSize(_picConf._picHeight, _ctx._gb->getBits(4));
+ _picConf._tileWidth = scaleTileSize(_picConf._picWidth, _ctx._gb->getBits(4));
} else {
- pic_conf.tile_height = pic_conf.pic_height;
- pic_conf.tile_width = pic_conf.pic_width;
+ _picConf._tileHeight = _picConf._picHeight;
+ _picConf._tileWidth = _picConf._picWidth;
}
// Decode chroma subsampling. We support only 4:4 aka YVU9.
- if (_ctx.gb->getBits(2)) {
+ if (_ctx._gb->getBits(2)) {
warning("Only YVU9 picture format is supported!");
return -1;
}
- pic_conf.chroma_height = (pic_conf.pic_height + 3) >> 2;
- pic_conf.chroma_width = (pic_conf.pic_width + 3) >> 2;
+ _picConf._chromaHeight = (_picConf._picHeight + 3) >> 2;
+ _picConf._chromaWidth = (_picConf._picWidth + 3) >> 2;
// decode subdivision of the planes
- pic_conf.luma_bands = decodePlaneSubdivision();
- pic_conf.chroma_bands = 0;
- if (pic_conf.luma_bands)
- pic_conf.chroma_bands = decodePlaneSubdivision();
- _ctx.is_scalable = pic_conf.luma_bands != 1 || pic_conf.chroma_bands != 1;
- if (_ctx.is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) {
+ _picConf._lumaBands = decodePlaneSubdivision();
+ _picConf._chromaBands = 0;
+ if (_picConf._lumaBands)
+ _picConf._chromaBands = decodePlaneSubdivision();
+ _ctx._isScalable = _picConf._lumaBands != 1 || _picConf._chromaBands != 1;
+ if (_ctx._isScalable && (_picConf._lumaBands != 4 || _picConf._chromaBands != 1)) {
warning("Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d",
- pic_conf.luma_bands, pic_conf.chroma_bands);
+ _picConf._lumaBands, _picConf._chromaBands);
return -1;
}
// check if picture layout was changed and reallocate buffers
- if (pic_conf.ivi_pic_config_cmp(_ctx.pic_conf)) {
- if (IVIPlaneDesc::ff_ivi_init_planes(_ctx.planes, &pic_conf, 1)) {
+ if (_picConf.ivi_pic_config_cmp(_ctx._picConf)) {
+ if (IVIPlaneDesc::ff_ivi_init_planes(_ctx._planes, &_picConf, 1)) {
warning("Couldn't reallocate color planes!");
- _ctx.pic_conf.luma_bands = 0;
+ _ctx._picConf._lumaBands = 0;
return -2;
}
- _ctx.pic_conf = pic_conf;
+ _ctx._picConf = _picConf;
// set default macroblock/block dimensions
for (p = 0; p <= 2; p++) {
- for (i = 0; i < (!p ? pic_conf.luma_bands : pic_conf.chroma_bands); i++) {
- _ctx.planes[p].bands[i].mb_size = !p ? (!_ctx.is_scalable ? 16 : 8) : 4;
- _ctx.planes[p].bands[i].blk_size = !p ? 8 : 4;
+ for (i = 0; i < (!p ? _picConf._lumaBands : _picConf._chromaBands); i++) {
+ _ctx._planes[p]._bands[i]._mbSize = !p ? (!_ctx._isScalable ? 16 : 8) : 4;
+ _ctx._planes[p]._bands[i]._blkSize = !p ? 8 : 4;
}
}
- if (IVIPlaneDesc::ff_ivi_init_tiles(_ctx.planes, _ctx.pic_conf.tile_width,
- _ctx.pic_conf.tile_height)) {
+ if (IVIPlaneDesc::ff_ivi_init_tiles(_ctx._planes, _ctx._picConf._tileWidth,
+ _ctx._picConf._tileHeight)) {
warning("Couldn't reallocate internal structures!");
return -2;
}
}
- _ctx.frame_num = _ctx.gb->getBits1() ? _ctx.gb->getBits(20) : 0;
+ _ctx._frameNum = _ctx._gb->getBits1() ? _ctx._gb->getBits(20) : 0;
// skip decTimeEst field if present
- if (_ctx.gb->getBits1())
- _ctx.gb->skipBits(8);
+ if (_ctx._gb->getBits1())
+ _ctx._gb->skipBits(8);
// decode macroblock and block huffman codebooks
- 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))
+ if (_ctx._mbVlc.ff_ivi_dec_huff_desc(&_ctx, _ctx._gb->getBits1(), IVI_MB_HUFF) ||
+ _ctx._blkVlc.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;
+ _ctx._rvmapSel = _ctx._gb->getBits1() ? _ctx._gb->getBits(3) : 8;
- _ctx.in_imf = _ctx.gb->getBits1();
- _ctx.in_q = _ctx.gb->getBits1();
+ _ctx._inImf = _ctx._gb->getBits1();
+ _ctx._inQ = _ctx._gb->getBits1();
- _ctx.pic_glob_quant = _ctx.gb->getBits(5);
+ _ctx._picGlobQuant = _ctx._gb->getBits(5);
// TODO: ignore this parameter if unused
- _ctx.unknown1 = _ctx.gb->getBits1() ? _ctx.gb->getBits(3) : 0;
+ _ctx._unknown1 = _ctx._gb->getBits1() ? _ctx._gb->getBits(3) : 0;
- _ctx.checksum = _ctx.gb->getBits1() ? _ctx.gb->getBits(16) : 0;
+ _ctx._checksum = _ctx._gb->getBits1() ? _ctx._gb->getBits(16) : 0;
// skip picture header extension if any
- while (_ctx.gb->getBits1()) {
- _ctx.gb->skipBits(8);
+ while (_ctx._gb->getBits1()) {
+ _ctx._gb->skipBits(8);
}
- if (_ctx.gb->getBits1()) {
+ if (_ctx._gb->getBits1()) {
warning("Bad blocks bits encountered!");
}
- _ctx.gb->alignGetBits();
+ _ctx._gb->alignGetBits();
return 0;
}
@@ -238,7 +238,7 @@ int Indeo4Decoder::decodePictureHeader() {
void Indeo4Decoder::switch_buffers() {
int is_prev_ref = 0, is_ref = 0;
- switch (_ctx.prev_frame_type) {
+ switch (_ctx._prevFrameType) {
case IVI4_FRAMETYPE_INTRA:
case IVI4_FRAMETYPE_INTRA1:
case IVI4_FRAMETYPE_INTER:
@@ -246,7 +246,7 @@ void Indeo4Decoder::switch_buffers() {
break;
}
- switch (_ctx.frame_type) {
+ switch (_ctx._frameType) {
case IVI4_FRAMETYPE_INTRA:
case IVI4_FRAMETYPE_INTRA1:
case IVI4_FRAMETYPE_INTER:
@@ -258,67 +258,67 @@ void Indeo4Decoder::switch_buffers() {
}
if (is_prev_ref && is_ref) {
- FFSWAP(int, _ctx.dst_buf, _ctx.ref_buf);
+ FFSWAP(int, _ctx._dstBuf, _ctx._refBuf);
} else if (is_prev_ref) {
- FFSWAP(int, _ctx.ref_buf, _ctx.b_ref_buf);
- FFSWAP(int, _ctx.dst_buf, _ctx.ref_buf);
+ FFSWAP(int, _ctx._refBuf, _ctx._bRefBuf);
+ FFSWAP(int, _ctx._dstBuf, _ctx._refBuf);
}
}
bool Indeo4Decoder::is_nonnull_frame() const {
- return _ctx.frame_type < IVI4_FRAMETYPE_NULL_FIRST;
+ return _ctx._frameType < IVI4_FRAMETYPE_NULL_FIRST;
}
int Indeo4Decoder::decode_band_hdr(IVIBandDesc *band) {
- int plane, band_num, indx, transform_id, scan_indx;
+ int plane, _bandNum, indx, transform_id, scan_indx;
int i;
- int quant_mat;
+ int _quantMat;
- plane = _ctx.gb->getBits(2);
- band_num = _ctx.gb->getBits(4);
- if (band->plane != plane || band->band_num != band_num) {
+ plane = _ctx._gb->getBits(2);
+ _bandNum = _ctx._gb->getBits(4);
+ if (band->_plane != plane || band->_bandNum != _bandNum) {
warning("Invalid band header sequence!");
return -1;
}
- band->is_empty = _ctx.gb->getBits1();
- if (!band->is_empty) {
- int old_blk_size = band->blk_size;
+ band->_isEmpty = _ctx._gb->getBits1();
+ if (!band->_isEmpty) {
+ int old_blk_size = band->_blkSize;
// skip header size
// If header size is not given, header size is 4 bytes.
- if (_ctx.gb->getBits1())
- _ctx.gb->skipBits(16);
+ if (_ctx._gb->getBits1())
+ _ctx._gb->skipBits(16);
- band->is_halfpel = _ctx.gb->getBits(2);
- if (band->is_halfpel >= 2) {
+ band->_isHalfpel = _ctx._gb->getBits(2);
+ if (band->_isHalfpel >= 2) {
warning("Invalid/unsupported mv resolution: %d!",
- band->is_halfpel);
+ band->_isHalfpel);
return -1;
}
- if (!band->is_halfpel)
- _ctx.uses_fullpel = 1;
+ if (!band->_isHalfpel)
+ _ctx._usesFullpel = true;
- band->checksum_present = _ctx.gb->getBits1();
- if (band->checksum_present)
- band->checksum = _ctx.gb->getBits(16);
+ band->_checksumPresent = _ctx._gb->getBits1();
+ if (band->_checksumPresent)
+ band->_checksum = _ctx._gb->getBits(16);
- indx = _ctx.gb->getBits(2);
+ indx = _ctx._gb->getBits(2);
if (indx == 3) {
warning("Invalid block size!");
return -1;
}
- band->mb_size = 16 >> indx;
- band->blk_size = 8 >> (indx >> 1);
+ band->_mbSize = 16 >> indx;
+ band->_blkSize = 8 >> (indx >> 1);
- band->inherit_mv = _ctx.gb->getBits1();
- band->inherit_qdelta = _ctx.gb->getBits1();
+ band->_inheritMv = _ctx._gb->getBits1();
+ band->_inheritQDelta = _ctx._gb->getBits1();
- band->glob_quant = _ctx.gb->getBits(5);
+ band->_globQuant = _ctx._gb->getBits(5);
- if (!_ctx.gb->getBits1() || _ctx.frame_type == IVI4_FRAMETYPE_INTRA) {
- transform_id = _ctx.gb->getBits(5);
+ if (!_ctx._gb->getBits1() || _ctx._frameType == IVI4_FRAMETYPE_INTRA) {
+ transform_id = _ctx._gb->getBits(5);
if ((uint)transform_id >= FF_ARRAY_ELEMS(_transforms) ||
- !_transforms[transform_id].inv_trans) {
+ !_transforms[transform_id]._invTrans) {
warning("Transform %d", transform_id);
return -3;
}
@@ -328,117 +328,117 @@ int Indeo4Decoder::decode_band_hdr(IVIBandDesc *band) {
return -3;
}
- if (transform_id < 10 && band->blk_size < 8) {
+ if (transform_id < 10 && band->_blkSize < 8) {
warning("wrong transform size!");
return -1;
}
if ((transform_id >= 0 && transform_id <= 2) || transform_id == 10)
- _ctx.uses_haar = 1;
+ _ctx._usesHaar = true;
- band->inv_transform = _transforms[transform_id].inv_trans;
- band->dc_transform = _transforms[transform_id].dc_trans;
- band->is_2d_trans = _transforms[transform_id].is_2d_trans;
+ band->_invTransform = _transforms[transform_id]._invTrans;
+ band->_dcTransform = _transforms[transform_id]._dcTrans;
+ band->_is2dTrans = _transforms[transform_id]._is2dTrans;
if (transform_id < 10)
- band->transform_size = 8;
+ band->_transformSize = 8;
else
- band->transform_size = 4;
+ band->_transformSize = 4;
- if (band->blk_size != band->transform_size) {
- warning("transform and block size mismatch (%d != %d)", band->transform_size, band->blk_size);
+ if (band->_blkSize != band->_transformSize) {
+ warning("transform and block size mismatch (%d != %d)", band->_transformSize, band->_blkSize);
return -1;
}
- scan_indx = _ctx.gb->getBits(4);
+ scan_indx = _ctx._gb->getBits(4);
if (scan_indx == 15) {
warning("Custom scan pattern encountered!");
return -1;
}
if (scan_indx > 4 && scan_indx < 10) {
- if (band->blk_size != 4) {
+ if (band->_blkSize != 4) {
warning("mismatching scan table!");
return -1;
}
- } else if (band->blk_size != 8) {
+ } else if (band->_blkSize != 8) {
warning("mismatching scan table!");
return -1;
}
- band->scan = _scan_index_to_tab[scan_indx];
- band->scan_size = band->blk_size;
+ band->_scan = _scan_index_to_tab[scan_indx];
+ band->_scanSize = band->_blkSize;
- quant_mat = _ctx.gb->getBits(5);
- if (quant_mat == 31) {
+ _quantMat = _ctx._gb->getBits(5);
+ if (_quantMat == 31) {
warning("Custom quant matrix encountered!");
return -1;
}
- if ((uint)quant_mat >= FF_ARRAY_ELEMS(_quant_index_to_tab)) {
- warning("Quantization matrix %d", quant_mat);
+ if ((uint)_quantMat >= FF_ARRAY_ELEMS(_quant_index_to_tab)) {
+ warning("Quantization matrix %d", _quantMat);
return -1;
}
- band->quant_mat = quant_mat;
+ band->_quantMat = _quantMat;
} else {
- if (old_blk_size != band->blk_size) {
+ if (old_blk_size != band->_blkSize) {
warning("The band block size does not match the configuration inherited");
return -1;
}
}
- if (_quant_index_to_tab[band->quant_mat] > 4 && band->blk_size == 4) {
+ if (_quant_index_to_tab[band->_quantMat] > 4 && band->_blkSize == 4) {
warning("Invalid quant matrix for 4x4 block encountered!");
- band->quant_mat = 0;
+ band->_quantMat = 0;
return -1;
}
- if (band->scan_size != band->blk_size) {
+ if (band->_scanSize != band->_blkSize) {
warning("mismatching scan table!");
return -1;
}
- if (band->transform_size == 8 && band->blk_size < 8) {
- warning("mismatching transform_size!");
+ if (band->_transformSize == 8 && band->_blkSize < 8) {
+ warning("mismatching _transformSize!");
return -1;
}
// decode block huffman codebook
- if (!_ctx.gb->getBits1())
- band->blk_vlc.tab = _ctx.blk_vlc.tab;
+ if (!_ctx._gb->getBits1())
+ band->_blkVlc._tab = _ctx._blkVlc._tab;
else
- if (band->blk_vlc.ff_ivi_dec_huff_desc(&_ctx, 1, IVI_BLK_HUFF))
+ if (band->_blkVlc.ff_ivi_dec_huff_desc(&_ctx, 1, IVI_BLK_HUFF))
return -1;
// select appropriate rvmap table for this band
- band->rvmap_sel = _ctx.gb->getBits1() ? _ctx.gb->getBits(3) : 8;
+ band->_rvmapSel = _ctx._gb->getBits1() ? _ctx._gb->getBits(3) : 8;
// decode rvmap probability corrections if any
- band->num_corr = 0; // there is no corrections
- if (_ctx.gb->getBits1()) {
- band->num_corr = _ctx.gb->getBits(8); // get number of correction pairs
- if (band->num_corr > 61) {
+ band->_numCorr = 0; // there is no corrections
+ if (_ctx._gb->getBits1()) {
+ band->_numCorr = _ctx._gb->getBits(8); // get number of correction pairs
+ if (band->_numCorr > 61) {
warning("Too many corrections: %d",
- band->num_corr);
+ band->_numCorr);
return -1;
}
// read correction pairs
- for (i = 0; i < band->num_corr * 2; i++)
- band->corr[i] = _ctx.gb->getBits(8);
+ for (i = 0; i < band->_numCorr * 2; i++)
+ band->_corr[i] = _ctx._gb->getBits(8);
}
}
- if (band->blk_size == 8) {
- band->intra_base = &_ivi4_quant_8x8_intra[_quant_index_to_tab[band->quant_mat]][0];
- band->inter_base = &_ivi4_quant_8x8_inter[_quant_index_to_tab[band->quant_mat]][0];
+ if (band->_blkSize == 8) {
+ band->_intraBase = &_ivi4_quant_8x8_intra[_quant_index_to_tab[band->_quantMat]][0];
+ band->_interBase = &_ivi4_quant_8x8_inter[_quant_index_to_tab[band->_quantMat]][0];
} else {
- band->intra_base = &_ivi4_quant_4x4_intra[_quant_index_to_tab[band->quant_mat]][0];
- band->inter_base = &_ivi4_quant_4x4_inter[_quant_index_to_tab[band->quant_mat]][0];
+ band->_intraBase = &_ivi4_quant_4x4_intra[_quant_index_to_tab[band->_quantMat]][0];
+ band->_interBase = &_ivi4_quant_4x4_inter[_quant_index_to_tab[band->_quantMat]][0];
}
// Indeo 4 doesn't use scale tables
- band->intra_scale = NULL;
- band->inter_scale = NULL;
+ band->_intraScale = NULL;
+ band->_interScale = NULL;
- _ctx.gb->alignGetBits();
+ _ctx._gb->alignGetBits();
- if (!band->scan) {
- warning("band->scan not set");
+ if (!band->_scan) {
+ warning("band->_scan not set");
return -1;
}
@@ -446,155 +446,154 @@ int Indeo4Decoder::decode_band_hdr(IVIBandDesc *band) {
}
int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
- int x, y, mv_x, mv_y, mv_delta, offs, mb_offset, blks_per_mb,
+ int x, y, _mvX, _mvY, mv_delta, offs, mb_offset, blks_per_mb,
mv_scale, mb_type_bits, s;
IVIMbInfo *mb, *ref_mb;
- int row_offset = band->mb_size * band->pitch;
+ int row_offset = band->_mbSize * band->_pitch;
- mb = tile->mbs;
- ref_mb = tile->ref_mbs;
- offs = tile->ypos * band->pitch + tile->xpos;
+ mb = tile->_mbs;
+ ref_mb = tile->_refMbs;
+ offs = tile->_yPos * band->_pitch + tile->_xPos;
- blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
- mb_type_bits = _ctx.frame_type == IVI4_FRAMETYPE_BIDIR ? 2 : 1;
+ blks_per_mb = band->_mbSize != band->_blkSize ? 4 : 1;
+ mb_type_bits = _ctx._frameType == IVI4_FRAMETYPE_BIDIR ? 2 : 1;
/* scale factor for motion vectors */
- mv_scale = (_ctx.planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
- mv_x = mv_y = 0;
+ mv_scale = (_ctx._planes[0]._bands[0]._mbSize >> 3) - (band->_mbSize >> 3);
+ _mvX = _mvY = 0;
- if (((tile->width + band->mb_size - 1) / band->mb_size) * ((tile->height + band->mb_size - 1) / band->mb_size) != tile->num_MBs) {
- warning("num_MBs mismatch %d %d %d %d", tile->width, tile->height, band->mb_size, tile->num_MBs);
+ if (((tile->_width + band->_mbSize - 1) / band->_mbSize) * ((tile->_height + band->_mbSize - 1) / band->_mbSize) != tile->_numMBs) {
+ warning("_numMBs mismatch %d %d %d %d", tile->_width, tile->_height, band->_mbSize, tile->_numMBs);
return -1;
}
- for (y = tile->ypos; y < tile->ypos + tile->height; y += band->mb_size) {
+ for (y = tile->_yPos; y < tile->_yPos + tile->_height; y += band->_mbSize) {
mb_offset = offs;
- for (x = tile->xpos; x < tile->xpos + tile->width; x += band->mb_size) {
- mb->xpos = x;
- mb->ypos = y;
- mb->buf_offs = mb_offset;
- mb->b_mv_x =
- mb->b_mv_y = 0;
+ for (x = tile->_xPos; x < tile->_xPos + tile->_width; x += band->_mbSize) {
+ mb->_xPos = x;
+ mb->_yPos = y;
+ mb->_bufOffs = mb_offset;
+ mb->_bMvX = mb->_bMvY = 0;
- if (_ctx.gb->getBits1()) {
- if (_ctx.frame_type == IVI4_FRAMETYPE_INTRA) {
+ if (_ctx._gb->getBits1()) {
+ if (_ctx._frameType == IVI4_FRAMETYPE_INTRA) {
warning("Empty macroblock in an INTRA picture!");
return -1;
}
- mb->type = 1; // empty macroblocks are always INTER
- mb->cbp = 0; // all blocks are empty
+ mb->_type = 1; // empty macroblocks are always INTER
+ mb->_cbp = 0; // all blocks are empty
- mb->q_delta = 0;
- if (!band->plane && !band->band_num && _ctx.in_q) {
- mb->q_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table,
+ mb->_qDelta = 0;
+ if (!band->_plane && !band->_bandNum && _ctx._inQ) {
+ mb->_qDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
IVI_VLC_BITS, 1);
- mb->q_delta = IVI_TOSIGNED(mb->q_delta);
+ mb->_qDelta = IVI_TOSIGNED(mb->_qDelta);
}
- mb->mv_x = mb->mv_y = 0; /* no motion vector coded */
- if (band->inherit_mv && ref_mb) {
- /* motion vector inheritance */
+ mb->_mvX = mb->_mvY = 0; // no motion vector coded
+ if (band->_inheritMv && ref_mb) {
+ // motion vector inheritance
if (mv_scale) {
- mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
- mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
+ mb->_mvX = ivi_scale_mv(ref_mb->_mvX, mv_scale);
+ mb->_mvY = ivi_scale_mv(ref_mb->_mvY, mv_scale);
} else {
- mb->mv_x = ref_mb->mv_x;
- mb->mv_y = ref_mb->mv_y;
+ mb->_mvX = ref_mb->_mvX;
+ mb->_mvY = ref_mb->_mvY;
}
}
} else {
- if (band->inherit_mv) {
+ if (band->_inheritMv) {
// copy mb_type from corresponding reference mb
if (!ref_mb) {
warning("ref_mb unavailable");
return -1;
}
- mb->type = ref_mb->type;
- } else if (_ctx.frame_type == IVI4_FRAMETYPE_INTRA ||
- _ctx.frame_type == IVI4_FRAMETYPE_INTRA1) {
- mb->type = 0; // mb_type is always INTRA for intra-frames
+ mb->_type = ref_mb->_type;
+ } else if (_ctx._frameType == IVI4_FRAMETYPE_INTRA ||
+ _ctx._frameType == IVI4_FRAMETYPE_INTRA1) {
+ mb->_type = 0; // mb_type is always INTRA for intra-frames
} else {
- mb->type = _ctx.gb->getBits(mb_type_bits);
+ mb->_type = _ctx._gb->getBits(mb_type_bits);
}
- mb->cbp = _ctx.gb->getBits(blks_per_mb);
+ mb->_cbp = _ctx._gb->getBits(blks_per_mb);
- mb->q_delta = 0;
- if (band->inherit_qdelta) {
- if (ref_mb) mb->q_delta = ref_mb->q_delta;
- } else if (mb->cbp || (!band->plane && !band->band_num &&
- _ctx.in_q)) {
- mb->q_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table,
+ mb->_qDelta = 0;
+ if (band->_inheritQDelta) {
+ if (ref_mb) mb->_qDelta = ref_mb->_qDelta;
+ } else if (mb->_cbp || (!band->_plane && !band->_bandNum &&
+ _ctx._inQ)) {
+ mb->_qDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
IVI_VLC_BITS, 1);
- mb->q_delta = IVI_TOSIGNED(mb->q_delta);
+ mb->_qDelta = IVI_TOSIGNED(mb->_qDelta);
}
- if (!mb->type) {
- mb->mv_x = mb->mv_y = 0; // there is no motion vector in intra-macroblocks
+ if (!mb->_type) {
+ mb->_mvX = mb->_mvY = 0; // there is no motion vector in intra-macroblocks
} else {
- if (band->inherit_mv) {
+ if (band->_inheritMv) {
if (ref_mb) {
// motion vector inheritance
if (mv_scale) {
- mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
- mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
+ mb->_mvX = ivi_scale_mv(ref_mb->_mvX, mv_scale);
+ mb->_mvY = ivi_scale_mv(ref_mb->_mvY, mv_scale);
} else {
- mb->mv_x = ref_mb->mv_x;
- mb->mv_y = ref_mb->mv_y;
+ mb->_mvX = ref_mb->_mvX;
+ mb->_mvY = ref_mb->_mvY;
}
}
} else {
// decode motion vector deltas
- mv_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table,
+ mv_delta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
IVI_VLC_BITS, 1);
- mv_y += IVI_TOSIGNED(mv_delta);
- mv_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table,
+ _mvY += IVI_TOSIGNED(mv_delta);
+ mv_delta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
IVI_VLC_BITS, 1);
- mv_x += IVI_TOSIGNED(mv_delta);
- mb->mv_x = mv_x;
- mb->mv_y = mv_y;
- if (mb->type == 3) {
- mv_delta = _ctx.gb->getVLC2(
- _ctx.mb_vlc.tab->_table,
+ _mvX += IVI_TOSIGNED(mv_delta);
+ mb->_mvX = _mvX;
+ mb->_mvY = _mvY;
+ if (mb->_type == 3) {
+ mv_delta = _ctx._gb->getVLC2(
+ _ctx._mbVlc._tab->_table,
IVI_VLC_BITS, 1);
- mv_y += IVI_TOSIGNED(mv_delta);
- mv_delta = _ctx.gb->getVLC2(
- _ctx.mb_vlc.tab->_table,
+ _mvY += IVI_TOSIGNED(mv_delta);
+ mv_delta = _ctx._gb->getVLC2(
+ _ctx._mbVlc._tab->_table,
IVI_VLC_BITS, 1);
- mv_x += IVI_TOSIGNED(mv_delta);
- mb->b_mv_x = -mv_x;
- mb->b_mv_y = -mv_y;
+ _mvX += IVI_TOSIGNED(mv_delta);
+ mb->_bMvX = -_mvX;
+ mb->_bMvY = -_mvY;
}
}
- if (mb->type == 2) {
- mb->b_mv_x = -mb->mv_x;
- mb->b_mv_y = -mb->mv_y;
- mb->mv_x = 0;
- mb->mv_y = 0;
+ if (mb->_type == 2) {
+ mb->_bMvX = -mb->_mvX;
+ mb->_bMvY = -mb->_mvY;
+ mb->_mvX = 0;
+ mb->_mvY = 0;
}
}
}
- s = band->is_halfpel;
- if (mb->type)
- if (x + (mb->mv_x >> s) + (y + (mb->mv_y >> s))*band->pitch < 0 ||
- x + ((mb->mv_x + s) >> s) + band->mb_size - 1
- + (y + band->mb_size - 1 + ((mb->mv_y + s) >> s))*band->pitch > band->bufsize - 1) {
- warning("motion vector %d %d outside reference", x*s + mb->mv_x, y*s + mb->mv_y);
+ s = band->_isHalfpel;
+ if (mb->_type)
+ 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);
return -1;
}
mb++;
if (ref_mb)
ref_mb++;
- mb_offset += band->mb_size;
+ mb_offset += band->_mbSize;
}
offs += row_offset;
}
- _ctx.gb->alignGetBits();
+ _ctx._gb->alignGetBits();
return 0;
}
@@ -605,12 +604,12 @@ int Indeo4Decoder::scaleTileSize(int def_size, int size_factor) {
int Indeo4Decoder::decodePlaneSubdivision() {
int i;
- switch (_ctx.gb->getBits(2)) {
+ switch (_ctx._gb->getBits(2)) {
case 3:
return 1;
case 2:
for (i = 0; i < 4; i++)
- if (_ctx.gb->getBits(2) != 3)
+ if (_ctx._gb->getBits(2) != 3)
return 0;
return 4;
default:
diff --git a/image/codecs/indeo4.h b/image/codecs/indeo4.h
index 1034f18..86e6020 100644
--- a/image/codecs/indeo4.h
+++ b/image/codecs/indeo4.h
@@ -52,9 +52,9 @@ using namespace Indeo;
*/
class Indeo4Decoder : public IndeoDecoderBase {
struct Transform {
- InvTransformPtr *inv_trans;
- DCTransformPtr *dc_trans;
- int is_2d_trans;
+ InvTransformPtr *_invTrans;
+ DCTransformPtr *_dcTrans;
+ bool _is2dTrans;
};
public:
Indeo4Decoder(uint16 width, uint16 height);
diff --git a/image/codecs/indeo5.cpp b/image/codecs/indeo5.cpp
index b2aebe9..5434e26 100644
--- a/image/codecs/indeo5.cpp
+++ b/image/codecs/indeo5.cpp
@@ -52,10 +52,10 @@ enum {
#define IVI5_PIC_SIZE_ESC 15
Indeo5Decoder::Indeo5Decoder(uint16 width, uint16 height) : IndeoDecoderBase(width, height) {
- _ctx.is_indeo4 = true;
- _ctx.ref_buf = 1;
- _ctx.b_ref_buf = 3;
- _ctx.p_frame = new AVFrame();
+ _ctx._isIndeo4 = false;
+ _ctx._refBuf = 1;
+ _ctx._bRefBuf = 3;
+ _ctx._pFrame = new AVFrame();
}
bool Indeo5Decoder::isIndeo5(Common::SeekableReadStream &stream) {
@@ -83,21 +83,21 @@ const Graphics::Surface *Indeo5Decoder::decodeFrame(Common::SeekableReadStream &
// Set up the frame data buffer
byte *frameData = new byte[stream.size()];
stream.read(frameData, stream.size());
- _ctx.frame_data = frameData;
- _ctx.frame_size = stream.size();
+ _ctx._frameData = frameData;
+ _ctx._frameSize = stream.size();
// Set up the GetBits instance for reading the data
- _ctx.gb = new GetBits(_ctx.frame_data, _ctx.frame_size * 8);
+ _ctx._gb = new GetBits(_ctx._frameData, _ctx._frameSize * 8);
// Decode the frame
int err = decodeIndeoFrame();
// Free the bit reader and frame buffer
- delete _ctx.gb;
- _ctx.gb = nullptr;
+ delete _ctx._gb;
+ _ctx._gb = nullptr;
delete[] frameData;
- _ctx.frame_data = nullptr;
- _ctx.frame_size = 0;
+ _ctx._frameData = nullptr;
+ _ctx._frameSize = 0;
return (err < 0) ? nullptr : &_surface->rawSurface();
}
@@ -108,87 +108,87 @@ int Indeo5Decoder::decodePictureHeader() {
int ret;
- if (_ctx.gb->getBits(5) != 0x1F) {
+ if (_ctx._gb->getBits(5) != 0x1F) {
warning("Invalid picture start code!");
return -1;
}
- _ctx.prev_frame_type = _ctx.frame_type;
- _ctx.frame_type = _ctx.gb->getBits(3);
- if (_ctx.frame_type >= 5) {
- warning("Invalid frame type: %d", _ctx.frame_type);
+ _ctx._prevFrameType = _ctx._frameType;
+ _ctx._frameType = _ctx._gb->getBits(3);
+ if (_ctx._frameType >= 5) {
+ warning("Invalid frame type: %d", _ctx._frameType);
return -1;
}
- _ctx.frame_num = _ctx.gb->getBits(8);
+ _ctx._frameNum = _ctx._gb->getBits(8);
- if (_ctx.frame_type == FRAMETYPE_INTRA) {
+ if (_ctx._frameType == FRAMETYPE_INTRA) {
if ((ret = decode_gop_header()) < 0) {
warning("Invalid GOP header, skipping frames.");
- _ctx.gop_invalid = 1;
+ _ctx._gopInvalid = true;
return ret;
}
- _ctx.gop_invalid = 0;
+ _ctx._gopInvalid = false;
}
- if (_ctx.frame_type == FRAMETYPE_INTER_SCAL && !_ctx.is_scalable) {
+ if (_ctx._frameType == FRAMETYPE_INTER_SCAL && !_ctx._isScalable) {
warning("Scalable inter frame in non scalable stream");
- _ctx.frame_type = FRAMETYPE_INTER;
+ _ctx._frameType = FRAMETYPE_INTER;
return -1;
}
- if (_ctx.frame_type != FRAMETYPE_NULL) {
- _ctx.frame_flags = _ctx.gb->getBits(8);
+ if (_ctx._frameType != FRAMETYPE_NULL) {
+ _ctx._frameFlags = _ctx._gb->getBits(8);
- _ctx.pic_hdr_size = (_ctx.frame_flags & 1) ? _ctx.gb->getBitsLong(24) : 0;
+ _ctx._picHdrSize = (_ctx._frameFlags & 1) ? _ctx._gb->getBitsLong(24) : 0;
- _ctx.checksum = (_ctx.frame_flags & 0x10) ? _ctx.gb->getBits(16) : 0;
+ _ctx._checksum = (_ctx._frameFlags & 0x10) ? _ctx._gb->getBits(16) : 0;
// skip unknown extension if any
- if (_ctx.frame_flags & 0x20)
+ if (_ctx._frameFlags & 0x20)
skip_hdr_extension(); // XXX: untested
// decode macroblock huffman codebook
- ret = _ctx.mb_vlc.ff_ivi_dec_huff_desc(&_ctx, _ctx.frame_flags & 0x40,
+ ret = _ctx._mbVlc.ff_ivi_dec_huff_desc(&_ctx, _ctx._frameFlags & 0x40,
IVI_MB_HUFF);
if (ret < 0)
return ret;
- _ctx.gb->skipBits(3); // FIXME: unknown meaning!
+ _ctx._gb->skipBits(3); // FIXME: unknown meaning!
}
- _ctx.gb->alignGetBits();
+ _ctx._gb->alignGetBits();
return 0;
}
void Indeo5Decoder::switch_buffers() {
- switch (_ctx.prev_frame_type) {
+ switch (_ctx._prevFrameType) {
case FRAMETYPE_INTRA:
case FRAMETYPE_INTER:
- _ctx.buf_switch ^= 1;
- _ctx.dst_buf = _ctx.buf_switch;
- _ctx.ref_buf = _ctx.buf_switch ^ 1;
+ _ctx._bufSwitch ^= 1;
+ _ctx._dstBuf = _ctx._bufSwitch;
+ _ctx._refBuf = _ctx._bufSwitch ^ 1;
break;
case FRAMETYPE_INTER_SCAL:
- if (!_ctx.inter_scal) {
- _ctx.ref2_buf = 2;
- _ctx.inter_scal = 1;
+ if (!_ctx._interScal) {
+ _ctx._ref2Buf = 2;
+ _ctx._interScal = 1;
}
- FFSWAP(int, _ctx.dst_buf, _ctx.ref2_buf);
- _ctx.ref_buf = _ctx.ref2_buf;
+ FFSWAP(int, _ctx._dstBuf, _ctx._ref2Buf);
+ _ctx._refBuf = _ctx._ref2Buf;
break;
case FRAMETYPE_INTER_NOREF:
break;
}
- switch (_ctx.frame_type) {
+ switch (_ctx._frameType) {
case FRAMETYPE_INTRA:
- _ctx.buf_switch = 0;
+ _ctx._bufSwitch = 0;
// FALLTHROUGH
case FRAMETYPE_INTER:
- _ctx.inter_scal = 0;
- _ctx.dst_buf = _ctx.buf_switch;
- _ctx.ref_buf = _ctx.buf_switch ^ 1;
+ _ctx._interScal = 0;
+ _ctx._dstBuf = _ctx._bufSwitch;
+ _ctx._refBuf = _ctx._bufSwitch ^ 1;
break;
case FRAMETYPE_INTER_SCAL:
case FRAMETYPE_INTER_NOREF:
@@ -198,207 +198,209 @@ void Indeo5Decoder::switch_buffers() {
}
bool Indeo5Decoder::is_nonnull_frame() const {
- return _ctx.frame_type != FRAMETYPE_NULL;
+ return _ctx._frameType != FRAMETYPE_NULL;
}
int Indeo5Decoder::decode_band_hdr(IVIBandDesc *band) {
int i, ret;
uint8 band_flags;
- band_flags = _ctx.gb->getBits(8);
+ band_flags = _ctx._gb->getBits(8);
if (band_flags & 1) {
- band->is_empty = 1;
+ band->_isEmpty = true;
return 0;
}
- band->data_size = (_ctx.frame_flags & 0x80) ? _ctx.gb->getBitsLong(24) : 0;
+ band->_dataSize = (_ctx._frameFlags & 0x80) ? _ctx._gb->getBitsLong(24) : 0;
- band->inherit_mv = band_flags & 2;
- band->inherit_qdelta = band_flags & 8;
- band->qdelta_present = band_flags & 4;
- if (!band->qdelta_present) band->inherit_qdelta = 1;
+ band->_inheritMv = (band_flags & 2) != 0;
+ band->_inheritQDelta = (band_flags & 8) != 0;
+ band->_qdeltaPresent = (band_flags & 4) != 0;
+ if (!band->_qdeltaPresent)
+ band->_inheritQDelta = 1;
// decode rvmap probability corrections if any
- band->num_corr = 0; // there are no corrections
+ band->_numCorr = 0; // there are no corrections
if (band_flags & 0x10) {
- band->num_corr = _ctx.gb->getBits(8); // get number of correction pairs
- if (band->num_corr > 61) {
- warning("Too many corrections: %d", band->num_corr);
+ band->_numCorr = _ctx._gb->getBits(8); // get number of correction pairs
+ if (band->_numCorr > 61) {
+ warning("Too many corrections: %d", band->_numCorr);
return -1;
}
// read correction pairs
- for (i = 0; i < band->num_corr * 2; i++)
- band->corr[i] = _ctx.gb->getBits(8);
+ for (i = 0; i < band->_numCorr * 2; i++)
+ band->_corr[i] = _ctx._gb->getBits(8);
}
// select appropriate rvmap table for this band
- band->rvmap_sel = (band_flags & 0x40) ? _ctx.gb->getBits(3) : 8;
+ band->_rvmapSel = (band_flags & 0x40) ? _ctx._gb->getBits(3) : 8;
// decode block huffman codebook
- ret = band->blk_vlc.ff_ivi_dec_huff_desc(&_ctx, band_flags & 0x80, IVI_BLK_HUFF);
+ ret = band->_blkVlc.ff_ivi_dec_huff_desc(&_ctx, band_flags & 0x80, IVI_BLK_HUFF);
if (ret < 0)
return ret;
- band->checksum_present = _ctx.gb->getBits1();
- if (band->checksum_present)
- band->checksum = _ctx.gb->getBits(16);
+ band->_checksumPresent = _ctx._gb->getBits1();
+ if (band->_checksumPresent)
+ band->_checksum = _ctx._gb->getBits(16);
- band->glob_quant = _ctx.gb->getBits(5);
+ band->_globQuant = _ctx._gb->getBits(5);
// skip unknown extension if any
if (band_flags & 0x20) { // XXX: untested
- _ctx.gb->alignGetBits();
+ _ctx._gb->alignGetBits();
skip_hdr_extension();
}
- _ctx.gb->alignGetBits();
+ _ctx._gb->alignGetBits();
return 0;
}
int Indeo5Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
- int x, y, mv_x, mv_y, mv_delta, offs, mb_offset,
+ int x, y, _mvX, _mvY, mv_delta, offs, mb_offset,
mv_scale, blks_per_mb, s;
IVIMbInfo *mb, *ref_mb;
- int row_offset = band->mb_size * band->pitch;
+ int row_offset = band->_mbSize * band->_pitch;
- mb = tile->mbs;
- ref_mb = tile->ref_mbs;
- offs = tile->ypos * band->pitch + tile->xpos;
+ mb = tile->_mbs;
+ ref_mb = tile->_refMbs;
+ offs = tile->_yPos * band->_pitch + tile->_xPos;
if (!ref_mb &&
- ((band->qdelta_present && band->inherit_qdelta) || band->inherit_mv))
+ ((band->_qdeltaPresent && band->_inheritQDelta) || band->_inheritMv))
return -1;
- if (tile->num_MBs != IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size)) {
+ if (tile->_numMBs != IVI_MBs_PER_TILE(tile->_width, tile->_height, band->_mbSize)) {
warning("Allocated tile size %d mismatches parameters %d",
- tile->num_MBs, IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size));
+ tile->_numMBs, IVI_MBs_PER_TILE(tile->_width, tile->_height, band->_mbSize));
return -1;
}
// scale factor for motion vectors
- mv_scale = (_ctx.planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
- mv_x = mv_y = 0;
+ mv_scale = (_ctx._planes[0]._bands[0]._mbSize >> 3) - (band->_mbSize >> 3);
+ _mvX = _mvY = 0;
- for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
+ for (y = tile->_yPos; y < (tile->_yPos + tile->_height); y += band->_mbSize) {
mb_offset = offs;
- for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
- mb->xpos = x;
- mb->ypos = y;
- mb->buf_offs = mb_offset;
+ for (x = tile->_xPos; x < (tile->_xPos + tile->_width); x += band->_mbSize) {
+ mb->_xPos = x;
+ mb->_yPos = y;
+ mb->_bufOffs = mb_offset;
- if (_ctx.gb->getBits1()) {
- if (_ctx.frame_type == FRAMETYPE_INTRA) {
+ if (_ctx._gb->getBits1()) {
+ if (_ctx._frameType == FRAMETYPE_INTRA) {
warning("Empty macroblock in an INTRA picture!");
return -1;
}
- mb->type = 1; // empty macroblocks are always INTER
- mb->cbp = 0; // all blocks are empty
+ mb->_type = 1; // empty macroblocks are always INTER
+ mb->_cbp = 0; // all blocks are empty
- mb->q_delta = 0;
- if (!band->plane && !band->band_num && (_ctx.frame_flags & 8)) {
- mb->q_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table, IVI_VLC_BITS, 1);
- mb->q_delta = IVI_TOSIGNED(mb->q_delta);
+ mb->_qDelta = 0;
+ if (!band->_plane && !band->_bandNum && (_ctx._frameFlags & 8)) {
+ mb->_qDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table, IVI_VLC_BITS, 1);
+ mb->_qDelta = IVI_TOSIGNED(mb->_qDelta);
}
- mb->mv_x = mb->mv_y = 0; // no motion vector coded
- if (band->inherit_mv && ref_mb) {
+ mb->_mvX = mb->_mvY = 0; // no motion vector coded
+ if (band->_inheritMv && ref_mb) {
// motion vector inheritance
if (mv_scale) {
- mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
- mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
+ mb->_mvX = ivi_scale_mv(ref_mb->_mvX, mv_scale);
+ mb->_mvY = ivi_scale_mv(ref_mb->_mvY, mv_scale);
} else {
- mb->mv_x = ref_mb->mv_x;
- mb->mv_y = ref_mb->mv_y;
+ mb->_mvX = ref_mb->_mvX;
+ mb->_mvY = ref_mb->_mvY;
}
}
} else {
- if (band->inherit_mv && ref_mb) {
- mb->type = ref_mb->type; // copy mb_type from corresponding reference mb
- } else if (_ctx.frame_type == FRAMETYPE_INTRA) {
- mb->type = 0; // mb_type is always INTRA for intra-frames
+ if (band->_inheritMv && ref_mb) {
+ mb->_type = ref_mb->_type; // copy mb_type from corresponding reference mb
+ } else if (_ctx._frameType == FRAMETYPE_INTRA) {
+ mb->_type = 0; // mb_type is always INTRA for intra-frames
} else {
- mb->type = _ctx.gb->getBits1();
+ mb->_type = _ctx._gb->getBits1();
}
- blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
- mb->cbp = _ctx.gb->getBits(blks_per_mb);
-
- mb->q_delta = 0;
- if (band->qdelta_present) {
- if (band->inherit_qdelta) {
- if (ref_mb) mb->q_delta = ref_mb->q_delta;
- } else if (mb->cbp || (!band->plane && !band->band_num &&
- (_ctx.frame_flags & 8))) {
- mb->q_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table, IVI_VLC_BITS, 1);
- mb->q_delta = IVI_TOSIGNED(mb->q_delta);
+ blks_per_mb = band->_mbSize != band->_blkSize ? 4 : 1;
+ mb->_cbp = _ctx._gb->getBits(blks_per_mb);
+
+ mb->_qDelta = 0;
+ if (band->_qdeltaPresent) {
+ if (band->_inheritQDelta) {
+ if (ref_mb) mb->_qDelta = ref_mb->_qDelta;
+ } else if (mb->_cbp || (!band->_plane && !band->_bandNum &&
+ (_ctx._frameFlags & 8))) {
+ mb->_qDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table, IVI_VLC_BITS, 1);
+ mb->_qDelta = IVI_TOSIGNED(mb->_qDelta);
}
}
- if (!mb->type) {
- mb->mv_x = mb->mv_y = 0; // there is no motion vector in intra-macroblocks
+ if (!mb->_type) {
+ mb->_mvX = mb->_mvY = 0; // there is no motion vector in intra-macroblocks
} else {
- if (band->inherit_mv && ref_mb) {
+ if (band->_inheritMv && ref_mb) {
// motion vector inheritance
if (mv_scale) {
- mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
- mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
+ mb->_mvX = ivi_scale_mv(ref_mb->_mvX, mv_scale);
+ mb->_mvY = ivi_scale_mv(ref_mb->_mvY, mv_scale);
} else {
- mb->mv_x = ref_mb->mv_x;
- mb->mv_y = ref_mb->mv_y;
+ mb->_mvX = ref_mb->_mvX;
+ mb->_mvY = ref_mb->_mvY;
}
} else {
// decode motion vector deltas
- mv_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table, IVI_VLC_BITS, 1);
- mv_y += IVI_TOSIGNED(mv_delta);
- mv_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table, IVI_VLC_BITS, 1);
- mv_x += IVI_TOSIGNED(mv_delta);
- mb->mv_x = mv_x;
- mb->mv_y = mv_y;
+ mv_delta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table, IVI_VLC_BITS, 1);
+ _mvY += IVI_TOSIGNED(mv_delta);
+ mv_delta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table, IVI_VLC_BITS, 1);
+ _mvX += IVI_TOSIGNED(mv_delta);
+ mb->_mvX = _mvX;
+ mb->_mvY = _mvY;
}
}
}
- s = band->is_halfpel;
- if (mb->type)
- if (x + (mb->mv_x >> s) + (y + (mb->mv_y >> s))*band->pitch < 0 ||
- x + ((mb->mv_x + s) >> s) + band->mb_size - 1
- + (y + band->mb_size - 1 + ((mb->mv_y + s) >> s))*band->pitch > band->bufsize - 1) {
- warning("motion vector %d %d outside reference", x*s + mb->mv_x, y*s + mb->mv_y);
+ s = band->_isHalfpel;
+ if (mb->_type)
+ 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);
return -1;
}
mb++;
if (ref_mb)
ref_mb++;
- mb_offset += band->mb_size;
+ mb_offset += band->_mbSize;
}
offs += row_offset;
}
- _ctx.gb->alignGetBits();
+ _ctx._gb->alignGetBits();
return 0;
}
int Indeo5Decoder::decode_gop_header() {
- int result, i, p, tile_size, pic_size_indx, mb_size, blk_size, is_scalable;
- int quant_mat, blk_size_changed = 0;
+ int result, i, p, tile_size, pic_size_indx, mbSize, blkSize, isScalable;
+ int quantMat;
+ bool blk_size_changed = false;
IVIBandDesc *band, *band1, *band2;
IVIPicConfig pic_conf;
- _ctx.gop_flags = _ctx.gb->getBits(8);
+ _ctx._gopFlags = _ctx._gb->getBits(8);
- _ctx.gop_hdr_size = (_ctx.gop_flags & 1) ? _ctx.gb->getBits(16) : 0;
+ _ctx._gopHdrSize = (_ctx._gopFlags & 1) ? _ctx._gb->getBits(16) : 0;
- if (_ctx.gop_flags & IVI5_IS_PROTECTED)
- _ctx.lock_word = _ctx.gb->getBitsLong(32);
+ if (_ctx._gopFlags & IVI5_IS_PROTECTED)
+ _ctx._lockWord = _ctx._gb->getBitsLong(32);
- tile_size = (_ctx.gop_flags & 0x40) ? 64 << _ctx.gb->getBits(2) : 0;
+ tile_size = (_ctx._gopFlags & 0x40) ? 64 << _ctx._gb->getBits(2) : 0;
if (tile_size > 256) {
warning("Invalid tile size: %d", tile_size);
return -1;
@@ -406,73 +408,73 @@ int Indeo5Decoder::decode_gop_header() {
// decode number of wavelet bands
// num_levels * 3 + 1
- pic_conf.luma_bands = _ctx.gb->getBits(2) * 3 + 1;
- pic_conf.chroma_bands = _ctx.gb->getBits1() * 3 + 1;
- is_scalable = pic_conf.luma_bands != 1 || pic_conf.chroma_bands != 1;
- if (is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) {
+ pic_conf._lumaBands = _ctx._gb->getBits(2) * 3 + 1;
+ pic_conf._chromaBands = _ctx._gb->getBits1() * 3 + 1;
+ isScalable = pic_conf._lumaBands != 1 || pic_conf._chromaBands != 1;
+ if (isScalable && (pic_conf._lumaBands != 4 || pic_conf._chromaBands != 1)) {
warning("Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d",
- pic_conf.luma_bands, pic_conf.chroma_bands);
+ pic_conf._lumaBands, pic_conf._chromaBands);
return -1;
}
- pic_size_indx = _ctx.gb->getBits(4);
+ pic_size_indx = _ctx._gb->getBits(4);
if (pic_size_indx == IVI5_PIC_SIZE_ESC) {
- pic_conf.pic_height = _ctx.gb->getBits(13);
- pic_conf.pic_width = _ctx.gb->getBits(13);
+ pic_conf._picHeight = _ctx._gb->getBits(13);
+ pic_conf._picWidth = _ctx._gb->getBits(13);
} else {
- pic_conf.pic_height = _ivi5_common_pic_sizes[pic_size_indx * 2 + 1] << 2;
- pic_conf.pic_width = _ivi5_common_pic_sizes[pic_size_indx * 2] << 2;
+ pic_conf._picHeight = _ivi5_common_pic_sizes[pic_size_indx * 2 + 1] << 2;
+ pic_conf._picWidth = _ivi5_common_pic_sizes[pic_size_indx * 2] << 2;
}
- if (_ctx.gop_flags & 2) {
+ if (_ctx._gopFlags & 2) {
warning("YV12 picture format");
return -2;
}
- pic_conf.chroma_height = (pic_conf.pic_height + 3) >> 2;
- pic_conf.chroma_width = (pic_conf.pic_width + 3) >> 2;
+ pic_conf._chromaHeight = (pic_conf._picHeight + 3) >> 2;
+ pic_conf._chromaWidth = (pic_conf._picWidth + 3) >> 2;
if (!tile_size) {
- pic_conf.tile_height = pic_conf.pic_height;
- pic_conf.tile_width = pic_conf.pic_width;
+ pic_conf._tileHeight = pic_conf._picHeight;
+ pic_conf._tileWidth = pic_conf._picWidth;
} else {
- pic_conf.tile_height = pic_conf.tile_width = tile_size;
+ pic_conf._tileHeight = pic_conf._tileWidth = tile_size;
}
// check if picture layout was changed and reallocate buffers
- if (pic_conf.ivi_pic_config_cmp(_ctx.pic_conf) || _ctx.gop_invalid) {
- result = IVIPlaneDesc::ff_ivi_init_planes(_ctx.planes, &pic_conf, 0);
+ if (pic_conf.ivi_pic_config_cmp(_ctx._picConf) || _ctx._gopInvalid) {
+ result = IVIPlaneDesc::ff_ivi_init_planes(_ctx._planes, &pic_conf, 0);
if (result < 0) {
warning("Couldn't reallocate color planes!");
return result;
}
- _ctx.pic_conf = pic_conf;
- _ctx.is_scalable = is_scalable;
+ _ctx._picConf = pic_conf;
+ _ctx._isScalable = isScalable;
blk_size_changed = 1; // force reallocation of the internal structures
}
for (p = 0; p <= 1; p++) {
- for (i = 0; i < (!p ? pic_conf.luma_bands : pic_conf.chroma_bands); i++) {
- band = &_ctx.planes[p].bands[i];
+ for (i = 0; i < (!p ? pic_conf._lumaBands : pic_conf._chromaBands); i++) {
+ band = &_ctx._planes[p]._bands[i];
- band->is_halfpel = _ctx.gb->getBits1();
+ band->_isHalfpel = _ctx._gb->getBits1();
- mb_size = _ctx.gb->getBits1();
- blk_size = 8 >> _ctx.gb->getBits1();
- mb_size = blk_size << !mb_size;
+ mbSize = _ctx._gb->getBits1();
+ blkSize = 8 >> _ctx._gb->getBits1();
+ mbSize = blkSize << !mbSize;
- if (p == 0 && blk_size == 4) {
+ if (p == 0 && blkSize == 4) {
warning("4x4 luma blocks are unsupported!");
return -2;
}
- blk_size_changed = mb_size != band->mb_size || blk_size != band->blk_size;
+ blk_size_changed = mbSize != band->_mbSize || blkSize != band->_blkSize;
if (blk_size_changed) {
- band->mb_size = mb_size;
- band->blk_size = blk_size;
+ band->_mbSize = mbSize;
+ band->_blkSize = blkSize;
}
- if (_ctx.gb->getBits1()) {
+ if (_ctx._gb->getBits1()) {
warning("Extended transform info");
return -2;
}
@@ -480,73 +482,73 @@ int Indeo5Decoder::decode_gop_header() {
// select transform function and scan pattern according to plane and band number
switch ((p << 2) + i) {
case 0:
- band->inv_transform = IndeoDSP::ff_ivi_inverse_slant_8x8;
- band->dc_transform = IndeoDSP::ff_ivi_dc_slant_2d;
- band->scan = ff_zigzag_direct;
- band->transform_size = 8;
+ band->_invTransform = IndeoDSP::ff_ivi_inverse_slant_8x8;
+ band->_dcTransform = IndeoDSP::ff_ivi_dc_slant_2d;
+ band->_scan = ff_zigzag_direct;
+ band->_transformSize = 8;
break;
case 1:
- band->inv_transform = IndeoDSP::ff_ivi_row_slant8;
- band->dc_transform = IndeoDSP::ff_ivi_dc_row_slant;
- band->scan = _ff_ivi_vertical_scan_8x8;
- band->transform_size = 8;
+ band->_invTransform = IndeoDSP::ff_ivi_row_slant8;
+ band->_dcTransform = IndeoDSP::ff_ivi_dc_row_slant;
+ band->_scan = _ff_ivi_vertical_scan_8x8;
+ band->_transformSize = 8;
break;
case 2:
- band->inv_transform = IndeoDSP::ff_ivi_col_slant8;
- band->dc_transform = IndeoDSP::ff_ivi_dc_col_slant;
- band->scan = _ff_ivi_horizontal_scan_8x8;
- band->transform_size = 8;
+ band->_invTransform = IndeoDSP::ff_ivi_col_slant8;
+ band->_dcTransform = IndeoDSP::ff_ivi_dc_col_slant;
+ band->_scan = _ff_ivi_horizontal_scan_8x8;
+ band->_transformSize = 8;
break;
case 3:
- band->inv_transform = IndeoDSP::ff_ivi_put_pixels_8x8;
- band->dc_transform = IndeoDSP::ff_ivi_put_dc_pixel_8x8;
- band->scan = _ff_ivi_horizontal_scan_8x8;
- band->transform_size = 8;
+ band->_invTransform = IndeoDSP::ff_ivi_put_pixels_8x8;
+ band->_dcTransform = IndeoDSP::ff_ivi_put_dc_pixel_8x8;
+ band->_scan = _ff_ivi_horizontal_scan_8x8;
+ band->_transformSize = 8;
break;
case 4:
- band->inv_transform = IndeoDSP::ff_ivi_inverse_slant_4x4;
- band->dc_transform = IndeoDSP::ff_ivi_dc_slant_2d;
- band->scan = _ff_ivi_direct_scan_4x4;
- band->transform_size = 4;
+ band->_invTransform = IndeoDSP::ff_ivi_inverse_slant_4x4;
+ band->_dcTransform = IndeoDSP::ff_ivi_dc_slant_2d;
+ band->_scan = _ff_ivi_direct_scan_4x4;
+ band->_transformSize = 4;
break;
}
- band->is_2d_trans = band->inv_transform == IndeoDSP::ff_ivi_inverse_slant_8x8 ||
- band->inv_transform == IndeoDSP::ff_ivi_inverse_slant_4x4;
+ band->_is2dTrans = band->_invTransform == IndeoDSP::ff_ivi_inverse_slant_8x8 ||
+ band->_invTransform == IndeoDSP::ff_ivi_inverse_slant_4x4;
- if (band->transform_size != band->blk_size) {
- warning("transform and block size mismatch (%d != %d)", band->transform_size, band->blk_size);
+ if (band->_transformSize != band->_blkSize) {
+ warning("transform and block size mismatch (%d != %d)", band->_transformSize, band->_blkSize);
return -1;
}
// select dequant matrix according to plane and band number
if (!p) {
- quant_mat = (pic_conf.luma_bands > 1) ? i + 1 : 0;
+ quantMat = (pic_conf._lumaBands > 1) ? i + 1 : 0;
} else {
- quant_mat = 5;
+ quantMat = 5;
}
- if (band->blk_size == 8) {
- if (quant_mat >= 5) {
- warning("quant_mat %d too large!", quant_mat);
+ if (band->_blkSize == 8) {
+ if (quantMat >= 5) {
+ warning("_quantMat %d too large!", quantMat);
return -1;
}
- band->intra_base = &_ivi5_base_quant_8x8_intra[quant_mat][0];
- band->inter_base = &_ivi5_base_quant_8x8_inter[quant_mat][0];
- band->intra_scale = &_ivi5_scale_quant_8x8_intra[quant_mat][0];
- band->inter_scale = &_ivi5_scale_quant_8x8_inter[quant_mat][0];
+ band->_intraBase = &_ivi5_base_quant_8x8_intra[quantMat][0];
+ band->_interBase = &_ivi5_base_quant_8x8_inter[quantMat][0];
+ band->_intraScale = &_ivi5_scale_quant_8x8_intra[quantMat][0];
+ band->_interScale = &_ivi5_scale_quant_8x8_inter[quantMat][0];
} else {
- band->intra_base = _ivi5_base_quant_4x4_intra;
- band->inter_base = _ivi5_base_quant_4x4_inter;
- band->intra_scale = _ivi5_scale_quant_4x4_intra;
- band->inter_scale = _ivi5_scale_quant_4x4_inter;
+ band->_intraBase = _ivi5_base_quant_4x4_intra;
+ band->_interBase = _ivi5_base_quant_4x4_inter;
+ band->_intraScale = _ivi5_scale_quant_4x4_intra;
+ band->_interScale = _ivi5_scale_quant_4x4_inter;
}
- if (_ctx.gb->getBits(2)) {
+ if (_ctx._gb->getBits(2)) {
warning("End marker missing!");
return -1;
}
@@ -554,58 +556,58 @@ int Indeo5Decoder::decode_gop_header() {
}
// copy chroma parameters into the 2nd chroma plane
- for (i = 0; i < pic_conf.chroma_bands; i++) {
- band1 = &_ctx.planes[1].bands[i];
- band2 = &_ctx.planes[2].bands[i];
-
- band2->width = band1->width;
- band2->height = band1->height;
- band2->mb_size = band1->mb_size;
- band2->blk_size = band1->blk_size;
- band2->is_halfpel = band1->is_halfpel;
- band2->intra_base = band1->intra_base;
- band2->inter_base = band1->inter_base;
- band2->intra_scale = band1->intra_scale;
- band2->inter_scale = band1->inter_scale;
- band2->scan = band1->scan;
- band2->inv_transform = band1->inv_transform;
- band2->dc_transform = band1->dc_transform;
- band2->is_2d_trans = band1->is_2d_trans;
- band2->transform_size = band1->transform_size;
+ for (i = 0; i < pic_conf._chromaBands; i++) {
+ band1 = &_ctx._planes[1]._bands[i];
+ band2 = &_ctx._planes[2]._bands[i];
+
+ band2->_width = band1->_width;
+ band2->_height = band1->_height;
+ band2->_mbSize = band1->_mbSize;
+ band2->_blkSize = band1->_blkSize;
+ band2->_isHalfpel = band1->_isHalfpel;
+ band2->_intraBase = band1->_intraBase;
+ band2->_interBase = band1->_interBase;
+ band2->_intraScale = band1->_intraScale;
+ band2->_interScale = band1->_interScale;
+ band2->_scan = band1->_scan;
+ band2->_invTransform = band1->_invTransform;
+ band2->_dcTransform = band1->_dcTransform;
+ band2->_is2dTrans = band1->_is2dTrans;
+ band2->_transformSize = band1->_transformSize;
}
// reallocate internal structures if needed
if (blk_size_changed) {
- result = IVIPlaneDesc::ff_ivi_init_tiles(_ctx.planes, pic_conf.tile_width,
- pic_conf.tile_height);
+ result = IVIPlaneDesc::ff_ivi_init_tiles(_ctx._planes, pic_conf._tileWidth,
+ pic_conf._tileHeight);
if (result < 0) {
warning("Couldn't reallocate internal structures!");
return result;
}
}
- if (_ctx.gop_flags & 8) {
- if (_ctx.gb->getBits(3)) {
+ if (_ctx._gopFlags & 8) {
+ if (_ctx._gb->getBits(3)) {
warning("Alignment bits are not zero!");
return -1;
}
- if (_ctx.gb->getBits1())
- _ctx.gb->skipBitsLong(24); // skip transparency fill color
+ if (_ctx._gb->getBits1())
+ _ctx._gb->skipBitsLong(24); // skip transparency fill color
}
- _ctx.gb->alignGetBits();
+ _ctx._gb->alignGetBits();
- _ctx.gb->skipBits(23); // FIXME: unknown meaning
+ _ctx._gb->skipBits(23); // FIXME: unknown meaning
// skip GOP extension if any
- if (_ctx.gb->getBits1()) {
+ if (_ctx._gb->getBits1()) {
do {
- i = _ctx.gb->getBits(16);
+ i = _ctx._gb->getBits(16);
} while (i & 0x8000);
}
- _ctx.gb->alignGetBits();
+ _ctx._gb->alignGetBits();
return 0;
}
@@ -614,11 +616,11 @@ int Indeo5Decoder::skip_hdr_extension() {
int i, len;
do {
- len = _ctx.gb->getBits(8);
- if (8 * len > _ctx.gb->getBitsLeft())
+ len = _ctx._gb->getBits(8);
+ if (8 * len > _ctx._gb->getBitsLeft())
return -1;
for (i = 0; i < len; i++)
- _ctx.gb->skipBits(8);
+ _ctx._gb->skipBits(8);
} while (len);
return 0;
Commit: e06442afb6b154f749c4d839fd2a23e434e08dda
https://github.com/scummvm/scummvm/commit/e06442afb6b154f749c4d839fd2a23e434e08dda
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T17:00:06-04:00
Commit Message:
IMAGE: Cleanup of method parameters and locals in Indeo decoders
Changed paths:
image/codecs/indeo/indeo.cpp
image/codecs/indeo/indeo.h
image/codecs/indeo4.cpp
image/codecs/indeo4.h
image/codecs/indeo5.cpp
image/codecs/indeo5.h
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index 632e39e..4f29016 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -81,27 +81,27 @@ static const IVIHuffDesc ivi_blk_huff_desc[8] = {
/**
* calculate number of _tiles in a stride
*/
-#define IVI_NUM_TILES(stride, tile_size) (((stride) + (tile_size) - 1) / (tile_size))
+#define IVI_NUM_TILES(stride, tileSize) (((stride) + (tileSize) - 1) / (tileSize))
/*------------------------------------------------------------------------*/
-int IVIHuffDesc::ivi_create_huff_from_desc(VLC *vlc, int flag) const {
- int pos, i, j, codes_per_row, prefix, not_last_row;
+int IVIHuffDesc::createHuffFromDesc(VLC *vlc, bool flag) const {
+ int pos, i, j, codesPerRow, prefix, notLastRow;
uint16 codewords[256];
uint8 bits[256];
pos = 0; // current position = 0
for (i = 0; i < _numRows; i++) {
- codes_per_row = 1 << _xBits[i];
- not_last_row = (i != _numRows - 1);
- prefix = ((1 << i) - 1) << (_xBits[i] + not_last_row);
+ codesPerRow = 1 << _xBits[i];
+ notLastRow = (i != _numRows - 1);
+ prefix = ((1 << i) - 1) << (_xBits[i] + notLastRow);
- for (j = 0; j < codes_per_row; j++) {
+ for (j = 0; j < codesPerRow; j++) {
if (pos >= 256) // Some Indeo5 codebooks can have more than 256
break; // elements, but only 256 codes are allowed!
- bits[pos] = i + _xBits[i] + not_last_row;
+ bits[pos] = i + _xBits[i] + notLastRow;
if (bits[pos] > IVI_VLC_BITS)
return -1; // invalid descriptor
@@ -120,12 +120,11 @@ int IVIHuffDesc::ivi_create_huff_from_desc(VLC *vlc, int flag) const {
/*------------------------------------------------------------------------*/
-bool IVIHuffDesc::ivi_huff_desc_cmp(const IVIHuffDesc *desc2) const {
- return _numRows != desc2->_numRows ||
- memcmp(_xBits, desc2->_xBits, _numRows);
+bool IVIHuffDesc::huffDescCompare(const IVIHuffDesc *desc2) const {
+ return _numRows != desc2->_numRows || memcmp(_xBits, desc2->_xBits, _numRows);
}
-void IVIHuffDesc::ivi_huff_desc_copy(const IVIHuffDesc *src) {
+void IVIHuffDesc::huffDescCopy(const IVIHuffDesc *src) {
_numRows = src->_numRows;
memcpy(_xBits, src->_xBits, src->_numRows);
}
@@ -135,13 +134,13 @@ void IVIHuffDesc::ivi_huff_desc_copy(const IVIHuffDesc *src) {
IVIHuffTab::IVIHuffTab() : _tab(nullptr) {
}
-int IVIHuffTab::ff_ivi_dec_huff_desc(IVI45DecContext *ctx, int desc_coded, int which_tab) {
+int IVIHuffTab::decodeHuffDesc(IVI45DecContext *ctx, int descCoded, int whichTab) {
int i, result;
- IVIHuffDesc new_huff;
+ IVIHuffDesc newHuff;
- if (!desc_coded) {
+ if (!descCoded) {
// select default table
- _tab = (which_tab) ? &ctx->_iviBlkVlcTabs[7]
+ _tab = (whichTab) ? &ctx->_iviBlkVlcTabs[7]
: &ctx->_iviMbVlcTabs[7];
return 0;
}
@@ -149,22 +148,22 @@ int IVIHuffTab::ff_ivi_dec_huff_desc(IVI45DecContext *ctx, int desc_coded, int w
_tabSel = ctx->_gb->getBits(3);
if (_tabSel == 7) {
// custom huffman table (explicitly encoded)
- new_huff._numRows = ctx->_gb->getBits(4);
- if (!new_huff._numRows) {
+ newHuff._numRows = ctx->_gb->getBits(4);
+ if (!newHuff._numRows) {
warning("Empty custom Huffman table!");
return -1;
}
- for (i = 0; i < new_huff._numRows; i++)
- new_huff._xBits[i] = ctx->_gb->getBits(4);
+ for (i = 0; i < newHuff._numRows; i++)
+ newHuff._xBits[i] = ctx->_gb->getBits(4);
// Have we got the same custom table? Rebuild if not.
- if (new_huff.ivi_huff_desc_cmp(&_custDesc) || !_custTab._table) {
- _custDesc.ivi_huff_desc_copy(&new_huff);
+ if (newHuff.huffDescCompare(&_custDesc) || !_custTab._table) {
+ _custDesc.huffDescCopy(&newHuff);
if (_custTab._table)
_custTab.ff_free_vlc();
- result = _custDesc.ivi_create_huff_from_desc(&_custTab, 0);
+ result = _custDesc.createHuffFromDesc(&_custTab, false);
if (result) {
// reset faulty description
_custDesc._numRows = 0;
@@ -175,7 +174,7 @@ int IVIHuffTab::ff_ivi_dec_huff_desc(IVI45DecContext *ctx, int desc_coded, int w
_tab = &_custTab;
} else {
// select one of predefined tables
- _tab = (which_tab) ? &ctx->_iviBlkVlcTabs[_tabSel]
+ _tab = (whichTab) ? &ctx->_iviBlkVlcTabs[_tabSel]
: &ctx->_iviMbVlcTabs[_tabSel];
}
@@ -210,17 +209,17 @@ IVIBandDesc::IVIBandDesc() : _plane(0), _bandNum(0), _width(0), _height(0),
Common::fill(&_corr[0], &_corr[61 * 2], 0);
}
-int IVIBandDesc::ivi_init_tiles(IVITile *ref_tile, int p, int b, int t_height, int t_width) {
+int IVIBandDesc::initTiles(IVITile *refTile, int p, int b, int tHeight, int tWidth) {
int x, y;
IVITile *tile = _tiles;
- for (y = 0; y < _height; y += t_height) {
- for (x = 0; x < _width; x += t_width) {
+ for (y = 0; y < _height; y += tHeight) {
+ for (x = 0; x < _width; x += tWidth) {
tile->_xPos = x;
tile->_yPos = y;
tile->_mbSize = _mbSize;
- tile->_width = MIN(_width - x, t_width);
- tile->_height = MIN(_height - y, t_height);
+ tile->_width = MIN(_width - x, tWidth);
+ tile->_height = MIN(_height - y, tHeight);
tile->_dataSize = 0;
tile->_isEmpty = false;
@@ -235,12 +234,12 @@ int IVIBandDesc::ivi_init_tiles(IVITile *ref_tile, int p, int b, int t_height, i
tile->_refMbs = 0;
if (p || b) {
- if (tile->_numMBs != ref_tile->_numMBs) {
- warning("ref_tile mismatch");
+ if (tile->_numMBs != refTile->_numMBs) {
+ warning("refTile mismatch");
return -1;
}
- tile->_refMbs = ref_tile->_mbs;
- ref_tile++;
+ tile->_refMbs = refTile->_mbs;
+ refTile++;
}
tile++;
}
@@ -267,15 +266,15 @@ bool IVIPicConfig::ivi_pic_config_cmp(const IVIPicConfig &cfg2) {
IVIPlaneDesc::IVIPlaneDesc() : _width(0), _height(0), _numBands(0), _bands(nullptr) {
}
-int IVIPlaneDesc::ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg, bool _isIndeo4) {
+int IVIPlaneDesc::initPlanes(IVIPlaneDesc *planes, const IVIPicConfig *cfg, bool isIndeo4) {
int p, b;
uint32 b_width, b_height, align_fac, width_aligned,
- height_aligned, buf_size;
+ height_aligned, bufSize;
IVIBandDesc *band;
- ivi_free_buffers(planes);
+ freeBuffers(planes);
- if (av_image_check_size(cfg->_picWidth, cfg->_picHeight, 0, NULL) < 0 ||
+ if (checkImageSize(cfg->_picWidth, cfg->_picHeight, 0) < 0 ||
cfg->_lumaBands < 1 || cfg->_chromaBands < 1)
return -1;
@@ -307,7 +306,7 @@ int IVIPlaneDesc::ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *c
align_fac = p ? 8 : 16;
width_aligned = FFALIGN(b_width, align_fac);
height_aligned = FFALIGN(b_height, align_fac);
- buf_size = width_aligned * height_aligned * sizeof(int16);
+ bufSize = width_aligned * height_aligned * sizeof(int16);
for (b = 0; b < planes[p]._numBands; b++) {
band = &planes[p]._bands[b]; // select appropriate _plane/band
@@ -317,20 +316,20 @@ int IVIPlaneDesc::ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *c
band->_height = b_height;
band->_pitch = width_aligned;
band->_aHeight = height_aligned;
- band->_bufs[0] = (int16 *)av_mallocz(buf_size);
- band->_bufs[1] = (int16 *)av_mallocz(buf_size);
- band->_bufSize = buf_size / 2;
+ band->_bufs[0] = (int16 *)av_mallocz(bufSize);
+ band->_bufs[1] = (int16 *)av_mallocz(bufSize);
+ band->_bufSize = bufSize / 2;
if (!band->_bufs[0] || !band->_bufs[1])
return -2;
// allocate the 3rd band buffer for scalability mode
if (cfg->_lumaBands > 1) {
- band->_bufs[2] = (int16 *)av_mallocz(buf_size);
+ band->_bufs[2] = (int16 *)av_mallocz(bufSize);
if (!band->_bufs[2])
return -2;
}
- if (_isIndeo4) {
- band->_bufs[3] = (int16 *)av_mallocz(buf_size);
+ if (isIndeo4) {
+ band->_bufs[3] = (int16 *)av_mallocz(bufSize);
if (!band->_bufs[3])
return -2;
}
@@ -342,27 +341,26 @@ int IVIPlaneDesc::ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *c
return 0;
}
-int IVIPlaneDesc::ff_ivi_init_tiles(IVIPlaneDesc *planes,
- int _tileWidth, int _tileHeight) {
- int p, b, x_tiles, y_tiles, t_width, t_height, ret;
+int IVIPlaneDesc::initTiles(IVIPlaneDesc *planes, int tileWidth, int tileHeight) {
+ int p, b, xTiles, yTiles, tWidth, tHeight, ret;
IVIBandDesc *band;
for (p = 0; p < 3; p++) {
- t_width = !p ? _tileWidth : (_tileWidth + 3) >> 2;
- t_height = !p ? _tileHeight : (_tileHeight + 3) >> 2;
+ tWidth = !p ? tileWidth : (tileWidth + 3) >> 2;
+ tHeight = !p ? tileHeight : (tileHeight + 3) >> 2;
if (!p && planes[0]._numBands == 4) {
- t_width >>= 1;
- t_height >>= 1;
+ tWidth >>= 1;
+ tHeight >>= 1;
}
- if (t_width <= 0 || t_height <= 0)
+ if (tWidth <= 0 || tHeight <= 0)
return -3;
for (b = 0; b < planes[p]._numBands; b++) {
band = &planes[p]._bands[b];
- x_tiles = IVI_NUM_TILES(band->_width, t_width);
- y_tiles = IVI_NUM_TILES(band->_height, t_height);
- band->_numTiles = x_tiles * y_tiles;
+ xTiles = IVI_NUM_TILES(band->_width, tWidth);
+ yTiles = IVI_NUM_TILES(band->_height, tHeight);
+ band->_numTiles = xTiles * yTiles;
av_freep(&band->_tiles);
band->_tiles = (IVITile *)av_mallocz_array(band->_numTiles, sizeof(IVITile));
@@ -371,8 +369,8 @@ int IVIPlaneDesc::ff_ivi_init_tiles(IVIPlaneDesc *planes,
// use the first luma band as reference for motion vectors
// and quant
- ret = band->ivi_init_tiles(planes[0]._bands[0]._tiles,
- p, b, t_height, t_width);
+ ret = band->initTiles(planes[0]._bands[0]._tiles,
+ p, b, tHeight, tWidth);
if (ret < 0)
return ret;
}
@@ -381,7 +379,7 @@ int IVIPlaneDesc::ff_ivi_init_tiles(IVIPlaneDesc *planes,
return 0;
}
-void IVIPlaneDesc::ivi_free_buffers(IVIPlaneDesc *planes) {
+void IVIPlaneDesc::freeBuffers(IVIPlaneDesc *planes) {
int p, b, t;
for (p = 0; p < 3; p++) {
@@ -403,6 +401,13 @@ void IVIPlaneDesc::ivi_free_buffers(IVIPlaneDesc *planes) {
}
}
+int IVIPlaneDesc::checkImageSize(unsigned int w, unsigned int h, int log_offset) {
+ if (((w + 128) * (uint64)(h + 128)) < (MAX_INTEGER / 8))
+ return 0;
+
+ error("Picture size %ux%u is invalid", w, h);
+}
+
/*------------------------------------------------------------------------*/
AVFrame::AVFrame() {
@@ -410,7 +415,7 @@ AVFrame::AVFrame() {
Common::fill(&_linesize[0], &_linesize[AV_NUM_DATA_POINTERS], 0);
}
-int AVFrame::ff_set_dimensions(uint16 width, uint16 height) {
+int AVFrame::setDimensions(uint16 width, uint16 height) {
_width = width;
_height = height;
_linesize[0] = _linesize[1] = _linesize[2] = width;
@@ -418,8 +423,8 @@ int AVFrame::ff_set_dimensions(uint16 width, uint16 height) {
return 0;
}
-int AVFrame::ff_get_buffer(int flags) {
- av_frame_free();
+int AVFrame::getBuffer(int flags) {
+ freeFrame();
// Luminance channel
_data[0] = (uint8 *)av_mallocz(_width * _height);
@@ -433,7 +438,7 @@ int AVFrame::ff_get_buffer(int flags) {
return 0;
}
-void AVFrame::av_frame_free() {
+void AVFrame::freeFrame() {
av_freep(&_data[0]);
av_freep(&_data[1]);
av_freep(&_data[2]);
@@ -458,27 +463,27 @@ 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;
- ivi_mb_huff_desc[i].ivi_create_huff_from_desc(&_iviMbVlcTabs[i], 1);
+ ivi_mb_huff_desc[i].createHuffFromDesc(&_iviMbVlcTabs[i], true);
_iviBlkVlcTabs[i]._table = _tableData + (i * 2 + 1) * 8192;
_iviBlkVlcTabs[i]._table_allocated = 8192;
- ivi_blk_huff_desc[i].ivi_create_huff_from_desc(&_iviBlkVlcTabs[i], 1);
+ ivi_blk_huff_desc[i].createHuffFromDesc(&_iviBlkVlcTabs[i], true);
}
}
/*------------------------------------------------------------------------*/
-IndeoDecoderBase::IndeoDecoderBase(uint16 _width, uint16 _height) : Codec() {
+IndeoDecoderBase::IndeoDecoderBase(uint16 width, uint16 height) : Codec() {
_pixelFormat = g_system->getScreenFormat();
assert(_pixelFormat.bytesPerPixel > 1);
_surface = new Graphics::ManagedSurface();
- _surface->create(_width, _height, _pixelFormat);
- _surface->fillRect(Common::Rect(0, 0, _width, _height), 0);
+ _surface->create(width, height, _pixelFormat);
+ _surface->fillRect(Common::Rect(0, 0, width, height), 0);
_ctx._bRefBuf = 3; // buffer 2 is used for scalability mode
}
IndeoDecoderBase::~IndeoDecoderBase() {
delete _surface;
- IVIPlaneDesc::ivi_free_buffers(_ctx._planes);
+ IVIPlaneDesc::freeBuffers(_ctx._planes);
if (_ctx._mbVlc._custTab._table)
_ctx._mbVlc._custTab.ff_free_vlc();
@@ -512,11 +517,11 @@ int IndeoDecoderBase::decodeIndeoFrame() {
return -1;
}
- switch_buffers();
+ switchBuffers();
//{ START_TIMER;
- if (is_nonnull_frame()) {
+ if (isNonNullFrame()) {
_ctx._bufInvalid[_ctx._dstBuf] = 1;
for (p = 0; p < 3; p++) {
for (b = 0; b < _ctx._planes[p]._numBands; b++) {
@@ -542,28 +547,28 @@ int IndeoDecoderBase::decodeIndeoFrame() {
//STOP_TIMER("decode_planes"); }
- if (!is_nonnull_frame())
+ if (!isNonNullFrame())
return 0;
assert(_ctx._planes[0]._width <= _surface->w && _ctx._planes[0]._height <= _surface->h);
- result = frame->ff_set_dimensions(_ctx._planes[0]._width, _ctx._planes[0]._height);
+ result = frame->setDimensions(_ctx._planes[0]._width, _ctx._planes[0]._height);
if (result < 0)
return result;
- if ((result = frame->ff_get_buffer(0)) < 0)
+ if ((result = frame->getBuffer(0)) < 0)
return result;
if (_ctx._isScalable) {
if (_ctx._isIndeo4)
- ff_ivi_recompose_haar(&_ctx._planes[0], frame->_data[0], frame->_linesize[0]);
+ recomposeHaar(&_ctx._planes[0], frame->_data[0], frame->_linesize[0]);
else
- ff_ivi_recompose53(&_ctx._planes[0], frame->_data[0], frame->_linesize[0]);
+ recompose53(&_ctx._planes[0], frame->_data[0], frame->_linesize[0]);
} else {
- ivi_output_plane(&_ctx._planes[0], frame->_data[0], frame->_linesize[0]);
+ outputPlane(&_ctx._planes[0], frame->_data[0], frame->_linesize[0]);
}
- ivi_output_plane(&_ctx._planes[2], frame->_data[1], frame->_linesize[1]);
- ivi_output_plane(&_ctx._planes[1], frame->_data[2], frame->_linesize[2]);
+ outputPlane(&_ctx._planes[2], frame->_data[1], frame->_linesize[1]);
+ outputPlane(&_ctx._planes[1], frame->_data[2], frame->_linesize[2]);
// If the bidirectional mode is enabled, next I and the following P
// frame will be sent together. Unfortunately the approach below seems
@@ -592,7 +597,7 @@ int IndeoDecoderBase::decodeIndeoFrame() {
frame->_width, frame->_width);
// Free the now un-needed frame data
- frame->av_frame_free();
+ frame->freeFrame();
return 0;
}
@@ -615,7 +620,7 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
}
band->_dataPtr = _ctx._frameData + (_ctx._gb->getBitsCount() >> 3);
- result = decode_band_hdr(band);
+ result = decodeBandHeader(band);
if (result) {
warning("Error while decoding band header: %d",
result);
@@ -653,24 +658,24 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
}
tile->_isEmpty = _ctx._gb->getBits1();
if (tile->_isEmpty) {
- result = ivi_process_empty_tile(band, tile,
+ result = processEmptyTile(band, tile,
(_ctx._planes[0]._bands[0]._mbSize >> 3) - (band->_mbSize >> 3));
if (result < 0)
break;
warning("Empty tile encountered!");
} else {
- tile->_dataSize = ivi_dec_tile_data_size(_ctx._gb);
+ tile->_dataSize = decodeTileDataSize(_ctx._gb);
if (!tile->_dataSize) {
warning("Tile data size is zero!");
result = -1;
break;
}
- result = decode_mb_info(band, tile);
+ result = decodeMbInfo(band, tile);
if (result < 0)
break;
- result = ivi_decode_blocks(_ctx._gb, band, tile);
+ result = decodeBlocks(_ctx._gb, band, tile);
if (result < 0) {
warning("Corrupted tile data encountered!");
break;
@@ -704,28 +709,28 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
return result;
}
-void IndeoDecoderBase::ff_ivi_recompose_haar(const IVIPlaneDesc *_plane,
- uint8 *dst, const int dst_pitch) {
+void IndeoDecoderBase::recomposeHaar(const IVIPlaneDesc *_plane,
+ uint8 *dst, const int dstPitch) {
int x, y, indx, b0, b1, b2, b3, p0, p1, p2, p3;
- const short * b0_ptr, *b1_ptr, *b2_ptr, *b3_ptr;
+ const short * b0Ptr, *b1Ptr, *b2Ptr, *b3Ptr;
int32 _pitch;
// all bands should have the same _pitch
_pitch = _plane->_bands[0]._pitch;
// get pointers to the wavelet bands
- b0_ptr = _plane->_bands[0]._buf;
- b1_ptr = _plane->_bands[1]._buf;
- b2_ptr = _plane->_bands[2]._buf;
- b3_ptr = _plane->_bands[3]._buf;
+ b0Ptr = _plane->_bands[0]._buf;
+ b1Ptr = _plane->_bands[1]._buf;
+ b2Ptr = _plane->_bands[2]._buf;
+ b3Ptr = _plane->_bands[3]._buf;
for (y = 0; y < _plane->_height; y += 2) {
for (x = 0, indx = 0; x < _plane->_width; x += 2, indx++) {
// load coefficients
- b0 = b0_ptr[indx]; //should be: b0 = (_numBands > 0) ? b0_ptr[indx] : 0;
- b1 = b1_ptr[indx]; //should be: b1 = (_numBands > 1) ? b1_ptr[indx] : 0;
- b2 = b2_ptr[indx]; //should be: b2 = (_numBands > 2) ? b2_ptr[indx] : 0;
- b3 = b3_ptr[indx]; //should be: b3 = (_numBands > 3) ? b3_ptr[indx] : 0;
+ b0 = b0Ptr[indx]; //should be: b0 = (_numBands > 0) ? b0Ptr[indx] : 0;
+ b1 = b1Ptr[indx]; //should be: b1 = (_numBands > 1) ? b1Ptr[indx] : 0;
+ b2 = b2Ptr[indx]; //should be: b2 = (_numBands > 2) ? b2Ptr[indx] : 0;
+ b3 = b3Ptr[indx]; //should be: b3 = (_numBands > 3) ? b3Ptr[indx] : 0;
// haar wavelet recomposition
p0 = (b0 + b1 + b2 + b3 + 2) >> 2;
@@ -736,28 +741,27 @@ void IndeoDecoderBase::ff_ivi_recompose_haar(const IVIPlaneDesc *_plane,
// bias, convert and output four pixels
dst[x] = av_clip_uint8(p0 + 128);
dst[x + 1] = av_clip_uint8(p1 + 128);
- dst[dst_pitch + x] = av_clip_uint8(p2 + 128);
- dst[dst_pitch + x + 1] = av_clip_uint8(p3 + 128);
+ dst[dstPitch + x] = av_clip_uint8(p2 + 128);
+ dst[dstPitch + x + 1] = av_clip_uint8(p3 + 128);
}// for x
- dst += dst_pitch << 1;
+ dst += dstPitch << 1;
- b0_ptr += _pitch;
- b1_ptr += _pitch;
- b2_ptr += _pitch;
- b3_ptr += _pitch;
+ b0Ptr += _pitch;
+ b1Ptr += _pitch;
+ b2Ptr += _pitch;
+ b3Ptr += _pitch;
}// for y
}
-
-void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *_plane,
- uint8 *dst, const int dst_pitch) {
+void IndeoDecoderBase::recompose53(const IVIPlaneDesc *_plane,
+ uint8 *dst, const int dstPitch) {
int x, y, indx;
int32 p0, p1, p2, p3, tmp0, tmp1, tmp2;
int32 b0_1, b0_2, b1_1, b1_2, b1_3, b2_1, b2_2, b2_3, b2_4, b2_5, b2_6;
int32 b3_1, b3_2, b3_3, b3_4, b3_5, b3_6, b3_7, b3_8, b3_9;
int32 _pitch, back_pitch;
- const short * b0_ptr, *b1_ptr, *b2_ptr, *b3_ptr;
+ const short * b0Ptr, *b1Ptr, *b2Ptr, *b3Ptr;
const int _numBands = 4;
// all bands should have the same _pitch
@@ -767,10 +771,10 @@ void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *_plane,
back_pitch = 0;
// get pointers to the wavelet bands
- b0_ptr = _plane->_bands[0]._buf;
- b1_ptr = _plane->_bands[1]._buf;
- b2_ptr = _plane->_bands[2]._buf;
- b3_ptr = _plane->_bands[3]._buf;
+ b0Ptr = _plane->_bands[0]._buf;
+ b1Ptr = _plane->_bands[1]._buf;
+ b2Ptr = _plane->_bands[2]._buf;
+ b3Ptr = _plane->_bands[3]._buf;
for (y = 0; y < _plane->_height; y += 2) {
@@ -778,38 +782,38 @@ void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *_plane,
_pitch = 0;
// load storage variables with values
if (_numBands > 0) {
- b0_1 = b0_ptr[0];
- b0_2 = b0_ptr[_pitch];
+ b0_1 = b0Ptr[0];
+ b0_2 = b0Ptr[_pitch];
}
if (_numBands > 1) {
- b1_1 = b1_ptr[back_pitch];
- b1_2 = b1_ptr[0];
- b1_3 = b1_1 - b1_2 * 6 + b1_ptr[_pitch];
+ b1_1 = b1Ptr[back_pitch];
+ b1_2 = b1Ptr[0];
+ b1_3 = b1_1 - b1_2 * 6 + b1Ptr[_pitch];
}
if (_numBands > 2) {
- b2_2 = b2_ptr[0]; // b2[x, y ]
- b2_3 = b2_2; // b2[x+1,y ] = b2[x,y]
- b2_5 = b2_ptr[_pitch]; // b2[x ,y+1]
- b2_6 = b2_5; // b2[x+1,y+1] = b2[x,y+1]
+ b2_2 = b2Ptr[0]; // b2[x, y ]
+ b2_3 = b2_2; // b2[x+1,y ] = b2[x,y]
+ b2_5 = b2Ptr[_pitch]; // b2[x ,y+1]
+ b2_6 = b2_5; // b2[x+1,y+1] = b2[x,y+1]
}
if (_numBands > 3) {
- b3_2 = b3_ptr[back_pitch]; // b3[x ,y-1]
- b3_3 = b3_2; // b3[x+1,y-1] = b3[x ,y-1]
- b3_5 = b3_ptr[0]; // b3[x ,y ]
- b3_6 = b3_5; // b3[x+1,y ] = b3[x ,y ]
- b3_8 = b3_2 - b3_5 * 6 + b3_ptr[_pitch];
+ b3_2 = b3Ptr[back_pitch]; // b3[x ,y-1]
+ b3_3 = b3_2; // b3[x+1,y-1] = b3[x ,y-1]
+ b3_5 = b3Ptr[0]; // b3[x ,y ]
+ b3_6 = b3_5; // b3[x+1,y ] = b3[x ,y ]
+ b3_8 = b3_2 - b3_5 * 6 + b3Ptr[_pitch];
b3_9 = b3_8;
}
for (x = 0, indx = 0; x < _plane->_width; x += 2, indx++) {
if (x + 2 >= _plane->_width) {
- b0_ptr--;
- b1_ptr--;
- b2_ptr--;
- b3_ptr--;
+ b0Ptr--;
+ b1Ptr--;
+ b2Ptr--;
+ b3Ptr--;
}
// some values calculated in the previous iterations can
@@ -831,8 +835,8 @@ void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *_plane,
if (_numBands > 0) {
tmp0 = b0_1;
tmp2 = b0_2;
- b0_1 = b0_ptr[indx + 1];
- b0_2 = b0_ptr[_pitch + indx + 1];
+ b0_1 = b0Ptr[indx + 1];
+ b0_2 = b0Ptr[_pitch + indx + 1];
tmp1 = tmp0 + b0_1;
p0 = tmp0 << 4;
@@ -845,11 +849,11 @@ void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *_plane,
if (_numBands > 1) {
tmp0 = b1_2;
tmp1 = b1_1;
- b1_2 = b1_ptr[indx + 1];
- b1_1 = b1_ptr[back_pitch + indx + 1];
+ b1_2 = b1Ptr[indx + 1];
+ b1_1 = b1Ptr[back_pitch + indx + 1];
tmp2 = tmp1 - tmp0 * 6 + b1_3;
- b1_3 = b1_1 - b1_2 * 6 + b1_ptr[_pitch + indx + 1];
+ b1_3 = b1_1 - b1_2 * 6 + b1Ptr[_pitch + indx + 1];
p0 += (tmp0 + tmp1) << 3;
p1 += (tmp0 + tmp1 + b1_1 + b1_2) << 2;
@@ -859,8 +863,8 @@ void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *_plane,
// process the LH-band by applying LPF vertically and HPF horizontally
if (_numBands > 2) {
- b2_3 = b2_ptr[indx + 1];
- b2_6 = b2_ptr[_pitch + indx + 1];
+ b2_3 = b2Ptr[indx + 1];
+ b2_6 = b2Ptr[_pitch + indx + 1];
tmp0 = b2_1 + b2_2;
tmp1 = b2_1 - b2_2 * 6 + b2_3;
@@ -873,14 +877,14 @@ void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *_plane,
// process the HH-band by applying HPF both vertically and horizontally
if (_numBands > 3) {
- b3_6 = b3_ptr[indx + 1]; // b3[x+1,y ]
- b3_3 = b3_ptr[back_pitch + indx + 1]; // b3[x+1,y-1]
+ b3_6 = b3Ptr[indx + 1]; // b3[x+1,y ]
+ b3_3 = b3Ptr[back_pitch + indx + 1]; // b3[x+1,y-1]
tmp0 = b3_1 + b3_4;
tmp1 = b3_2 + b3_5;
tmp2 = b3_3 + b3_6;
- b3_9 = b3_3 - b3_6 * 6 + b3_ptr[_pitch + indx + 1];
+ b3_9 = b3_3 - b3_6 * 6 + b3Ptr[_pitch + indx + 1];
p0 += (tmp0 + tmp1) << 2;
p1 += (tmp0 - tmp1 * 6 + tmp2) << 1;
@@ -891,25 +895,25 @@ void IndeoDecoderBase::ff_ivi_recompose53(const IVIPlaneDesc *_plane,
// output four pixels
dst[x] = av_clip_uint8((p0 >> 6) + 128);
dst[x + 1] = av_clip_uint8((p1 >> 6) + 128);
- dst[dst_pitch + x] = av_clip_uint8((p2 >> 6) + 128);
- dst[dst_pitch + x + 1] = av_clip_uint8((p3 >> 6) + 128);
+ dst[dstPitch + x] = av_clip_uint8((p2 >> 6) + 128);
+ dst[dstPitch + x + 1] = av_clip_uint8((p3 >> 6) + 128);
}// for x
- dst += dst_pitch << 1;
+ dst += dstPitch << 1;
back_pitch = -_pitch;
- b0_ptr += _pitch + 1;
- b1_ptr += _pitch + 1;
- b2_ptr += _pitch + 1;
- b3_ptr += _pitch + 1;
+ b0Ptr += _pitch + 1;
+ b1Ptr += _pitch + 1;
+ b2Ptr += _pitch + 1;
+ b3Ptr += _pitch + 1;
}
}
-void IndeoDecoderBase::ivi_output_plane(IVIPlaneDesc *_plane, uint8 *dst, int dst_pitch) {
+void IndeoDecoderBase::outputPlane(IVIPlaneDesc *_plane, uint8 *dst, int dstPitch) {
int x, y;
const int16 * src = _plane->_bands[0]._buf;
- uint32 _pitch = _plane->_bands[0]._pitch;
+ uint32 pitch = _plane->_bands[0]._pitch;
if (!src)
return;
@@ -917,40 +921,40 @@ void IndeoDecoderBase::ivi_output_plane(IVIPlaneDesc *_plane, uint8 *dst, int ds
for (y = 0; y < _plane->_height; y++) {
for (x = 0; x < _plane->_width; x++)
dst[x] = av_clip_uint8(src[x] + 128);
- src += _pitch;
- dst += dst_pitch;
+ src += pitch;
+ dst += dstPitch;
}
}
-int IndeoDecoderBase::ivi_process_empty_tile(IVIBandDesc *band,
- IVITile *tile, int32 mv_scale) {
- int x, y, need_mc, mbn, blk, num_blocks, _mvX, _mvY, mc_type;
- int offs, mb_offset, row_offset, ret;
- IVIMbInfo *mb, *ref_mb;
+int IndeoDecoderBase::processEmptyTile(IVIBandDesc *band,
+ IVITile *tile, int32 mvScale) {
+ int x, y, needMc, mbn, blk, numBlocks, mvX, mvY, mcType;
+ int offs, mbOffset, rowOffset, ret;
+ IVIMbInfo *mb, *refMb;
const int16 * src;
int16 * dst;
- IviMCFunc mc_no_delta_func;
+ IviMCFunc mcNoDeltaFunc;
if (tile->_numMBs != IVI_MBs_PER_TILE(tile->_width, tile->_height, band->_mbSize)) {
warning("Allocated tile size %d mismatches "
- "parameters %d in ivi_process_empty_tile()",
+ "parameters %d in processEmptyTile()",
tile->_numMBs, IVI_MBs_PER_TILE(tile->_width, tile->_height, band->_mbSize));
return -1;
}
offs = tile->_yPos * band->_pitch + tile->_xPos;
mb = tile->_mbs;
- ref_mb = tile->_refMbs;
- row_offset = band->_mbSize * band->_pitch;
- need_mc = 0; // reset the mc tracking flag
+ refMb = tile->_refMbs;
+ rowOffset = band->_mbSize * band->_pitch;
+ needMc = 0; // reset the mc tracking flag
for (y = tile->_yPos; y < (tile->_yPos + tile->_height); y += band->_mbSize) {
- mb_offset = offs;
+ mbOffset = offs;
for (x = tile->_xPos; x < (tile->_xPos + tile->_width); x += band->_mbSize) {
mb->_xPos = x;
mb->_yPos = y;
- mb->_bufOffs = mb_offset;
+ mb->_bufOffs = mbOffset;
mb->_type = 1; // set the macroblocks _type = INTER
mb->_cbp = 0; // all blocks are empty
@@ -961,19 +965,19 @@ int IndeoDecoderBase::ivi_process_empty_tile(IVIBandDesc *band,
mb->_mvY = 0;
}
- if (band->_inheritQDelta && ref_mb)
- mb->_qDelta = ref_mb->_qDelta;
+ if (band->_inheritQDelta && refMb)
+ mb->_qDelta = refMb->_qDelta;
- if (band->_inheritMv && ref_mb) {
+ if (band->_inheritMv && refMb) {
// motion vector inheritance
- if (mv_scale) {
- mb->_mvX = ivi_scale_mv(ref_mb->_mvX, mv_scale);
- mb->_mvY = ivi_scale_mv(ref_mb->_mvY, mv_scale);
+ if (mvScale) {
+ mb->_mvX = scaleMV(refMb->_mvX, mvScale);
+ mb->_mvY = scaleMV(refMb->_mvY, mvScale);
} else {
- mb->_mvX = ref_mb->_mvX;
- mb->_mvY = ref_mb->_mvY;
+ mb->_mvX = refMb->_mvX;
+ mb->_mvY = refMb->_mvY;
}
- need_mc |= mb->_mvX || mb->_mvY; // tracking non-zero motion vectors
+ needMc |= mb->_mvX || mb->_mvY; // tracking non-zero motion vectors
{
int dmv_x, dmv_y, cx, cy;
@@ -993,34 +997,34 @@ int IndeoDecoderBase::ivi_process_empty_tile(IVIBandDesc *band,
}
mb++;
- if (ref_mb)
- ref_mb++;
- mb_offset += band->_mbSize;
+ if (refMb)
+ refMb++;
+ mbOffset += band->_mbSize;
} // for x
- offs += row_offset;
+ offs += rowOffset;
} // for y
- if (band->_inheritMv && need_mc) { // apply motion compensation if there is at least one non-zero motion vector
- num_blocks = (band->_mbSize != band->_blkSize) ? 4 : 1; // number of blocks per mb
- mc_no_delta_func = (band->_blkSize == 8) ? IndeoDSP::ff_ivi_mc_8x8_no_delta
+ if (band->_inheritMv && needMc) { // apply motion compensation if there is at least one non-zero motion vector
+ numBlocks = (band->_mbSize != band->_blkSize) ? 4 : 1; // number of blocks per mb
+ mcNoDeltaFunc = (band->_blkSize == 8) ? IndeoDSP::ff_ivi_mc_8x8_no_delta
: IndeoDSP::ff_ivi_mc_4x4_no_delta;
for (mbn = 0, mb = tile->_mbs; mbn < tile->_numMBs; mb++, mbn++) {
- _mvX = mb->_mvX;
- _mvY = mb->_mvY;
+ mvX = mb->_mvX;
+ mvY = mb->_mvY;
if (!band->_isHalfpel) {
- mc_type = 0; // we have only fullpel vectors
+ mcType = 0; // we have only fullpel vectors
} else {
- mc_type = ((_mvY & 1) << 1) | (_mvX & 1);
- _mvX >>= 1;
- _mvY >>= 1; // convert halfpel vectors into fullpel ones
+ mcType = ((mvY & 1) << 1) | (mvX & 1);
+ mvX >>= 1;
+ mvY >>= 1; // convert halfpel vectors into fullpel ones
}
- for (blk = 0; blk < num_blocks; blk++) {
+ for (blk = 0; blk < numBlocks; blk++) {
// adjust block position in the buffer according with its number
offs = mb->_bufOffs + band->_blkSize * ((blk & 1) + !!(blk & 2) * band->_pitch);
- ret = ivi_mc(band, mc_no_delta_func, nullptr, offs,
- _mvX, _mvY, 0, 0, mc_type, -1);
+ ret = iviMc(band, mcNoDeltaFunc, nullptr, offs,
+ mvX, mvY, 0, 0, mcType, -1);
if (ret < 0)
return ret;
}
@@ -1039,53 +1043,53 @@ int IndeoDecoderBase::ivi_process_empty_tile(IVIBandDesc *band,
return 0;
}
-int IndeoDecoderBase::ivi_dec_tile_data_size(GetBits *_gb) {
+int IndeoDecoderBase::decodeTileDataSize(GetBits *gb) {
int len = 0;
- if (_gb->getBits1()) {
- len = _gb->getBits(8);
+ if (gb->getBits1()) {
+ len = gb->getBits(8);
if (len == 255)
- len = _gb->getBitsLong(24);
+ len = gb->getBitsLong(24);
}
// align the bitstream reader on the byte boundary
- _gb->alignGetBits();
+ gb->alignGetBits();
return len;
}
-int IndeoDecoderBase::ivi_decode_blocks(GetBits *_gb, IVIBandDesc *band, IVITile *tile) {
- int mbn, blk, num_blocks, _blkSize, ret, is_intra;
- int mc_type = 0, mc_type2 = -1;
- int _mvX = 0, _mvY = 0, mv_x2 = 0, mv_y2 = 0;
- int32 prev_dc;
- uint32 _cbp, quant, _bufOffs;
+int IndeoDecoderBase::decodeBlocks(GetBits *_gb, IVIBandDesc *band, IVITile *tile) {
+ int mbn, blk, numBlocks, blkSize, ret, isIntra;
+ int mcType = 0, mcType2 = -1;
+ int mvX = 0, mvY = 0, mvX2 = 0, mvY2 = 0;
+ int32 prevDc;
+ uint32 cbp, quant, bufOffs;
IVIMbInfo *mb;
- IviMCFunc mc_with_delta_func, mc_no_delta_func;
- IviMCAvgFunc mc_avg_with_delta_func, mc_avg_no_delta_func;
- const uint8 *scale_tab;
+ IviMCFunc mcWithDeltaFunc, mcNoDeltaFunc;
+ IviMCAvgFunc mcAvgWithDeltaFunc, mcAvgNoDeltaFunc;
+ const uint8 *scaleTab;
// init intra prediction for the DC coefficient
- prev_dc = 0;
- _blkSize = band->_blkSize;
+ prevDc = 0;
+ blkSize = band->_blkSize;
// number of blocks per mb
- num_blocks = (band->_mbSize != _blkSize) ? 4 : 1;
- if (_blkSize == 8) {
- mc_with_delta_func = IndeoDSP::ff_ivi_mc_8x8_delta;
- mc_no_delta_func = IndeoDSP::ff_ivi_mc_8x8_no_delta;
- mc_avg_with_delta_func = IndeoDSP::ff_ivi_mc_avg_8x8_delta;
- mc_avg_no_delta_func = IndeoDSP::ff_ivi_mc_avg_8x8_no_delta;
+ numBlocks = (band->_mbSize != blkSize) ? 4 : 1;
+ if (blkSize == 8) {
+ mcWithDeltaFunc = IndeoDSP::ff_ivi_mc_8x8_delta;
+ mcNoDeltaFunc = IndeoDSP::ff_ivi_mc_8x8_no_delta;
+ mcAvgWithDeltaFunc = IndeoDSP::ff_ivi_mc_avg_8x8_delta;
+ mcAvgNoDeltaFunc = IndeoDSP::ff_ivi_mc_avg_8x8_no_delta;
} else {
- mc_with_delta_func = IndeoDSP::ff_ivi_mc_4x4_delta;
- mc_no_delta_func = IndeoDSP::ff_ivi_mc_4x4_no_delta;
- mc_avg_with_delta_func = IndeoDSP::ff_ivi_mc_avg_4x4_delta;
- mc_avg_no_delta_func = IndeoDSP::ff_ivi_mc_avg_4x4_no_delta;
+ mcWithDeltaFunc = IndeoDSP::ff_ivi_mc_4x4_delta;
+ mcNoDeltaFunc = IndeoDSP::ff_ivi_mc_4x4_no_delta;
+ mcAvgWithDeltaFunc = IndeoDSP::ff_ivi_mc_avg_4x4_delta;
+ mcAvgNoDeltaFunc = IndeoDSP::ff_ivi_mc_avg_4x4_no_delta;
}
for (mbn = 0, mb = tile->_mbs; mbn < tile->_numMBs; mb++, mbn++) {
- is_intra = !mb->_type;
- _cbp = mb->_cbp;
- _bufOffs = mb->_bufOffs;
+ isIntra = !mb->_type;
+ cbp = mb->_cbp;
+ bufOffs = mb->_bufOffs;
quant = band->_globQuant + mb->_qDelta;
if (_ctx._isIndeo4)
@@ -1093,27 +1097,27 @@ int IndeoDecoderBase::ivi_decode_blocks(GetBits *_gb, IVIBandDesc *band, IVITile
else
quant = av_clip((int)quant, 0, 23);
- scale_tab = is_intra ? band->_intraScale : band->_interScale;
- if (scale_tab)
- quant = scale_tab[quant];
+ scaleTab = isIntra ? band->_intraScale : band->_interScale;
+ if (scaleTab)
+ quant = scaleTab[quant];
- if (!is_intra) {
- _mvX = mb->_mvX;
- _mvY = mb->_mvY;
- mv_x2 = mb->_bMvX;
- mv_y2 = mb->_bMvY;
+ if (!isIntra) {
+ mvX = mb->_mvX;
+ mvY = mb->_mvY;
+ mvX2 = mb->_bMvX;
+ mvY2 = mb->_bMvY;
if (band->_isHalfpel) {
- mc_type = ((_mvY & 1) << 1) | (_mvX & 1);
- mc_type2 = ((mv_y2 & 1) << 1) | (mv_x2 & 1);
- _mvX >>= 1;
- _mvY >>= 1;
- mv_x2 >>= 1;
- mv_y2 >>= 1; // convert halfpel vectors into fullpel ones
+ mcType = ((mvY & 1) << 1) | (mvX & 1);
+ mcType2 = ((mvY2 & 1) << 1) | (mvX2 & 1);
+ mvX >>= 1;
+ mvY >>= 1;
+ mvX2 >>= 1;
+ mvY2 >>= 1; // convert halfpel vectors into fullpel ones
}
if (mb->_type == 2)
- mc_type = -1;
+ mcType = -1;
if (mb->_type != 2 && mb->_type != 3)
- mc_type2 = -1;
+ mcType2 = -1;
if (mb->_type) {
int dmv_x, dmv_y, cx, cy;
@@ -1146,42 +1150,42 @@ int IndeoDecoderBase::ivi_decode_blocks(GetBits *_gb, IVIBandDesc *band, IVITile
}
}
- for (blk = 0; blk < num_blocks; blk++) {
+ for (blk = 0; blk < numBlocks; blk++) {
// adjust block position in the buffer according to its number
if (blk & 1) {
- _bufOffs += _blkSize;
+ bufOffs += blkSize;
} else if (blk == 2) {
- _bufOffs -= _blkSize;
- _bufOffs += _blkSize * band->_pitch;
+ bufOffs -= blkSize;
+ bufOffs += blkSize * band->_pitch;
}
- if (_cbp & 1) { // block coded ?
- ret = ivi_decode_coded_blocks(_gb, band, mc_with_delta_func,
- mc_avg_with_delta_func,
- _mvX, _mvY, mv_x2, mv_y2,
- &prev_dc, is_intra,
- mc_type, mc_type2, quant,
- _bufOffs);
+ if (cbp & 1) { // block coded ?
+ ret = ivi_decode_coded_blocks(_gb, band, mcWithDeltaFunc,
+ mcAvgWithDeltaFunc,
+ mvX, mvY, mvX2, mvY2,
+ &prevDc, isIntra,
+ mcType, mcType2, quant,
+ bufOffs);
if (ret < 0)
return ret;
} else {
// block not coded
// for intra blocks apply the dc slant transform
// for inter - perform the motion compensation without delta
- if (is_intra) {
- ret = ivi_dc_transform(band, &prev_dc, _bufOffs, _blkSize);
+ if (isIntra) {
+ ret = ivi_dc_transform(band, &prevDc, bufOffs, blkSize);
if (ret < 0)
return ret;
} else {
- ret = ivi_mc(band, mc_no_delta_func, mc_avg_no_delta_func,
- _bufOffs, _mvX, _mvY, mv_x2, mv_y2,
- mc_type, mc_type2);
+ ret = iviMc(band, mcNoDeltaFunc, mcAvgNoDeltaFunc,
+ bufOffs, mvX, mvY, mvX2, mvY2,
+ mcType, mcType2);
if (ret < 0)
return ret;
}
}
- _cbp >>= 1;
+ cbp >>= 1;
}// for blk
}// for mbn
@@ -1189,66 +1193,66 @@ int IndeoDecoderBase::ivi_decode_blocks(GetBits *_gb, IVIBandDesc *band, IVITile
return 0;
}
-int IndeoDecoderBase::ivi_scale_mv(int mv, int mv_scale){
- return (mv + (mv > 0) + (mv_scale - 1)) >> mv_scale;
+int IndeoDecoderBase::scaleMV(int mv, int mvScale) {
+ return (mv + (mv > 0) + (mvScale - 1)) >> mvScale;
}
-int IndeoDecoderBase::ivi_mc(IVIBandDesc *band, IviMCFunc mc, IviMCAvgFunc mc_avg,
- int offs, int _mvX, int _mvY, int mv_x2, int mv_y2,
- int mc_type, int mc_type2){
- int ref_offs = offs + _mvY * band->_pitch + _mvX;
- int buf_size = band->_pitch * band->_aHeight;
- int min_size = band->_pitch * (band->_blkSize - 1) + band->_blkSize;
- int ref_size = (mc_type > 1) * band->_pitch + (mc_type & 1);
-
- if (mc_type != -1) {
- assert(offs >= 0 && ref_offs >= 0 && band->_refBuf);
- assert(buf_size - min_size >= offs);
- assert(buf_size - min_size - ref_size >= ref_offs);
+int IndeoDecoderBase::iviMc(IVIBandDesc *band, IviMCFunc mc, IviMCAvgFunc mcAvg,
+ int offs, int mvX, int mvY, int mvX2, int mvY2,
+ int mcType, int mcType2) {
+ int refOffs = offs + mvY * band->_pitch + mvX;
+ int bufSize = band->_pitch * band->_aHeight;
+ int minSize = band->_pitch * (band->_blkSize - 1) + band->_blkSize;
+ int refSize = (mcType > 1) * band->_pitch + (mcType & 1);
+
+ if (mcType != -1) {
+ assert(offs >= 0 && refOffs >= 0 && band->_refBuf);
+ assert(bufSize - minSize >= offs);
+ assert(bufSize - minSize - refSize >= refOffs);
}
- if (mc_type2 == -1) {
- mc(band->_buf + offs, band->_refBuf + ref_offs, band->_pitch, mc_type);
+ if (mcType2 == -1) {
+ mc(band->_buf + offs, band->_refBuf + refOffs, band->_pitch, mcType);
} else {
- int ref_offs2 = offs + mv_y2 * band->_pitch + mv_x2;
- int ref_size2 = (mc_type2 > 1) * band->_pitch + (mc_type2 & 1);
+ int ref_offs2 = offs + mvY2 * band->_pitch + mvX2;
+ int ref_size2 = (mcType2 > 1) * band->_pitch + (mcType2 & 1);
if (offs < 0 || ref_offs2 < 0 || !band->_bRefBuf)
return -1;
- if (buf_size - min_size - ref_size2 < ref_offs2)
+ if (bufSize - minSize - ref_size2 < ref_offs2)
return -1;
- if (mc_type == -1)
+ if (mcType == -1)
mc(band->_buf + offs, band->_bRefBuf + ref_offs2,
- band->_pitch, mc_type2);
+ band->_pitch, mcType2);
else
- mc_avg(band->_buf + offs, band->_refBuf + ref_offs,
+ mcAvg(band->_buf + offs, band->_refBuf + refOffs,
band->_bRefBuf + ref_offs2, band->_pitch,
- mc_type, mc_type2);
+ mcType, mcType2);
}
return 0;
}
-int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *_gb, IVIBandDesc *band,
- IviMCFunc mc, IviMCAvgFunc mc_avg, int _mvX, int _mvY,
- int mv_x2, int mv_y2, int *prev_dc, int is_intra,
- int mc_type, int mc_type2, uint32 quant, int offs) {
- const uint16 *base_tab = is_intra ? band->_intraBase : band->_interBase;
+int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
+ IviMCFunc mc, IviMCAvgFunc mcAvg, int mvX, int mvY,
+ int mvX2, int mvY2, int *prevDc, int isIntra,
+ int mcType, int mcType2, uint32 quant, int offs) {
+ const uint16 *base_tab = isIntra ? band->_intraBase : band->_interBase;
RVMapDesc *rvmap = band->_rvMap;
- uint8 col_flags[8];
+ uint8 colFlags[8];
int32 trvec[64];
uint32 sym = 0, q;
int lo, hi;
int pos, run, val;
- int _blkSize = band->_blkSize;
- int num_coeffs = _blkSize * _blkSize;
- int col_mask = _blkSize - 1;
- int scan_pos = -1;
- int min_size = band->_pitch * (band->_transformSize - 1) +
+ int blkSize = band->_blkSize;
+ int numCoeffs = blkSize * blkSize;
+ int colMask = blkSize - 1;
+ int scanPos = -1;
+ int minSize = band->_pitch * (band->_transformSize - 1) +
band->_transformSize;
- int buf_size = band->_pitch * band->_aHeight - offs;
+ int bufSize = band->_pitch * band->_aHeight - offs;
- if (min_size > buf_size)
+ if (minSize > bufSize)
return -1;
if (!band->_scan) {
@@ -1257,20 +1261,20 @@ int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *_gb, IVIBandDesc *band,
}
// zero transform vector
- memset(trvec, 0, num_coeffs * sizeof(trvec[0]));
+ memset(trvec, 0, numCoeffs * sizeof(trvec[0]));
// zero column flags
- memset(col_flags, 0, sizeof(col_flags));
- while (scan_pos <= num_coeffs) {
- sym = _gb->getVLC2(band->_blkVlc._tab->_table,
+ memset(colFlags, 0, sizeof(colFlags));
+ while (scanPos <= numCoeffs) {
+ sym = gb->getVLC2(band->_blkVlc._tab->_table,
IVI_VLC_BITS, 1);
if (sym == rvmap->_eobSym)
break; // End of block
- // Escape - run/val explicitly coded using 3 vlc codes
+ // Escape - run/val explicitly coded using 3 vlc codes
if (sym == rvmap->_escSym) {
- run = _gb->getVLC2(band->_blkVlc._tab->_table, IVI_VLC_BITS, 1) + 1;
- lo = _gb->getVLC2(band->_blkVlc._tab->_table, IVI_VLC_BITS, 1);
- hi = _gb->getVLC2(band->_blkVlc._tab->_table, IVI_VLC_BITS, 1);
+ run = gb->getVLC2(band->_blkVlc._tab->_table, IVI_VLC_BITS, 1) + 1;
+ lo = gb->getVLC2(band->_blkVlc._tab->_table, IVI_VLC_BITS, 1);
+ hi = gb->getVLC2(band->_blkVlc._tab->_table, IVI_VLC_BITS, 1);
// merge them and convert into signed val
val = IVI_TOSIGNED((hi << 6) | lo);
} else {
@@ -1283,10 +1287,10 @@ int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *_gb, IVIBandDesc *band,
}
// de-zigzag and dequantize
- scan_pos += run;
- if (scan_pos >= num_coeffs || scan_pos < 0)
+ scanPos += run;
+ if (scanPos >= numCoeffs || scanPos < 0)
break;
- pos = band->_scan[scan_pos];
+ pos = band->_scan[scanPos];
if (!val)
warning("Val = 0 encountered!");
@@ -1296,17 +1300,17 @@ int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *_gb, IVIBandDesc *band,
val = val * q + FFSIGN(val) * (((q ^ 1) - 1) >> 1);
trvec[pos] = val;
// track columns containing non-zero coeffs
- col_flags[pos & col_mask] |= !!val;
+ colFlags[pos & colMask] |= !!val;
}
- if (scan_pos < 0 || (scan_pos >= num_coeffs && sym != rvmap->_eobSym))
+ if (scanPos < 0 || (scanPos >= numCoeffs && sym != rvmap->_eobSym))
return -1; // corrupt block data
// undoing DC coeff prediction for intra-blocks
- if (is_intra && band->_is2dTrans) {
- *prev_dc += trvec[0];
- trvec[0] = *prev_dc;
- col_flags[0] |= !!*prev_dc;
+ if (isIntra && band->_is2dTrans) {
+ *prevDc += trvec[0];
+ trvec[0] = *prevDc;
+ colFlags[0] |= !!*prevDc;
}
if (band->_transformSize > band->_blkSize) {
@@ -1316,25 +1320,25 @@ int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *_gb, IVIBandDesc *band,
// apply inverse transform
band->_invTransform(trvec, band->_buf + offs,
- band->_pitch, col_flags);
+ band->_pitch, colFlags);
// apply motion compensation
- if (!is_intra)
- return ivi_mc(band, mc, mc_avg, offs, _mvX, _mvY, mv_x2, mv_y2,
- mc_type, mc_type2);
+ if (!isIntra)
+ return iviMc(band, mc, mcAvg, offs, mvX, mvY, mvX2, mvY2,
+ mcType, mcType2);
return 0;
}
-int IndeoDecoderBase::ivi_dc_transform(IVIBandDesc *band, int *prev_dc,
+int IndeoDecoderBase::ivi_dc_transform(IVIBandDesc *band, int *prevDc,
int bufOffs, int blkSize) {
- int buf_size = band->_pitch * band->_aHeight - bufOffs;
- int min_size = (blkSize - 1) * band->_pitch + blkSize;
+ int bufSize = band->_pitch * band->_aHeight - bufOffs;
+ int minSize = (blkSize - 1) * band->_pitch + blkSize;
- if (min_size > buf_size)
+ if (minSize > bufSize)
return -1;
- band->_dcTransform(prev_dc, band->_buf + bufOffs,
+ band->_dcTransform(prevDc, band->_buf + bufOffs,
band->_pitch, blkSize);
return 0;
@@ -1342,15 +1346,6 @@ int IndeoDecoderBase::ivi_dc_transform(IVIBandDesc *band, int *prev_dc,
/*------------------------------------------------------------------------*/
-int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) {
- if (((w + 128) * (uint64)(h + 128)) < (MAX_INTEGER / 8))
- return 0;
-
- error("Picture size %ux%u is invalid", w, h);
-}
-
-/*------------------------------------------------------------------------*/
-
const uint8 IndeoDecoderBase::_ff_ivi_vertical_scan_8x8[64] = {
0, 8, 16, 24, 32, 40, 48, 56,
1, 9, 17, 25, 33, 41, 49, 57,
diff --git a/image/codecs/indeo/indeo.h b/image/codecs/indeo/indeo.h
index b9e4693..5f6d67f 100644
--- a/image/codecs/indeo/indeo.h
+++ b/image/codecs/indeo/indeo.h
@@ -66,7 +66,7 @@ enum {
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(*IviMCFunc) (int16 *buf, const int16 *refBuf, uint32 pitch, int mc_type);
+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);
@@ -82,8 +82,8 @@ typedef void(*IviMCAvgFunc) (int16 *buf, const int16 *refBuf1, const int16 *refB
/**
* calculate number of macroblocks in a tile
*/
-#define IVI_MBs_PER_TILE(_tileWidth, _tileHeight, _mbSize) \
- ((((_tileWidth) + (_mbSize) - 1) / (_mbSize)) * (((_tileHeight) + (_mbSize) - 1) / (_mbSize)))
+#define IVI_MBs_PER_TILE(tileWidth, tileHeight, mbSize) \
+ ((((tileWidth) + (mbSize) - 1) / (mbSize)) * (((tileHeight) + (mbSize) - 1) / (mbSize)))
/**
* huffman codebook descriptor
@@ -96,32 +96,32 @@ struct IVIHuffDesc {
* Generate a huffman codebook from the given descriptor
* and convert it into the FFmpeg VLC table.
*
- * @param[out] vlc where to place the generated VLC table
- * @param[in] flag flag: 1 - for static or 0 for dynamic tables
- * @return result code: 0 - OK, -1 = error (invalid codebook descriptor)
+ * @param[out] vlc Where to place the generated VLC table
+ * @param[in] flag Flag: true - for static or false for dynamic tables
+ * @returns result code: 0 - OK, -1 = error (invalid codebook descriptor)
*/
- int ivi_create_huff_from_desc(VLC *vlc, int flag) const;
+ int createHuffFromDesc(VLC *vlc, bool flag) const;
/*
* Compare two huffman codebook descriptors.
*
- * @param[in] desc2 ptr to the 2nd descriptor to compare
- * @return comparison result: 0 - equal, 1 - not equal
+ * @param[in] desc2 Ptr to the 2nd descriptor to compare
+ * @returns comparison result: 0 - equal, 1 - not equal
*/
- bool ivi_huff_desc_cmp(const IVIHuffDesc *desc2) const;
+ bool huffDescCompare(const IVIHuffDesc *desc2) const;
/*
* Copy huffman codebook descriptors.
*
- * @param[in] src ptr to the source descriptor
+ * @param[in] src ptr to the source descriptor
*/
- void ivi_huff_desc_copy(const IVIHuffDesc *src);
+ void huffDescCopy(const IVIHuffDesc *src);
};
struct IVI45DecContext;
/**
- * macroblock/block huffman table descriptor
+ * Macroblock/block huffman table descriptor
*/
struct IVIHuffTab {
public:
@@ -138,7 +138,16 @@ public:
*/
IVIHuffTab();
- int ff_ivi_dec_huff_desc(IVI45DecContext *ctx, int desc_coded, int which_tab);
+ /**
+ * Decode a huffman codebook descriptor from the bitstream
+ * and select specified huffman table.
+ *
+ * @param[in] ctx Decoder context
+ * @param[in] descCoded Flag signalling if table descriptor was coded
+ * @param[in] whichTab Codebook purpose (IVI_MB_HUFF or IVI_BLK_HUFF)
+ * @returns Zero on success, negative value otherwise
+ */
+ int decodeHuffDesc(IVI45DecContext *ctx, int descCoded, int whichTab);
};
/**
@@ -237,7 +246,7 @@ struct IVIBandDesc {
IVIBandDesc();
- int ivi_init_tiles(IVITile *ref_tile, int p, int b, int t_height, int t_width);
+ int initTiles(IVITile *refTile, int p, int b, int tHeight, int tWidth);
};
struct IVIPicConfig {
@@ -269,16 +278,27 @@ struct IVIPlaneDesc {
IVIPlaneDesc();
- static int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg, bool _isIndeo4);
+ static int initPlanes(IVIPlaneDesc *planes, const IVIPicConfig *cfg, bool isIndeo4);
- static int ff_ivi_init_tiles(IVIPlaneDesc *planes, int _tileWidth, int _tileHeight);
+ static int initTiles(IVIPlaneDesc *planes, int tileWidth, int tileHeight);
/*
* Free planes, bands and macroblocks buffers.
*
* @param[in] planes pointer to the array of the plane descriptors
*/
- static void ivi_free_buffers(IVIPlaneDesc *planes);
+ static void freeBuffers(IVIPlaneDesc *planes);
+
+ /**
+ * Check if the given dimension of an image is valid, meaning that all
+ * bytes of the image can be addressed with a signed int.
+ *
+ * @param w the width of the picture
+ * @param h the height of the picture
+ * @param log_offset the offset to sum to the log level for logging with log_ctx
+ * @returns >= 0 if valid, a negative error code otherwise
+ */
+ static int checkImageSize(unsigned int w, unsigned int h, int logOffset);
};
struct AVFrame {
@@ -327,22 +347,22 @@ struct AVFrame {
/**
* Destructor
*/
- ~AVFrame() { av_frame_free(); }
+ ~AVFrame() { freeFrame(); }
/**
* Sets the frame dimensions
*/
- int ff_set_dimensions(uint16 width, uint16 height);
+ int setDimensions(uint16 width, uint16 height);
/**
* Get a buffer for a frame
*/
- int ff_get_buffer(int flags);
+ int getBuffer(int flags);
/**
* Frees any data loaded for the frame
*/
- void av_frame_free();
+ void freeFrame();
};
struct IVI45DecContext {
@@ -424,43 +444,41 @@ private:
/**
* Haar wavelet recomposition filter for Indeo 4
*
- * @param[in] plane pointer to the descriptor of the plane being processed
- * @param[out] dst pointer to the destination buffer
- * @param[in] dst_pitch _pitch of the destination buffer
+ * @param[in] plane Pointer to the descriptor of the plane being processed
+ * @param[out] dst pointer to the destination buffer
+ * @param[in] dstPitch Pitch of the destination buffer
*/
- void ff_ivi_recompose_haar(const IVIPlaneDesc *plane, uint8 *dst,
- const int dst_pitch);
+ void recomposeHaar(const IVIPlaneDesc *plane, uint8 *dst, const int dstPitch);
/**
* 5/3 wavelet recomposition filter for Indeo5
*
- * @param[in] plane pointer to the descriptor of the plane being processed
- * @param[out] dst pointer to the destination buffer
- * @param[in] dst_pitch _pitch of the destination buffer
+ * @param[in] plane Pointer to the descriptor of the plane being processed
+ * @param[out] dst Pointer to the destination buffer
+ * @param[in] dstPitch Pitch of the destination buffer
*/
- void ff_ivi_recompose53(const IVIPlaneDesc *plane,
- uint8 *dst, const int dst_pitch);
+ void recompose53(const IVIPlaneDesc *plane, uint8 *dst, const int dstPitch);
/*
* Convert and output the current plane.
* This conversion is done by adding back the bias value of 128
* (subtracted in the encoder) and clipping the result.
*
- * @param[in] plane pointer to the descriptor of the plane being processed
- * @param[out] dst pointer to the buffer receiving converted pixels
- * @param[in] dst_pitch _pitch for moving to the next y line
+ * @param[in] plane Pointer to the descriptor of the plane being processed
+ * @param[out] dst Pointer to the buffer receiving converted pixels
+ * @param[in] dstPitch Pitch for moving to the next y line
*/
- void ivi_output_plane(IVIPlaneDesc *plane, uint8 *dst, int dst_pitch);
+ void outputPlane(IVIPlaneDesc *plane, uint8 *dst, int dstPitch);
/**
* Handle empty tiles by performing data copying and motion
* compensation respectively.
*
- * @param[in] band pointer to the band descriptor
- * @param[in] tile pointer to the tile descriptor
- * @param[in] mv_scale scaling factor for motion vectors
+ * @param[in] band Pointer to the band descriptor
+ * @param[in] tile Pointer to the tile descriptor
+ * @param[in] mvScale Scaling factor for motion vectors
*/
- int ivi_process_empty_tile(IVIBandDesc *band, IVITile *tile, int32 mv_scale);
+ int processEmptyTile(IVIBandDesc *band, IVITile *tile, int32 mvScale);
/*
* Decode size of the tile data.
@@ -470,9 +488,9 @@ private:
* where X1-X3 is size of the tile data
*
* @param[in,out] gb the GetBit context
- * @return size of the tile data in bytes
+ * @returns Size of the tile data in bytes
*/
- int ivi_dec_tile_data_size(GetBits *gb);
+ int decodeTileDataSize(GetBits *gb);
/*
* Decode block data:
@@ -480,21 +498,20 @@ private:
* dequantize them, apply inverse transform and motion compensation
* in order to reconstruct the picture.
*
- * @param[in,out] gb the GetBit context
- * @param[in] band pointer to the band descriptor
- * @param[in] tile pointer to the tile descriptor
- * @return result code: 0 - OK, -1 = error (corrupted blocks data)
+ * @param[in,out] gb The GetBit context
+ * @param[in] band Pointer to the band descriptor
+ * @param[in] tile Pointer to the tile descriptor
+ * @returns Result code: 0 - OK, -1 = error (corrupted blocks data)
*/
- int ivi_decode_blocks(GetBits *gb, IVIBandDesc *band, IVITile *tile);
+ int decodeBlocks(GetBits *gb, IVIBandDesc *band, IVITile *tile);
- int ivi_mc(IVIBandDesc *band, IviMCFunc mc, IviMCAvgFunc mc_avg,
- int offs, int _mvX, int _mvY, int mv_x2, int mv_y2,
- int mc_type, int mc_type2);
+ int iviMc(IVIBandDesc *band, IviMCFunc mc, IviMCAvgFunc mcAvg,
+ int offs, int mvX, int mvY, int mvX2, int mvY2, int mcType, int mcType2);
int ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
- IviMCFunc mc, IviMCAvgFunc mc_avg, int _mvX, int _mvY,
- int mv_x2, int mv_y2, int *prev_dc, int is_intra,
- int mc_type, int mc_type2, uint32 quant, int offs);
+ IviMCFunc mc, IviMCAvgFunc mcAvg, int mvX, int mvY,
+ int mvX2, int mvY2, int *prevDc, int isIntra,
+ int mcType, int mcType2, uint32 quant, int offs);
int ivi_dc_transform(IVIBandDesc *band, int *prevDc, int bufOffs,
int blkSize);
@@ -524,27 +541,27 @@ protected:
/**
* Rearrange decoding and reference buffers.
*/
- virtual void switch_buffers() = 0;
+ virtual void switchBuffers() = 0;
- virtual bool is_nonnull_frame() const = 0;
+ virtual bool isNonNullFrame() const = 0;
/**
* Decode Indeo band header.
*
- * @param[in,out] band pointer to the band descriptor
- * @return result code: 0 = OK, negative number = error
+ * @param[in,out] band Pointer to the band descriptor
+ * @returns Result code: 0 = OK, negative number = error
*/
- virtual int decode_band_hdr(IVIBandDesc *band) = 0;
+ virtual int decodeBandHeader(IVIBandDesc *band) = 0;
/**
* Decode information (block type, _cbp, quant delta, motion vector)
* for all macroblocks in the current tile.
*
- * @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
+ * @param[in,out] band Pointer to the band descriptor
+ * @param[in,out] tile Pointer to the tile descriptor
+ * @returns Result code: 0 = OK, negative number = error
*/
- virtual int decode_mb_info(IVIBandDesc *band, IVITile *tile)= 0;
+ virtual int decodeMbInfo(IVIBandDesc *band, IVITile *tile) = 0;
/**
* Decodes the Indeo frame from the bit reader already
@@ -555,25 +572,12 @@ protected:
/**
* scale motion vector
*/
- int ivi_scale_mv(int mv, int mv_scale);
+ int scaleMV(int mv, int mvScale);
public:
IndeoDecoderBase(uint16 width, uint16 height);
virtual ~IndeoDecoderBase();
};
-/*------------------------------------------------------------------------*/
-
-/**
- * Check if the given dimension of an image is valid, meaning that all
- * bytes of the image can be addressed with a signed int.
- *
- * @param w the width of the picture
- * @param h the height of the picture
- * @param log_offset the offset to sum to the log level for logging with log_ctx
- * @returns >= 0 if valid, a negative error code otherwise
- */
-extern int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
-
} // End of namespace Indeo
} // End of namespace Image
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index 12ab988..caefab2 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -175,7 +175,7 @@ int Indeo4Decoder::decodePictureHeader() {
// check if picture layout was changed and reallocate buffers
if (_picConf.ivi_pic_config_cmp(_ctx._picConf)) {
- if (IVIPlaneDesc::ff_ivi_init_planes(_ctx._planes, &_picConf, 1)) {
+ if (IVIPlaneDesc::initPlanes(_ctx._planes, &_picConf, 1)) {
warning("Couldn't reallocate color planes!");
_ctx._picConf._lumaBands = 0;
return -2;
@@ -191,7 +191,7 @@ int Indeo4Decoder::decodePictureHeader() {
}
}
- if (IVIPlaneDesc::ff_ivi_init_tiles(_ctx._planes, _ctx._picConf._tileWidth,
+ if (IVIPlaneDesc::initTiles(_ctx._planes, _ctx._picConf._tileWidth,
_ctx._picConf._tileHeight)) {
warning("Couldn't reallocate internal structures!");
return -2;
@@ -205,8 +205,8 @@ int Indeo4Decoder::decodePictureHeader() {
_ctx._gb->skipBits(8);
// decode macroblock and block huffman codebooks
- if (_ctx._mbVlc.ff_ivi_dec_huff_desc(&_ctx, _ctx._gb->getBits1(), IVI_MB_HUFF) ||
- _ctx._blkVlc.ff_ivi_dec_huff_desc(&_ctx, _ctx._gb->getBits1(), IVI_BLK_HUFF))
+ if (_ctx._mbVlc.decodeHuffDesc(&_ctx, _ctx._gb->getBits1(), IVI_MB_HUFF) ||
+ _ctx._blkVlc.decodeHuffDesc(&_ctx, _ctx._gb->getBits1(), IVI_BLK_HUFF))
return -1;
_ctx._rvmapSel = _ctx._gb->getBits1() ? _ctx._gb->getBits(3) : 8;
@@ -235,7 +235,7 @@ int Indeo4Decoder::decodePictureHeader() {
return 0;
}
-void Indeo4Decoder::switch_buffers() {
+void Indeo4Decoder::switchBuffers() {
int is_prev_ref = 0, is_ref = 0;
switch (_ctx._prevFrameType) {
@@ -265,18 +265,18 @@ void Indeo4Decoder::switch_buffers() {
}
}
-bool Indeo4Decoder::is_nonnull_frame() const {
+bool Indeo4Decoder::isNonNullFrame() const {
return _ctx._frameType < IVI4_FRAMETYPE_NULL_FIRST;
}
-int Indeo4Decoder::decode_band_hdr(IVIBandDesc *band) {
- int plane, _bandNum, indx, transform_id, scan_indx;
+int Indeo4Decoder::decodeBandHeader(IVIBandDesc *band) {
+ int plane, bandNum, indx, transformId, scanIndx;
int i;
- int _quantMat;
+ int quantMat;
plane = _ctx._gb->getBits(2);
- _bandNum = _ctx._gb->getBits(4);
- if (band->_plane != plane || band->_bandNum != _bandNum) {
+ bandNum = _ctx._gb->getBits(4);
+ if (band->_plane != plane || band->_bandNum != bandNum) {
warning("Invalid band header sequence!");
return -1;
}
@@ -316,30 +316,30 @@ int Indeo4Decoder::decode_band_hdr(IVIBandDesc *band) {
band->_globQuant = _ctx._gb->getBits(5);
if (!_ctx._gb->getBits1() || _ctx._frameType == IVI4_FRAMETYPE_INTRA) {
- transform_id = _ctx._gb->getBits(5);
- if ((uint)transform_id >= FF_ARRAY_ELEMS(_transforms) ||
- !_transforms[transform_id]._invTrans) {
- warning("Transform %d", transform_id);
+ transformId = _ctx._gb->getBits(5);
+ if ((uint)transformId >= FF_ARRAY_ELEMS(_transforms) ||
+ !_transforms[transformId]._invTrans) {
+ warning("Transform %d", transformId);
return -3;
}
- if ((transform_id >= 7 && transform_id <= 9) ||
- transform_id == 17) {
+ if ((transformId >= 7 && transformId <= 9) ||
+ transformId == 17) {
warning("DCT transform");
return -3;
}
- if (transform_id < 10 && band->_blkSize < 8) {
+ if (transformId < 10 && band->_blkSize < 8) {
warning("wrong transform size!");
return -1;
}
- if ((transform_id >= 0 && transform_id <= 2) || transform_id == 10)
+ if ((transformId >= 0 && transformId <= 2) || transformId == 10)
_ctx._usesHaar = true;
- band->_invTransform = _transforms[transform_id]._invTrans;
- band->_dcTransform = _transforms[transform_id]._dcTrans;
- band->_is2dTrans = _transforms[transform_id]._is2dTrans;
+ band->_invTransform = _transforms[transformId]._invTrans;
+ band->_dcTransform = _transforms[transformId]._dcTrans;
+ band->_is2dTrans = _transforms[transformId]._is2dTrans;
- if (transform_id < 10)
+ if (transformId < 10)
band->_transformSize = 8;
else
band->_transformSize = 4;
@@ -349,12 +349,12 @@ int Indeo4Decoder::decode_band_hdr(IVIBandDesc *band) {
return -1;
}
- scan_indx = _ctx._gb->getBits(4);
- if (scan_indx == 15) {
+ scanIndx = _ctx._gb->getBits(4);
+ if (scanIndx == 15) {
warning("Custom scan pattern encountered!");
return -1;
}
- if (scan_indx > 4 && scan_indx < 10) {
+ if (scanIndx > 4 && scanIndx < 10) {
if (band->_blkSize != 4) {
warning("mismatching scan table!");
return -1;
@@ -364,19 +364,19 @@ int Indeo4Decoder::decode_band_hdr(IVIBandDesc *band) {
return -1;
}
- band->_scan = _scan_index_to_tab[scan_indx];
+ band->_scan = _scan_index_to_tab[scanIndx];
band->_scanSize = band->_blkSize;
- _quantMat = _ctx._gb->getBits(5);
- if (_quantMat == 31) {
+ quantMat = _ctx._gb->getBits(5);
+ if (quantMat == 31) {
warning("Custom quant matrix encountered!");
return -1;
}
- if ((uint)_quantMat >= FF_ARRAY_ELEMS(_quant_index_to_tab)) {
- warning("Quantization matrix %d", _quantMat);
+ if ((uint)quantMat >= FF_ARRAY_ELEMS(_quant_index_to_tab)) {
+ warning("Quantization matrix %d", quantMat);
return -1;
}
- band->_quantMat = _quantMat;
+ band->_quantMat = quantMat;
} else {
if (old_blk_size != band->_blkSize) {
warning("The band block size does not match the configuration inherited");
@@ -401,7 +401,7 @@ int Indeo4Decoder::decode_band_hdr(IVIBandDesc *band) {
if (!_ctx._gb->getBits1())
band->_blkVlc._tab = _ctx._blkVlc._tab;
else
- if (band->_blkVlc.ff_ivi_dec_huff_desc(&_ctx, 1, IVI_BLK_HUFF))
+ if (band->_blkVlc.decodeHuffDesc(&_ctx, 1, IVI_BLK_HUFF))
return -1;
// select appropriate rvmap table for this band
@@ -445,35 +445,35 @@ int Indeo4Decoder::decode_band_hdr(IVIBandDesc *band) {
return 0;
}
-int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
- int x, y, _mvX, _mvY, mv_delta, offs, mb_offset, blks_per_mb,
- mv_scale, mb_type_bits, s;
- IVIMbInfo *mb, *ref_mb;
- int row_offset = band->_mbSize * band->_pitch;
+int Indeo4Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
+ int x, y, mvX, mvY, mvDelta, offs, mbOffset, blksPerMb,
+ mvScale, mbTypeBits, s;
+ IVIMbInfo *mb, *ref_mb;
+ int row_offset = band->_mbSize * band->_pitch;
mb = tile->_mbs;
ref_mb = tile->_refMbs;
offs = tile->_yPos * band->_pitch + tile->_xPos;
- blks_per_mb = band->_mbSize != band->_blkSize ? 4 : 1;
- mb_type_bits = _ctx._frameType == IVI4_FRAMETYPE_BIDIR ? 2 : 1;
+ blksPerMb = band->_mbSize != band->_blkSize ? 4 : 1;
+ mbTypeBits = _ctx._frameType == IVI4_FRAMETYPE_BIDIR ? 2 : 1;
/* scale factor for motion vectors */
- mv_scale = (_ctx._planes[0]._bands[0]._mbSize >> 3) - (band->_mbSize >> 3);
- _mvX = _mvY = 0;
+ mvScale = (_ctx._planes[0]._bands[0]._mbSize >> 3) - (band->_mbSize >> 3);
+ mvX = mvY = 0;
if (((tile->_width + band->_mbSize - 1) / band->_mbSize) * ((tile->_height + band->_mbSize - 1) / band->_mbSize) != tile->_numMBs) {
- warning("_numMBs mismatch %d %d %d %d", tile->_width, tile->_height, band->_mbSize, tile->_numMBs);
+ warning("numMBs mismatch %d %d %d %d", tile->_width, tile->_height, band->_mbSize, tile->_numMBs);
return -1;
}
for (y = tile->_yPos; y < tile->_yPos + tile->_height; y += band->_mbSize) {
- mb_offset = offs;
+ mbOffset = offs;
for (x = tile->_xPos; x < tile->_xPos + tile->_width; x += band->_mbSize) {
mb->_xPos = x;
mb->_yPos = y;
- mb->_bufOffs = mb_offset;
+ mb->_bufOffs = mbOffset;
mb->_bMvX = mb->_bMvY = 0;
if (_ctx._gb->getBits1()) {
@@ -494,9 +494,9 @@ int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
mb->_mvX = mb->_mvY = 0; // no motion vector coded
if (band->_inheritMv && ref_mb) {
// motion vector inheritance
- if (mv_scale) {
- mb->_mvX = ivi_scale_mv(ref_mb->_mvX, mv_scale);
- mb->_mvY = ivi_scale_mv(ref_mb->_mvY, mv_scale);
+ if (mvScale) {
+ mb->_mvX = scaleMV(ref_mb->_mvX, mvScale);
+ mb->_mvY = scaleMV(ref_mb->_mvY, mvScale);
} else {
mb->_mvX = ref_mb->_mvX;
mb->_mvY = ref_mb->_mvY;
@@ -514,10 +514,10 @@ int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
_ctx._frameType == IVI4_FRAMETYPE_INTRA1) {
mb->_type = 0; // mb_type is always INTRA for intra-frames
} else {
- mb->_type = _ctx._gb->getBits(mb_type_bits);
+ mb->_type = _ctx._gb->getBits(mbTypeBits);
}
- mb->_cbp = _ctx._gb->getBits(blks_per_mb);
+ mb->_cbp = _ctx._gb->getBits(blksPerMb);
mb->_qDelta = 0;
if (band->_inheritQDelta) {
@@ -535,9 +535,9 @@ int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
if (band->_inheritMv) {
if (ref_mb) {
// motion vector inheritance
- if (mv_scale) {
- mb->_mvX = ivi_scale_mv(ref_mb->_mvX, mv_scale);
- mb->_mvY = ivi_scale_mv(ref_mb->_mvY, mv_scale);
+ if (mvScale) {
+ mb->_mvX = scaleMV(ref_mb->_mvX, mvScale);
+ mb->_mvY = scaleMV(ref_mb->_mvY, mvScale);
} else {
mb->_mvX = ref_mb->_mvX;
mb->_mvY = ref_mb->_mvY;
@@ -545,25 +545,25 @@ int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
}
} else {
// decode motion vector deltas
- mv_delta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
+ mvDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
IVI_VLC_BITS, 1);
- _mvY += IVI_TOSIGNED(mv_delta);
- mv_delta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
+ mvY += IVI_TOSIGNED(mvDelta);
+ mvDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
IVI_VLC_BITS, 1);
- _mvX += IVI_TOSIGNED(mv_delta);
- mb->_mvX = _mvX;
- mb->_mvY = _mvY;
+ mvX += IVI_TOSIGNED(mvDelta);
+ mb->_mvX = mvX;
+ mb->_mvY = mvY;
if (mb->_type == 3) {
- mv_delta = _ctx._gb->getVLC2(
+ mvDelta = _ctx._gb->getVLC2(
_ctx._mbVlc._tab->_table,
IVI_VLC_BITS, 1);
- _mvY += IVI_TOSIGNED(mv_delta);
- mv_delta = _ctx._gb->getVLC2(
+ mvY += IVI_TOSIGNED(mvDelta);
+ mvDelta = _ctx._gb->getVLC2(
_ctx._mbVlc._tab->_table,
IVI_VLC_BITS, 1);
- _mvX += IVI_TOSIGNED(mv_delta);
- mb->_bMvX = -_mvX;
- mb->_bMvY = -_mvY;
+ mvX += IVI_TOSIGNED(mvDelta);
+ mb->_bMvX = -mvX;
+ mb->_bMvY = -mvY;
}
}
if (mb->_type == 2) {
@@ -587,7 +587,7 @@ int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
mb++;
if (ref_mb)
ref_mb++;
- mb_offset += band->_mbSize;
+ mbOffset += band->_mbSize;
}
offs += row_offset;
@@ -597,8 +597,8 @@ int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
return 0;
}
-int Indeo4Decoder::scaleTileSize(int def_size, int size_factor) {
- return size_factor == 15 ? def_size : (size_factor + 1) << 5;
+int Indeo4Decoder::scaleTileSize(int defSize, int sizeFactor) {
+ return sizeFactor == 15 ? defSize : (sizeFactor + 1) << 5;
}
int Indeo4Decoder::decodePlaneSubdivision() {
@@ -607,11 +607,13 @@ int Indeo4Decoder::decodePlaneSubdivision() {
switch (_ctx._gb->getBits(2)) {
case 3:
return 1;
+
case 2:
for (i = 0; i < 4; i++)
if (_ctx._gb->getBits(2) != 3)
return 0;
return 4;
+
default:
return 0;
}
diff --git a/image/codecs/indeo4.h b/image/codecs/indeo4.h
index 86e6020..26bddaa 100644
--- a/image/codecs/indeo4.h
+++ b/image/codecs/indeo4.h
@@ -73,9 +73,9 @@ protected:
/**
* Rearrange decoding and reference buffers.
*/
- virtual void switch_buffers();
+ virtual void switchBuffers();
- virtual bool is_nonnull_frame() const;
+ virtual bool isNonNullFrame() const;
/**
* Decode Indeo 4 band header.
@@ -83,7 +83,7 @@ protected:
* @param[in,out] band pointer to the band descriptor
* @return result code: 0 = OK, negative number = error
*/
- virtual int decode_band_hdr(IVIBandDesc *band);
+ virtual int decodeBandHeader(IVIBandDesc *band);
/**
* Decode information (block type, cbp, quant delta, motion vector)
@@ -93,9 +93,9 @@ protected:
* @param[in,out] tile pointer to the tile descriptor
* @return result code: 0 = OK, negative number = error
*/
- virtual int decode_mb_info(IVIBandDesc *band, IVITile *tile);
+ virtual int decodeMbInfo(IVIBandDesc *band, IVITile *tile);
private:
- int scaleTileSize(int def_size, int size_factor);
+ int scaleTileSize(int defSize, int sizeFactor);
/**
* Decode subdivision of a plane.
@@ -104,8 +104,8 @@ private:
* - 4 wavelet bands per plane, size factor 1:4, code pattern: 2,3,3,3,3
* Anything else is either unsupported or corrupt.
*
- * @param[in,out] gb the GetBit context
- * @return number of wavelet bands or 0 on error
+ * @param[in,out] gb The GetBit context
+ * @returns Number of wavelet bands or 0 on error
*/
int decodePlaneSubdivision();
diff --git a/image/codecs/indeo5.cpp b/image/codecs/indeo5.cpp
index 5434e26..6eacbb8 100644
--- a/image/codecs/indeo5.cpp
+++ b/image/codecs/indeo5.cpp
@@ -103,8 +103,8 @@ const Graphics::Surface *Indeo5Decoder::decodeFrame(Common::SeekableReadStream &
}
int Indeo5Decoder::decodePictureHeader() {
- int pic_size_indx, i, p;
- IVIPicConfig pic_conf;
+ int picSizeIndx, i, p;
+ IVIPicConfig picConf;
int ret;
@@ -149,7 +149,7 @@ int Indeo5Decoder::decodePictureHeader() {
skip_hdr_extension(); // XXX: untested
// decode macroblock huffman codebook
- ret = _ctx._mbVlc.ff_ivi_dec_huff_desc(&_ctx, _ctx._frameFlags & 0x40,
+ ret = _ctx._mbVlc.decodeHuffDesc(&_ctx, _ctx._frameFlags & 0x40,
IVI_MB_HUFF);
if (ret < 0)
return ret;
@@ -161,7 +161,7 @@ int Indeo5Decoder::decodePictureHeader() {
return 0;
}
-void Indeo5Decoder::switch_buffers() {
+void Indeo5Decoder::switchBuffers() {
switch (_ctx._prevFrameType) {
case FRAMETYPE_INTRA:
case FRAMETYPE_INTER:
@@ -169,6 +169,7 @@ void Indeo5Decoder::switch_buffers() {
_ctx._dstBuf = _ctx._bufSwitch;
_ctx._refBuf = _ctx._bufSwitch ^ 1;
break;
+
case FRAMETYPE_INTER_SCAL:
if (!_ctx._interScal) {
_ctx._ref2Buf = 2;
@@ -177,6 +178,7 @@ void Indeo5Decoder::switch_buffers() {
FFSWAP(int, _ctx._dstBuf, _ctx._ref2Buf);
_ctx._refBuf = _ctx._ref2Buf;
break;
+
case FRAMETYPE_INTER_NOREF:
break;
}
@@ -190,6 +192,7 @@ void Indeo5Decoder::switch_buffers() {
_ctx._dstBuf = _ctx._bufSwitch;
_ctx._refBuf = _ctx._bufSwitch ^ 1;
break;
+
case FRAMETYPE_INTER_SCAL:
case FRAMETYPE_INTER_NOREF:
case FRAMETYPE_NULL:
@@ -197,32 +200,32 @@ void Indeo5Decoder::switch_buffers() {
}
}
-bool Indeo5Decoder::is_nonnull_frame() const {
+bool Indeo5Decoder::isNonNullFrame() const {
return _ctx._frameType != FRAMETYPE_NULL;
}
-int Indeo5Decoder::decode_band_hdr(IVIBandDesc *band) {
+int Indeo5Decoder::decodeBandHeader(IVIBandDesc *band) {
int i, ret;
- uint8 band_flags;
+ uint8 bandFlags;
- band_flags = _ctx._gb->getBits(8);
+ bandFlags = _ctx._gb->getBits(8);
- if (band_flags & 1) {
+ if (bandFlags & 1) {
band->_isEmpty = true;
return 0;
}
band->_dataSize = (_ctx._frameFlags & 0x80) ? _ctx._gb->getBitsLong(24) : 0;
- band->_inheritMv = (band_flags & 2) != 0;
- band->_inheritQDelta = (band_flags & 8) != 0;
- band->_qdeltaPresent = (band_flags & 4) != 0;
+ band->_inheritMv = (bandFlags & 2) != 0;
+ band->_inheritQDelta = (bandFlags & 8) != 0;
+ band->_qdeltaPresent = (bandFlags & 4) != 0;
if (!band->_qdeltaPresent)
band->_inheritQDelta = 1;
// decode rvmap probability corrections if any
band->_numCorr = 0; // there are no corrections
- if (band_flags & 0x10) {
+ if (bandFlags & 0x10) {
band->_numCorr = _ctx._gb->getBits(8); // get number of correction pairs
if (band->_numCorr > 61) {
warning("Too many corrections: %d", band->_numCorr);
@@ -235,10 +238,10 @@ int Indeo5Decoder::decode_band_hdr(IVIBandDesc *band) {
}
// select appropriate rvmap table for this band
- band->_rvmapSel = (band_flags & 0x40) ? _ctx._gb->getBits(3) : 8;
+ band->_rvmapSel = (bandFlags & 0x40) ? _ctx._gb->getBits(3) : 8;
// decode block huffman codebook
- ret = band->_blkVlc.ff_ivi_dec_huff_desc(&_ctx, band_flags & 0x80, IVI_BLK_HUFF);
+ ret = band->_blkVlc.decodeHuffDesc(&_ctx, bandFlags & 0x80, IVI_BLK_HUFF);
if (ret < 0)
return ret;
@@ -249,7 +252,7 @@ int Indeo5Decoder::decode_band_hdr(IVIBandDesc *band) {
band->_globQuant = _ctx._gb->getBits(5);
// skip unknown extension if any
- if (band_flags & 0x20) { // XXX: untested
+ if (bandFlags & 0x20) { // XXX: untested
_ctx._gb->alignGetBits();
skip_hdr_extension();
}
@@ -259,17 +262,17 @@ int Indeo5Decoder::decode_band_hdr(IVIBandDesc *band) {
return 0;
}
-int Indeo5Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
- int x, y, _mvX, _mvY, mv_delta, offs, mb_offset,
- mv_scale, blks_per_mb, s;
- IVIMbInfo *mb, *ref_mb;
- int row_offset = band->_mbSize * band->_pitch;
+int Indeo5Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
+ int x, y, mvX, mvY, mvDelta, offs, mbOffset,
+ mvScale, blksPerMb, s;
+ IVIMbInfo *mb, *refMb;
+ int rowOffset = band->_mbSize * band->_pitch;
mb = tile->_mbs;
- ref_mb = tile->_refMbs;
+ refMb = tile->_refMbs;
offs = tile->_yPos * band->_pitch + tile->_xPos;
- if (!ref_mb &&
+ if (!refMb &&
((band->_qdeltaPresent && band->_inheritQDelta) || band->_inheritMv))
return -1;
@@ -280,16 +283,16 @@ int Indeo5Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
}
// scale factor for motion vectors
- mv_scale = (_ctx._planes[0]._bands[0]._mbSize >> 3) - (band->_mbSize >> 3);
- _mvX = _mvY = 0;
+ mvScale = (_ctx._planes[0]._bands[0]._mbSize >> 3) - (band->_mbSize >> 3);
+ mvX = mvY = 0;
for (y = tile->_yPos; y < (tile->_yPos + tile->_height); y += band->_mbSize) {
- mb_offset = offs;
+ mbOffset = offs;
for (x = tile->_xPos; x < (tile->_xPos + tile->_width); x += band->_mbSize) {
mb->_xPos = x;
mb->_yPos = y;
- mb->_bufOffs = mb_offset;
+ mb->_bufOffs = mbOffset;
if (_ctx._gb->getBits1()) {
if (_ctx._frameType == FRAMETYPE_INTRA) {
@@ -306,32 +309,32 @@ int Indeo5Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
}
mb->_mvX = mb->_mvY = 0; // no motion vector coded
- if (band->_inheritMv && ref_mb) {
+ if (band->_inheritMv && refMb) {
// motion vector inheritance
- if (mv_scale) {
- mb->_mvX = ivi_scale_mv(ref_mb->_mvX, mv_scale);
- mb->_mvY = ivi_scale_mv(ref_mb->_mvY, mv_scale);
+ if (mvScale) {
+ mb->_mvX = scaleMV(refMb->_mvX, mvScale);
+ mb->_mvY = scaleMV(refMb->_mvY, mvScale);
} else {
- mb->_mvX = ref_mb->_mvX;
- mb->_mvY = ref_mb->_mvY;
+ mb->_mvX = refMb->_mvX;
+ mb->_mvY = refMb->_mvY;
}
}
} else {
- if (band->_inheritMv && ref_mb) {
- mb->_type = ref_mb->_type; // copy mb_type from corresponding reference mb
+ if (band->_inheritMv && refMb) {
+ mb->_type = refMb->_type; // copy mb_type from corresponding reference mb
} else if (_ctx._frameType == FRAMETYPE_INTRA) {
mb->_type = 0; // mb_type is always INTRA for intra-frames
} else {
mb->_type = _ctx._gb->getBits1();
}
- blks_per_mb = band->_mbSize != band->_blkSize ? 4 : 1;
- mb->_cbp = _ctx._gb->getBits(blks_per_mb);
+ blksPerMb = band->_mbSize != band->_blkSize ? 4 : 1;
+ mb->_cbp = _ctx._gb->getBits(blksPerMb);
mb->_qDelta = 0;
if (band->_qdeltaPresent) {
if (band->_inheritQDelta) {
- if (ref_mb) mb->_qDelta = ref_mb->_qDelta;
+ if (refMb) mb->_qDelta = refMb->_qDelta;
} else if (mb->_cbp || (!band->_plane && !band->_bandNum &&
(_ctx._frameFlags & 8))) {
mb->_qDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table, IVI_VLC_BITS, 1);
@@ -342,23 +345,23 @@ int Indeo5Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
if (!mb->_type) {
mb->_mvX = mb->_mvY = 0; // there is no motion vector in intra-macroblocks
} else {
- if (band->_inheritMv && ref_mb) {
+ if (band->_inheritMv && refMb) {
// motion vector inheritance
- if (mv_scale) {
- mb->_mvX = ivi_scale_mv(ref_mb->_mvX, mv_scale);
- mb->_mvY = ivi_scale_mv(ref_mb->_mvY, mv_scale);
+ if (mvScale) {
+ mb->_mvX = scaleMV(refMb->_mvX, mvScale);
+ mb->_mvY = scaleMV(refMb->_mvY, mvScale);
} else {
- mb->_mvX = ref_mb->_mvX;
- mb->_mvY = ref_mb->_mvY;
+ mb->_mvX = refMb->_mvX;
+ mb->_mvY = refMb->_mvY;
}
} else {
// decode motion vector deltas
- mv_delta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table, IVI_VLC_BITS, 1);
- _mvY += IVI_TOSIGNED(mv_delta);
- mv_delta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table, IVI_VLC_BITS, 1);
- _mvX += IVI_TOSIGNED(mv_delta);
- mb->_mvX = _mvX;
- mb->_mvY = _mvY;
+ mvDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table, IVI_VLC_BITS, 1);
+ mvY += IVI_TOSIGNED(mvDelta);
+ mvDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table, IVI_VLC_BITS, 1);
+ mvX += IVI_TOSIGNED(mvDelta);
+ mb->_mvX = mvX;
+ mb->_mvY = mvY;
}
}
}
@@ -373,12 +376,12 @@ int Indeo5Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
}
mb++;
- if (ref_mb)
- ref_mb++;
- mb_offset += band->_mbSize;
+ if (refMb)
+ refMb++;
+ mbOffset += band->_mbSize;
}
- offs += row_offset;
+ offs += rowOffset;
}
_ctx._gb->alignGetBits();
@@ -387,11 +390,11 @@ int Indeo5Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
}
int Indeo5Decoder::decode_gop_header() {
- int result, i, p, tile_size, pic_size_indx, mbSize, blkSize, isScalable;
+ int result, i, p, tile_size, picSizeIndx, mbSize, blkSize, isScalable;
int quantMat;
- bool blk_size_changed = false;
+ bool blkSizeChanged = false;
IVIBandDesc *band, *band1, *band2;
- IVIPicConfig pic_conf;
+ IVIPicConfig picConf;
_ctx._gopFlags = _ctx._gb->getBits(8);
@@ -408,22 +411,22 @@ int Indeo5Decoder::decode_gop_header() {
// decode number of wavelet bands
// num_levels * 3 + 1
- pic_conf._lumaBands = _ctx._gb->getBits(2) * 3 + 1;
- pic_conf._chromaBands = _ctx._gb->getBits1() * 3 + 1;
- isScalable = pic_conf._lumaBands != 1 || pic_conf._chromaBands != 1;
- if (isScalable && (pic_conf._lumaBands != 4 || pic_conf._chromaBands != 1)) {
+ picConf._lumaBands = _ctx._gb->getBits(2) * 3 + 1;
+ picConf._chromaBands = _ctx._gb->getBits1() * 3 + 1;
+ isScalable = picConf._lumaBands != 1 || picConf._chromaBands != 1;
+ if (isScalable && (picConf._lumaBands != 4 || picConf._chromaBands != 1)) {
warning("Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d",
- pic_conf._lumaBands, pic_conf._chromaBands);
+ picConf._lumaBands, picConf._chromaBands);
return -1;
}
- pic_size_indx = _ctx._gb->getBits(4);
- if (pic_size_indx == IVI5_PIC_SIZE_ESC) {
- pic_conf._picHeight = _ctx._gb->getBits(13);
- pic_conf._picWidth = _ctx._gb->getBits(13);
+ picSizeIndx = _ctx._gb->getBits(4);
+ if (picSizeIndx == IVI5_PIC_SIZE_ESC) {
+ picConf._picHeight = _ctx._gb->getBits(13);
+ picConf._picWidth = _ctx._gb->getBits(13);
} else {
- pic_conf._picHeight = _ivi5_common_pic_sizes[pic_size_indx * 2 + 1] << 2;
- pic_conf._picWidth = _ivi5_common_pic_sizes[pic_size_indx * 2] << 2;
+ picConf._picHeight = _ivi5_common_pic_sizes[picSizeIndx * 2 + 1] << 2;
+ picConf._picWidth = _ivi5_common_pic_sizes[picSizeIndx * 2] << 2;
}
if (_ctx._gopFlags & 2) {
@@ -431,30 +434,30 @@ int Indeo5Decoder::decode_gop_header() {
return -2;
}
- pic_conf._chromaHeight = (pic_conf._picHeight + 3) >> 2;
- pic_conf._chromaWidth = (pic_conf._picWidth + 3) >> 2;
+ picConf._chromaHeight = (picConf._picHeight + 3) >> 2;
+ picConf._chromaWidth = (picConf._picWidth + 3) >> 2;
if (!tile_size) {
- pic_conf._tileHeight = pic_conf._picHeight;
- pic_conf._tileWidth = pic_conf._picWidth;
+ picConf._tileHeight = picConf._picHeight;
+ picConf._tileWidth = picConf._picWidth;
} else {
- pic_conf._tileHeight = pic_conf._tileWidth = tile_size;
+ picConf._tileHeight = picConf._tileWidth = tile_size;
}
// check if picture layout was changed and reallocate buffers
- if (pic_conf.ivi_pic_config_cmp(_ctx._picConf) || _ctx._gopInvalid) {
- result = IVIPlaneDesc::ff_ivi_init_planes(_ctx._planes, &pic_conf, 0);
+ if (picConf.ivi_pic_config_cmp(_ctx._picConf) || _ctx._gopInvalid) {
+ result = IVIPlaneDesc::initPlanes(_ctx._planes, &picConf, 0);
if (result < 0) {
warning("Couldn't reallocate color planes!");
return result;
}
- _ctx._picConf = pic_conf;
+ _ctx._picConf = picConf;
_ctx._isScalable = isScalable;
- blk_size_changed = 1; // force reallocation of the internal structures
+ blkSizeChanged = 1; // force reallocation of the internal structures
}
for (p = 0; p <= 1; p++) {
- for (i = 0; i < (!p ? pic_conf._lumaBands : pic_conf._chromaBands); i++) {
+ for (i = 0; i < (!p ? picConf._lumaBands : picConf._chromaBands); i++) {
band = &_ctx._planes[p]._bands[i];
band->_isHalfpel = _ctx._gb->getBits1();
@@ -468,8 +471,8 @@ int Indeo5Decoder::decode_gop_header() {
return -2;
}
- blk_size_changed = mbSize != band->_mbSize || blkSize != band->_blkSize;
- if (blk_size_changed) {
+ blkSizeChanged = mbSize != band->_mbSize || blkSize != band->_blkSize;
+ if (blkSizeChanged) {
band->_mbSize = mbSize;
band->_blkSize = blkSize;
}
@@ -527,7 +530,7 @@ int Indeo5Decoder::decode_gop_header() {
// select dequant matrix according to plane and band number
if (!p) {
- quantMat = (pic_conf._lumaBands > 1) ? i + 1 : 0;
+ quantMat = (picConf._lumaBands > 1) ? i + 1 : 0;
} else {
quantMat = 5;
}
@@ -556,7 +559,7 @@ int Indeo5Decoder::decode_gop_header() {
}
// copy chroma parameters into the 2nd chroma plane
- for (i = 0; i < pic_conf._chromaBands; i++) {
+ for (i = 0; i < picConf._chromaBands; i++) {
band1 = &_ctx._planes[1]._bands[i];
band2 = &_ctx._planes[2]._bands[i];
@@ -577,9 +580,9 @@ int Indeo5Decoder::decode_gop_header() {
}
// reallocate internal structures if needed
- if (blk_size_changed) {
- result = IVIPlaneDesc::ff_ivi_init_tiles(_ctx._planes, pic_conf._tileWidth,
- pic_conf._tileHeight);
+ if (blkSizeChanged) {
+ result = IVIPlaneDesc::initTiles(_ctx._planes, picConf._tileWidth,
+ picConf._tileHeight);
if (result < 0) {
warning("Couldn't reallocate internal structures!");
return result;
diff --git a/image/codecs/indeo5.h b/image/codecs/indeo5.h
index 102c610..9832967 100644
--- a/image/codecs/indeo5.h
+++ b/image/codecs/indeo5.h
@@ -73,9 +73,9 @@ protected:
/**
* Rearrange decoding and reference buffers.
*/
- virtual void switch_buffers();
+ virtual void switchBuffers();
- virtual bool is_nonnull_frame() const;
+ virtual bool isNonNullFrame() const;
/**
* Decode Indeo 4 band header.
@@ -83,7 +83,7 @@ protected:
* @param[in,out] band pointer to the band descriptor
* @return result code: 0 = OK, negative number = error
*/
- virtual int decode_band_hdr(IVIBandDesc *band);
+ virtual int decodeBandHeader(IVIBandDesc *band);
/**
* Decode information (block type, cbp, quant delta, motion vector)
@@ -93,7 +93,7 @@ protected:
* @param[in,out] tile pointer to the tile descriptor
* @return result code: 0 = OK, negative number = error
*/
- virtual int decode_mb_info(IVIBandDesc *band, IVITile *tile);
+ virtual int decodeMbInfo(IVIBandDesc *band, IVITile *tile);
private:
/**
* Decode Indeo5 GOP (Group of pictures) header.
Commit: 9c6a55a2a660d2c59e9c0e22402e4d16e08ef987
https://github.com/scummvm/scummvm/commit/9c6a55a2a660d2c59e9c0e22402e4d16e08ef987
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T18:07:13-04:00
Commit Message:
IMAGE: Cleanup of miscellaneous methods and arrays in Indeo decoders
Changed paths:
image/codecs/indeo/indeo.cpp
image/codecs/indeo/indeo.h
image/codecs/indeo/indeo_dsp.cpp
image/codecs/indeo/indeo_dsp.h
image/codecs/indeo/mem.cpp
image/codecs/indeo/mem.h
image/codecs/indeo/vlc.cpp
image/codecs/indeo4.cpp
image/codecs/indeo5.cpp
image/codecs/indeo5.h
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index 4f29016..f473b26 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -105,7 +105,7 @@ int IVIHuffDesc::createHuffFromDesc(VLC *vlc, bool flag) const {
if (bits[pos] > IVI_VLC_BITS)
return -1; // invalid descriptor
- codewords[pos] = inv_bits((prefix | j), bits[pos]);
+ codewords[pos] = invertBits((prefix | j), bits[pos]);
if (!bits[pos])
bits[pos] = 1;
@@ -227,8 +227,8 @@ int IVIBandDesc::initTiles(IVITile *refTile, int p, int b, int tHeight, int tWid
tile->_numMBs = IVI_MBs_PER_TILE(tile->_width, tile->_height,
_mbSize);
- av_freep(&tile->_mbs);
- tile->_mbs = (IVIMbInfo *)av_mallocz_array(tile->_numMBs, sizeof(IVIMbInfo));
+ avFreeP(&tile->_mbs);
+ tile->_mbs = (IVIMbInfo *)avMallocZArray(tile->_numMBs, sizeof(IVIMbInfo));
if (!tile->_mbs)
return -2;
@@ -289,7 +289,7 @@ int IVIPlaneDesc::initPlanes(IVIPlaneDesc *planes, const IVIPicConfig *cfg, bool
planes[1]._numBands = planes[2]._numBands = cfg->_chromaBands;
for (p = 0; p < 3; p++) {
- planes[p]._bands = (IVIBandDesc *)av_mallocz_array(planes[p]._numBands, sizeof(IVIBandDesc));
+ planes[p]._bands = (IVIBandDesc *)avMallocZArray(planes[p]._numBands, sizeof(IVIBandDesc));
if (!planes[p]._bands)
return -2;
@@ -316,20 +316,20 @@ int IVIPlaneDesc::initPlanes(IVIPlaneDesc *planes, const IVIPicConfig *cfg, bool
band->_height = b_height;
band->_pitch = width_aligned;
band->_aHeight = height_aligned;
- band->_bufs[0] = (int16 *)av_mallocz(bufSize);
- band->_bufs[1] = (int16 *)av_mallocz(bufSize);
+ band->_bufs[0] = (int16 *)avMallocZ(bufSize);
+ band->_bufs[1] = (int16 *)avMallocZ(bufSize);
band->_bufSize = bufSize / 2;
if (!band->_bufs[0] || !band->_bufs[1])
return -2;
// allocate the 3rd band buffer for scalability mode
if (cfg->_lumaBands > 1) {
- band->_bufs[2] = (int16 *)av_mallocz(bufSize);
+ band->_bufs[2] = (int16 *)avMallocZ(bufSize);
if (!band->_bufs[2])
return -2;
}
if (isIndeo4) {
- band->_bufs[3] = (int16 *)av_mallocz(bufSize);
+ band->_bufs[3] = (int16 *)avMallocZ(bufSize);
if (!band->_bufs[3])
return -2;
}
@@ -362,8 +362,8 @@ int IVIPlaneDesc::initTiles(IVIPlaneDesc *planes, int tileWidth, int tileHeight)
yTiles = IVI_NUM_TILES(band->_height, tHeight);
band->_numTiles = xTiles * yTiles;
- av_freep(&band->_tiles);
- band->_tiles = (IVITile *)av_mallocz_array(band->_numTiles, sizeof(IVITile));
+ avFreeP(&band->_tiles);
+ band->_tiles = (IVITile *)avMallocZArray(band->_numTiles, sizeof(IVITile));
if (!band->_tiles)
return -2;
@@ -385,18 +385,18 @@ void IVIPlaneDesc::freeBuffers(IVIPlaneDesc *planes) {
for (p = 0; p < 3; p++) {
if (planes[p]._bands)
for (b = 0; b < planes[p]._numBands; b++) {
- av_freep(&planes[p]._bands[b]._bufs[0]);
- av_freep(&planes[p]._bands[b]._bufs[1]);
- av_freep(&planes[p]._bands[b]._bufs[2]);
- av_freep(&planes[p]._bands[b]._bufs[3]);
+ avFreeP(&planes[p]._bands[b]._bufs[0]);
+ avFreeP(&planes[p]._bands[b]._bufs[1]);
+ avFreeP(&planes[p]._bands[b]._bufs[2]);
+ avFreeP(&planes[p]._bands[b]._bufs[3]);
if (planes[p]._bands[b]._blkVlc._custTab._table)
planes[p]._bands[b]._blkVlc._custTab.ff_free_vlc();
for (t = 0; t < planes[p]._bands[b]._numTiles; t++)
- av_freep(&planes[p]._bands[b]._tiles[t]._mbs);
- av_freep(&planes[p]._bands[b]._tiles);
+ avFreeP(&planes[p]._bands[b]._tiles[t]._mbs);
+ avFreeP(&planes[p]._bands[b]._tiles);
}
- av_freep(&planes[p]._bands);
+ avFreeP(&planes[p]._bands);
planes[p]._numBands = 0;
}
}
@@ -427,11 +427,11 @@ int AVFrame::getBuffer(int flags) {
freeFrame();
// Luminance channel
- _data[0] = (uint8 *)av_mallocz(_width * _height);
+ _data[0] = (uint8 *)avMallocZ(_width * _height);
// UV Chroma Channels
- _data[1] = (uint8 *)av_malloc(_width * _height);
- _data[2] = (uint8 *)av_malloc(_width * _height);
+ _data[1] = (uint8 *)avMalloc(_width * _height);
+ _data[2] = (uint8 *)avMalloc(_width * _height);
Common::fill(_data[1], _data[1] + _width * _height, 0x80);
Common::fill(_data[2], _data[2] + _width * _height, 0x80);
@@ -439,9 +439,9 @@ int AVFrame::getBuffer(int flags) {
}
void AVFrame::freeFrame() {
- av_freep(&_data[0]);
- av_freep(&_data[1]);
- av_freep(&_data[2]);
+ avFreeP(&_data[0]);
+ avFreeP(&_data[1]);
+ avFreeP(&_data[2]);
}
/*------------------------------------------------------------------------*/
@@ -739,10 +739,10 @@ void IndeoDecoderBase::recomposeHaar(const IVIPlaneDesc *_plane,
p3 = (b0 - b1 - b2 + b3 + 2) >> 2;
// bias, convert and output four pixels
- dst[x] = av_clip_uint8(p0 + 128);
- dst[x + 1] = av_clip_uint8(p1 + 128);
- dst[dstPitch + x] = av_clip_uint8(p2 + 128);
- dst[dstPitch + x + 1] = av_clip_uint8(p3 + 128);
+ dst[x] = avClipUint8(p0 + 128);
+ dst[x + 1] = avClipUint8(p1 + 128);
+ dst[dstPitch + x] = avClipUint8(p2 + 128);
+ dst[dstPitch + x + 1] = avClipUint8(p3 + 128);
}// for x
dst += dstPitch << 1;
@@ -893,10 +893,10 @@ void IndeoDecoderBase::recompose53(const IVIPlaneDesc *_plane,
}
// output four pixels
- dst[x] = av_clip_uint8((p0 >> 6) + 128);
- dst[x + 1] = av_clip_uint8((p1 >> 6) + 128);
- dst[dstPitch + x] = av_clip_uint8((p2 >> 6) + 128);
- dst[dstPitch + x + 1] = av_clip_uint8((p3 >> 6) + 128);
+ dst[x] = avClipUint8((p0 >> 6) + 128);
+ dst[x + 1] = avClipUint8((p1 >> 6) + 128);
+ dst[dstPitch + x] = avClipUint8((p2 >> 6) + 128);
+ dst[dstPitch + x + 1] = avClipUint8((p3 >> 6) + 128);
}// for x
dst += dstPitch << 1;
@@ -920,7 +920,7 @@ void IndeoDecoderBase::outputPlane(IVIPlaneDesc *_plane, uint8 *dst, int dstPitc
for (y = 0; y < _plane->_height; y++) {
for (x = 0; x < _plane->_width; x++)
- dst[x] = av_clip_uint8(src[x] + 128);
+ dst[x] = avClipUint8(src[x] + 128);
src += pitch;
dst += dstPitch;
}
@@ -1006,8 +1006,8 @@ int IndeoDecoderBase::processEmptyTile(IVIBandDesc *band,
if (band->_inheritMv && needMc) { // apply motion compensation if there is at least one non-zero motion vector
numBlocks = (band->_mbSize != band->_blkSize) ? 4 : 1; // number of blocks per mb
- mcNoDeltaFunc = (band->_blkSize == 8) ? IndeoDSP::ff_ivi_mc_8x8_no_delta
- : IndeoDSP::ff_ivi_mc_4x4_no_delta;
+ mcNoDeltaFunc = (band->_blkSize == 8) ? IndeoDSP::ffIviMc8x8NoDelta
+ : IndeoDSP::ffIviMc4x4NoDelta;
for (mbn = 0, mb = tile->_mbs; mbn < tile->_numMBs; mb++, mbn++) {
mvX = mb->_mvX;
@@ -1075,15 +1075,15 @@ int IndeoDecoderBase::decodeBlocks(GetBits *_gb, IVIBandDesc *band, IVITile *til
// number of blocks per mb
numBlocks = (band->_mbSize != blkSize) ? 4 : 1;
if (blkSize == 8) {
- mcWithDeltaFunc = IndeoDSP::ff_ivi_mc_8x8_delta;
- mcNoDeltaFunc = IndeoDSP::ff_ivi_mc_8x8_no_delta;
- mcAvgWithDeltaFunc = IndeoDSP::ff_ivi_mc_avg_8x8_delta;
- mcAvgNoDeltaFunc = IndeoDSP::ff_ivi_mc_avg_8x8_no_delta;
+ mcWithDeltaFunc = IndeoDSP::ffIviMc8x8Delta;
+ mcNoDeltaFunc = IndeoDSP::ffIviMc8x8NoDelta;
+ mcAvgWithDeltaFunc = IndeoDSP::ffIviMcAvg8x8Delta;
+ mcAvgNoDeltaFunc = IndeoDSP::ffIviMcAvg8x8NoDelta;
} else {
- mcWithDeltaFunc = IndeoDSP::ff_ivi_mc_4x4_delta;
- mcNoDeltaFunc = IndeoDSP::ff_ivi_mc_4x4_no_delta;
- mcAvgWithDeltaFunc = IndeoDSP::ff_ivi_mc_avg_4x4_delta;
- mcAvgNoDeltaFunc = IndeoDSP::ff_ivi_mc_avg_4x4_no_delta;
+ mcWithDeltaFunc = IndeoDSP::ffIviMc4x4Delta;
+ mcNoDeltaFunc = IndeoDSP::ffIviMc4x4NoDelta;
+ mcAvgWithDeltaFunc = IndeoDSP::ffIviMcAvg4x4Delta;
+ mcAvgNoDeltaFunc = IndeoDSP::ffIviMcAvg4x4NoDelta;
}
for (mbn = 0, mb = tile->_mbs; mbn < tile->_numMBs; mb++, mbn++) {
@@ -1093,7 +1093,7 @@ int IndeoDecoderBase::decodeBlocks(GetBits *_gb, IVIBandDesc *band, IVITile *til
quant = band->_globQuant + mb->_qDelta;
if (_ctx._isIndeo4)
- quant = av_clip_uintp2(quant, 5);
+ quant = avClipUintp2(quant, 5);
else
quant = av_clip((int)quant, 0, 23);
@@ -1346,7 +1346,7 @@ int IndeoDecoderBase::ivi_dc_transform(IVIBandDesc *band, int *prevDc,
/*------------------------------------------------------------------------*/
-const uint8 IndeoDecoderBase::_ff_ivi_vertical_scan_8x8[64] = {
+const uint8 IndeoDecoderBase::_ffIviVerticalScan8x8[64] = {
0, 8, 16, 24, 32, 40, 48, 56,
1, 9, 17, 25, 33, 41, 49, 57,
2, 10, 18, 26, 34, 42, 50, 58,
@@ -1357,7 +1357,7 @@ const uint8 IndeoDecoderBase::_ff_ivi_vertical_scan_8x8[64] = {
7, 15, 23, 31, 39, 47, 55, 63
};
-const uint8 IndeoDecoderBase::_ff_ivi_horizontal_scan_8x8[64] = {
+const uint8 IndeoDecoderBase::_ffIviHorizontalScan8x8[64] = {
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23,
@@ -1368,7 +1368,7 @@ const uint8 IndeoDecoderBase::_ff_ivi_horizontal_scan_8x8[64] = {
56, 57, 58, 59, 60, 61, 62, 63
};
-const uint8 IndeoDecoderBase::_ff_ivi_direct_scan_4x4[16] = {
+const uint8 IndeoDecoderBase::_ffIviDirectScan4x4[16] = {
0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
};
diff --git a/image/codecs/indeo/indeo.h b/image/codecs/indeo/indeo.h
index 5f6d67f..2c1ed95 100644
--- a/image/codecs/indeo/indeo.h
+++ b/image/codecs/indeo/indeo.h
@@ -523,9 +523,9 @@ protected:
/**
* Scan patterns shared between indeo4 and indeo5
*/
- static const uint8 _ff_ivi_vertical_scan_8x8[64];
- static const uint8 _ff_ivi_horizontal_scan_8x8[64];
- static const uint8 _ff_ivi_direct_scan_4x4[16];
+ static const uint8 _ffIviVerticalScan8x8[64];
+ static const uint8 _ffIviHorizontalScan8x8[64];
+ static const uint8 _ffIviDirectScan4x4[16];
protected:
/**
* Returns the pixel format for the decoder's surface
diff --git a/image/codecs/indeo/indeo_dsp.cpp b/image/codecs/indeo/indeo_dsp.cpp
index f13ce91..d4803b8 100644
--- a/image/codecs/indeo/indeo_dsp.cpp
+++ b/image/codecs/indeo/indeo_dsp.cpp
@@ -71,13 +71,13 @@ namespace Indeo {
d3 = COMPENSATE(t2);\
d4 = COMPENSATE(t3); }
-void IndeoDSP::ff_ivi_inverse_haar_8x8(const int32 *in, int16 *out, uint32 pitch,
+void IndeoDSP::ffIviInverseHaar8x8(const int32 *in, int16 *out, uint32 pitch,
const uint8 *flags) {
- int i, shift, sp1, sp2, sp3, sp4;
+ int i, shift, sp1, sp2, sp3, sp4;
const int32 *src;
- int32 *dst;
- int tmp[64];
- int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+ int32 * dst;
+ int tmp[64];
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
// apply the InvHaar8 to all columns
#define COMPENSATE(x) (x)
@@ -126,10 +126,10 @@ void IndeoDSP::ff_ivi_inverse_haar_8x8(const int32 *in, int16 *out, uint32 pitch
#undef COMPENSATE
}
-void IndeoDSP::ff_ivi_row_haar8(const int32 *in, int16 *out, uint32 pitch,
+void IndeoDSP::ffIviRowHaar8(const int32 *in, int16 *out, uint32 pitch,
const uint8 *flags) {
- int i;
- int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+ int i;
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
// apply the InvHaar8 to all rows
#define COMPENSATE(x) (x)
@@ -150,10 +150,10 @@ void IndeoDSP::ff_ivi_row_haar8(const int32 *in, int16 *out, uint32 pitch,
#undef COMPENSATE
}
-void IndeoDSP::ff_ivi_col_haar8(const int32 *in, int16 *out, uint32 pitch,
+void IndeoDSP::ffIviColHaar8(const int32 *in, int16 *out, uint32 pitch,
const uint8 *flags) {
- int i;
- int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+ int i;
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
// apply the InvHaar8 to all columns
#define COMPENSATE(x) (x)
@@ -179,13 +179,13 @@ void IndeoDSP::ff_ivi_col_haar8(const int32 *in, int16 *out, uint32 pitch,
#undef COMPENSATE
}
-void IndeoDSP::ff_ivi_inverse_haar_4x4(const int32 *in, int16 *out, uint32 pitch,
+void IndeoDSP::ffIviInverseHaar4x4(const int32 *in, int16 *out, uint32 pitch,
const uint8 *flags) {
- int i, shift, sp1, sp2;
+ int i, shift, sp1, sp2;
const int32 *src;
- int32 *dst;
- int tmp[16];
- int t0, t1, t2, t3, t4;
+ int32 * dst;
+ int tmp[16];
+ int t0, t1, t2, t3, t4;
// apply the InvHaar4 to all columns
#define COMPENSATE(x) (x)
@@ -226,10 +226,10 @@ void IndeoDSP::ff_ivi_inverse_haar_4x4(const int32 *in, int16 *out, uint32 pitch
#undef COMPENSATE
}
-void IndeoDSP::ff_ivi_row_haar4(const int32 *in, int16 *out, uint32 pitch,
+void IndeoDSP::ffIviRowHaar4(const int32 *in, int16 *out, uint32 pitch,
const uint8 *flags) {
- int i;
- int t0, t1, t2, t3, t4;
+ int i;
+ int t0, t1, t2, t3, t4;
// apply the InvHaar4 to all rows
#define COMPENSATE(x) (x)
@@ -247,10 +247,10 @@ void IndeoDSP::ff_ivi_row_haar4(const int32 *in, int16 *out, uint32 pitch,
#undef COMPENSATE
}
-void IndeoDSP::ff_ivi_col_haar4(const int32 *in, int16 *out, uint32 pitch,
+void IndeoDSP::ffIviColHaar4(const int32 *in, int16 *out, uint32 pitch,
const uint8 *flags) {
- int i;
- int t0, t1, t2, t3, t4;
+ int i;
+ int t0, t1, t2, t3, t4;
// apply the InvHaar8 to all columns
#define COMPENSATE(x) (x)
@@ -271,16 +271,16 @@ void IndeoDSP::ff_ivi_col_haar4(const int32 *in, int16 *out, uint32 pitch,
#undef COMPENSATE
}
-void IndeoDSP::ff_ivi_dc_haar_2d(const int32 *in, int16 *out, uint32 pitch,
- int blk_size) {
- int x, y;
- int16 dc_coeff;
+void IndeoDSP::ffIviDcHaar2d(const int32 *in, int16 *out, uint32 pitch,
+ int blkSize) {
+ int x, y;
+ int16 dcCoeff;
- dc_coeff = (*in + 0) >> 3;
+ dcCoeff = (*in + 0) >> 3;
- for (y = 0; y < blk_size; out += pitch, y++) {
- for (x = 0; x < blk_size; x++)
- out[x] = dc_coeff;
+ for (y = 0; y < blkSize; out += pitch, y++) {
+ for (x = 0; x < blkSize; x++)
+ out[x] = dcCoeff;
}
}
@@ -334,12 +334,12 @@ void IndeoDSP::ff_ivi_dc_haar_2d(const int32 *in, int16 *out, uint32 pitch,
d3 = COMPENSATE(t3);\
d4 = COMPENSATE(t4);}
-void IndeoDSP::ff_ivi_inverse_slant_8x8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) {
- int i;
+void IndeoDSP::ffIviInverseSlant8x8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) {
+ int i;
const int32 *src;
- int32 *dst;
- int tmp[64];
- int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+ int32 * dst;
+ int tmp[64];
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
#define COMPENSATE(x) (x)
src = in;
@@ -374,12 +374,12 @@ void IndeoDSP::ff_ivi_inverse_slant_8x8(const int32 *in, int16 *out, uint32 pitc
#undef COMPENSATE
}
-void IndeoDSP::ff_ivi_inverse_slant_4x4(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) {
- int i;
+void IndeoDSP::ffIviInverseSlant4x4(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) {
+ int i;
const int32 *src;
- int32 *dst;
- int tmp[16];
- int t0, t1, t2, t3, t4;
+ int32 * dst;
+ int tmp[16];
+ int t0, t1, t2, t3, t4;
#define COMPENSATE(x) (x)
src = in;
@@ -413,23 +413,23 @@ void IndeoDSP::ff_ivi_inverse_slant_4x4(const int32 *in, int16 *out, uint32 pitc
#undef COMPENSATE
}
-void IndeoDSP::ff_ivi_dc_slant_2d(const int32 *in, int16 *out, uint32 pitch,
- int blk_size) {
- int x, y;
- int16 dc_coeff;
+void IndeoDSP::ffIviDcSlant2d(const int32 *in, int16 *out, uint32 pitch,
+ int blkSize) {
+ int x, y;
+ int16 dcCoeff;
- dc_coeff = (*in + 1) >> 1;
+ dcCoeff = (*in + 1) >> 1;
- for (y = 0; y < blk_size; out += pitch, y++) {
- for (x = 0; x < blk_size; x++)
- out[x] = dc_coeff;
+ for (y = 0; y < blkSize; out += pitch, y++) {
+ for (x = 0; x < blkSize; x++)
+ out[x] = dcCoeff;
}
}
-void IndeoDSP::ff_ivi_row_slant8(const int32 *in, int16 *out, uint32 pitch,
+void IndeoDSP::ffIviRowSlant8(const int32 *in, int16 *out, uint32 pitch,
const uint8 *flags) {
- int i;
- int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+ int i;
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
#define COMPENSATE(x) (((x) + 1)>>1)
for (i = 0; i < 8; i++) {
@@ -446,26 +446,26 @@ void IndeoDSP::ff_ivi_row_slant8(const int32 *in, int16 *out, uint32 pitch,
#undef COMPENSATE
}
-void IndeoDSP::ff_ivi_dc_row_slant(const int32 *in, int16 *out, uint32 pitch, int blk_size) {
- int x, y;
- int16 dc_coeff;
+void IndeoDSP::ffIviDcRowSlant(const int32 *in, int16 *out, uint32 pitch, int blkSize) {
+ int x, y;
+ int16 dcCoeff;
- dc_coeff = (*in + 1) >> 1;
+ dcCoeff = (*in + 1) >> 1;
- for (x = 0; x < blk_size; x++)
- out[x] = dc_coeff;
+ for (x = 0; x < blkSize; x++)
+ out[x] = dcCoeff;
out += pitch;
- for (y = 1; y < blk_size; out += pitch, y++) {
- for (x = 0; x < blk_size; x++)
+ for (y = 1; y < blkSize; out += pitch, y++) {
+ for (x = 0; x < blkSize; x++)
out[x] = 0;
}
}
-void IndeoDSP::ff_ivi_col_slant8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) {
- int i, row2, row4, row8;
- int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+void IndeoDSP::ffIviColSlant8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) {
+ int i, row2, row4, row8;
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
row2 = pitch << 1;
row4 = pitch << 2;
@@ -489,23 +489,23 @@ void IndeoDSP::ff_ivi_col_slant8(const int32 *in, int16 *out, uint32 pitch, cons
#undef COMPENSATE
}
-void IndeoDSP::ff_ivi_dc_col_slant(const int32 *in, int16 *out, uint32 pitch, int blk_size) {
- int x, y;
- int16 dc_coeff;
+void IndeoDSP::ffIviDcColSlant(const int32 *in, int16 *out, uint32 pitch, int blkSize) {
+ int x, y;
+ int16 dcCoeff;
- dc_coeff = (*in + 1) >> 1;
+ dcCoeff = (*in + 1) >> 1;
- for (y = 0; y < blk_size; out += pitch, y++) {
- out[0] = dc_coeff;
- for (x = 1; x < blk_size; x++)
+ for (y = 0; y < blkSize; out += pitch, y++) {
+ out[0] = dcCoeff;
+ for (x = 1; x < blkSize; x++)
out[x] = 0;
}
}
-void IndeoDSP::ff_ivi_row_slant4(const int32 *in, int16 *out,
+void IndeoDSP::ffIviRowSlant4(const int32 *in, int16 *out,
uint32 pitch, const uint8 *flags) {
- int i;
- int t0, t1, t2, t3, t4;
+ int i;
+ int t0, t1, t2, t3, t4;
#define COMPENSATE(x) (((x) + 1)>>1)
for (i = 0; i < 4; i++) {
@@ -522,10 +522,10 @@ void IndeoDSP::ff_ivi_row_slant4(const int32 *in, int16 *out,
#undef COMPENSATE
}
-void IndeoDSP::ff_ivi_col_slant4(const int32 *in, int16 *out, uint32 pitch,
+void IndeoDSP::ffIviColSlant4(const int32 *in, int16 *out, uint32 pitch,
const uint8 *flags) {
- int i, row2;
- int t0, t1, t2, t3, t4;
+ int i, row2;
+ int t0, t1, t2, t3, t4;
row2 = pitch << 1;
@@ -545,18 +545,18 @@ void IndeoDSP::ff_ivi_col_slant4(const int32 *in, int16 *out, uint32 pitch,
#undef COMPENSATE
}
-void IndeoDSP::ff_ivi_put_pixels_8x8(const int32 *in, int16 *out, uint32 pitch,
+void IndeoDSP::ffIviPutPixels8x8(const int32 *in, int16 *out, uint32 pitch,
const uint8 *flags) {
- int x, y;
+ int x, y;
for (y = 0; y < 8; out += pitch, in += 8, y++)
for (x = 0; x < 8; x++)
out[x] = in[x];
}
-void IndeoDSP::ff_ivi_put_dc_pixel_8x8(const int32 *in, int16 *out, uint32 pitch,
- int blk_size) {
- int y;
+void IndeoDSP::ffIviPutDcPixel8x8(const int32 *in, int16 *out, uint32 pitch,
+ int blkSize) {
+ int y;
out[0] = in[0];
memset(out + 1, 0, 7*sizeof(out[0]));
@@ -567,60 +567,60 @@ void IndeoDSP::ff_ivi_put_dc_pixel_8x8(const int32 *in, int16 *out, uint32 pitch
}
#define IVI_MC_TEMPLATE(size, suffix, OP) \
-static void ivi_mc_ ## size ##x## size ## suffix(int16 *buf, \
+static void iviMc ## size ##x## size ## suffix(int16 *buf, \
uint32 dpitch, \
- const int16 *ref_buf, \
- uint32 pitch, int mc_type) \
+ const int16 *refBuf, \
+ uint32 pitch, int mcType) \
{ \
- int i, j; \
+ int i, j; \
const int16 *wptr; \
\
- switch (mc_type) { \
+ switch (mcType) { \
case 0: /* fullpel (no interpolation) */ \
- for (i = 0; i < size; i++, buf += dpitch, ref_buf += pitch) { \
+ for (i = 0; i < size; i++, buf += dpitch, refBuf += pitch) { \
for (j = 0; j < size; j++) {\
- OP(buf[j], ref_buf[j]); \
+ OP(buf[j], refBuf[j]); \
} \
} \
break; \
case 1: /* horizontal halfpel interpolation */ \
- for (i = 0; i < size; i++, buf += dpitch, ref_buf += pitch) \
+ for (i = 0; i < size; i++, buf += dpitch, refBuf += pitch) \
for (j = 0; j < size; j++) \
- OP(buf[j], (ref_buf[j] + ref_buf[j+1]) >> 1); \
+ OP(buf[j], (refBuf[j] + refBuf[j+1]) >> 1); \
break; \
case 2: /* vertical halfpel interpolation */ \
- wptr = ref_buf + pitch; \
- for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, ref_buf += pitch) \
+ wptr = refBuf + pitch; \
+ for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, refBuf += pitch) \
for (j = 0; j < size; j++) \
- OP(buf[j], (ref_buf[j] + wptr[j]) >> 1); \
+ OP(buf[j], (refBuf[j] + wptr[j]) >> 1); \
break; \
case 3: /* vertical and horizontal halfpel interpolation */ \
- wptr = ref_buf + pitch; \
- for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, ref_buf += pitch) \
+ wptr = refBuf + pitch; \
+ for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, refBuf += pitch) \
for (j = 0; j < size; j++) \
- OP(buf[j], (ref_buf[j] + ref_buf[j+1] + wptr[j] + wptr[j+1]) >> 2); \
+ OP(buf[j], (refBuf[j] + refBuf[j+1] + wptr[j] + wptr[j+1]) >> 2); \
break; \
} \
} \
\
-void IndeoDSP::ff_ivi_mc_ ## size ##x## size ## suffix(int16 *buf, const int16 *ref_buf, \
- uint32 pitch, int mc_type) \
+void IndeoDSP::ffIviMc ## size ##x## size ## suffix(int16 *buf, const int16 *refBuf, \
+ uint32 pitch, int mcType) \
{ \
- ivi_mc_ ## size ##x## size ## suffix(buf, pitch, ref_buf, pitch, mc_type); \
+ iviMc ## size ##x## size ## suffix(buf, pitch, refBuf, pitch, mcType); \
}
#define IVI_MC_AVG_TEMPLATE(size, suffix, OP) \
-void IndeoDSP::ff_ivi_mc_avg_ ## size ##x## size ## suffix(int16 *buf, \
- const int16 *ref_buf, \
- const int16 *ref_buf2, \
+void IndeoDSP::ffIviMcAvg ## size ##x## size ## suffix(int16 *buf, \
+ const int16 *refBuf, \
+ const int16 *refBuf2, \
uint32 pitch, \
- int mc_type, int mc_type2) \
+ int mcType, int mcType2) \
{ \
int16 tmp[size * size]; \
int i, j; \
\
- ivi_mc_ ## size ##x## size ## _no_delta(tmp, size, ref_buf, pitch, mc_type); \
- ivi_mc_ ## size ##x## size ## _delta(tmp, size, ref_buf2, pitch, mc_type2); \
+ iviMc ## size ##x## size ## NoDelta(tmp, size, refBuf, pitch, mcType); \
+ iviMc ## size ##x## size ## Delta(tmp, size, refBuf2, pitch, mcType2); \
for (i = 0; i < size; i++, buf += pitch) { \
for (j = 0; j < size; j++) {\
OP(buf[j], tmp[i * size + j] >> 1); \
@@ -631,14 +631,14 @@ void IndeoDSP::ff_ivi_mc_avg_ ## size ##x## size ## suffix(int16 *buf, \
#define OP_PUT(a, b) (a) = (b)
#define OP_ADD(a, b) (a) += (b)
-IVI_MC_TEMPLATE(8, _no_delta, OP_PUT)
-IVI_MC_TEMPLATE(8, _delta, OP_ADD)
-IVI_MC_TEMPLATE(4, _no_delta, OP_PUT)
-IVI_MC_TEMPLATE(4, _delta, OP_ADD)
-IVI_MC_AVG_TEMPLATE(8, _no_delta, OP_PUT)
-IVI_MC_AVG_TEMPLATE(8, _delta, OP_ADD)
-IVI_MC_AVG_TEMPLATE(4, _no_delta, OP_PUT)
-IVI_MC_AVG_TEMPLATE(4, _delta, OP_ADD)
+IVI_MC_TEMPLATE(8, NoDelta, OP_PUT)
+IVI_MC_TEMPLATE(8, Delta, OP_ADD)
+IVI_MC_TEMPLATE(4, NoDelta, OP_PUT)
+IVI_MC_TEMPLATE(4, Delta, OP_ADD)
+IVI_MC_AVG_TEMPLATE(8, NoDelta, OP_PUT)
+IVI_MC_AVG_TEMPLATE(8, Delta, OP_ADD)
+IVI_MC_AVG_TEMPLATE(4, NoDelta, OP_PUT)
+IVI_MC_AVG_TEMPLATE(4, Delta, OP_ADD)
} // End of namespace Indeo
} // End of namespace Image
diff --git a/image/codecs/indeo/indeo_dsp.h b/image/codecs/indeo/indeo_dsp.h
index fc50339..5f4b04f 100644
--- a/image/codecs/indeo/indeo_dsp.h
+++ b/image/codecs/indeo/indeo_dsp.h
@@ -43,293 +43,293 @@ public:
/**
* two-dimensional inverse Haar 8x8 transform for Indeo 4
*
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags:
- * != 0 - non_empty column, 0 - empty one
- * (this array must be filled by caller)
+ * @param[in] in Pointer to the vector of transform coefficients
+ * @param[out] out Pointer to the output buffer (frame)
+ * @param[in] pitch Pitch to move to the next y line
+ * @param[in] flags Pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
*/
- static void ff_ivi_inverse_haar_8x8(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags);
- static void ff_ivi_inverse_haar_8x1(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags);
- static void ff_ivi_inverse_haar_1x8(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags);
+ static void ffIviInverseHaar8x8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
+ static void ffIviInverseHaar8x1(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
+ static void ffIviInverseHaar1x8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
/**
* one-dimensional inverse 8-point Haar transform on rows for Indeo 4
*
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags:
- * != 0 - non_empty column, 0 - empty one
- * (this array must be filled by caller)
+ * @param[in] in Pointer to the vector of transform coefficients
+ * @param[out] out Pointer to the output buffer (frame)
+ * @param[in] pitch Pitch to move to the next y line
+ * @param[in] flags Pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
*/
- static void ff_ivi_row_haar8(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags);
+ static void ffIviRowHaar8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
/**
* one-dimensional inverse 8-point Haar transform on columns for Indeo 4
*
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags:
- * != 0 - non_empty column, 0 - empty one
- * (this array must be filled by caller)
+ * @param[in] in Pointer to the vector of transform coefficients
+ * @param[out] out Pointer to the output buffer (frame)
+ * @param[in] pitch Pitch to move to the next y line
+ * @param[in] flags Pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
*/
- static void ff_ivi_col_haar8(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags);
+ static void ffIviColHaar8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
/**
* two-dimensional inverse Haar 4x4 transform for Indeo 4
*
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags:
- * != 0 - non_empty column, 0 - empty one
- * (this array must be filled by caller)
+ * @param[in] in Pointer to the vector of transform coefficients
+ * @param[out] out Pointer to the output buffer (frame)
+ * @param[in] pitch Pitch to move to the next y line
+ * @param[in] flags Pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
*/
- static void ff_ivi_inverse_haar_4x4(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags);
+ static void ffIviInverseHaar4x4(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
/**
* one-dimensional inverse 4-point Haar transform on rows for Indeo 4
*
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags:
- * != 0 - non_empty column, 0 - empty one
- * (this array must be filled by caller)
+ * @param[in] in Pointer to the vector of transform coefficients
+ * @param[out] out Pointer to the output buffer (frame)
+ * @param[in] pitch Pitch to move to the next y line
+ * @param[in] flags Pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
*/
- static void ff_ivi_row_haar4(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags);
+ static void ffIviRowHaar4(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
/**
* one-dimensional inverse 4-point Haar transform on columns for Indeo 4
*
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags:
- * != 0 - non_empty column, 0 - empty one
- * (this array must be filled by caller)
+ * @param[in] in Pointer to the vector of transform coefficients
+ * @param[out] out Pointer to the output buffer (frame)
+ * @param[in] pitch Pitch to move to the next y line
+ * @param[in] flags Pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
*/
- static void ff_ivi_col_haar4(const int32 *in, int16 *out, uint32 pitch,
+ static void ffIviColHaar4(const int32 *in, int16 *out, uint32 pitch,
const uint8 *flags);
/**
* DC-only two-dimensional inverse Haar transform for Indeo 4.
* Performing the inverse transform in this case is equivalent to
- * spreading DC_coeff >> 3 over the whole block.
+ * spreading dcCoeff >> 3 over the whole block.
*
- * @param[in] in pointer to the dc coefficient
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] blk_size transform block size
+ * @param[in] in Pointer to the dc coefficient
+ * @param[out] out Pointer to the output buffer (frame)
+ * @param[in] pitch Pitch to move to the next y line
+ * @param[in] blkSize Transform block size
*/
- static void ff_ivi_dc_haar_2d(const int32 *in, int16 *out, uint32 pitch,
- int blk_size);
+ static void ffIviDcHaar2d(const int32 *in, int16 *out, uint32 pitch,
+ int blkSize);
/**
* two-dimensional inverse slant 8x8 transform
*
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags:
- * != 0 - non_empty column, 0 - empty one
- * (this array must be filled by caller)
+ * @param[in] in Pointer to the vector of transform coefficients
+ * @param[out] out Pointer to the output buffer (frame)
+ * @param[in] pitch Pitch to move to the next y line
+ * @param[in] flags Pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
*/
- static void ff_ivi_inverse_slant_8x8(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags);
+ static void ffIviInverseSlant8x8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
/**
* two-dimensional inverse slant 4x4 transform
*
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags:
- * != 0 - non_empty column, 0 - empty one
- * (this array must be filled by caller)
+ * @param[in] in Pointer to the vector of transform coefficients
+ * @param[out] out Pointer to the output buffer (frame)
+ * @param[in] pitch Pitch to move to the next y line
+ * @param[in] flags Pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
*/
- static void ff_ivi_inverse_slant_4x4(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags);
+ static void ffIviInverseSlant4x4(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
/**
* DC-only two-dimensional inverse slant transform.
* Performing the inverse slant transform in this case is equivalent to
- * spreading (DC_coeff + 1)/2 over the whole block.
+ * spreading (dcCoeff + 1)/2 over the whole block.
* It works much faster than performing the slant transform on a vector of zeroes.
*
- * @param[in] in pointer to the dc coefficient
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] blk_size transform block size
+ * @param[in] in Pointer to the dc coefficient
+ * @param[out] out Pointer to the output buffer (frame)
+ * @param[in] pitch Pitch to move to the next y line
+ * @param[in] blkSize Transform block size
*/
- static void ff_ivi_dc_slant_2d(const int32 *in, int16 *out, uint32 pitch, int blk_size);
+ static void ffIviDcSlant2d(const int32 *in, int16 *out, uint32 pitch, int blkSize);
/**
* inverse 1D row slant transform
*
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags (unused here)
+ * @param[in] in Pointer to the vector of transform coefficients
+ * @param[out] out Pointer to the output buffer (frame)
+ * @param[in] pitch Pitch to move to the next y line
+ * @param[in] flags Pointer to the array of column flags (unused here)
*/
- static void ff_ivi_row_slant8(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags);
+ static void ffIviRowSlant8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
/**
* inverse 1D column slant transform
*
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags:
- * != 0 - non_empty column, 0 - empty one
- * (this array must be filled by caller)
+ * @param[in] in Pointer to the vector of transform coefficients
+ * @param[out] out Pointer to the output buffer (frame)
+ * @param[in] pitch Pitch to move to the next y line
+ * @param[in] flags Pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
*/
- static void ff_ivi_col_slant8(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags);
+ static void ffIviColSlant8(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
/**
* inverse 1D row slant transform
*
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags (unused here)
+ * @param[in] in Pointer to the vector of transform coefficients
+ * @param[out] out Pointer to the output buffer (frame)
+ * @param[in] pitch Pitch to move to the next y line
+ * @param[in] flags Pointer to the array of column flags (unused here)
*/
- static void ff_ivi_row_slant4(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags);
+ static void ffIviRowSlant4(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
/**
* inverse 1D column slant transform
*
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags:
- * != 0 - non_empty column, 0 - empty one
- * (this array must be filled by caller)
+ * @param[in] in Pointer to the vector of transform coefficients
+ * @param[out] out Pointer to the output buffer (frame)
+ * @param[in] pitch Pitch to move to the next y line
+ * @param[in] flags Pointer to the array of column flags:
+ * != 0 - non_empty column, 0 - empty one
+ * (this array must be filled by caller)
*/
- static void ff_ivi_col_slant4(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags);
+ static void ffIviColSlant4(const int32 *in, int16 *out, uint32 pitch,
+ const uint8 *flags);
/**
* DC-only inverse row slant transform
*/
- static void ff_ivi_dc_row_slant(const int32 *in, int16 *out, uint32 pitch, int blk_size);
+ static void ffIviDcRowSlant(const int32 *in, int16 *out, uint32 pitch, int blkSize);
/**
* DC-only inverse column slant transform
*/
- static void ff_ivi_dc_col_slant(const int32 *in, int16 *out, uint32 pitch, int blk_size);
+ static void ffIviDcColSlant(const int32 *in, int16 *out, uint32 pitch, int blkSize);
/**
* Copy the pixels into the frame buffer.
*/
- static void ff_ivi_put_pixels_8x8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags);
+ static void ffIviPutPixels8x8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags);
/**
* Copy the DC coefficient into the first pixel of the block and
* zero all others.
*/
- static void ff_ivi_put_dc_pixel_8x8(const int32 *in, int16 *out, uint32 pitch, int blk_size);
+ static void ffIviPutDcPixel8x8(const int32 *in, int16 *out, uint32 pitch, int blkSize);
/**
* 8x8 block motion compensation with adding delta
*
- * @param[in,out] buf pointer to the block in the current frame buffer containing delta
- * @param[in] ref_buf pointer to the corresponding block in the reference frame
- * @param[in] pitch pitch for moving to the next y line
- * @param[in] mc_type interpolation type
+ * @param[in,out] buf Pointer to the block in the current frame buffer containing delta
+ * @param[in] refBuf Pointer to the corresponding block in the reference frame
+ * @param[in] pitch Pitch for moving to the next y line
+ * @param[in] mcType Interpolation type
*/
- static void ff_ivi_mc_8x8_delta(int16 *buf, const int16 *ref_buf, uint32 pitch, int mc_type);
+ static void ffIviMc8x8Delta(int16 *buf, const int16 *refBuf, uint32 pitch, int mcType);
/**
* 4x4 block motion compensation with adding delta
*
- * @param[in,out] buf pointer to the block in the current frame buffer containing delta
- * @param[in] ref_buf pointer to the corresponding block in the reference frame
- * @param[in] pitch pitch for moving to the next y line
- * @param[in] mc_type interpolation type
+ * @param[in,out] buf Pointer to the block in the current frame buffer containing delta
+ * @param[in] refBuf Pointer to the corresponding block in the reference frame
+ * @param[in] pitch Pitch for moving to the next y line
+ * @param[in] mcType Interpolation type
*/
- static void ff_ivi_mc_4x4_delta(int16 *buf, const int16 *ref_buf, uint32 pitch, int mc_type);
+ static void ffIviMc4x4Delta(int16 *buf, const int16 *refBuf, uint32 pitch, int mcType);
/**
* motion compensation without adding delta
*
- * @param[in,out] buf pointer to the block in the current frame receiving the result
- * @param[in] ref_buf pointer to the corresponding block in the reference frame
- * @param[in] pitch pitch for moving to the next y line
- * @param[in] mc_type interpolation type
+ * @param[in,out] buf Pointer to the block in the current frame buffer containing delta
+ * @param[in] refBuf Pointer to the corresponding block in the reference frame
+ * @param[in] pitch Pitch for moving to the next y line
+ * @param[in] mcType Interpolation type
*/
- static void ff_ivi_mc_8x8_no_delta(int16 *buf, const int16 *ref_buf, uint32 pitch, int mc_type);
+ static void ffIviMc8x8NoDelta(int16 *buf, const int16 *refBuf, uint32 pitch, int mcType);
/**
* 4x4 block motion compensation without adding delta
*
- * @param[in,out] buf pointer to the block in the current frame receiving the result
- * @param[in] ref_buf pointer to the corresponding block in the reference frame
- * @param[in] pitch pitch for moving to the next y line
- * @param[in] mc_type interpolation type
+ * @param[in,out] buf Pointer to the block in the current frame receiving the result
+ * @param[in] refBuf Pointer to the corresponding block in the reference frame
+ * @param[in] pitch Pitch for moving to the next y line
+ * @param[in] mcType Interpolation type
*/
- static void ff_ivi_mc_4x4_no_delta(int16 *buf, const int16 *ref_buf, uint32 pitch, int mc_type);
+ static void ffIviMc4x4NoDelta(int16 *buf, const int16 *refBuf, uint32 pitch, int mcType);
/**
* 8x8 block motion compensation with adding delta
*
- * @param[in,out] buf pointer to the block in the current frame buffer containing delta
- * @param[in] ref_buf pointer to the corresponding block in the backward reference frame
- * @param[in] ref_buf2 pointer to the corresponding block in the forward reference frame
- * @param[in] pitch pitch for moving to the next y line
- * @param[in] mc_type interpolation type for backward reference
- * @param[in] mc_type2 interpolation type for forward reference
+ * @param[in,out] buf Pointer to the block in the current frame buffer containing delta
+ * @param[in] refBuf Pointer to the corresponding block in the backward reference frame
+ * @param[in] refBuf2 Pointer to the corresponding block in the forward reference frame
+ * @param[in] pitch Pitch for moving to the next y line
+ * @param[in] mcType Interpolation type for backward reference
+ * @param[in] mcType2 Interpolation type for forward reference
*/
- static void ff_ivi_mc_avg_8x8_delta(int16 *buf, const int16 *ref_buf, const int16 *ref_buf2, uint32 pitch, int mc_type, int mc_type2);
+ static void ffIviMcAvg8x8Delta(int16 *buf, const int16 *refBuf, const int16 *refBuf2, uint32 pitch, int mcType, int mcType2);
/**
* 4x4 block motion compensation with adding delta
*
- * @param[in,out] buf pointer to the block in the current frame buffer containing delta
- * @param[in] ref_buf pointer to the corresponding block in the backward reference frame
- * @param[in] ref_buf2 pointer to the corresponding block in the forward reference frame
- * @param[in] pitch pitch for moving to the next y line
- * @param[in] mc_type interpolation type for backward reference
- * @param[in] mc_type2 interpolation type for forward reference
+ * @param[in,out] buf Pointer to the block in the current frame buffer containing delta
+ * @param[in] refBuf Pointer to the corresponding block in the backward reference frame
+ * @param[in] refBuf2 Pointer to the corresponding block in the forward reference frame
+ * @param[in] pitch Pitch for moving to the next y line
+ * @param[in] mcType Interpolation type for backward reference
+ * @param[in] mcType2 Interpolation type for forward reference
*/
- static void ff_ivi_mc_avg_4x4_delta(int16 *buf, const int16 *ref_buf, const int16 *ref_buf2, uint32 pitch, int mc_type, int mc_type2);
+ static void ffIviMcAvg4x4Delta(int16 *buf, const int16 *refBuf, const int16 *refBuf2, uint32 pitch, int mcType, int mcType2);
/**
* motion compensation without adding delta for B-frames
*
- * @param[in,out] buf pointer to the block in the current frame receiving the result
- * @param[in] ref_buf pointer to the corresponding block in the backward reference frame
- * @param[in] ref_buf2 pointer to the corresponding block in the forward reference frame
- * @param[in] pitch pitch for moving to the next y line
- * @param[in] mc_type interpolation type for backward reference
- * @param[in] mc_type2 interpolation type for forward reference
+ * @param[in,out] buf Pointer to the block in the current frame buffer containing delta
+ * @param[in] refBuf Pointer to the corresponding block in the backward reference frame
+ * @param[in] refBuf2 Pointer to the corresponding block in the forward reference frame
+ * @param[in] pitch Pitch for moving to the next y line
+ * @param[in] mcType Interpolation type for backward reference
+ * @param[in] mcType2 Interpolation type for forward reference
*/
- static void ff_ivi_mc_avg_8x8_no_delta(int16 *buf, const int16 *ref_buf, const int16 *ref_buf2, uint32 pitch, int mc_type, int mc_type2);
+ static void ffIviMcAvg8x8NoDelta(int16 *buf, const int16 *refBuf, const int16 *refBuf2, uint32 pitch, int mcType, int mcType2);
/**
* 4x4 block motion compensation without adding delta for B-frames
*
- * @param[in,out] buf pointer to the block in the current frame receiving the result
- * @param[in] ref_buf pointer to the corresponding block in the backward reference frame
- * @param[in] ref_buf2 pointer to the corresponding block in the forward reference frame
- * @param[in] pitch pitch for moving to the next y line
- * @param[in] mc_type interpolation type for backward reference
- * @param[in] mc_type2 interpolation type for forward reference
+ * @param[in,out] buf Pointer to the block in the current frame buffer containing delta
+ * @param[in] refBuf Pointer to the corresponding block in the backward reference frame
+ * @param[in] refBuf2 Pointer to the corresponding block in the forward reference frame
+ * @param[in] pitch Pitch for moving to the next y line
+ * @param[in] mcType Interpolation type for backward reference
+ * @param[in] mcType2 Interpolation type for forward reference
*/
- static void ff_ivi_mc_avg_4x4_no_delta(int16 *buf, const int16 *ref_buf, const int16 *ref_buf2, uint32 pitch, int mc_type, int mc_type2);
+ static void ffIviMcAvg4x4NoDelta(int16 *buf, const int16 *refBuf, const int16 *refBuf2, uint32 pitch, int mcType, int mcType2);
};
} // End of namespace Indeo
diff --git a/image/codecs/indeo/mem.cpp b/image/codecs/indeo/mem.cpp
index 9987415..89f2af7 100644
--- a/image/codecs/indeo/mem.cpp
+++ b/image/codecs/indeo/mem.cpp
@@ -31,7 +31,7 @@
namespace Image {
namespace Indeo {
-const uint8 ff_reverse[256] = {
+const uint8 ffReverse[256] = {
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8,
0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4,
@@ -50,6 +50,17 @@ const uint8 ff_reverse[256] = {
0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF,
};
+const uint8 ffZigZagDirect[64] = {
+ 0, 1, 8, 16, 9, 2, 3, 10,
+ 17, 24, 32, 25, 18, 11, 4, 5,
+ 12, 19, 26, 33, 40, 48, 41, 34,
+ 27, 20, 13, 6, 7, 14, 21, 28,
+ 35, 42, 49, 56, 57, 50, 43, 36,
+ 29, 22, 15, 23, 30, 37, 44, 51,
+ 58, 59, 52, 45, 38, 31, 39, 46,
+ 53, 60, 61, 54, 47, 55, 62, 63
+};
+
/*------------------------------------------------------------------------*/
/**
@@ -59,7 +70,7 @@ const uint8 ff_reverse[256] = {
* @param[out] r Pointer to the result of the operation
* @return 0 on success, AVERROR(EINVAL) on overflow
*/
-static inline int av_size_mult(size_t a, size_t b, size_t *r) {
+static inline int avSizeMult(size_t a, size_t b, size_t *r) {
size_t t = a * b;
// Hack inspired from glibc: don't try the division if nelem and elsize
@@ -72,56 +83,56 @@ static inline int av_size_mult(size_t a, size_t b, size_t *r) {
/*------------------------------------------------------------------------*/
-void *av_malloc(size_t size) {
+void *avMalloc(size_t size) {
return malloc(size);
}
-void *av_mallocz(size_t size) {
- void *ptr = av_malloc(size);
+void *avMallocZ(size_t size) {
+ void *ptr = avMalloc(size);
if (ptr)
memset(ptr, 0, size);
return ptr;
}
-void *av_malloc_array(size_t nmemb, size_t size) {
+void *avMallocArray(size_t nmemb, size_t size) {
if (!size || nmemb >= MAX_INTEGER / size)
return nullptr;
return malloc(nmemb * size);
}
-void *av_mallocz_array(size_t nmemb, size_t size) {
+void *avMallocZArray(size_t nmemb, size_t size) {
if (!size || nmemb >= MAX_INTEGER / size)
return NULL;
- return av_mallocz(nmemb * size);
+ return avMallocZ(nmemb * size);
}
-void av_free(void *ptr) {
+void avFree(void *ptr) {
free(ptr);
}
-void av_freep(void *arg) {
+void avFreeP(void *arg) {
void **ptr = (void **)arg;
free(*ptr);
*ptr = nullptr;
}
-static void *av_realloc(void *ptr, size_t size) {
+static void *avRealloc(void *ptr, size_t size) {
return realloc(ptr, size + !size);
}
-void *av_realloc_f(void *ptr, size_t nelem, size_t elsize) {
+void *avReallocF(void *ptr, size_t nelem, size_t elsize) {
size_t size;
void *r;
- if (av_size_mult(elsize, nelem, &size)) {
- av_free(ptr);
+ if (avSizeMult(elsize, nelem, &size)) {
+ avFree(ptr);
return nullptr;
}
- r = av_realloc(ptr, size);
+ r = avRealloc(ptr, size);
if (!r)
- av_free(ptr);
+ avFree(ptr);
return r;
}
@@ -130,53 +141,39 @@ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize) {
/**
* Swap the order of the bytes in the passed value
*/
-uint32 bitswap_32(uint32 x) {
- return (uint32)ff_reverse[x & 0xFF] << 24 |
- (uint32)ff_reverse[(x >> 8) & 0xFF] << 16 |
- (uint32)ff_reverse[(x >> 16) & 0xFF] << 8 |
- (uint32)ff_reverse[x >> 24];
+uint32 bitswap32(uint32 x) {
+ return (uint32)ffReverse[x & 0xFF] << 24 |
+ (uint32)ffReverse[(x >> 8) & 0xFF] << 16 |
+ (uint32)ffReverse[(x >> 16) & 0xFF] << 8 |
+ (uint32)ffReverse[x >> 24];
}
/**
* Reverse "nbits" bits of the value "val" and return the result
* in the least significant bits.
*/
-uint16 inv_bits(uint16 val, int nbits) {
+uint16 invertBits(uint16 val, int nbits) {
uint16 res;
if (nbits <= 8) {
- res = ff_reverse[val] >> (8 - nbits);
+ res = ffReverse[val] >> (8 - nbits);
} else {
- res = ((ff_reverse[val & 0xFF] << 8) +
- (ff_reverse[val >> 8])) >> (16 - nbits);
+ res = ((ffReverse[val & 0xFF] << 8) +
+ (ffReverse[val >> 8])) >> (16 - nbits);
}
return res;
}
-uint8 av_clip_uint8(int a) {
+uint8 avClipUint8(int a) {
if (a&(~0xFF)) return (-a) >> 31;
else return a;
}
-unsigned av_clip_uintp2(int a, int p) {
+unsigned avClipUintp2(int a, int p) {
if (a & ~((1 << p) - 1)) return -a >> 31 & ((1 << p) - 1);
else return a;
}
-
-/*------------------------------------------------------------------------*/
-
-const uint8 ff_zigzag_direct[64] = {
- 0, 1, 8, 16, 9, 2, 3, 10,
- 17, 24, 32, 25, 18, 11, 4, 5,
- 12, 19, 26, 33, 40, 48, 41, 34,
- 27, 20, 13, 6, 7, 14, 21, 28,
- 35, 42, 49, 56, 57, 50, 43, 36,
- 29, 22, 15, 23, 30, 37, 44, 51,
- 58, 59, 52, 45, 38, 31, 39, 46,
- 53, 60, 61, 54, 47, 55, 62, 63
-};
-
} // End of namespace Indeo
} // End of namespace Image
diff --git a/image/codecs/indeo/mem.h b/image/codecs/indeo/mem.h
index cc927e6..7fadb14 100644
--- a/image/codecs/indeo/mem.h
+++ b/image/codecs/indeo/mem.h
@@ -49,7 +49,7 @@ namespace Indeo {
* be allocated
* @see av_mallocz()
*/
-extern void *av_malloc(size_t size);
+extern void *avMalloc(size_t size);
/**
* Allocate a memory block with alignment suitable for all memory accesses
@@ -60,7 +60,7 @@ extern void *av_malloc(size_t size);
* @return Pointer to the allocated block, or `NULL` if it cannot be allocated
* @see av_malloc()
*/
-extern void *av_mallocz(size_t size);
+extern void *avMallocZ(size_t size);
/**
* Allocate a memory block for an array with av_malloc().
@@ -73,7 +73,7 @@ extern void *av_mallocz(size_t size);
* be allocated
* @see av_malloc()
*/
-extern void *av_malloc_array(size_t nmemb, size_t size);
+extern void *avMallocArray(size_t nmemb, size_t size);
/**
* Allocate a memory block for an array with av_mallocz().
@@ -88,7 +88,7 @@ extern void *av_malloc_array(size_t nmemb, size_t size);
* @see av_mallocz()
* @see av_malloc_array()
*/
-extern void *av_mallocz_array(size_t nmemb, size_t size);
+extern void *avMallocZArray(size_t nmemb, size_t size);
/**
* Free a memory block which has been allocated with a function of av_malloc()
@@ -101,7 +101,7 @@ extern void *av_mallocz_array(size_t nmemb, size_t size);
* behind dangling pointers.
* @see av_freep()
*/
-extern void av_free(void *ptr);
+extern void avFree(void *ptr);
/**
* Free a memory block which has been allocated with a function of av_malloc()
@@ -110,7 +110,7 @@ extern void av_free(void *ptr);
* @param ptr Pointer to the pointer to the memory block which should be freed
* @note `*ptr = NULL` is safe and leads to no action.
*/
-extern void av_freep(void *arg);
+extern void avFreeP(void *arg);
/**
@@ -128,25 +128,25 @@ extern void av_freep(void *arg);
* @endcode
* pattern.
*/
-extern void *av_realloc_f(void *ptr, size_t nelem, size_t elsize);
+extern void *avReallocF(void *ptr, size_t nelem, size_t elsize);
/**
* Reverse "nbits" bits of the value "val" and return the result
* in the least significant bits.
*/
-extern uint16 inv_bits(uint16 val, int nbits);
+extern uint16 invertBits(uint16 val, int nbits);
/**
* Swap the order of the bytes in the passed value
*/
-extern uint32 bitswap_32(uint32 x);
+extern uint32 bitswap32(uint32 x);
/**
* Clip a signed integer value into the 0-255 range.
* @param a value to clip
* @return clipped value
*/
-extern uint8 av_clip_uint8(int a);
+extern uint8 avClipUint8(int a);
/**
* Clip a signed integer to an unsigned power of two range.
@@ -154,7 +154,7 @@ extern uint8 av_clip_uint8(int a);
* @param p bit position to clip at
* @return clipped value
*/
-extern unsigned av_clip_uintp2(int a, int p);
+extern unsigned avClipUintp2(int a, int p);
/**
* Clip a signed integer value into the amin-amax range.
@@ -165,9 +165,7 @@ extern unsigned av_clip_uintp2(int a, int p);
*/
#define av_clip CLIP
-/*------------------------------------------------------------------------*/
-
-extern const uint8 ff_zigzag_direct[64];
+extern const uint8 ffZigZagDirect[64];
} // End of namespace Indeo
} // End of namespace Image
diff --git a/image/codecs/indeo/vlc.cpp b/image/codecs/indeo/vlc.cpp
index 485acfb..0328bd8 100644
--- a/image/codecs/indeo/vlc.cpp
+++ b/image/codecs/indeo/vlc.cpp
@@ -123,7 +123,7 @@ namespace Image {
return -1; \
} \
if (flags & INIT_VLC_LE) \
- buf[j].code = bitswap_32(buf[j].code); \
+ buf[j].code = bitswap32(buf[j].code); \
else \
buf[j].code <<= 32 - buf[j].bits; \
if (symbols) \
@@ -165,7 +165,7 @@ int VLC::init_vlc(int nb_bits, int nb_codes, const void *p_bits, int bits_wrap,
vlc->_table_allocated = 0;
vlc->_table_size = 0;
- buf = (VLCcode *)av_malloc_array((nb_codes + 1), sizeof(VLCcode));
+ buf = (VLCcode *)avMallocArray((nb_codes + 1), sizeof(VLCcode));
assert(buf);
}
@@ -190,7 +190,7 @@ int VLC::init_vlc(int nb_bits, int nb_codes, const void *p_bits, int bits_wrap,
} else {
free(buf);
if (ret < 0) {
- av_freep(&vlc->_table);
+ avFreeP(&vlc->_table);
return -1;
}
}
@@ -237,7 +237,7 @@ int VLC::build_table(int table_nb_bits, int nb_codes,
nb = 1 << (table_nb_bits - n);
inc = 1;
if (flags & INIT_VLC_LE) {
- j = bitswap_32(code);
+ j = bitswap32(code);
inc = 1 << n;
}
for (k = 0; k < nb; k++) {
@@ -272,7 +272,7 @@ int VLC::build_table(int table_nb_bits, int nb_codes,
subtable_bits = MAX(subtable_bits, n);
}
subtable_bits = MIN(subtable_bits, table_nb_bits);
- j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix;
+ 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);
@@ -304,7 +304,7 @@ int VLC::alloc_table(int size, int use_static) {
assert(!use_static);
vlc->_table_allocated += (1 << vlc->_bits);
- vlc->_table = (int16(*)[2])av_realloc_f(vlc->_table, vlc->_table_allocated, sizeof(VLC_TYPE) * 2);
+ vlc->_table = (int16(*)[2])avReallocF(vlc->_table, vlc->_table_allocated, sizeof(VLC_TYPE) * 2);
if (!vlc->_table) {
vlc->_table_allocated = 0;
vlc->_table_size = 0;
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index caefab2..78eb036 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -624,22 +624,22 @@ int Indeo4Decoder::decodePlaneSubdivision() {
/**
* Indeo 4 8x8 scan (zigzag) patterns
*/
-static const uint8 ivi4_alternate_scan_8x8[64] = {
+static const uint8 ivi4AlternateScan8x8[64] = {
0, 8, 1, 9, 16, 24, 2, 3, 17, 25, 10, 11, 32, 40, 48, 56,
4, 5, 6, 7, 33, 41, 49, 57, 18, 19, 26, 27, 12, 13, 14, 15,
34, 35, 43, 42, 50, 51, 59, 58, 20, 21, 22, 23, 31, 30, 29, 28,
36, 37, 38, 39, 47, 46, 45, 44, 52, 53, 54, 55, 63, 62, 61, 60
};
-static const uint8 ivi4_alternate_scan_4x4[16] = {
+static const uint8 ivi4AlternateScan4x4[16] = {
0, 1, 4, 5, 8, 12, 2, 3, 9, 13, 6, 7, 10, 11, 14, 15
};
-static const uint8 ivi4_vertical_scan_4x4[16] = {
+static const uint8 ivi4VerticalScan4x4[16] = {
0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15
};
-static const uint8 ivi4_horizontal_scan_4x4[16] = {
+static const uint8 ivi4HorizontalScan4x4[16] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
};
@@ -648,47 +648,47 @@ const uint Indeo4Decoder::_ivi4_common_pic_sizes[14] = {
};
Indeo4Decoder::Transform Indeo4Decoder::_transforms[18] = {
- { IndeoDSP::ff_ivi_inverse_haar_8x8, IndeoDSP::ff_ivi_dc_haar_2d, 1 },
- { IndeoDSP::ff_ivi_row_haar8, IndeoDSP::ff_ivi_dc_haar_2d, 0 },
- { IndeoDSP::ff_ivi_col_haar8, IndeoDSP::ff_ivi_dc_haar_2d, 0 },
- { IndeoDSP::ff_ivi_put_pixels_8x8, IndeoDSP::ff_ivi_put_dc_pixel_8x8, 1 },
- { IndeoDSP::ff_ivi_inverse_slant_8x8, IndeoDSP::ff_ivi_dc_slant_2d, 1 },
- { IndeoDSP::ff_ivi_row_slant8, IndeoDSP::ff_ivi_dc_row_slant, 1 },
- { IndeoDSP::ff_ivi_col_slant8, IndeoDSP::ff_ivi_dc_col_slant, 1 },
+ { IndeoDSP::ffIviInverseHaar8x8, IndeoDSP::ffIviDcHaar2d, 1 },
+ { IndeoDSP::ffIviRowHaar8, IndeoDSP::ffIviDcHaar2d, 0 },
+ { IndeoDSP::ffIviColHaar8, IndeoDSP::ffIviDcHaar2d, 0 },
+ { IndeoDSP::ffIviPutPixels8x8, IndeoDSP::ffIviPutDcPixel8x8, 1 },
+ { IndeoDSP::ffIviInverseSlant8x8, IndeoDSP::ffIviDcSlant2d, 1 },
+ { IndeoDSP::ffIviRowSlant8, IndeoDSP::ffIviDcRowSlant, 1 },
+ { IndeoDSP::ffIviColSlant8, IndeoDSP::ffIviDcColSlant, 1 },
{ NULL, NULL, 0 }, // inverse DCT 8x8
{ NULL, NULL, 0 }, // inverse DCT 8x1
{ NULL, NULL, 0 }, // inverse DCT 1x8
- { IndeoDSP::ff_ivi_inverse_haar_4x4, IndeoDSP::ff_ivi_dc_haar_2d, 1 },
- { IndeoDSP::ff_ivi_inverse_slant_4x4, IndeoDSP::ff_ivi_dc_slant_2d, 1 },
+ { IndeoDSP::ffIviInverseHaar4x4, IndeoDSP::ffIviDcHaar2d, 1 },
+ { IndeoDSP::ffIviInverseSlant4x4, IndeoDSP::ffIviDcSlant2d, 1 },
{ NULL, NULL, 0 }, // no transform 4x4
- { IndeoDSP::ff_ivi_row_haar4, IndeoDSP::ff_ivi_dc_haar_2d, 0 },
- { IndeoDSP::ff_ivi_col_haar4, IndeoDSP::ff_ivi_dc_haar_2d, 0 },
- { IndeoDSP::ff_ivi_row_slant4, IndeoDSP::ff_ivi_dc_row_slant, 0 },
- { IndeoDSP::ff_ivi_col_slant4, IndeoDSP::ff_ivi_dc_col_slant, 0 },
+ { IndeoDSP::ffIviRowHaar4, IndeoDSP::ffIviDcHaar2d, 0 },
+ { IndeoDSP::ffIviColHaar4, IndeoDSP::ffIviDcHaar2d, 0 },
+ { IndeoDSP::ffIviRowSlant4, IndeoDSP::ffIviDcRowSlant, 0 },
+ { IndeoDSP::ffIviColSlant4, IndeoDSP::ffIviDcColSlant, 0 },
{ NULL, NULL, 0 }, // inverse DCT 4x4
};
const uint8 *const Indeo4Decoder::_scan_index_to_tab[15] = {
// for 8x8 transforms
- ff_zigzag_direct,
- ivi4_alternate_scan_8x8,
- _ff_ivi_horizontal_scan_8x8,
- _ff_ivi_vertical_scan_8x8,
- ff_zigzag_direct,
+ ffZigZagDirect,
+ ivi4AlternateScan8x8,
+ _ffIviHorizontalScan8x8,
+ _ffIviVerticalScan8x8,
+ ffZigZagDirect,
// for 4x4 transforms
- _ff_ivi_direct_scan_4x4,
- ivi4_alternate_scan_4x4,
- ivi4_vertical_scan_4x4,
- ivi4_horizontal_scan_4x4,
- _ff_ivi_direct_scan_4x4,
+ _ffIviDirectScan4x4,
+ ivi4AlternateScan4x4,
+ ivi4VerticalScan4x4,
+ ivi4HorizontalScan4x4,
+ _ffIviDirectScan4x4,
// TODO: check if those are needed
- _ff_ivi_horizontal_scan_8x8,
- _ff_ivi_horizontal_scan_8x8,
- _ff_ivi_horizontal_scan_8x8,
- _ff_ivi_horizontal_scan_8x8,
- _ff_ivi_horizontal_scan_8x8
+ _ffIviHorizontalScan8x8,
+ _ffIviHorizontalScan8x8,
+ _ffIviHorizontalScan8x8,
+ _ffIviHorizontalScan8x8,
+ _ffIviHorizontalScan8x8
};
/**
diff --git a/image/codecs/indeo5.cpp b/image/codecs/indeo5.cpp
index 6eacbb8..d7bb9d9 100644
--- a/image/codecs/indeo5.cpp
+++ b/image/codecs/indeo5.cpp
@@ -425,8 +425,8 @@ int Indeo5Decoder::decode_gop_header() {
picConf._picHeight = _ctx._gb->getBits(13);
picConf._picWidth = _ctx._gb->getBits(13);
} else {
- picConf._picHeight = _ivi5_common_pic_sizes[picSizeIndx * 2 + 1] << 2;
- picConf._picWidth = _ivi5_common_pic_sizes[picSizeIndx * 2] << 2;
+ picConf._picHeight = _commonPicSizes[picSizeIndx * 2 + 1] << 2;
+ picConf._picWidth = _commonPicSizes[picSizeIndx * 2] << 2;
}
if (_ctx._gopFlags & 2) {
@@ -485,43 +485,43 @@ int Indeo5Decoder::decode_gop_header() {
// select transform function and scan pattern according to plane and band number
switch ((p << 2) + i) {
case 0:
- band->_invTransform = IndeoDSP::ff_ivi_inverse_slant_8x8;
- band->_dcTransform = IndeoDSP::ff_ivi_dc_slant_2d;
- band->_scan = ff_zigzag_direct;
+ band->_invTransform = IndeoDSP::ffIviInverseSlant8x8;
+ band->_dcTransform = IndeoDSP::ffIviDcSlant2d;
+ band->_scan = ffZigZagDirect;
band->_transformSize = 8;
break;
case 1:
- band->_invTransform = IndeoDSP::ff_ivi_row_slant8;
- band->_dcTransform = IndeoDSP::ff_ivi_dc_row_slant;
- band->_scan = _ff_ivi_vertical_scan_8x8;
+ band->_invTransform = IndeoDSP::ffIviRowSlant8;
+ band->_dcTransform = IndeoDSP::ffIviDcRowSlant;
+ band->_scan = _ffIviVerticalScan8x8;
band->_transformSize = 8;
break;
case 2:
- band->_invTransform = IndeoDSP::ff_ivi_col_slant8;
- band->_dcTransform = IndeoDSP::ff_ivi_dc_col_slant;
- band->_scan = _ff_ivi_horizontal_scan_8x8;
+ band->_invTransform = IndeoDSP::ffIviColSlant8;
+ band->_dcTransform = IndeoDSP::ffIviDcColSlant;
+ band->_scan = _ffIviHorizontalScan8x8;
band->_transformSize = 8;
break;
case 3:
- band->_invTransform = IndeoDSP::ff_ivi_put_pixels_8x8;
- band->_dcTransform = IndeoDSP::ff_ivi_put_dc_pixel_8x8;
- band->_scan = _ff_ivi_horizontal_scan_8x8;
+ band->_invTransform = IndeoDSP::ffIviPutPixels8x8;
+ band->_dcTransform = IndeoDSP::ffIviPutDcPixel8x8;
+ band->_scan = _ffIviHorizontalScan8x8;
band->_transformSize = 8;
break;
case 4:
- band->_invTransform = IndeoDSP::ff_ivi_inverse_slant_4x4;
- band->_dcTransform = IndeoDSP::ff_ivi_dc_slant_2d;
- band->_scan = _ff_ivi_direct_scan_4x4;
+ band->_invTransform = IndeoDSP::ffIviInverseSlant4x4;
+ band->_dcTransform = IndeoDSP::ffIviDcSlant2d;
+ band->_scan = _ffIviDirectScan4x4;
band->_transformSize = 4;
break;
}
- band->_is2dTrans = band->_invTransform == IndeoDSP::ff_ivi_inverse_slant_8x8 ||
- band->_invTransform == IndeoDSP::ff_ivi_inverse_slant_4x4;
+ band->_is2dTrans = band->_invTransform == IndeoDSP::ffIviInverseSlant8x8 ||
+ band->_invTransform == IndeoDSP::ffIviInverseSlant4x4;
if (band->_transformSize != band->_blkSize) {
warning("transform and block size mismatch (%d != %d)", band->_transformSize, band->_blkSize);
@@ -540,15 +540,15 @@ int Indeo5Decoder::decode_gop_header() {
warning("_quantMat %d too large!", quantMat);
return -1;
}
- band->_intraBase = &_ivi5_base_quant_8x8_intra[quantMat][0];
- band->_interBase = &_ivi5_base_quant_8x8_inter[quantMat][0];
- band->_intraScale = &_ivi5_scale_quant_8x8_intra[quantMat][0];
- band->_interScale = &_ivi5_scale_quant_8x8_inter[quantMat][0];
+ band->_intraBase = &_baseQuant8x8Intra[quantMat][0];
+ band->_interBase = &_baseQuant8x8Inter[quantMat][0];
+ band->_intraScale = &_scaleQuant8x8Intra[quantMat][0];
+ band->_interScale = &_scaleQuant8x8Inter[quantMat][0];
} else {
- band->_intraBase = _ivi5_base_quant_4x4_intra;
- band->_interBase = _ivi5_base_quant_4x4_inter;
- band->_intraScale = _ivi5_scale_quant_4x4_intra;
- band->_interScale = _ivi5_scale_quant_4x4_inter;
+ band->_intraBase = _baseQuant4x4Intra;
+ band->_interBase = _baseQuant4x4Inter;
+ band->_intraScale = _scaleQuant4x4Intra;
+ band->_interScale = _scaleQuant4x4Inter;
}
if (_ctx._gb->getBits(2)) {
@@ -631,17 +631,12 @@ int Indeo5Decoder::skip_hdr_extension() {
/*------------------------------------------------------------------------*/
-const uint8 Indeo5Decoder::_ivi5_common_pic_sizes[30] = {
+const uint8 Indeo5Decoder::_commonPicSizes[30] = {
160, 120, 80, 60, 40, 30, 176, 120, 88, 60, 88, 72, 44, 36, 60, 45, 160, 60,
176, 60, 20, 15, 22, 18, 0, 0, 0, 0, 0, 0
};
-const uint8 Indeo5Decoder::ivi5_common_pic_sizes[30] = {
- 160, 120, 80, 60, 40, 30, 176, 120, 88, 60, 88, 72, 44, 36, 60, 45, 160, 60,
- 176, 60, 20, 15, 22, 18, 0, 0, 0, 0, 0, 0
-};
-
-const uint16 Indeo5Decoder::_ivi5_base_quant_8x8_inter[5][64] = {
+const uint16 Indeo5Decoder::_baseQuant8x8Inter[5][64] = {
{0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a, 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e,
0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62, 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66,
0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a, 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e,
@@ -669,7 +664,7 @@ const uint16 Indeo5Decoder::_ivi5_base_quant_8x8_inter[5][64] = {
}
};
-const uint16 Indeo5Decoder::_ivi5_base_quant_8x8_intra[5][64] = {
+const uint16 Indeo5Decoder::_baseQuant8x8Intra[5][64] = {
{0x1a, 0x2e, 0x36, 0x42, 0x46, 0x4a, 0x4e, 0x5a, 0x2e, 0x32, 0x3e, 0x42, 0x46, 0x4e, 0x56, 0x6a,
0x36, 0x3e, 0x3e, 0x44, 0x4a, 0x54, 0x66, 0x72, 0x42, 0x42, 0x44, 0x4a, 0x52, 0x62, 0x6c, 0x7a,
0x46, 0x46, 0x4a, 0x52, 0x5e, 0x66, 0x72, 0x8e, 0x4a, 0x4e, 0x54, 0x62, 0x66, 0x6e, 0x86, 0xa6,
@@ -697,16 +692,16 @@ const uint16 Indeo5Decoder::_ivi5_base_quant_8x8_intra[5][64] = {
}
};
-const uint16 Indeo5Decoder::_ivi5_base_quant_4x4_inter[16] = {
+const uint16 Indeo5Decoder::_baseQuant4x4Inter[16] = {
0x1e, 0x3e, 0x4a, 0x52, 0x3e, 0x4a, 0x52, 0x56, 0x4a, 0x52, 0x56, 0x5e, 0x52, 0x56, 0x5e, 0x66
};
-const uint16 Indeo5Decoder::_ivi5_base_quant_4x4_intra[16] = {
+const uint16 Indeo5Decoder::_baseQuant4x4Intra[16] = {
0x1e, 0x3e, 0x4a, 0x52, 0x3e, 0x4a, 0x52, 0x5e, 0x4a, 0x52, 0x5e, 0x7a, 0x52, 0x5e, 0x7a, 0x92
};
-const uint8 Indeo5Decoder::_ivi5_scale_quant_8x8_inter[5][24] = {
+const uint8 Indeo5Decoder::_scaleQuant8x8Inter[5][24] = {
{0x0b, 0x11, 0x13, 0x14, 0x15, 0x16, 0x18, 0x1a, 0x1b, 0x1d, 0x20, 0x22,
0x23, 0x25, 0x28, 0x2a, 0x2e, 0x32, 0x35, 0x39, 0x3d, 0x41, 0x44, 0x4a,
},
@@ -724,7 +719,7 @@ const uint8 Indeo5Decoder::_ivi5_scale_quant_8x8_inter[5][24] = {
},
};
-const uint8 Indeo5Decoder::_ivi5_scale_quant_8x8_intra[5][24] = {
+const uint8 Indeo5Decoder::_scaleQuant8x8Intra[5][24] = {
{0x0b, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x17, 0x18, 0x1a, 0x1c, 0x1e, 0x20,
0x22, 0x24, 0x27, 0x28, 0x2a, 0x2d, 0x2f, 0x31, 0x34, 0x37, 0x39, 0x3c,
},
@@ -742,12 +737,12 @@ const uint8 Indeo5Decoder::_ivi5_scale_quant_8x8_intra[5][24] = {
}
};
-const uint8 Indeo5Decoder::_ivi5_scale_quant_4x4_inter[24] = {
+const uint8 Indeo5Decoder::_scaleQuant4x4Inter[24] = {
0x0b, 0x0d, 0x0d, 0x0e, 0x11, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
};
-const uint8 Indeo5Decoder::_ivi5_scale_quant_4x4_intra[24] = {
+const uint8 Indeo5Decoder::_scaleQuant4x4Intra[24] = {
0x01, 0x0b, 0x0b, 0x0d, 0x0d, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x13, 0x14,
0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20
};
diff --git a/image/codecs/indeo5.h b/image/codecs/indeo5.h
index 9832967..169bef9 100644
--- a/image/codecs/indeo5.h
+++ b/image/codecs/indeo5.h
@@ -112,12 +112,7 @@ private:
/**
* standard picture dimensions (width, height divided by 4)
*/
- static const uint8 _ivi5_common_pic_sizes[30];
-
- /**
- * standard picture dimensions (width, height divided by 4)
- */
- static const uint8 ivi5_common_pic_sizes[30];
+ static const uint8 _commonPicSizes[30];
/**
* Indeo5 dequantization matrixes consist of two tables: base table
@@ -128,17 +123,17 @@ private:
* ivi5_base_quant_bbb_ttt - base tables for block size 'bbb' of type 'ttt'
* ivi5_scale_quant_bbb_ttt - scale tables for block size 'bbb' of type 'ttt'
*/
- static const uint16 _ivi5_base_quant_8x8_inter[5][64];
- static const uint16 _ivi5_base_quant_8x8_intra[5][64];
+ static const uint16 _baseQuant8x8Inter[5][64];
+ static const uint16 _baseQuant8x8Intra[5][64];
- static const uint16 _ivi5_base_quant_4x4_inter[16];
- static const uint16 _ivi5_base_quant_4x4_intra[16];
+ static const uint16 _baseQuant4x4Inter[16];
+ static const uint16 _baseQuant4x4Intra[16];
- static const uint8 _ivi5_scale_quant_8x8_inter[5][24];
- static const uint8 _ivi5_scale_quant_8x8_intra[5][24];
+ static const uint8 _scaleQuant8x8Inter[5][24];
+ static const uint8 _scaleQuant8x8Intra[5][24];
- static const uint8 _ivi5_scale_quant_4x4_inter[24];
- static const uint8 _ivi5_scale_quant_4x4_intra[24];
+ static const uint8 _scaleQuant4x4Inter[24];
+ static const uint8 _scaleQuant4x4Intra[24];
};
} // End of namespace Image
Commit: 23b1dbbb0e9c10035a1df98bffa9d6eaa5a6d338
https://github.com/scummvm/scummvm/commit/23b1dbbb0e9c10035a1df98bffa9d6eaa5a6d338
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T20:35:02-04:00
Commit Message:
IMAGE: Refactored Indeo GetBits class to derive from Common::BitStream
Changed paths:
image/codecs/indeo/get_bits.cpp
image/codecs/indeo/get_bits.h
image/codecs/indeo/indeo.cpp
image/codecs/indeo4.cpp
image/codecs/indeo5.cpp
diff --git a/image/codecs/indeo/get_bits.cpp b/image/codecs/indeo/get_bits.cpp
index ade4baa..ede5fa2 100644
--- a/image/codecs/indeo/get_bits.cpp
+++ b/image/codecs/indeo/get_bits.cpp
@@ -21,439 +21,39 @@
*/
#include "image/codecs/indeo/get_bits.h"
-#include "image/codecs/indeo/mem.h"
-#include "common/algorithm.h"
-#include "common/endian.h"
-#include "common/textconsole.h"
-
-/* Intel Indeo 4 bitstream reader
- *
- * Original copyright note:
- * Copyright (c) 2004 Michael Niedermayer
- */
namespace Image {
namespace Indeo {
-/* Macro documentation
- * name
- * arbitrary name which is used as prefix for local variables
- *
- * OPEN_READER(name)
- * load index into local variable
- *
- * CLOSE_READER(name)
- * store local index back into class state
- *
- * UPDATE_CACHE(name)
- * Refill the internal cache from the bitstream.
- * After this call at least MIN_CACHE_BITS will be available.
- *
- * GET_CACHE(name)
- * Will output the contents of the internal cache,
- * next bit is MSB of 32 or 64 bits (FIXME 64 bits).
- *
- * SHOW_UBITS(name, num)
- * Will return the next num bits.
- *
- * SHOW_SBITS(name, num)
- * Will return the next num bits and do sign extension.
- *
- * SKIP_BITS(name, num)
- * Will skip over the next num bits.
- * Note, this is equivalent to SKIP_CACHE; SKIP_COUNTER.
- *
- * SKIP_CACHE(name, num)
- * Will remove the next num bits from the cache (note SKIP_COUNTER
- * MUST be called before UPDATE_CACHE / CLOSE_READER).
- *
- * SKIP_COUNTER(name, num)
- * Will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS).
- *
- * LAST_SKIP_BITS(name, num)
- * Like SKIP_BITS, to be used if next call is UPDATE_CACHE or CLOSE_READER.
- *
- * BITS_LEFT(name)
- * Return the number of bits left
- *
- * For examples see getBits, show_bits, skip_bits, get_vlc.
- */
-#define BITSTREAM_READER_LE
-
-#ifdef LONG_BITSTREAM_READER
-# define MIN_CACHE_BITS 32
-#else
-# define MIN_CACHE_BITS 25
-#endif
-
-#define NEG_USR32(a,s) (((uint32)(a)) >> (32 -(s)))
-
-#define OPEN_READER_NOSIZE(name) \
- unsigned int name ## _index = _index; \
- unsigned int name ## _cache
-
-#define OPEN_READER(name) OPEN_READER_NOSIZE(name)
-#define BITS_AVAILABLE(name) 1
-
-#define CLOSE_READER(name) _index = name ## _index
-
-# ifdef LONG_BITSTREAM_READER
-# define UPDATE_CACHE_LE(name) name ## _cache = \
- AV_RL64(_buffer + (name ## _index >> 3)) >> (name ## _index & 7)
-
-# define UPDATE_CACHE_BE(name) name ## _cache = \
- AV_RB64(_buffer + (name ## _index >> 3)) >> (32 - (name ## _index & 7))
-#else
-# define UPDATE_CACHE_LE(name) name ## _cache = \
- READ_LE_UINT32(_buffer + (name ## _index >> 3)) >> (name ## _index & 7)
-
-# define UPDATE_CACHE_BE(name) name ## _cache = \
- AV_RB32(_buffer + (name ## _index >> 3)) << (name ## _index & 7)
-#endif
-
-#ifdef BITSTREAM_READER_LE
-# define UPDATE_CACHE(name) UPDATE_CACHE_LE(name)
-# define SKIP_CACHE(name, num) name ## _cache >>= (num)
-#else
-# define UPDATE_CACHE(name) UPDATE_CACHE_BE(name)
-# define SKIP_CACHE(name, num) name ## _cache <<= (num)
-#endif
-
-#define SKIP_COUNTER(name, num) name ## _index += (num)
-
-#define BITS_LEFT(name) ((int)(_size_in_bits - name ## _index))
-
-#define SKIP_BITS(name, num) \
- do { \
- SKIP_CACHE(name, num); \
- SKIP_COUNTER(name, num); \
- } while (0)
-
-#define LAST_SKIP_BITS(name, num) SKIP_COUNTER(name, num)
-
-#define SHOW_UBITS_LE(name, num) zeroExtend(name ## _cache, num)
-#define SHOW_SBITS_LE(name, num) signExtend(name ## _cache, num)
-
-#define SHOW_UBITS_BE(name, num) NEG_USR32(name ## _cache, num)
-#define SHOW_SBITS_BE(name, num) NEG_SSR32(name ## _cache, num)
-
-#ifdef BITSTREAM_READER_LE
-# define SHOW_UBITS(name, num) SHOW_UBITS_LE(name, num)
-# define SHOW_SBITS(name, num) SHOW_SBITS_LE(name, num)
-#else
-# define SHOW_UBITS(name, num) SHOW_UBITS_BE(name, num)
-# define SHOW_SBITS(name, num) SHOW_SBITS_BE(name, num)
-#endif
-
-#define GET_CACHE(name) ((uint32) name ## _cache)
-
-
-static int signExtend(int val, uint bits) {
- uint shift = 8 * sizeof(int) - bits;
- union { uint u; int s; } v = { (unsigned)val << shift };
- return v.s >> shift;
-}
-
-static uint zeroExtend(uint val, uint bits) {
- return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits);
-}
-
-GetBits::GetBits(const byte *buffer, size_t totalBits) {
- assert(buffer && totalBits < (MAX_INTEGER - 7));
-
- _buffer = buffer;
- _sizeInBits = totalBits;
- _sizeInBitsPlus8 = totalBits + 8;
- _index = 0;
-}
-
-GetBits::GetBits(const GetBits &src) : _index(src._index), _buffer(src._buffer),
- _sizeInBits(src._sizeInBits), _sizeInBitsPlus8(src._sizeInBitsPlus8){
-}
-
-int GetBits::getXbits(int n) {
- int sign;
- int cache;
- OPEN_READER(re);
- assert(n > 0 && n <= 25);
- UPDATE_CACHE(re);
- cache = GET_CACHE(re);
- sign = ~cache >> 31;
- LAST_SKIP_BITS(re, n);
- CLOSE_READER(re);
- return (NEG_USR32(sign ^ cache, n) ^ sign) - sign;
-}
-
-int GetBits::getSbits(int n) {
- int tmp;
- OPEN_READER(re);
- assert(n > 0 && n <= 25);
- UPDATE_CACHE(re);
- tmp = SHOW_SBITS(re, n);
- LAST_SKIP_BITS(re, n);
- CLOSE_READER(re);
- return tmp;
-}
-
-/**
-* Read 1-25 bits.
-*/
-uint GetBits::getBits(int n) {
- int tmp;
- OPEN_READER(re);
- assert(n > 0 && n <= 25);
- UPDATE_CACHE(re);
- tmp = SHOW_UBITS(re, n);
- LAST_SKIP_BITS(re, n);
- CLOSE_READER(re);
- return tmp;
-}
-
-int GetBits::getBitsZ(int n) {
- return n ? getBits(n) : 0;
-}
-
-uint GetBits::getBitsLE(int n) {
- int tmp;
- OPEN_READER(re);
- assert(n > 0 && n <= 25);
- UPDATE_CACHE_LE(re);
- tmp = SHOW_UBITS_LE(re, n);
- LAST_SKIP_BITS(re, n);
- CLOSE_READER(re);
- return tmp;
-}
-
-uint GetBits::showBits(int n) {
- int tmp;
- OPEN_READER_NOSIZE(re);
- assert(n > 0 && n <= 25);
- UPDATE_CACHE(re);
- tmp = SHOW_UBITS(re, n);
- return tmp;
-}
-
-void GetBits::skipBits(int n) {
- OPEN_READER(re);
- LAST_SKIP_BITS(re, n);
- CLOSE_READER(re);
-}
-
-uint GetBits::getBits1() {
- uint index = _index;
- uint8 result = _buffer[index >> 3];
-#ifdef BITSTREAM_READER_LE
- result >>= index & 7;
- result &= 1;
-#else
- result <<= index & 7;
- result >>= 8 - 1;
-#endif
- index++;
- _index = index;
-
- return result;
-}
-
-uint GetBits::showBits1() {
- return showBits(1);
-}
-
-void GetBits::skipBits1() {
- skipBits(1);
-}
-
-/**
-* Read 0-32 bits.
-*/
-uint GetBits::getBitsLong(int n) {
- if (!n) {
- return 0;
- } else if (n <= MIN_CACHE_BITS) {
- return getBits(n);
- } else {
-#ifdef BITSTREAM_READER_LE
- unsigned ret = getBits(16);
- return ret | (getBits(n - 16) << 16);
-#else
- unsigned ret = getBits(16) << (n - 16);
- return ret | getBits(n - 16);
-#endif
- }
-}
-
-/**
- * Read 0-64 bits.
- */
-uint64 GetBits::getBits64(int n) {
- if (n <= 32) {
- return getBitsLong(n);
- } else {
-#ifdef BITSTREAM_READER_LE
- uint64 ret = getBitsLong(32);
- return ret | (uint64)getBitsLong(n - 32) << 32;
-#else
- uint64 ret = (uint64)getBitsLong(n - 32) << 32;
- return ret | getBitsLong(32);
-#endif
- }
-}
-
-int GetBits::getSbitsLong(int n) {
- return signExtend(getBitsLong(n), n);
-}
-
-/**
-* Show 0-32 bits.
-*/
-uint GetBits::showBitsLong(int n) {
- if (n <= MIN_CACHE_BITS) {
- return showBits(n);
- } else {
- GetBits gb(*this);
- return gb.getBitsLong(n);
- }
-}
-
-int GetBits::checkMarker(void *logctx, const char *msg) {
- int bit = getBits1();
- if (!bit)
- warning("Marker bit missing at %d of %d %s\n",
- getBitsCount() - 1, _sizeInBits, msg);
-
- return bit;
-}
-
-const byte *GetBits::alignGetBits() {
- int n = -(int)getBitsCount() & 7;
- if (n)
- skipBits(n);
-
- return _buffer + (_index >> 3);
-}
-
-/**
- * If the vlc code is invalid and max_depth=1, then no bits will be removed.
- * If the vlc code is invalid and max_depth>1, then the number of bits removed
- * is undefined.
- */
-#define GET_VLC(code, name, table, bits, max_depth) \
- do { \
- int n, nb_bits; \
- unsigned int index; \
- \
- index = SHOW_UBITS(name, bits); \
- code = table[index][0]; \
- n = table[index][1]; \
- \
- if (max_depth > 1 && n < 0) { \
- LAST_SKIP_BITS(name, bits); \
- UPDATE_CACHE(name); \
- \
- nb_bits = -n; \
- \
- index = SHOW_UBITS(name, nb_bits) + code; \
- code = table[index][0]; \
- n = table[index][1]; \
- if (max_depth > 2 && n < 0) { \
- LAST_SKIP_BITS(name, nb_bits); \
- UPDATE_CACHE(name); \
- \
- nb_bits = -n; \
- \
- index = SHOW_UBITS(name, nb_bits) + code; \
- code = table[index][0]; \
- n = table[index][1]; \
- } \
- } \
- SKIP_BITS(name, n); \
- } while (0)
-
-#define GET_RL_VLC(level, run, name, table, bits, \
- max_depth, need_update) \
- do { \
- int n, nb_bits; \
- unsigned int index; \
- \
- index = SHOW_UBITS(name, bits); \
- level = table[index].level; \
- n = table[index].len; \
- \
- if (max_depth > 1 && n < 0) { \
- SKIP_BITS(name, bits); \
- if (need_update) { \
- UPDATE_CACHE(name); \
- } \
- \
- nb_bits = -n; \
- \
- index = SHOW_UBITS(name, nb_bits) + level; \
- level = table[index].level; \
- n = table[index].len; \
- if (max_depth > 2 && n < 0) { \
- LAST_SKIP_BITS(name, nb_bits); \
- if (need_update) { \
- UPDATE_CACHE(name); \
- } \
- nb_bits = -n; \
- \
- index = SHOW_UBITS(name, nb_bits) + level; \
- level = table[index].level; \
- n = table[index].len; \
- } \
- } \
- run = table[index].run; \
- SKIP_BITS(name, n); \
- } while (0)
-
-/**
-* Parse a vlc code.
-* @param bits is the number of bits which will be read at once, must be
-* identical to nb_bits in init_vlc()
-* @param max_depth is the number of times bits bits must be read to completely
-* read the longest vlc code
-* = (max_vlc_length + bits - 1) / bits
-*/
int GetBits::getVLC2(int16 (*table)[2], int bits, int maxDepth) {
int code;
+ int n, nbBits;
+ unsigned int index;
- OPEN_READER(re);
- UPDATE_CACHE(re);
+ index = peekBits(bits);
+ code = table[index][0];
+ n = table[index][1];
- GET_VLC(code, re, table, bits, maxDepth);
+ if (maxDepth > 1 && n < 0) {
+ skip(bits);
+ nbBits = -n;
- CLOSE_READER(re);
+ index = peekBits(nbBits) + code;
+ code = table[index][0];
+ n = table[index][1];
- return code;
-}
+ if (maxDepth > 2 && n < 0) {
+ skip(nbBits);
+ nbBits = -n;
-int GetBits::decode012() {
- int n;
- n = getBits1();
- if (n == 0)
- return 0;
- else
- return getBits1() + 1;
-}
-
-int GetBits::decode210() {
- if (getBits1())
- return 0;
- else
- return 2 - getBits1();
-}
-
-int GetBits::skip1stop8dataBits() {
- if (getBitsLeft() <= 0)
- return -1;
-
- while (getBits1()) {
- skipBits(8);
- if (getBitsLeft() <= 0)
- return -1;
+ index = peekBits(nbBits) + code;
+ code = table[index][0];
+ n = table[index][1];
+ }
}
- return 0;
+ skip(n);
+ return code;
}
} // End of namespace Indeo
diff --git a/image/codecs/indeo/get_bits.h b/image/codecs/indeo/get_bits.h
index 986bfc8..359d8fc 100644
--- a/image/codecs/indeo/get_bits.h
+++ b/image/codecs/indeo/get_bits.h
@@ -20,152 +20,41 @@
*
*/
-#include "common/scummsys.h"
-
-/* Indeo 4 & 5 bitstream reader
- *
- * Original copyright note:
- * Copyright (c) 2004 Michael Niedermayer
- */
-
#ifndef IMAGE_CODECS_INDEO_GET_BITS_H
#define IMAGE_CODECS_INDEO_GET_BITS_H
-#include "common/scummsys.h"
-#include "common/stream.h"
-#include "common/types.h"
+#include "common/bitstream.h"
namespace Image {
namespace Indeo {
-#define AV_INPUT_BUFFER_PADDING_SIZE 32
-
/**
* Intel Indeo Bitstream reader
*/
-class GetBits {
-private:
- const byte *_buffer;
- uint _index;
- uint _sizeInBits;
- uint _sizeInBitsPlus8;
+class GetBits : public Common::BitStream8LSB {
public:
/**
* Constructor
- * @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.
+ * @param stream Source stream to reader from
+ * @param disposeAfterUse Whether to destroy stream in destructor
*/
- GetBits(const byte *buffer, size_t totalBits);
-
- /**
- * Copy constructor
- */
- GetBits(const GetBits &src);
-
- /**
- * Returns the number of bits read
- */
- uint getBitsCount() const { return _index; }
+ GetBits(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse
+ = DisposeAfterUse::YES) : Common::BitStream8LSB(stream, disposeAfterUse) {}
/**
* The number of bits left
*/
- int getBitsLeft() const { return _sizeInBits - _index; }
-
- void skipBitsLong(uint n) { _index += n; }
-
- /**
- * Read MPEG-1 dc-style VLC (sign bit + mantissa with no MSB).
- * if MSB not set it is negative
- * @param n length in bits
- */
- int getXbits(int n);
-
- /**
- * Returns the next n bits, and does sign extension
- */
- int getSbits(int n);
-
- /**
- * Read 1-25 bits.
- */
- uint getBits(int n);
-
- /**
- * Read 0-25 bits.
- */
- int getBitsZ(int n);
-
- uint getBitsLE(int n);
-
- /**
- * Show 1-25 bits.
- * Returns the data without updating the index
- */
- uint showBits(int n);
-
- /**
- * Skips a specified number of bits
- */
- void skipBits(int n);
-
- /**
- * Returns the next bit
- */
- uint getBits1();
-
- /**
- * Shows the next following bit
- */
- uint showBits1();
-
- /**
- * Skips the next bit
- */
- void skipBits1();
-
- /**
- * Read 0-32 bits.
- */
- uint getBitsLong(int n);
-
- /**
- * Read 0-64 bits.
- */
- uint64 getBits64(int n);
-
- /**
- * Read 0-32 bits as a signed integer.
- */
- int getSbitsLong(int n);
-
- /**
- * Show 0-32 bits.
- */
- uint showBitsLong(int n);
-
- int checkMarker(void *logctx, const char *msg);
+ int getBitsLeft() const { return size() - pos(); }
/**
* Parse a VLC code.
* @param bits is the number of bits which will be read at once, must be
- * identical to nb_bits in init_vlc()
- * @param max_depth is the number of times bits bits must be read to completely
+ * identical to nbBits in init_vlc()
+ * @param maxDepth is the number of times bits bits must be read to completely
* read the longest vlc code
* = (max_vlc_length + bits - 1) / bits
*/
int getVLC2(int16 (*table)[2], int bits, int maxDepth);
-
- int decode012();
-
- int decode210();
-
- int skip1stop8dataBits();
-
- const byte *alignGetBits();
};
} // End of namespace Indeo
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index f473b26..1250c57 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -582,10 +582,10 @@ int IndeoDecoderBase::decodeIndeoFrame() {
if (_ctx._gb->getBitsLeft() < 8)
return -1;
}
- left = _ctx._gb->getBitsCount() & 0x18;
- _ctx._gb->skipBitsLong(64 - left);
+ left = _ctx._gb->pos() & 0x18;
+ _ctx._gb->skip(64 - left);
if (_ctx._gb->getBitsLeft() > 18 &&
- _ctx._gb->showBitsLong(21) == 0xBFFF8) { // syncheader + inter _type
+ _ctx._gb->peekBits(21) == 0xBFFF8) { // syncheader + inter _type
error("Indeo decoder: Mode not currently implemented in ScummVM");
}
}
@@ -618,7 +618,7 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
band->_refBuf = band->_bufs[_ctx._refBuf];
band->_bRefBuf = 0;
}
- band->_dataPtr = _ctx._frameData + (_ctx._gb->getBitsCount() >> 3);
+ band->_dataPtr = _ctx._frameData + (_ctx._gb->pos() >> 3);
result = decodeBandHeader(band);
if (result) {
@@ -646,7 +646,7 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
band->_rvMap->_escSym ^= idx1 ^ idx2;
}
- pos = _ctx._gb->getBitsCount();
+ pos = _ctx._gb->pos();
for (t = 0; t < band->_numTiles; t++) {
tile = &band->_tiles[t];
@@ -656,7 +656,7 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
band->_mbSize, tile->_mbSize);
return -1;
}
- tile->_isEmpty = _ctx._gb->getBits1();
+ tile->_isEmpty = _ctx._gb->getBit();
if (tile->_isEmpty) {
result = processEmptyTile(band, tile,
(_ctx._planes[0]._bands[0]._mbSize >> 3) - (band->_mbSize >> 3));
@@ -681,7 +681,7 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
break;
}
- if ((((int)_ctx._gb->getBitsCount() - pos) >> 3) != tile->_dataSize) {
+ if ((((int)_ctx._gb->pos() - pos) >> 3) != tile->_dataSize) {
warning("Tile _dataSize mismatch!");
result = -1;
break;
@@ -704,7 +704,7 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
band->_rvMap->_escSym ^= idx1 ^ idx2;
}
- _ctx._gb->alignGetBits();
+ _ctx._gb->align();
return result;
}
@@ -1046,14 +1046,14 @@ int IndeoDecoderBase::processEmptyTile(IVIBandDesc *band,
int IndeoDecoderBase::decodeTileDataSize(GetBits *gb) {
int len = 0;
- if (gb->getBits1()) {
+ if (gb->getBit()) {
len = gb->getBits(8);
if (len == 255)
- len = gb->getBitsLong(24);
+ len = gb->getBits(24);
}
// align the bitstream reader on the byte boundary
- gb->alignGetBits();
+ gb->align();
return len;
}
@@ -1189,7 +1189,7 @@ int IndeoDecoderBase::decodeBlocks(GetBits *_gb, IVIBandDesc *band, IVITile *til
}// for blk
}// for mbn
- _gb->alignGetBits();
+ _gb->align();
return 0;
}
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index 78eb036..60707e6 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -29,6 +29,7 @@
*/
#include "common/endian.h"
+#include "common/memstream.h"
#include "common/stream.h"
#include "common/textconsole.h"
#include "common/util.h"
@@ -58,7 +59,7 @@ bool Indeo4Decoder::isIndeo4(Common::SeekableReadStream &stream) {
stream.seek(-16, SEEK_CUR);
// Validate the first 18-bit word has the correct identifier
- Indeo::GetBits gb(buffer, 16 * 8);
+ Indeo::GetBits gb(new Common::MemoryReadStream(buffer, 16 * 8), DisposeAfterUse::YES);
bool isIndeo4 = gb.getBits(18) == 0x3FFF8;
return isIndeo4;
@@ -76,7 +77,7 @@ const Graphics::Surface *Indeo4Decoder::decodeFrame(Common::SeekableReadStream &
_ctx._frameSize = stream.size();
// Set up the GetBits instance for reading the data
- _ctx._gb = new GetBits(_ctx._frameData, _ctx._frameSize * 8);
+ _ctx._gb = new GetBits(new Common::MemoryReadStream(_ctx._frameData, _ctx._frameSize * 8));
// Decode the frame
int err = decodeIndeoFrame();
@@ -110,15 +111,15 @@ int Indeo4Decoder::decodePictureHeader() {
if (_ctx._frameType == IVI4_FRAMETYPE_BIDIR)
_ctx._hasBFrames = true;
- _ctx._hasTransp = _ctx._gb->getBits1();
+ _ctx._hasTransp = _ctx._gb->getBit();
// unknown bit: Mac decoder ignores this bit, XANIM returns error
- if (_ctx._gb->getBits1()) {
+ if (_ctx._gb->getBit()) {
warning("Sync bit is set!");
return -1;
}
- _ctx._dataSize = _ctx._gb->getBits1() ? _ctx._gb->getBits(24) : 0;
+ _ctx._dataSize = _ctx._gb->getBit() ? _ctx._gb->getBits(24) : 0;
// null frames don't contain anything else so we just return
if (_ctx._frameType >= IVI4_FRAMETYPE_NULL_FIRST) {
@@ -129,8 +130,8 @@ int Indeo4Decoder::decodePictureHeader() {
// Check key lock status. If enabled - ignore lock word.
// Usually we have to prompt the user for the password, but
// we don't do that because Indeo 4 videos can be decoded anyway
- if (_ctx._gb->getBits1()) {
- _ctx._gb->skipBitsLong(32);
+ if (_ctx._gb->getBit()) {
+ _ctx._gb->skip(32);
warning("Password-protected clip!");
}
@@ -144,7 +145,7 @@ int Indeo4Decoder::decodePictureHeader() {
}
// Decode tile dimensions.
- _ctx._usesTiling = _ctx._gb->getBits1();
+ _ctx._usesTiling = _ctx._gb->getBit();
if (_ctx._usesTiling) {
_picConf._tileHeight = scaleTileSize(_picConf._picHeight, _ctx._gb->getBits(4));
_picConf._tileWidth = scaleTileSize(_picConf._picWidth, _ctx._gb->getBits(4));
@@ -198,39 +199,39 @@ int Indeo4Decoder::decodePictureHeader() {
}
}
- _ctx._frameNum = _ctx._gb->getBits1() ? _ctx._gb->getBits(20) : 0;
+ _ctx._frameNum = _ctx._gb->getBit() ? _ctx._gb->getBits(20) : 0;
// skip decTimeEst field if present
- if (_ctx._gb->getBits1())
- _ctx._gb->skipBits(8);
+ if (_ctx._gb->getBit())
+ _ctx._gb->skip(8);
// decode macroblock and block huffman codebooks
- if (_ctx._mbVlc.decodeHuffDesc(&_ctx, _ctx._gb->getBits1(), IVI_MB_HUFF) ||
- _ctx._blkVlc.decodeHuffDesc(&_ctx, _ctx._gb->getBits1(), IVI_BLK_HUFF))
+ if (_ctx._mbVlc.decodeHuffDesc(&_ctx, _ctx._gb->getBit(), IVI_MB_HUFF) ||
+ _ctx._blkVlc.decodeHuffDesc(&_ctx, _ctx._gb->getBit(), IVI_BLK_HUFF))
return -1;
- _ctx._rvmapSel = _ctx._gb->getBits1() ? _ctx._gb->getBits(3) : 8;
+ _ctx._rvmapSel = _ctx._gb->getBit() ? _ctx._gb->getBits(3) : 8;
- _ctx._inImf = _ctx._gb->getBits1();
- _ctx._inQ = _ctx._gb->getBits1();
+ _ctx._inImf = _ctx._gb->getBit();
+ _ctx._inQ = _ctx._gb->getBit();
_ctx._picGlobQuant = _ctx._gb->getBits(5);
// TODO: ignore this parameter if unused
- _ctx._unknown1 = _ctx._gb->getBits1() ? _ctx._gb->getBits(3) : 0;
+ _ctx._unknown1 = _ctx._gb->getBit() ? _ctx._gb->getBits(3) : 0;
- _ctx._checksum = _ctx._gb->getBits1() ? _ctx._gb->getBits(16) : 0;
+ _ctx._checksum = _ctx._gb->getBit() ? _ctx._gb->getBits(16) : 0;
// skip picture header extension if any
- while (_ctx._gb->getBits1()) {
- _ctx._gb->skipBits(8);
+ while (_ctx._gb->getBit()) {
+ _ctx._gb->skip(8);
}
- if (_ctx._gb->getBits1()) {
+ if (_ctx._gb->getBit()) {
warning("Bad blocks bits encountered!");
}
- _ctx._gb->alignGetBits();
+ _ctx._gb->align();
return 0;
}
@@ -281,13 +282,13 @@ int Indeo4Decoder::decodeBandHeader(IVIBandDesc *band) {
return -1;
}
- band->_isEmpty = _ctx._gb->getBits1();
+ band->_isEmpty = _ctx._gb->getBit();
if (!band->_isEmpty) {
int old_blk_size = band->_blkSize;
// skip header size
// If header size is not given, header size is 4 bytes.
- if (_ctx._gb->getBits1())
- _ctx._gb->skipBits(16);
+ if (_ctx._gb->getBit())
+ _ctx._gb->skip(16);
band->_isHalfpel = _ctx._gb->getBits(2);
if (band->_isHalfpel >= 2) {
@@ -298,7 +299,7 @@ int Indeo4Decoder::decodeBandHeader(IVIBandDesc *band) {
if (!band->_isHalfpel)
_ctx._usesFullpel = true;
- band->_checksumPresent = _ctx._gb->getBits1();
+ band->_checksumPresent = _ctx._gb->getBit();
if (band->_checksumPresent)
band->_checksum = _ctx._gb->getBits(16);
@@ -310,12 +311,12 @@ int Indeo4Decoder::decodeBandHeader(IVIBandDesc *band) {
band->_mbSize = 16 >> indx;
band->_blkSize = 8 >> (indx >> 1);
- band->_inheritMv = _ctx._gb->getBits1();
- band->_inheritQDelta = _ctx._gb->getBits1();
+ band->_inheritMv = _ctx._gb->getBit();
+ band->_inheritQDelta = _ctx._gb->getBit();
band->_globQuant = _ctx._gb->getBits(5);
- if (!_ctx._gb->getBits1() || _ctx._frameType == IVI4_FRAMETYPE_INTRA) {
+ if (!_ctx._gb->getBit() || _ctx._frameType == IVI4_FRAMETYPE_INTRA) {
transformId = _ctx._gb->getBits(5);
if ((uint)transformId >= FF_ARRAY_ELEMS(_transforms) ||
!_transforms[transformId]._invTrans) {
@@ -398,18 +399,18 @@ int Indeo4Decoder::decodeBandHeader(IVIBandDesc *band) {
}
// decode block huffman codebook
- if (!_ctx._gb->getBits1())
+ if (!_ctx._gb->getBit())
band->_blkVlc._tab = _ctx._blkVlc._tab;
else
if (band->_blkVlc.decodeHuffDesc(&_ctx, 1, IVI_BLK_HUFF))
return -1;
// select appropriate rvmap table for this band
- band->_rvmapSel = _ctx._gb->getBits1() ? _ctx._gb->getBits(3) : 8;
+ band->_rvmapSel = _ctx._gb->getBit() ? _ctx._gb->getBits(3) : 8;
// decode rvmap probability corrections if any
band->_numCorr = 0; // there is no corrections
- if (_ctx._gb->getBits1()) {
+ if (_ctx._gb->getBit()) {
band->_numCorr = _ctx._gb->getBits(8); // get number of correction pairs
if (band->_numCorr > 61) {
warning("Too many corrections: %d",
@@ -435,7 +436,7 @@ int Indeo4Decoder::decodeBandHeader(IVIBandDesc *band) {
band->_intraScale = NULL;
band->_interScale = NULL;
- _ctx._gb->alignGetBits();
+ _ctx._gb->align();
if (!band->_scan) {
warning("band->_scan not set");
@@ -476,7 +477,7 @@ int Indeo4Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
mb->_bufOffs = mbOffset;
mb->_bMvX = mb->_bMvY = 0;
- if (_ctx._gb->getBits1()) {
+ if (_ctx._gb->getBit()) {
if (_ctx._frameType == IVI4_FRAMETYPE_INTRA) {
warning("Empty macroblock in an INTRA picture!");
return -1;
@@ -593,7 +594,7 @@ int Indeo4Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
offs += row_offset;
}
- _ctx._gb->alignGetBits();
+ _ctx._gb->align();
return 0;
}
diff --git a/image/codecs/indeo5.cpp b/image/codecs/indeo5.cpp
index d7bb9d9..2b33a6b 100644
--- a/image/codecs/indeo5.cpp
+++ b/image/codecs/indeo5.cpp
@@ -29,6 +29,7 @@
*/
#include "common/endian.h"
+#include "common/memstream.h"
#include "common/stream.h"
#include "common/textconsole.h"
#include "common/util.h"
@@ -69,7 +70,7 @@ bool Indeo5Decoder::isIndeo5(Common::SeekableReadStream &stream) {
stream.seek(-16, SEEK_CUR);
// Validate the first 5-bit word has the correct identifier
- Indeo::GetBits gb(buffer, 16 * 8);
+ Indeo::GetBits gb(new Common::MemoryReadStream(buffer, 16 * 8));
bool isIndeo5 = gb.getBits(5) == 0x1F;
return isIndeo5;
@@ -87,7 +88,7 @@ const Graphics::Surface *Indeo5Decoder::decodeFrame(Common::SeekableReadStream &
_ctx._frameSize = stream.size();
// Set up the GetBits instance for reading the data
- _ctx._gb = new GetBits(_ctx._frameData, _ctx._frameSize * 8);
+ _ctx._gb = new GetBits(new Common::MemoryReadStream(_ctx._frameData, _ctx._frameSize * 8));
// Decode the frame
int err = decodeIndeoFrame();
@@ -140,7 +141,7 @@ int Indeo5Decoder::decodePictureHeader() {
if (_ctx._frameType != FRAMETYPE_NULL) {
_ctx._frameFlags = _ctx._gb->getBits(8);
- _ctx._picHdrSize = (_ctx._frameFlags & 1) ? _ctx._gb->getBitsLong(24) : 0;
+ _ctx._picHdrSize = (_ctx._frameFlags & 1) ? _ctx._gb->getBits(24) : 0;
_ctx._checksum = (_ctx._frameFlags & 0x10) ? _ctx._gb->getBits(16) : 0;
@@ -154,10 +155,10 @@ int Indeo5Decoder::decodePictureHeader() {
if (ret < 0)
return ret;
- _ctx._gb->skipBits(3); // FIXME: unknown meaning!
+ _ctx._gb->skip(3); // FIXME: unknown meaning!
}
- _ctx._gb->alignGetBits();
+ _ctx._gb->align();
return 0;
}
@@ -215,7 +216,7 @@ int Indeo5Decoder::decodeBandHeader(IVIBandDesc *band) {
return 0;
}
- band->_dataSize = (_ctx._frameFlags & 0x80) ? _ctx._gb->getBitsLong(24) : 0;
+ band->_dataSize = (_ctx._frameFlags & 0x80) ? _ctx._gb->getBits(24) : 0;
band->_inheritMv = (bandFlags & 2) != 0;
band->_inheritQDelta = (bandFlags & 8) != 0;
@@ -245,7 +246,7 @@ int Indeo5Decoder::decodeBandHeader(IVIBandDesc *band) {
if (ret < 0)
return ret;
- band->_checksumPresent = _ctx._gb->getBits1();
+ band->_checksumPresent = _ctx._gb->getBit();
if (band->_checksumPresent)
band->_checksum = _ctx._gb->getBits(16);
@@ -253,11 +254,11 @@ int Indeo5Decoder::decodeBandHeader(IVIBandDesc *band) {
// skip unknown extension if any
if (bandFlags & 0x20) { // XXX: untested
- _ctx._gb->alignGetBits();
+ _ctx._gb->align();
skip_hdr_extension();
}
- _ctx._gb->alignGetBits();
+ _ctx._gb->align();
return 0;
}
@@ -294,7 +295,7 @@ int Indeo5Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
mb->_yPos = y;
mb->_bufOffs = mbOffset;
- if (_ctx._gb->getBits1()) {
+ if (_ctx._gb->getBit()) {
if (_ctx._frameType == FRAMETYPE_INTRA) {
warning("Empty macroblock in an INTRA picture!");
return -1;
@@ -325,7 +326,7 @@ int Indeo5Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
} else if (_ctx._frameType == FRAMETYPE_INTRA) {
mb->_type = 0; // mb_type is always INTRA for intra-frames
} else {
- mb->_type = _ctx._gb->getBits1();
+ mb->_type = _ctx._gb->getBit();
}
blksPerMb = band->_mbSize != band->_blkSize ? 4 : 1;
@@ -384,7 +385,7 @@ int Indeo5Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
offs += rowOffset;
}
- _ctx._gb->alignGetBits();
+ _ctx._gb->align();
return 0;
}
@@ -401,7 +402,7 @@ int Indeo5Decoder::decode_gop_header() {
_ctx._gopHdrSize = (_ctx._gopFlags & 1) ? _ctx._gb->getBits(16) : 0;
if (_ctx._gopFlags & IVI5_IS_PROTECTED)
- _ctx._lockWord = _ctx._gb->getBitsLong(32);
+ _ctx._lockWord = _ctx._gb->getBits(32);
tile_size = (_ctx._gopFlags & 0x40) ? 64 << _ctx._gb->getBits(2) : 0;
if (tile_size > 256) {
@@ -412,7 +413,7 @@ int Indeo5Decoder::decode_gop_header() {
// decode number of wavelet bands
// num_levels * 3 + 1
picConf._lumaBands = _ctx._gb->getBits(2) * 3 + 1;
- picConf._chromaBands = _ctx._gb->getBits1() * 3 + 1;
+ picConf._chromaBands = _ctx._gb->getBit() * 3 + 1;
isScalable = picConf._lumaBands != 1 || picConf._chromaBands != 1;
if (isScalable && (picConf._lumaBands != 4 || picConf._chromaBands != 1)) {
warning("Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d",
@@ -460,10 +461,10 @@ int Indeo5Decoder::decode_gop_header() {
for (i = 0; i < (!p ? picConf._lumaBands : picConf._chromaBands); i++) {
band = &_ctx._planes[p]._bands[i];
- band->_isHalfpel = _ctx._gb->getBits1();
+ band->_isHalfpel = _ctx._gb->getBit();
- mbSize = _ctx._gb->getBits1();
- blkSize = 8 >> _ctx._gb->getBits1();
+ mbSize = _ctx._gb->getBit();
+ blkSize = 8 >> _ctx._gb->getBit();
mbSize = blkSize << !mbSize;
if (p == 0 && blkSize == 4) {
@@ -477,7 +478,7 @@ int Indeo5Decoder::decode_gop_header() {
band->_blkSize = blkSize;
}
- if (_ctx._gb->getBits1()) {
+ if (_ctx._gb->getBit()) {
warning("Extended transform info");
return -2;
}
@@ -595,22 +596,22 @@ int Indeo5Decoder::decode_gop_header() {
return -1;
}
- if (_ctx._gb->getBits1())
- _ctx._gb->skipBitsLong(24); // skip transparency fill color
+ if (_ctx._gb->getBit())
+ _ctx._gb->skip(24); // skip transparency fill color
}
- _ctx._gb->alignGetBits();
+ _ctx._gb->align();
- _ctx._gb->skipBits(23); // FIXME: unknown meaning
+ _ctx._gb->skip(23); // FIXME: unknown meaning
- // skip GOP extension if any
- if (_ctx._gb->getBits1()) {
+ // skip GOP extension if any
+ if (_ctx._gb->getBit()) {
do {
i = _ctx._gb->getBits(16);
} while (i & 0x8000);
}
- _ctx._gb->alignGetBits();
+ _ctx._gb->align();
return 0;
}
@@ -620,10 +621,10 @@ int Indeo5Decoder::skip_hdr_extension() {
do {
len = _ctx._gb->getBits(8);
- if (8 * len > _ctx._gb->getBitsLeft())
+ if (_ctx._gb->eos())
return -1;
for (i = 0; i < len; i++)
- _ctx._gb->skipBits(8);
+ _ctx._gb->skip(8);
} while (len);
return 0;
Commit: 2f7da2d3d9a6c9ef998a8e1b91a4554e6d1b9d74
https://github.com/scummvm/scummvm/commit/2f7da2d3d9a6c9ef998a8e1b91a4554e6d1b9d74
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T21:05:49-04:00
Commit Message:
IMAGE: Miscellaneous cleanup for Indeo decompressors
Changed paths:
image/codecs/indeo/indeo.cpp
image/codecs/indeo/indeo.h
image/codecs/indeo/mem.cpp
image/codecs/indeo/mem.h
image/codecs/indeo/vlc.cpp
image/codecs/indeo/vlc.h
image/codecs/indeo4.cpp
image/codecs/indeo4.h
image/codecs/indeo5.cpp
image/codecs/indeo5.h
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index 1250c57..0ce3b7d 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -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
diff --git a/image/codecs/indeo/indeo.h b/image/codecs/indeo/indeo.h
index 2c1ed95..bff5501 100644
--- a/image/codecs/indeo/indeo.h
+++ b/image/codecs/indeo/indeo.h
@@ -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
diff --git a/image/codecs/indeo/mem.cpp b/image/codecs/indeo/mem.cpp
index 89f2af7..326729b 100644
--- a/image/codecs/indeo/mem.cpp
+++ b/image/codecs/indeo/mem.cpp
@@ -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
diff --git a/image/codecs/indeo/mem.h b/image/codecs/indeo/mem.h
index 7fadb14..c94cc78 100644
--- a/image/codecs/indeo/mem.h
+++ b/image/codecs/indeo/mem.h
@@ -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
diff --git a/image/codecs/indeo/vlc.cpp b/image/codecs/indeo/vlc.cpp
index 0328bd8..e526a09 100644
--- a/image/codecs/indeo/vlc.cpp
+++ b/image/codecs/indeo/vlc.cpp
@@ -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;
diff --git a/image/codecs/indeo/vlc.h b/image/codecs/indeo/vlc.h
index 01c7b11..51e887d 100644
--- a/image/codecs/indeo/vlc.h
+++ b/image/codecs/indeo/vlc.h
@@ -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
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index 60707e6..7daecf4 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -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;
diff --git a/image/codecs/indeo4.h b/image/codecs/indeo4.h
index 26bddaa..4a6279d 100644
--- a/image/codecs/indeo4.h
+++ b/image/codecs/indeo4.h
@@ -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:
diff --git a/image/codecs/indeo5.cpp b/image/codecs/indeo5.cpp
index 2b33a6b..147bf44 100644
--- a/image/codecs/indeo5.cpp
+++ b/image/codecs/indeo5.cpp
@@ -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;
diff --git a/image/codecs/indeo5.h b/image/codecs/indeo5.h
index 169bef9..704bda5 100644
--- a/image/codecs/indeo5.h
+++ b/image/codecs/indeo5.h
@@ -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 {
Commit: a5f43663875e789baa8b7d9e79d5da4b3362f04a
https://github.com/scummvm/scummvm/commit/a5f43663875e789baa8b7d9e79d5da4b3362f04a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-10T22:18:05-04:00
Commit Message:
IMAGE: Fix leading spaces into tabs in Indeo decoders
Changed paths:
image/codecs/indeo/get_bits.cpp
image/codecs/indeo/indeo.cpp
image/codecs/indeo/indeo.h
image/codecs/indeo/indeo_dsp.cpp
image/codecs/indeo/indeo_dsp.h
image/codecs/indeo/mem.cpp
image/codecs/indeo/vlc.cpp
image/codecs/indeo/vlc.h
image/codecs/indeo4.cpp
image/codecs/indeo5.cpp
diff --git a/image/codecs/indeo/get_bits.cpp b/image/codecs/indeo/get_bits.cpp
index ede5fa2..f808a96 100644
--- a/image/codecs/indeo/get_bits.cpp
+++ b/image/codecs/indeo/get_bits.cpp
@@ -27,12 +27,12 @@ namespace Indeo {
int GetBits::getVLC2(int16 (*table)[2], int bits, int maxDepth) {
int code;
- int n, nbBits;
- unsigned int index;
+ int n, nbBits;
+ unsigned int index;
index = peekBits(bits);
- code = table[index][0];
- n = table[index][1];
+ code = table[index][0];
+ n = table[index][1];
if (maxDepth > 1 && n < 0) {
skip(bits);
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index 0ce3b7d..12b7b1f 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -48,32 +48,32 @@ namespace Indeo {
* startup from these descriptors.
*/
- /**
- * Static macroblock huffman tables
- */
+/**
+ * Static macroblock huffman tables
+ */
static const IVIHuffDesc ivi_mb_huff_desc[8] = {
- {8, {0, 4, 5, 4, 4, 4, 6, 6}},
- {12, {0, 2, 2, 3, 3, 3, 3, 5, 3, 2, 2, 2}},
- {12, {0, 2, 3, 4, 3, 3, 3, 3, 4, 3, 2, 2}},
- {12, {0, 3, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2}},
- {13, {0, 4, 4, 3, 3, 3, 3, 2, 3, 3, 2, 1, 1}},
- {9, {0, 4, 4, 4, 4, 3, 3, 3, 2}},
- {10, {0, 4, 4, 4, 4, 3, 3, 2, 2, 2}},
- {12, {0, 4, 4, 4, 3, 3, 2, 3, 2, 2, 2, 2}}
+ {8, {0, 4, 5, 4, 4, 4, 6, 6}},
+ {12, {0, 2, 2, 3, 3, 3, 3, 5, 3, 2, 2, 2}},
+ {12, {0, 2, 3, 4, 3, 3, 3, 3, 4, 3, 2, 2}},
+ {12, {0, 3, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2}},
+ {13, {0, 4, 4, 3, 3, 3, 3, 2, 3, 3, 2, 1, 1}},
+ {9, {0, 4, 4, 4, 4, 3, 3, 3, 2}},
+ {10, {0, 4, 4, 4, 4, 3, 3, 2, 2, 2}},
+ {12, {0, 4, 4, 4, 3, 3, 2, 3, 2, 2, 2, 2}}
};
/**
* static block huffman tables
*/
static const IVIHuffDesc ivi_blk_huff_desc[8] = {
- {10, {1, 2, 3, 4, 4, 7, 5, 5, 4, 1}},
- {11, {2, 3, 4, 4, 4, 7, 5, 4, 3, 3, 2}},
- {12, {2, 4, 5, 5, 5, 5, 6, 4, 4, 3, 1, 1}},
- {13, {3, 3, 4, 4, 5, 6, 6, 4, 4, 3, 2, 1, 1}},
- {11, {3, 4, 4, 5, 5, 5, 6, 5, 4, 2, 2}},
- {13, {3, 4, 5, 5, 5, 5, 6, 4, 3, 3, 2, 1, 1}},
- {13, {3, 4, 5, 5, 5, 6, 5, 4, 3, 3, 2, 1, 1}},
- {9, {3, 4, 4, 5, 5, 5, 6, 5, 5}}
+ {10, {1, 2, 3, 4, 4, 7, 5, 5, 4, 1} },
+ {11, {2, 3, 4, 4, 4, 7, 5, 4, 3, 3, 2} },
+ {12, {2, 4, 5, 5, 5, 5, 6, 4, 4, 3, 1, 1} },
+ {13, {3, 3, 4, 4, 5, 6, 6, 4, 4, 3, 2, 1, 1} },
+ {11, {3, 4, 4, 5, 5, 5, 6, 5, 4, 2, 2} },
+ {13, {3, 4, 5, 5, 5, 5, 6, 4, 3, 3, 2, 1, 1} },
+ {13, {3, 4, 5, 5, 5, 6, 5, 4, 3, 3, 2, 1, 1} },
+ {9, {3, 4, 4, 5, 5, 5, 6, 5, 5} }
};
/*------------------------------------------------------------------------*/
@@ -86,36 +86,36 @@ static const IVIHuffDesc ivi_blk_huff_desc[8] = {
/*------------------------------------------------------------------------*/
int IVIHuffDesc::createHuffFromDesc(VLC *vlc, bool flag) const {
- int pos, i, j, codesPerRow, prefix, notLastRow;
- uint16 codewords[256];
- uint8 bits[256];
+ int pos, i, j, codesPerRow, prefix, notLastRow;
+ uint16 codewords[256];
+ uint8 bits[256];
- pos = 0; // current position = 0
+ pos = 0; // current position = 0
- for (i = 0; i < _numRows; i++) {
- codesPerRow = 1 << _xBits[i];
- notLastRow = (i != _numRows - 1);
- prefix = ((1 << i) - 1) << (_xBits[i] + notLastRow);
+ for (i = 0; i < _numRows; i++) {
+ codesPerRow = 1 << _xBits[i];
+ notLastRow = (i != _numRows - 1);
+ prefix = ((1 << i) - 1) << (_xBits[i] + notLastRow);
- for (j = 0; j < codesPerRow; j++) {
- if (pos >= 256) // Some Indeo5 codebooks can have more than 256
- break; // elements, but only 256 codes are allowed!
+ for (j = 0; j < codesPerRow; j++) {
+ if (pos >= 256) // Some Indeo5 codebooks can have more than 256
+ break; // elements, but only 256 codes are allowed!
- bits[pos] = i + _xBits[i] + notLastRow;
- if (bits[pos] > IVI_VLC_BITS)
- return -1; // invalid descriptor
+ bits[pos] = i + _xBits[i] + notLastRow;
+ if (bits[pos] > IVI_VLC_BITS)
+ return -1; // invalid descriptor
- codewords[pos] = invertBits((prefix | j), bits[pos]);
- if (!bits[pos])
- bits[pos] = 1;
+ codewords[pos] = invertBits((prefix | j), bits[pos]);
+ if (!bits[pos])
+ bits[pos] = 1;
- pos++;
- }//for j
- }//for i
+ pos++;
+ }//for j
+ }//for i
- // number of codewords = pos
+ // number of codewords = pos
return vlc->init_vlc(IVI_VLC_BITS, pos, bits, 1, 1, codewords, 2, 2,
- (flag ? INIT_VLC_USE_NEW_STATIC : 0) | INIT_VLC_LE);
+ (flag ? INIT_VLC_USE_NEW_STATIC : 0) | INIT_VLC_LE);
}
/*------------------------------------------------------------------------*/
@@ -957,7 +957,7 @@ int IndeoDecoderBase::processEmptyTile(IVIBandDesc *band,
mb->_bufOffs = mbOffset;
mb->_type = 1; // set the macroblocks _type = INTER
- mb->_cbp = 0; // all blocks are empty
+ mb->_cbp = 0; // all blocks are empty
if (!band->_qdeltaPresent && !band->_plane && !band->_bandNum) {
mb->_qDelta = band->_globQuant;
@@ -1059,138 +1059,138 @@ int IndeoDecoderBase::decodeTileDataSize(GetBits *gb) {
}
int IndeoDecoderBase::decodeBlocks(GetBits *_gb, IVIBandDesc *band, IVITile *tile) {
- int mbn, blk, numBlocks, blkSize, ret, isIntra;
- int mcType = 0, mcType2 = -1;
- int mvX = 0, mvY = 0, mvX2 = 0, mvY2 = 0;
- int32 prevDc;
- uint32 cbp, quant, bufOffs;
- IVIMbInfo *mb;
- IviMCFunc mcWithDeltaFunc, mcNoDeltaFunc;
- IviMCAvgFunc mcAvgWithDeltaFunc, mcAvgNoDeltaFunc;
- const uint8 *scaleTab;
-
- // init intra prediction for the DC coefficient
- prevDc = 0;
- blkSize = band->_blkSize;
- // number of blocks per mb
- numBlocks = (band->_mbSize != blkSize) ? 4 : 1;
- if (blkSize == 8) {
- mcWithDeltaFunc = IndeoDSP::ffIviMc8x8Delta;
- mcNoDeltaFunc = IndeoDSP::ffIviMc8x8NoDelta;
- mcAvgWithDeltaFunc = IndeoDSP::ffIviMcAvg8x8Delta;
- mcAvgNoDeltaFunc = IndeoDSP::ffIviMcAvg8x8NoDelta;
- } else {
- mcWithDeltaFunc = IndeoDSP::ffIviMc4x4Delta;
- mcNoDeltaFunc = IndeoDSP::ffIviMc4x4NoDelta;
- mcAvgWithDeltaFunc = IndeoDSP::ffIviMcAvg4x4Delta;
- mcAvgNoDeltaFunc = IndeoDSP::ffIviMcAvg4x4NoDelta;
- }
-
- for (mbn = 0, mb = tile->_mbs; mbn < tile->_numMBs; mb++, mbn++) {
- isIntra = !mb->_type;
- cbp = mb->_cbp;
- bufOffs = mb->_bufOffs;
-
- quant = band->_globQuant + mb->_qDelta;
- if (_ctx._isIndeo4)
- quant = avClipUintp2(quant, 5);
- else
- quant = av_clip((int)quant, 0, 23);
-
- scaleTab = isIntra ? band->_intraScale : band->_interScale;
- if (scaleTab)
- quant = scaleTab[quant];
-
- if (!isIntra) {
- mvX = mb->_mvX;
- mvY = mb->_mvY;
- mvX2 = mb->_bMvX;
- mvY2 = mb->_bMvY;
- if (band->_isHalfpel) {
- mcType = ((mvY & 1) << 1) | (mvX & 1);
- mcType2 = ((mvY2 & 1) << 1) | (mvX2 & 1);
- mvX >>= 1;
- mvY >>= 1;
- mvX2 >>= 1;
- mvY2 >>= 1; // convert halfpel vectors into fullpel ones
- }
- if (mb->_type == 2)
- mcType = -1;
- if (mb->_type != 2 && mb->_type != 3)
- mcType2 = -1;
- if (mb->_type) {
- int dmv_x, dmv_y, cx, cy;
-
- dmv_x = mb->_mvX >> band->_isHalfpel;
- dmv_y = mb->_mvY >> band->_isHalfpel;
- cx = mb->_mvX & band->_isHalfpel;
- cy = mb->_mvY & band->_isHalfpel;
-
- if (mb->_xPos + dmv_x < 0 ||
- mb->_xPos + dmv_x + band->_mbSize + cx > band->_pitch ||
- mb->_yPos + dmv_y < 0 ||
- mb->_yPos + dmv_y + band->_mbSize + cy > band->_aHeight) {
- return -1;
- }
- }
- if (mb->_type == 2 || mb->_type == 3) {
- int dmv_x, dmv_y, cx, cy;
-
- dmv_x = mb->_bMvX >> band->_isHalfpel;
- dmv_y = mb->_bMvY >> band->_isHalfpel;
- cx = mb->_bMvX & band->_isHalfpel;
- cy = mb->_bMvY & band->_isHalfpel;
-
- if (mb->_xPos + dmv_x < 0 ||
- mb->_xPos + dmv_x + band->_mbSize + cx > band->_pitch ||
- mb->_yPos + dmv_y < 0 ||
- mb->_yPos + dmv_y + band->_mbSize + cy > band->_aHeight) {
- return -1;
- }
- }
- }
-
- for (blk = 0; blk < numBlocks; blk++) {
- // adjust block position in the buffer according to its number
- if (blk & 1) {
- bufOffs += blkSize;
- } else if (blk == 2) {
- bufOffs -= blkSize;
- bufOffs += blkSize * band->_pitch;
- }
-
- if (cbp & 1) { // block coded ?
- ret = ivi_decode_coded_blocks(_gb, band, mcWithDeltaFunc,
- mcAvgWithDeltaFunc,
- mvX, mvY, mvX2, mvY2,
- &prevDc, isIntra,
- mcType, mcType2, quant,
- bufOffs);
- if (ret < 0)
- return ret;
- } else {
- // block not coded
- // for intra blocks apply the dc slant transform
- // for inter - perform the motion compensation without delta
- if (isIntra) {
- ret = ivi_dc_transform(band, &prevDc, bufOffs, blkSize);
- if (ret < 0)
- return ret;
- } else {
- ret = iviMc(band, mcNoDeltaFunc, mcAvgNoDeltaFunc,
- bufOffs, mvX, mvY, mvX2, mvY2,
- mcType, mcType2);
- if (ret < 0)
- return ret;
- }
- }
-
- cbp >>= 1;
- }// for blk
- }// for mbn
+ int mbn, blk, numBlocks, blkSize, ret, isIntra;
+ int mcType = 0, mcType2 = -1;
+ int mvX = 0, mvY = 0, mvX2 = 0, mvY2 = 0;
+ int32 prevDc;
+ uint32 cbp, quant, bufOffs;
+ IVIMbInfo *mb;
+ IviMCFunc mcWithDeltaFunc, mcNoDeltaFunc;
+ IviMCAvgFunc mcAvgWithDeltaFunc, mcAvgNoDeltaFunc;
+ const uint8 *scaleTab;
+
+ // init intra prediction for the DC coefficient
+ prevDc = 0;
+ blkSize = band->_blkSize;
+ // number of blocks per mb
+ numBlocks = (band->_mbSize != blkSize) ? 4 : 1;
+ if (blkSize == 8) {
+ mcWithDeltaFunc = IndeoDSP::ffIviMc8x8Delta;
+ mcNoDeltaFunc = IndeoDSP::ffIviMc8x8NoDelta;
+ mcAvgWithDeltaFunc = IndeoDSP::ffIviMcAvg8x8Delta;
+ mcAvgNoDeltaFunc = IndeoDSP::ffIviMcAvg8x8NoDelta;
+ } else {
+ mcWithDeltaFunc = IndeoDSP::ffIviMc4x4Delta;
+ mcNoDeltaFunc = IndeoDSP::ffIviMc4x4NoDelta;
+ mcAvgWithDeltaFunc = IndeoDSP::ffIviMcAvg4x4Delta;
+ mcAvgNoDeltaFunc = IndeoDSP::ffIviMcAvg4x4NoDelta;
+ }
+
+ for (mbn = 0, mb = tile->_mbs; mbn < tile->_numMBs; mb++, mbn++) {
+ isIntra = !mb->_type;
+ cbp = mb->_cbp;
+ bufOffs = mb->_bufOffs;
+
+ quant = band->_globQuant + mb->_qDelta;
+ if (_ctx._isIndeo4)
+ quant = avClipUintp2(quant, 5);
+ else
+ quant = av_clip((int)quant, 0, 23);
+
+ scaleTab = isIntra ? band->_intraScale : band->_interScale;
+ if (scaleTab)
+ quant = scaleTab[quant];
+
+ if (!isIntra) {
+ mvX = mb->_mvX;
+ mvY = mb->_mvY;
+ mvX2 = mb->_bMvX;
+ mvY2 = mb->_bMvY;
+ if (band->_isHalfpel) {
+ mcType = ((mvY & 1) << 1) | (mvX & 1);
+ mcType2 = ((mvY2 & 1) << 1) | (mvX2 & 1);
+ mvX >>= 1;
+ mvY >>= 1;
+ mvX2 >>= 1;
+ mvY2 >>= 1; // convert halfpel vectors into fullpel ones
+ }
+ if (mb->_type == 2)
+ mcType = -1;
+ if (mb->_type != 2 && mb->_type != 3)
+ mcType2 = -1;
+ if (mb->_type) {
+ int dmv_x, dmv_y, cx, cy;
+
+ dmv_x = mb->_mvX >> band->_isHalfpel;
+ dmv_y = mb->_mvY >> band->_isHalfpel;
+ cx = mb->_mvX & band->_isHalfpel;
+ cy = mb->_mvY & band->_isHalfpel;
+
+ if (mb->_xPos + dmv_x < 0 ||
+ mb->_xPos + dmv_x + band->_mbSize + cx > band->_pitch ||
+ mb->_yPos + dmv_y < 0 ||
+ mb->_yPos + dmv_y + band->_mbSize + cy > band->_aHeight) {
+ return -1;
+ }
+ }
+ if (mb->_type == 2 || mb->_type == 3) {
+ int dmv_x, dmv_y, cx, cy;
+
+ dmv_x = mb->_bMvX >> band->_isHalfpel;
+ dmv_y = mb->_bMvY >> band->_isHalfpel;
+ cx = mb->_bMvX & band->_isHalfpel;
+ cy = mb->_bMvY & band->_isHalfpel;
+
+ if (mb->_xPos + dmv_x < 0 ||
+ mb->_xPos + dmv_x + band->_mbSize + cx > band->_pitch ||
+ mb->_yPos + dmv_y < 0 ||
+ mb->_yPos + dmv_y + band->_mbSize + cy > band->_aHeight) {
+ return -1;
+ }
+ }
+ }
+
+ for (blk = 0; blk < numBlocks; blk++) {
+ // adjust block position in the buffer according to its number
+ if (blk & 1) {
+ bufOffs += blkSize;
+ } else if (blk == 2) {
+ bufOffs -= blkSize;
+ bufOffs += blkSize * band->_pitch;
+ }
+
+ if (cbp & 1) { // block coded ?
+ ret = ivi_decode_coded_blocks(_gb, band, mcWithDeltaFunc,
+ mcAvgWithDeltaFunc,
+ mvX, mvY, mvX2, mvY2,
+ &prevDc, isIntra,
+ mcType, mcType2, quant,
+ bufOffs);
+ if (ret < 0)
+ return ret;
+ } else {
+ // block not coded
+ // for intra blocks apply the dc slant transform
+ // for inter - perform the motion compensation without delta
+ if (isIntra) {
+ ret = ivi_dc_transform(band, &prevDc, bufOffs, blkSize);
+ if (ret < 0)
+ return ret;
+ } else {
+ ret = iviMc(band, mcNoDeltaFunc, mcAvgNoDeltaFunc,
+ bufOffs, mvX, mvY, mvX2, mvY2,
+ mcType, mcType2);
+ if (ret < 0)
+ return ret;
+ }
+ }
+
+ cbp >>= 1;
+ }// for blk
+ }// for mbn
_gb->align();
- return 0;
+ return 0;
}
int IndeoDecoderBase::scaleMV(int mv, int mvScale) {
@@ -1198,39 +1198,39 @@ int IndeoDecoderBase::scaleMV(int mv, int mvScale) {
}
int IndeoDecoderBase::iviMc(IVIBandDesc *band, IviMCFunc mc, IviMCAvgFunc mcAvg,
- int offs, int mvX, int mvY, int mvX2, int mvY2,
- int mcType, int mcType2) {
- int refOffs = offs + mvY * band->_pitch + mvX;
- int bufSize = band->_pitch * band->_aHeight;
- int minSize = band->_pitch * (band->_blkSize - 1) + band->_blkSize;
- int refSize = (mcType > 1) * band->_pitch + (mcType & 1);
-
- if (mcType != -1) {
- assert(offs >= 0 && refOffs >= 0 && band->_refBuf);
- assert(bufSize - minSize >= offs);
- assert(bufSize - minSize - refSize >= refOffs);
- }
-
- if (mcType2 == -1) {
- mc(band->_buf + offs, band->_refBuf + refOffs, band->_pitch, mcType);
- } else {
- int ref_offs2 = offs + mvY2 * band->_pitch + mvX2;
- int ref_size2 = (mcType2 > 1) * band->_pitch + (mcType2 & 1);
- if (offs < 0 || ref_offs2 < 0 || !band->_bRefBuf)
- return -1;
- if (bufSize - minSize - ref_size2 < ref_offs2)
- return -1;
-
- if (mcType == -1)
- mc(band->_buf + offs, band->_bRefBuf + ref_offs2,
- band->_pitch, mcType2);
- else
- mcAvg(band->_buf + offs, band->_refBuf + refOffs,
- band->_bRefBuf + ref_offs2, band->_pitch,
- mcType, mcType2);
- }
-
- return 0;
+ int offs, int mvX, int mvY, int mvX2, int mvY2,
+ int mcType, int mcType2) {
+ int refOffs = offs + mvY * band->_pitch + mvX;
+ int bufSize = band->_pitch * band->_aHeight;
+ int minSize = band->_pitch * (band->_blkSize - 1) + band->_blkSize;
+ int refSize = (mcType > 1) * band->_pitch + (mcType & 1);
+
+ if (mcType != -1) {
+ assert(offs >= 0 && refOffs >= 0 && band->_refBuf);
+ assert(bufSize - minSize >= offs);
+ assert(bufSize - minSize - refSize >= refOffs);
+ }
+
+ if (mcType2 == -1) {
+ mc(band->_buf + offs, band->_refBuf + refOffs, band->_pitch, mcType);
+ } else {
+ int ref_offs2 = offs + mvY2 * band->_pitch + mvX2;
+ int ref_size2 = (mcType2 > 1) * band->_pitch + (mcType2 & 1);
+ if (offs < 0 || ref_offs2 < 0 || !band->_bRefBuf)
+ return -1;
+ if (bufSize - minSize - ref_size2 < ref_offs2)
+ return -1;
+
+ if (mcType == -1)
+ mc(band->_buf + offs, band->_bRefBuf + ref_offs2,
+ band->_pitch, mcType2);
+ else
+ mcAvg(band->_buf + offs, band->_refBuf + refOffs,
+ band->_bRefBuf + ref_offs2, band->_pitch,
+ mcType, mcType2);
+ }
+
+ return 0;
}
int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
@@ -1374,355 +1374,355 @@ const uint8 IndeoDecoderBase::_ffIviDirectScan4x4[16] = {
const RVMapDesc IVI45DecContext::_ff_ivi_rvmap_tabs[9] = {
{ // MapTab0
- 5, // _eobSym
- 2, // _escSym
- // run table
- {1, 1, 0, 1, 1, 0, 1, 1, 2, 2, 1, 1, 1, 1, 3, 3,
- 1, 1, 2, 2, 1, 1, 4, 4, 1, 1, 1, 1, 2, 2, 5, 5,
- 1, 1, 3, 3, 1, 1, 6, 6, 1, 2, 1, 2, 7, 7, 1, 1,
- 8, 8, 1, 1, 4, 2, 1, 4, 2, 1, 3, 3, 1, 1, 1, 9,
- 9, 1, 2, 1, 2, 1, 5, 5, 1, 1, 10, 10, 1, 1, 3, 3,
- 2, 2, 1, 1, 11, 11, 6, 4, 4, 1, 6, 1, 2, 1, 2, 12,
- 8, 1, 12, 7, 8, 7, 1, 16, 1, 16, 1, 3, 3, 13, 1, 13,
- 2, 2, 1, 15, 1, 5, 14, 15, 1, 5, 14, 1, 17, 8, 17, 8,
- 1, 4, 4, 2, 2, 1, 25, 25, 24, 24, 1, 3, 1, 3, 1, 8,
- 6, 7, 6, 1, 18, 8, 18, 1, 7, 23, 2, 2, 23, 1, 1, 21,
- 22, 9, 9, 22, 19, 1, 21, 5, 19, 5, 1, 33, 20, 33, 20, 8,
- 4, 4, 1, 32, 2, 2, 8, 3, 32, 26, 3, 1, 7, 7, 26, 6,
- 1, 6, 1, 1, 16, 1, 10, 1, 10, 2, 16, 29, 28, 2, 29, 28,
- 1, 27, 5, 8, 5, 27, 1, 8, 3, 7, 3, 31, 41, 31, 1, 41,
- 6, 1, 6, 7, 4, 4, 1, 1, 2, 1, 2, 11, 34, 30, 11, 1,
- 30, 15, 15, 34, 36, 40, 36, 40, 35, 35, 37, 37, 39, 39, 38, 38},
-
- // value table
- { 1, -1, 0, 2, -2, 0, 3, -3, 1, -1, 4, -4, 5, -5, 1, -1,
- 6, -6, 2, -2, 7, -7, 1, -1, 8, -8, 9, -9, 3, -3, 1, -1,
- 10, -10, 2, -2, 11, -11, 1, -1, 12, 4, -12, -4, 1, -1, 13, -13,
- 1, -1, 14, -14, 2, 5, 15, -2, -5, -15, -3, 3, 16, -16, 17, 1,
- -1, -17, 6, 18, -6, -18, 2, -2, 19, -19, 1, -1, 20, -20, 4, -4,
- 7, -7, 21, -21, 1, -1, 2, 3, -3, 22, -2, -22, 8, 23, -8, 1,
- 2, -23, -1, 2, -2, -2, 24, 1, -24, -1, 25, 5, -5, 1, -25, -1,
- 9, -9, 26, 1, -26, 3, 1, -1, 27, -3, -1, -27, 1, 3, -1, -3,
- 28, -4, 4, 10, -10, -28, 1, -1, 1, -1, 29, 6, -29, -6, 30, -4,
- 3, 3, -3, -30, 1, 4, -1, 31, -3, 1, 11, -11, -1, -31, 32, -1,
- -1, 2, -2, 1, 1, -32, 1, 4, -1, -4, 33, -1, 1, 1, -1, 5,
- 5, -5, -33, -1, -12, 12, -5, -7, 1, 1, 7, 34, 4, -4, -1, 4,
- -34, -4, 35, 36, -2, -35, -2, -36, 2, 13, 2, -1, 1, -13, 1, -1,
- 37, 1, -5, 6, 5, -1, 38, -6, -8, 5, 8, -1, 1, 1, -37, -1,
- 5, 39, -5, -5, 6, -6, -38, -39, -14, 40, 14, 2, 1, 1, -2, -40,
- -1, -2, 2, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1}
+ 5, // _eobSym
+ 2, // _escSym
+ // run table
+ {1, 1, 0, 1, 1, 0, 1, 1, 2, 2, 1, 1, 1, 1, 3, 3,
+ 1, 1, 2, 2, 1, 1, 4, 4, 1, 1, 1, 1, 2, 2, 5, 5,
+ 1, 1, 3, 3, 1, 1, 6, 6, 1, 2, 1, 2, 7, 7, 1, 1,
+ 8, 8, 1, 1, 4, 2, 1, 4, 2, 1, 3, 3, 1, 1, 1, 9,
+ 9, 1, 2, 1, 2, 1, 5, 5, 1, 1, 10, 10, 1, 1, 3, 3,
+ 2, 2, 1, 1, 11, 11, 6, 4, 4, 1, 6, 1, 2, 1, 2, 12,
+ 8, 1, 12, 7, 8, 7, 1, 16, 1, 16, 1, 3, 3, 13, 1, 13,
+ 2, 2, 1, 15, 1, 5, 14, 15, 1, 5, 14, 1, 17, 8, 17, 8,
+ 1, 4, 4, 2, 2, 1, 25, 25, 24, 24, 1, 3, 1, 3, 1, 8,
+ 6, 7, 6, 1, 18, 8, 18, 1, 7, 23, 2, 2, 23, 1, 1, 21,
+ 22, 9, 9, 22, 19, 1, 21, 5, 19, 5, 1, 33, 20, 33, 20, 8,
+ 4, 4, 1, 32, 2, 2, 8, 3, 32, 26, 3, 1, 7, 7, 26, 6,
+ 1, 6, 1, 1, 16, 1, 10, 1, 10, 2, 16, 29, 28, 2, 29, 28,
+ 1, 27, 5, 8, 5, 27, 1, 8, 3, 7, 3, 31, 41, 31, 1, 41,
+ 6, 1, 6, 7, 4, 4, 1, 1, 2, 1, 2, 11, 34, 30, 11, 1,
+ 30, 15, 15, 34, 36, 40, 36, 40, 35, 35, 37, 37, 39, 39, 38, 38},
+
+ // value table
+ { 1, -1, 0, 2, -2, 0, 3, -3, 1, -1, 4, -4, 5, -5, 1, -1,
+ 6, -6, 2, -2, 7, -7, 1, -1, 8, -8, 9, -9, 3, -3, 1, -1,
+ 10, -10, 2, -2, 11, -11, 1, -1, 12, 4, -12, -4, 1, -1, 13, -13,
+ 1, -1, 14, -14, 2, 5, 15, -2, -5, -15, -3, 3, 16, -16, 17, 1,
+ -1, -17, 6, 18, -6, -18, 2, -2, 19, -19, 1, -1, 20, -20, 4, -4,
+ 7, -7, 21, -21, 1, -1, 2, 3, -3, 22, -2, -22, 8, 23, -8, 1,
+ 2, -23, -1, 2, -2, -2, 24, 1, -24, -1, 25, 5, -5, 1, -25, -1,
+ 9, -9, 26, 1, -26, 3, 1, -1, 27, -3, -1, -27, 1, 3, -1, -3,
+ 28, -4, 4, 10, -10, -28, 1, -1, 1, -1, 29, 6, -29, -6, 30, -4,
+ 3, 3, -3, -30, 1, 4, -1, 31, -3, 1, 11, -11, -1, -31, 32, -1,
+ -1, 2, -2, 1, 1, -32, 1, 4, -1, -4, 33, -1, 1, 1, -1, 5,
+ 5, -5, -33, -1, -12, 12, -5, -7, 1, 1, 7, 34, 4, -4, -1, 4,
+ -34, -4, 35, 36, -2, -35, -2, -36, 2, 13, 2, -1, 1, -13, 1, -1,
+ 37, 1, -5, 6, 5, -1, 38, -6, -8, 5, 8, -1, 1, 1, -37, -1,
+ 5, 39, -5, -5, 6, -6, -38, -39, -14, 40, 14, 2, 1, 1, -2, -40,
+ -1, -2, 2, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1}
},{
- // MapTab1
- 0, // _eobSym
- 38, // _escSym
- // run table
- {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 8, 6, 8, 7,
- 7, 9, 9, 10, 10, 11, 11, 1, 12, 1, 12, 13, 13, 16, 14, 16,
- 14, 15, 15, 17, 17, 18, 0, 18, 19, 20, 21, 19, 22, 21, 20, 22,
- 25, 24, 2, 25, 24, 23, 23, 2, 26, 28, 26, 28, 29, 27, 29, 27,
- 33, 33, 1, 32, 1, 3, 32, 30, 36, 3, 36, 30, 31, 31, 35, 34,
- 37, 41, 34, 35, 37, 4, 41, 4, 49, 8, 8, 49, 40, 38, 5, 38,
- 40, 39, 5, 39, 42, 43, 42, 7, 57, 6, 43, 44, 6, 50, 7, 44,
- 57, 48, 50, 48, 45, 45, 46, 47, 51, 46, 47, 58, 1, 51, 58, 1,
- 52, 59, 53, 9, 52, 55, 55, 59, 53, 56, 54, 56, 54, 9, 64, 64,
- 60, 63, 60, 63, 61, 62, 61, 62, 2, 10, 2, 10, 11, 1, 11, 13,
- 12, 1, 12, 13, 16, 16, 8, 8, 14, 3, 3, 15, 14, 15, 4, 4,
- 1, 17, 17, 5, 1, 7, 7, 5, 6, 1, 2, 2, 6, 22, 1, 25,
- 21, 22, 8, 24, 1, 21, 25, 24, 8, 18, 18, 23, 9, 20, 23, 33,
- 29, 33, 20, 1, 19, 1, 29, 36, 9, 36, 19, 41, 28, 57, 32, 3,
- 28, 3, 1, 27, 49, 49, 1, 32, 26, 26, 2, 4, 4, 7, 57, 41,
- 2, 7, 10, 5, 37, 16, 10, 27, 8, 8, 13, 16, 37, 13, 1, 5},
-
- // value table
- {0, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1,
- -1, 1, -1, 1, -1, 1, -1, 2, 1, -2, -1, 1, -1, 1, 1, -1,
- -1, 1, -1, 1, -1, 1, 0, -1, 1, 1, 1, -1, 1, -1, -1, -1,
- 1, 1, 2, -1, -1, 1, -1, -2, 1, 1, -1, -1, 1, 1, -1, -1,
- 1, -1, 3, 1, -3, 2, -1, 1, 1, -2, -1, -1, -1, 1, 1, 1,
- 1, 1, -1, -1, -1, 2, -1, -2, 1, 2, -2, -1, 1, 1, 2, -1,
- -1, 1, -2, -1, 1, 1, -1, 2, 1, 2, -1, 1, -2, -1, -2, -1,
- -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 4, -1, -1, -4,
- 1, 1, 1, 2, -1, -1, 1, -1, -1, 1, -1, -1, 1, -2, 1, -1,
- 1, 1, -1, -1, 1, 1, -1, -1, 3, 2, -3, -2, 2, 5, -2, 2,
- 2, -5, -2, -2, -2, 2, -3, 3, 2, 3, -3, 2, -2, -2, 3, -3,
- 6, 2, -2, 3, -6, 3, -3, -3, 3, 7, -4, 4, -3, 2, -7, 2,
- 2, -2, -4, 2, 8, -2, -2, -2, 4, 2, -2, 2, 3, 2, -2, -2,
- 2, 2, -2, -8, -2, 9, -2, 2, -3, -2, 2, -2, 2, 2, 2, 4,
- -2, -4, 10, 2, 2, -2, -9, -2, 2, -2, 5, 4, -4, 4, -2, 2,
- -5, -4, -3, 4, 2, -3, 3, -2, -5, 5, 3, 3, -2, -3, -10, -4}
+ // MapTab1
+ 0, // _eobSym
+ 38, // _escSym
+ // run table
+ {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 8, 6, 8, 7,
+ 7, 9, 9, 10, 10, 11, 11, 1, 12, 1, 12, 13, 13, 16, 14, 16,
+ 14, 15, 15, 17, 17, 18, 0, 18, 19, 20, 21, 19, 22, 21, 20, 22,
+ 25, 24, 2, 25, 24, 23, 23, 2, 26, 28, 26, 28, 29, 27, 29, 27,
+ 33, 33, 1, 32, 1, 3, 32, 30, 36, 3, 36, 30, 31, 31, 35, 34,
+ 37, 41, 34, 35, 37, 4, 41, 4, 49, 8, 8, 49, 40, 38, 5, 38,
+ 40, 39, 5, 39, 42, 43, 42, 7, 57, 6, 43, 44, 6, 50, 7, 44,
+ 57, 48, 50, 48, 45, 45, 46, 47, 51, 46, 47, 58, 1, 51, 58, 1,
+ 52, 59, 53, 9, 52, 55, 55, 59, 53, 56, 54, 56, 54, 9, 64, 64,
+ 60, 63, 60, 63, 61, 62, 61, 62, 2, 10, 2, 10, 11, 1, 11, 13,
+ 12, 1, 12, 13, 16, 16, 8, 8, 14, 3, 3, 15, 14, 15, 4, 4,
+ 1, 17, 17, 5, 1, 7, 7, 5, 6, 1, 2, 2, 6, 22, 1, 25,
+ 21, 22, 8, 24, 1, 21, 25, 24, 8, 18, 18, 23, 9, 20, 23, 33,
+ 29, 33, 20, 1, 19, 1, 29, 36, 9, 36, 19, 41, 28, 57, 32, 3,
+ 28, 3, 1, 27, 49, 49, 1, 32, 26, 26, 2, 4, 4, 7, 57, 41,
+ 2, 7, 10, 5, 37, 16, 10, 27, 8, 8, 13, 16, 37, 13, 1, 5},
+
+ // value table
+ {0, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1,
+ -1, 1, -1, 1, -1, 1, -1, 2, 1, -2, -1, 1, -1, 1, 1, -1,
+ -1, 1, -1, 1, -1, 1, 0, -1, 1, 1, 1, -1, 1, -1, -1, -1,
+ 1, 1, 2, -1, -1, 1, -1, -2, 1, 1, -1, -1, 1, 1, -1, -1,
+ 1, -1, 3, 1, -3, 2, -1, 1, 1, -2, -1, -1, -1, 1, 1, 1,
+ 1, 1, -1, -1, -1, 2, -1, -2, 1, 2, -2, -1, 1, 1, 2, -1,
+ -1, 1, -2, -1, 1, 1, -1, 2, 1, 2, -1, 1, -2, -1, -2, -1,
+ -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 4, -1, -1, -4,
+ 1, 1, 1, 2, -1, -1, 1, -1, -1, 1, -1, -1, 1, -2, 1, -1,
+ 1, 1, -1, -1, 1, 1, -1, -1, 3, 2, -3, -2, 2, 5, -2, 2,
+ 2, -5, -2, -2, -2, 2, -3, 3, 2, 3, -3, 2, -2, -2, 3, -3,
+ 6, 2, -2, 3, -6, 3, -3, -3, 3, 7, -4, 4, -3, 2, -7, 2,
+ 2, -2, -4, 2, 8, -2, -2, -2, 4, 2, -2, 2, 3, 2, -2, -2,
+ 2, 2, -2, -8, -2, 9, -2, 2, -3, -2, 2, -2, 2, 2, 2, 4,
+ -2, -4, 10, 2, 2, -2, -9, -2, 2, -2, 5, 4, -4, 4, -2, 2,
+ -5, -4, -3, 4, 2, -3, 3, -2, -5, 5, 3, 3, -2, -3, -10, -4}
},{
- // MapTab2
- 2, // _eobSym
- 11, // _escSym
- // run table
- {1, 1, 0, 2, 2, 1, 1, 3, 3, 4, 4, 0, 1, 1, 5, 5,
- 2, 2, 6, 6, 7, 7, 1, 8, 1, 8, 3, 3, 9, 9, 1, 2,
- 2, 1, 4, 10, 4, 10, 11, 11, 1, 5, 12, 12, 1, 5, 13, 13,
- 3, 3, 6, 6, 2, 2, 14, 14, 16, 16, 15, 7, 15, 8, 8, 7,
- 1, 1, 17, 17, 4, 4, 1, 1, 18, 18, 2, 2, 5, 5, 25, 3,
- 9, 3, 25, 9, 19, 24, 19, 24, 1, 21, 20, 1, 21, 22, 20, 22,
- 23, 23, 8, 6, 33, 6, 8, 33, 7, 7, 26, 26, 1, 32, 1, 32,
- 28, 4, 28, 10, 29, 27, 27, 10, 41, 4, 29, 2, 2, 41, 36, 31,
- 49, 31, 34, 30, 34, 36, 30, 35, 1, 49, 11, 5, 35, 11, 1, 3,
- 3, 5, 37, 37, 8, 40, 8, 40, 12, 12, 42, 42, 1, 38, 16, 57,
- 1, 6, 16, 39, 38, 6, 7, 7, 13, 13, 39, 43, 2, 43, 57, 2,
- 50, 9, 44, 9, 50, 4, 15, 48, 44, 4, 1, 15, 48, 14, 14, 1,
- 45, 45, 8, 3, 5, 8, 51, 47, 3, 46, 46, 47, 5, 51, 1, 17,
- 17, 58, 1, 58, 2, 52, 52, 2, 53, 7, 59, 6, 6, 56, 53, 55,
- 7, 55, 1, 54, 59, 56, 54, 10, 1, 10, 4, 60, 1, 60, 8, 4,
- 8, 64, 64, 61, 1, 63, 3, 63, 62, 61, 5, 11, 5, 3, 11, 62},
-
- // value table
- { 1, -1, 0, 1, -1, 2, -2, 1, -1, 1, -1, 0, 3, -3, 1, -1,
- 2, -2, 1, -1, 1, -1, 4, 1, -4, -1, 2, -2, 1, -1, 5, 3,
- -3, -5, 2, 1, -2, -1, 1, -1, 6, 2, 1, -1, -6, -2, 1, -1,
- 3, -3, 2, -2, 4, -4, 1, -1, 1, -1, 1, 2, -1, 2, -2, -2,
- 7, -7, 1, -1, 3, -3, 8, -8, 1, -1, 5, -5, 3, -3, 1, 4,
- 2, -4, -1, -2, 1, 1, -1, -1, 9, 1, 1, -9, -1, 1, -1, -1,
- 1, -1, 3, -3, 1, 3, -3, -1, 3, -3, 1, -1, 10, 1, -10, -1,
- 1, 4, -1, 2, 1, -1, 1, -2, 1, -4, -1, 6, -6, -1, 1, 1,
- 1, -1, 1, 1, -1, -1, -1, 1, 11, -1, -2, 4, -1, 2, -11, 5,
- -5, -4, -1, 1, 4, 1, -4, -1, -2, 2, 1, -1, 12, 1, -2, 1,
- -12, 4, 2, 1, -1, -4, 4, -4, 2, -2, -1, 1, 7, -1, -1, -7,
- -1, -3, 1, 3, 1, 5, 2, 1, -1, -5, 13, -2, -1, 2, -2, -13,
- 1, -1, 5, 6, 5, -5, 1, 1, -6, 1, -1, -1, -5, -1, 14, 2,
- -2, 1, -14, -1, 8, 1, -1, -8, 1, 5, 1, 5, -5, 1, -1, 1,
- -5, -1, 15, 1, -1, -1, -1, 3, -15, -3, 6, 1, 16, -1, 6, -6,
- -6, 1, -1, 1, -16, 1, 7, -1, 1, -1, -6, -3, 6, -7, 3, -1}
+ // MapTab2
+ 2, // _eobSym
+ 11, // _escSym
+ // run table
+ {1, 1, 0, 2, 2, 1, 1, 3, 3, 4, 4, 0, 1, 1, 5, 5,
+ 2, 2, 6, 6, 7, 7, 1, 8, 1, 8, 3, 3, 9, 9, 1, 2,
+ 2, 1, 4, 10, 4, 10, 11, 11, 1, 5, 12, 12, 1, 5, 13, 13,
+ 3, 3, 6, 6, 2, 2, 14, 14, 16, 16, 15, 7, 15, 8, 8, 7,
+ 1, 1, 17, 17, 4, 4, 1, 1, 18, 18, 2, 2, 5, 5, 25, 3,
+ 9, 3, 25, 9, 19, 24, 19, 24, 1, 21, 20, 1, 21, 22, 20, 22,
+ 23, 23, 8, 6, 33, 6, 8, 33, 7, 7, 26, 26, 1, 32, 1, 32,
+ 28, 4, 28, 10, 29, 27, 27, 10, 41, 4, 29, 2, 2, 41, 36, 31,
+ 49, 31, 34, 30, 34, 36, 30, 35, 1, 49, 11, 5, 35, 11, 1, 3,
+ 3, 5, 37, 37, 8, 40, 8, 40, 12, 12, 42, 42, 1, 38, 16, 57,
+ 1, 6, 16, 39, 38, 6, 7, 7, 13, 13, 39, 43, 2, 43, 57, 2,
+ 50, 9, 44, 9, 50, 4, 15, 48, 44, 4, 1, 15, 48, 14, 14, 1,
+ 45, 45, 8, 3, 5, 8, 51, 47, 3, 46, 46, 47, 5, 51, 1, 17,
+ 17, 58, 1, 58, 2, 52, 52, 2, 53, 7, 59, 6, 6, 56, 53, 55,
+ 7, 55, 1, 54, 59, 56, 54, 10, 1, 10, 4, 60, 1, 60, 8, 4,
+ 8, 64, 64, 61, 1, 63, 3, 63, 62, 61, 5, 11, 5, 3, 11, 62},
+
+ // value table
+ { 1, -1, 0, 1, -1, 2, -2, 1, -1, 1, -1, 0, 3, -3, 1, -1,
+ 2, -2, 1, -1, 1, -1, 4, 1, -4, -1, 2, -2, 1, -1, 5, 3,
+ -3, -5, 2, 1, -2, -1, 1, -1, 6, 2, 1, -1, -6, -2, 1, -1,
+ 3, -3, 2, -2, 4, -4, 1, -1, 1, -1, 1, 2, -1, 2, -2, -2,
+ 7, -7, 1, -1, 3, -3, 8, -8, 1, -1, 5, -5, 3, -3, 1, 4,
+ 2, -4, -1, -2, 1, 1, -1, -1, 9, 1, 1, -9, -1, 1, -1, -1,
+ 1, -1, 3, -3, 1, 3, -3, -1, 3, -3, 1, -1, 10, 1, -10, -1,
+ 1, 4, -1, 2, 1, -1, 1, -2, 1, -4, -1, 6, -6, -1, 1, 1,
+ 1, -1, 1, 1, -1, -1, -1, 1, 11, -1, -2, 4, -1, 2, -11, 5,
+ -5, -4, -1, 1, 4, 1, -4, -1, -2, 2, 1, -1, 12, 1, -2, 1,
+ -12, 4, 2, 1, -1, -4, 4, -4, 2, -2, -1, 1, 7, -1, -1, -7,
+ -1, -3, 1, 3, 1, 5, 2, 1, -1, -5, 13, -2, -1, 2, -2, -13,
+ 1, -1, 5, 6, 5, -5, 1, 1, -6, 1, -1, -1, -5, -1, 14, 2,
+ -2, 1, -14, -1, 8, 1, -1, -8, 1, 5, 1, 5, -5, 1, -1, 1,
+ -5, -1, 15, 1, -1, -1, -1, 3, -15, -3, 6, 1, 16, -1, 6, -6,
+ -6, 1, -1, 1, -16, 1, 7, -1, 1, -1, -6, -3, 6, -7, 3, -1}
},{
- // MapTab3
- 0, // _eobSym
- 35, // _escSym
- // run table
- {0, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 5, 5, 6, 6, 7,
- 7, 8, 8, 9, 9, 2, 2, 10, 10, 1, 1, 11, 11, 12, 12, 3,
- 3, 13, 13, 0, 14, 14, 16, 15, 16, 15, 4, 4, 17, 1, 17, 1,
- 5, 5, 18, 18, 2, 2, 6, 6, 8, 19, 7, 8, 7, 19, 20, 20,
- 21, 21, 22, 24, 22, 24, 23, 23, 1, 1, 25, 25, 3, 3, 26, 26,
- 9, 9, 27, 27, 28, 28, 33, 29, 4, 33, 29, 1, 4, 1, 32, 32,
- 2, 2, 31, 10, 30, 10, 30, 31, 34, 34, 5, 5, 36, 36, 35, 41,
- 35, 11, 41, 11, 37, 1, 8, 8, 37, 6, 1, 6, 40, 7, 7, 40,
- 12, 38, 12, 39, 39, 38, 49, 13, 49, 13, 3, 42, 3, 42, 16, 16,
- 43, 43, 14, 14, 1, 1, 44, 15, 44, 15, 2, 2, 57, 48, 50, 48,
- 57, 50, 4, 45, 45, 4, 46, 47, 47, 46, 1, 51, 1, 17, 17, 51,
- 8, 9, 9, 5, 58, 8, 58, 5, 52, 52, 55, 56, 53, 56, 55, 59,
- 59, 53, 54, 1, 6, 54, 7, 7, 6, 1, 2, 3, 2, 3, 64, 60,
- 60, 10, 10, 64, 61, 62, 61, 63, 1, 63, 62, 1, 18, 24, 18, 4,
- 25, 4, 8, 21, 21, 1, 24, 22, 25, 22, 8, 11, 19, 11, 23, 1,
- 20, 23, 19, 20, 5, 12, 5, 1, 16, 2, 12, 13, 2, 13, 1, 16},
-
- // value table
- { 0, 1, -1, 1, -1, 1, -1, 1, -1, 2, -2, 1, -1, 1, -1, 1,
- -1, 1, -1, 1, -1, 2, -2, 1, -1, 3, -3, 1, -1, 1, -1, 2,
- -2, 1, -1, 0, 1, -1, 1, 1, -1, -1, 2, -2, 1, 4, -1, -4,
- 2, -2, 1, -1, -3, 3, 2, -2, 2, 1, 2, -2, -2, -1, 1, -1,
- 1, -1, 1, 1, -1, -1, 1, -1, 5, -5, 1, -1, 3, -3, 1, -1,
- 2, -2, 1, -1, 1, -1, 1, 1, 3, -1, -1, 6, -3, -6, -1, 1,
- 4, -4, 1, 2, 1, -2, -1, -1, 1, -1, 3, -3, 1, -1, 1, 1,
- -1, 2, -1, -2, 1, 7, -3, 3, -1, 3, -7, -3, 1, -3, 3, -1,
- 2, 1, -2, 1, -1, -1, 1, 2, -1, -2, -4, -1, 4, 1, 2, -2,
- 1, -1, -2, 2, 8, -8, -1, 2, 1, -2, -5, 5, 1, -1, -1, 1,
- -1, 1, 4, -1, 1, -4, -1, -1, 1, 1, 9, 1, -9, 2, -2, -1,
- -4, 3, -3, -4, -1, 4, 1, 4, 1, -1, 1, -1, 1, 1, -1, 1,
- -1, -1, -1, 10, 4, 1, 4, -4, -4, -10, 6, 5, -6, -5, 1, -1,
- 1, 3, -3, -1, 1, -1, -1, -1, 11, 1, 1, -11, -2, -2, 2, 5,
- -2, -5, -5, 2, -2, 12, 2, -2, 2, 2, 5, -3, -2, 3, -2, -12,
- -2, 2, 2, 2, -5, 3, 5, 13, -3, 7, -3, -3, -7, 3, -13, 3}
+ // MapTab3
+ 0, // _eobSym
+ 35, // _escSym
+ // run table
+ {0, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 5, 5, 6, 6, 7,
+ 7, 8, 8, 9, 9, 2, 2, 10, 10, 1, 1, 11, 11, 12, 12, 3,
+ 3, 13, 13, 0, 14, 14, 16, 15, 16, 15, 4, 4, 17, 1, 17, 1,
+ 5, 5, 18, 18, 2, 2, 6, 6, 8, 19, 7, 8, 7, 19, 20, 20,
+ 21, 21, 22, 24, 22, 24, 23, 23, 1, 1, 25, 25, 3, 3, 26, 26,
+ 9, 9, 27, 27, 28, 28, 33, 29, 4, 33, 29, 1, 4, 1, 32, 32,
+ 2, 2, 31, 10, 30, 10, 30, 31, 34, 34, 5, 5, 36, 36, 35, 41,
+ 35, 11, 41, 11, 37, 1, 8, 8, 37, 6, 1, 6, 40, 7, 7, 40,
+ 12, 38, 12, 39, 39, 38, 49, 13, 49, 13, 3, 42, 3, 42, 16, 16,
+ 43, 43, 14, 14, 1, 1, 44, 15, 44, 15, 2, 2, 57, 48, 50, 48,
+ 57, 50, 4, 45, 45, 4, 46, 47, 47, 46, 1, 51, 1, 17, 17, 51,
+ 8, 9, 9, 5, 58, 8, 58, 5, 52, 52, 55, 56, 53, 56, 55, 59,
+ 59, 53, 54, 1, 6, 54, 7, 7, 6, 1, 2, 3, 2, 3, 64, 60,
+ 60, 10, 10, 64, 61, 62, 61, 63, 1, 63, 62, 1, 18, 24, 18, 4,
+ 25, 4, 8, 21, 21, 1, 24, 22, 25, 22, 8, 11, 19, 11, 23, 1,
+ 20, 23, 19, 20, 5, 12, 5, 1, 16, 2, 12, 13, 2, 13, 1, 16},
+
+ // value table
+ { 0, 1, -1, 1, -1, 1, -1, 1, -1, 2, -2, 1, -1, 1, -1, 1,
+ -1, 1, -1, 1, -1, 2, -2, 1, -1, 3, -3, 1, -1, 1, -1, 2,
+ -2, 1, -1, 0, 1, -1, 1, 1, -1, -1, 2, -2, 1, 4, -1, -4,
+ 2, -2, 1, -1, -3, 3, 2, -2, 2, 1, 2, -2, -2, -1, 1, -1,
+ 1, -1, 1, 1, -1, -1, 1, -1, 5, -5, 1, -1, 3, -3, 1, -1,
+ 2, -2, 1, -1, 1, -1, 1, 1, 3, -1, -1, 6, -3, -6, -1, 1,
+ 4, -4, 1, 2, 1, -2, -1, -1, 1, -1, 3, -3, 1, -1, 1, 1,
+ -1, 2, -1, -2, 1, 7, -3, 3, -1, 3, -7, -3, 1, -3, 3, -1,
+ 2, 1, -2, 1, -1, -1, 1, 2, -1, -2, -4, -1, 4, 1, 2, -2,
+ 1, -1, -2, 2, 8, -8, -1, 2, 1, -2, -5, 5, 1, -1, -1, 1,
+ -1, 1, 4, -1, 1, -4, -1, -1, 1, 1, 9, 1, -9, 2, -2, -1,
+ -4, 3, -3, -4, -1, 4, 1, 4, 1, -1, 1, -1, 1, 1, -1, 1,
+ -1, -1, -1, 10, 4, 1, 4, -4, -4, -10, 6, 5, -6, -5, 1, -1,
+ 1, 3, -3, -1, 1, -1, -1, -1, 11, 1, 1, -11, -2, -2, 2, 5,
+ -2, -5, -5, 2, -2, 12, 2, -2, 2, 2, 5, -3, -2, 3, -2, -12,
+ -2, 2, 2, 2, -5, 3, 5, 13, -3, 7, -3, -3, -7, 3, -13, 3}
},{
- // MapTab4
- 0, // _eobSym
- 34, // _escSym
- // run table
- {0, 1, 1, 1, 2, 2, 1, 3, 3, 1, 1, 1, 4, 4, 1, 5,
- 2, 1, 5, 2, 1, 1, 6, 6, 1, 1, 1, 1, 1, 7, 3, 1,
- 2, 3, 0, 1, 2, 7, 1, 1, 1, 8, 1, 1, 8, 1, 1, 1,
- 9, 1, 9, 1, 2, 1, 1, 2, 1, 1, 10, 4, 1, 10, 1, 4,
- 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 2, 1, 5, 1, 1, 1,
- 2, 5, 1, 11, 1, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 1, 6, 1, 6, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 12,
- 3, 1, 12, 1, 1, 1, 2, 1, 1, 3, 1, 1, 1, 1, 1, 1,
- 4, 1, 1, 1, 2, 1, 1, 4, 1, 1, 1, 1, 1, 1, 2, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, 5,
- 1, 1, 1, 1, 1, 7, 1, 7, 1, 1, 2, 3, 1, 1, 1, 1,
- 5, 1, 1, 1, 1, 1, 1, 2, 13, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 13, 2, 1, 1, 4, 1, 1, 1,
- 3, 1, 6, 1, 1, 1, 14, 1, 1, 1, 1, 1, 14, 6, 1, 1,
- 1, 1, 15, 2, 4, 1, 2, 3, 15, 1, 1, 1, 8, 1, 1, 8,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1},
-
- // value table
- { 0, 1, -1, 2, 1, -1, -2, 1, -1, 3, -3, 4, 1, -1, -4, 1,
- 2, 5, -1, -2, -5, 6, 1, -1, -6, 7, -7, 8, -8, 1, 2, 9,
- 3, -2, 0, -9, -3, -1, 10, -10, 11, 1, -11, 12, -1, -12, 13, -13,
- 1, 14, -1, -14, 4, 15, -15, -4, 16, -16, 1, 2, 17, -1, -17, -2,
- 18, -18, 19, -19, 20, 3, -20, 21, -21, -3, 5, 22, 2, -22, -23, 23,
- -5, -2, 24, 1, -24, -1, 25, -25, 26, -26, -27, 27, 28, 29, -28, -29,
- 6, 30, 2, -31, -2, -30, 31, -6, -32, 32, 33, -33, 34, -35, -34, 1,
- 4, -36, -1, 35, 37, 36, 7, -37, 38, -4, -38, 39, 41, 40, -40, -39,
- 3, 42, -43, -41, -7, -42, 43, -3, 44, -44, 45, -45, 46, 47, 8, -47,
- -48, -46, 50, -50, 48, 49, 51, -49, 52, -52, 5, -51, -8, -53, 53, 3,
- -56, 56, 55, 54, -54, 2, 60, -2, -55, 58, 9, -5, 59, 57, -57, -63,
- -3, -58, -60, -61, 61, -59, -62, -9, 1, 64, 62, 69, -64, 63, 65, -67,
- -68, 66, -65, 68, -66, -69, 67, -70, -1, 10, 71, -71, 4, 73, 72, 70,
- 6, -76, -3, 74, -78, -74, 1, 78, 80, -72, -75, 76, -1, 3, -73, 79,
- 75, 77, 1, 11, -4, -79, -10, -6, -1, -77, -83, -80, 2, 81, -84, -2,
- 83, -81, 82, -82, 84, -87, -86, 85, -11, -85, 86, -89, 87, -88, 88, 89}
+ // MapTab4
+ 0, // _eobSym
+ 34, // _escSym
+ // run table
+ {0, 1, 1, 1, 2, 2, 1, 3, 3, 1, 1, 1, 4, 4, 1, 5,
+ 2, 1, 5, 2, 1, 1, 6, 6, 1, 1, 1, 1, 1, 7, 3, 1,
+ 2, 3, 0, 1, 2, 7, 1, 1, 1, 8, 1, 1, 8, 1, 1, 1,
+ 9, 1, 9, 1, 2, 1, 1, 2, 1, 1, 10, 4, 1, 10, 1, 4,
+ 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 2, 1, 5, 1, 1, 1,
+ 2, 5, 1, 11, 1, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 2, 1, 6, 1, 6, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 12,
+ 3, 1, 12, 1, 1, 1, 2, 1, 1, 3, 1, 1, 1, 1, 1, 1,
+ 4, 1, 1, 1, 2, 1, 1, 4, 1, 1, 1, 1, 1, 1, 2, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, 5,
+ 1, 1, 1, 1, 1, 7, 1, 7, 1, 1, 2, 3, 1, 1, 1, 1,
+ 5, 1, 1, 1, 1, 1, 1, 2, 13, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 13, 2, 1, 1, 4, 1, 1, 1,
+ 3, 1, 6, 1, 1, 1, 14, 1, 1, 1, 1, 1, 14, 6, 1, 1,
+ 1, 1, 15, 2, 4, 1, 2, 3, 15, 1, 1, 1, 8, 1, 1, 8,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1},
+
+ // value table
+ { 0, 1, -1, 2, 1, -1, -2, 1, -1, 3, -3, 4, 1, -1, -4, 1,
+ 2, 5, -1, -2, -5, 6, 1, -1, -6, 7, -7, 8, -8, 1, 2, 9,
+ 3, -2, 0, -9, -3, -1, 10, -10, 11, 1, -11, 12, -1, -12, 13, -13,
+ 1, 14, -1, -14, 4, 15, -15, -4, 16, -16, 1, 2, 17, -1, -17, -2,
+ 18, -18, 19, -19, 20, 3, -20, 21, -21, -3, 5, 22, 2, -22, -23, 23,
+ -5, -2, 24, 1, -24, -1, 25, -25, 26, -26, -27, 27, 28, 29, -28, -29,
+ 6, 30, 2, -31, -2, -30, 31, -6, -32, 32, 33, -33, 34, -35, -34, 1,
+ 4, -36, -1, 35, 37, 36, 7, -37, 38, -4, -38, 39, 41, 40, -40, -39,
+ 3, 42, -43, -41, -7, -42, 43, -3, 44, -44, 45, -45, 46, 47, 8, -47,
+ -48, -46, 50, -50, 48, 49, 51, -49, 52, -52, 5, -51, -8, -53, 53, 3,
+ -56, 56, 55, 54, -54, 2, 60, -2, -55, 58, 9, -5, 59, 57, -57, -63,
+ -3, -58, -60, -61, 61, -59, -62, -9, 1, 64, 62, 69, -64, 63, 65, -67,
+ -68, 66, -65, 68, -66, -69, 67, -70, -1, 10, 71, -71, 4, 73, 72, 70,
+ 6, -76, -3, 74, -78, -74, 1, 78, 80, -72, -75, 76, -1, 3, -73, 79,
+ 75, 77, 1, 11, -4, -79, -10, -6, -1, -77, -83, -80, 2, 81, -84, -2,
+ 83, -81, 82, -82, 84, -87, -86, 85, -11, -85, 86, -89, 87, -88, 88, 89}
},{
- // MapTab5
- 2, // _eobSym
- 33, // _escSym
- // run table
- {1, 1, 0, 2, 1, 2, 1, 3, 3, 1, 1, 4, 4, 2, 2, 1,
- 1, 5, 5, 6, 1, 6, 1, 7, 7, 3, 3, 2, 8, 2, 8, 1,
- 1, 0, 9, 9, 1, 1, 10, 4, 10, 4, 11, 11, 2, 1, 2, 1,
- 12, 12, 3, 3, 1, 1, 13, 5, 5, 13, 14, 1, 1, 14, 2, 2,
- 6, 6, 15, 1, 1, 15, 16, 4, 7, 16, 4, 7, 1, 1, 3, 3,
- 8, 8, 2, 2, 1, 1, 17, 17, 1, 1, 18, 18, 5, 5, 2, 2,
- 1, 1, 9, 19, 9, 19, 20, 3, 3, 20, 1, 10, 21, 1, 10, 4,
- 4, 21, 22, 6, 6, 22, 1, 1, 23, 24, 2, 2, 23, 24, 11, 1,
- 1, 11, 7, 25, 7, 1, 1, 25, 8, 8, 3, 26, 3, 1, 12, 2,
- 2, 26, 1, 12, 5, 5, 27, 4, 1, 4, 1, 27, 28, 1, 28, 13,
- 1, 13, 2, 29, 2, 1, 32, 6, 1, 30, 14, 29, 14, 6, 3, 31,
- 3, 1, 30, 1, 32, 31, 33, 9, 33, 1, 1, 7, 9, 7, 2, 2,
- 1, 1, 4, 36, 34, 4, 5, 10, 10, 5, 34, 1, 1, 35, 8, 8,
- 36, 3, 35, 1, 15, 3, 2, 1, 16, 15, 16, 2, 37, 1, 37, 1,
- 1, 1, 6, 6, 38, 1, 38, 11, 1, 39, 39, 40, 11, 2, 41, 4,
- 40, 1, 2, 4, 1, 1, 1, 41, 3, 1, 3, 1, 5, 7, 5, 7},
-
- // value table
- { 1, -1, 0, 1, 2, -1, -2, 1, -1, 3, -3, 1, -1, 2, -2, 4,
- -4, 1, -1, 1, 5, -1, -5, 1, -1, 2, -2, 3, 1, -3, -1, 6,
- -6, 0, 1, -1, 7, -7, 1, 2, -1, -2, 1, -1, 4, 8, -4, -8,
- 1, -1, 3, -3, 9, -9, 1, 2, -2, -1, 1, 10, -10, -1, 5, -5,
- 2, -2, 1, 11, -11, -1, 1, 3, 2, -1, -3, -2, 12, -12, 4, -4,
- 2, -2, -6, 6, 13, -13, 1, -1, 14, -14, 1, -1, 3, -3, 7, -7,
- 15, -15, 2, 1, -2, -1, 1, 5, -5, -1, -16, 2, 1, 16, -2, 4,
- -4, -1, 1, 3, -3, -1, 17, -17, 1, 1, -8, 8, -1, -1, 2, 18,
- -18, -2, 3, 1, -3, 19, -19, -1, 3, -3, 6, 1, -6, 20, 2, 9,
- -9, -1, -20, -2, 4, -4, 1, -5, 21, 5, -21, -1, 1, -22, -1, 2,
- 22, -2, 10, 1, -10, 23, 1, 4, -23, 1, 2, -1, -2, -4, -7, 1,
- 7, -24, -1, 24, -1, -1, 1, 3, -1, -25, 25, 4, -3, -4, 11, -11,
- 26, -26, 6, 1, 1, -6, -5, -3, 3, 5, -1, -27, 27, 1, 4, -4,
- -1, -8, -1, 28, 2, 8, -12, -28, -2, -2, 2, 12, -1, 29, 1, -29,
- 30, -30, 5, -5, 1, -31, -1, 3, 31, -1, 1, 1, -3, -13, 1, -7,
- -1, -32, 13, 7, 32, 33, -33, -1, -9, -34, 9, 34, -6, 5, 6, -5}
+ // MapTab5
+ 2, // _eobSym
+ 33, // _escSym
+ // run table
+ {1, 1, 0, 2, 1, 2, 1, 3, 3, 1, 1, 4, 4, 2, 2, 1,
+ 1, 5, 5, 6, 1, 6, 1, 7, 7, 3, 3, 2, 8, 2, 8, 1,
+ 1, 0, 9, 9, 1, 1, 10, 4, 10, 4, 11, 11, 2, 1, 2, 1,
+ 12, 12, 3, 3, 1, 1, 13, 5, 5, 13, 14, 1, 1, 14, 2, 2,
+ 6, 6, 15, 1, 1, 15, 16, 4, 7, 16, 4, 7, 1, 1, 3, 3,
+ 8, 8, 2, 2, 1, 1, 17, 17, 1, 1, 18, 18, 5, 5, 2, 2,
+ 1, 1, 9, 19, 9, 19, 20, 3, 3, 20, 1, 10, 21, 1, 10, 4,
+ 4, 21, 22, 6, 6, 22, 1, 1, 23, 24, 2, 2, 23, 24, 11, 1,
+ 1, 11, 7, 25, 7, 1, 1, 25, 8, 8, 3, 26, 3, 1, 12, 2,
+ 2, 26, 1, 12, 5, 5, 27, 4, 1, 4, 1, 27, 28, 1, 28, 13,
+ 1, 13, 2, 29, 2, 1, 32, 6, 1, 30, 14, 29, 14, 6, 3, 31,
+ 3, 1, 30, 1, 32, 31, 33, 9, 33, 1, 1, 7, 9, 7, 2, 2,
+ 1, 1, 4, 36, 34, 4, 5, 10, 10, 5, 34, 1, 1, 35, 8, 8,
+ 36, 3, 35, 1, 15, 3, 2, 1, 16, 15, 16, 2, 37, 1, 37, 1,
+ 1, 1, 6, 6, 38, 1, 38, 11, 1, 39, 39, 40, 11, 2, 41, 4,
+ 40, 1, 2, 4, 1, 1, 1, 41, 3, 1, 3, 1, 5, 7, 5, 7},
+
+ // value table
+ { 1, -1, 0, 1, 2, -1, -2, 1, -1, 3, -3, 1, -1, 2, -2, 4,
+ -4, 1, -1, 1, 5, -1, -5, 1, -1, 2, -2, 3, 1, -3, -1, 6,
+ -6, 0, 1, -1, 7, -7, 1, 2, -1, -2, 1, -1, 4, 8, -4, -8,
+ 1, -1, 3, -3, 9, -9, 1, 2, -2, -1, 1, 10, -10, -1, 5, -5,
+ 2, -2, 1, 11, -11, -1, 1, 3, 2, -1, -3, -2, 12, -12, 4, -4,
+ 2, -2, -6, 6, 13, -13, 1, -1, 14, -14, 1, -1, 3, -3, 7, -7,
+ 15, -15, 2, 1, -2, -1, 1, 5, -5, -1, -16, 2, 1, 16, -2, 4,
+ -4, -1, 1, 3, -3, -1, 17, -17, 1, 1, -8, 8, -1, -1, 2, 18,
+ -18, -2, 3, 1, -3, 19, -19, -1, 3, -3, 6, 1, -6, 20, 2, 9,
+ -9, -1, -20, -2, 4, -4, 1, -5, 21, 5, -21, -1, 1, -22, -1, 2,
+ 22, -2, 10, 1, -10, 23, 1, 4, -23, 1, 2, -1, -2, -4, -7, 1,
+ 7, -24, -1, 24, -1, -1, 1, 3, -1, -25, 25, 4, -3, -4, 11, -11,
+ 26, -26, 6, 1, 1, -6, -5, -3, 3, 5, -1, -27, 27, 1, 4, -4,
+ -1, -8, -1, 28, 2, 8, -12, -28, -2, -2, 2, 12, -1, 29, 1, -29,
+ 30, -30, 5, -5, 1, -31, -1, 3, 31, -1, 1, 1, -3, -13, 1, -7,
+ -1, -32, 13, 7, 32, 33, -33, -1, -9, -34, 9, 34, -6, 5, 6, -5}
},{
- // MapTab6
- 2, // _eobSym
- 13, // _escSym
- // run table
- {1, 1, 0, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 0, 2, 2,
- 4, 1, 4, 1, 1, 1, 5, 5, 1, 1, 6, 6, 2, 2, 1, 1,
- 3, 3, 7, 7, 1, 1, 8, 8, 1, 1, 2, 2, 1, 9, 1, 9,
- 4, 4, 10, 1, 1, 10, 1, 1, 11, 11, 3, 3, 1, 2, 1, 2,
- 1, 1, 12, 12, 5, 5, 1, 1, 13, 1, 1, 13, 2, 2, 1, 1,
- 6, 6, 1, 1, 4, 14, 4, 14, 3, 1, 3, 1, 1, 1, 15, 7,
- 15, 2, 2, 7, 1, 1, 1, 8, 1, 8, 16, 16, 1, 1, 1, 1,
- 2, 1, 1, 2, 1, 1, 3, 5, 5, 3, 4, 1, 1, 4, 1, 1,
- 17, 17, 9, 1, 1, 9, 2, 2, 1, 1, 10, 10, 1, 6, 1, 1,
- 6, 18, 1, 1, 18, 1, 1, 1, 2, 2, 3, 1, 3, 1, 1, 1,
- 4, 1, 19, 1, 19, 7, 1, 1, 20, 1, 4, 20, 1, 7, 11, 2,
- 1, 11, 21, 2, 8, 5, 1, 8, 1, 5, 21, 1, 1, 1, 22, 1,
- 1, 22, 1, 1, 3, 3, 1, 23, 2, 12, 24, 1, 1, 2, 1, 1,
- 12, 23, 1, 1, 24, 1, 1, 1, 4, 1, 1, 1, 2, 1, 6, 6,
- 4, 2, 1, 1, 1, 1, 1, 1, 1, 14, 13, 3, 1, 25, 9, 25,
- 14, 1, 9, 3, 13, 1, 1, 1, 1, 1, 10, 1, 1, 2, 10, 2},
-
- // value table
- {-20, -1, 0, 2, -2, 1, -1, 3, -3, 1, -1, 4, -4, 0, 2, -2,
- 1, 5, -1, -5, 6, -6, 1, -1, 7, -7, 1, -1, 3, -3, 8, -8,
- 2, -2, 1, -1, 9, -9, 1, -1, 10, -10, 4, -4, 11, 1, -11, -1,
- 2, -2, 1, 12, -12, -1, 13, -13, 1, -1, 3, -3, 14, 5, -14, -5,
- -15, 15, -1, 1, 2, -2, 16, -16, 1, 17, -17, -1, 6, -6, 18, -18,
- 2, -2, -19, 19, -3, 1, 3, -1, 4, 20, -4, 1, -21, 21, 1, 2,
- -1, -7, 7, -2, 22, -22, 23, 2, -23, -2, 1, -1, -24, 24, -25, 25,
- -8, -26, 26, 8, -27, 27, 5, 3, -3, -5, -4, 28, -28, 4, 29, -29,
- 1, -1, -2, -30, 30, 2, 9, -9, -31, 31, 2, -2, -32, 3, 32, -33,
- -3, 1, 33, -34, -1, 34, -35, 35, -10, 10, -6, 36, 6, -36, 37, -37,
- -5, 38, 1, -38, -1, 3, 39, -39, -1, 40, 5, 1, -40, -3, 2, -11,
- -41, -2, 1, 11, -3, -4, 41, 3, 42, 4, -1, -43, -42, 43, 1, -44,
- 45, -1, 44, -45, -7, 7, -46, 1, -12, 2, 1, -47, 46, 12, 47, 48,
- -2, -1, -48, 49, -1, -50, -49, 50, -6, -51, 51, 52, -13, 53, -4, 4,
- 6, 13, -53, -52, -54, 55, 54, -55, -56, -2, 2, -8, 56, 1, -3, -1,
- 2, 58, 3, 8, -2, 57, -58, -60, -59, -57, -3, 60, 59, -14, 3, 14}
+ // MapTab6
+ 2, // _eobSym
+ 13, // _escSym
+ // run table
+ {1, 1, 0, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 0, 2, 2,
+ 4, 1, 4, 1, 1, 1, 5, 5, 1, 1, 6, 6, 2, 2, 1, 1,
+ 3, 3, 7, 7, 1, 1, 8, 8, 1, 1, 2, 2, 1, 9, 1, 9,
+ 4, 4, 10, 1, 1, 10, 1, 1, 11, 11, 3, 3, 1, 2, 1, 2,
+ 1, 1, 12, 12, 5, 5, 1, 1, 13, 1, 1, 13, 2, 2, 1, 1,
+ 6, 6, 1, 1, 4, 14, 4, 14, 3, 1, 3, 1, 1, 1, 15, 7,
+ 15, 2, 2, 7, 1, 1, 1, 8, 1, 8, 16, 16, 1, 1, 1, 1,
+ 2, 1, 1, 2, 1, 1, 3, 5, 5, 3, 4, 1, 1, 4, 1, 1,
+ 17, 17, 9, 1, 1, 9, 2, 2, 1, 1, 10, 10, 1, 6, 1, 1,
+ 6, 18, 1, 1, 18, 1, 1, 1, 2, 2, 3, 1, 3, 1, 1, 1,
+ 4, 1, 19, 1, 19, 7, 1, 1, 20, 1, 4, 20, 1, 7, 11, 2,
+ 1, 11, 21, 2, 8, 5, 1, 8, 1, 5, 21, 1, 1, 1, 22, 1,
+ 1, 22, 1, 1, 3, 3, 1, 23, 2, 12, 24, 1, 1, 2, 1, 1,
+ 12, 23, 1, 1, 24, 1, 1, 1, 4, 1, 1, 1, 2, 1, 6, 6,
+ 4, 2, 1, 1, 1, 1, 1, 1, 1, 14, 13, 3, 1, 25, 9, 25,
+ 14, 1, 9, 3, 13, 1, 1, 1, 1, 1, 10, 1, 1, 2, 10, 2},
+
+ // value table
+ {-20, -1, 0, 2, -2, 1, -1, 3, -3, 1, -1, 4, -4, 0, 2, -2,
+ 1, 5, -1, -5, 6, -6, 1, -1, 7, -7, 1, -1, 3, -3, 8, -8,
+ 2, -2, 1, -1, 9, -9, 1, -1, 10, -10, 4, -4, 11, 1, -11, -1,
+ 2, -2, 1, 12, -12, -1, 13, -13, 1, -1, 3, -3, 14, 5, -14, -5,
+ -15, 15, -1, 1, 2, -2, 16, -16, 1, 17, -17, -1, 6, -6, 18, -18,
+ 2, -2, -19, 19, -3, 1, 3, -1, 4, 20, -4, 1, -21, 21, 1, 2,
+ -1, -7, 7, -2, 22, -22, 23, 2, -23, -2, 1, -1, -24, 24, -25, 25,
+ -8, -26, 26, 8, -27, 27, 5, 3, -3, -5, -4, 28, -28, 4, 29, -29,
+ 1, -1, -2, -30, 30, 2, 9, -9, -31, 31, 2, -2, -32, 3, 32, -33,
+ -3, 1, 33, -34, -1, 34, -35, 35, -10, 10, -6, 36, 6, -36, 37, -37,
+ -5, 38, 1, -38, -1, 3, 39, -39, -1, 40, 5, 1, -40, -3, 2, -11,
+ -41, -2, 1, 11, -3, -4, 41, 3, 42, 4, -1, -43, -42, 43, 1, -44,
+ 45, -1, 44, -45, -7, 7, -46, 1, -12, 2, 1, -47, 46, 12, 47, 48,
+ -2, -1, -48, 49, -1, -50, -49, 50, -6, -51, 51, 52, -13, 53, -4, 4,
+ 6, 13, -53, -52, -54, 55, 54, -55, -56, -2, 2, -8, 56, 1, -3, -1,
+ 2, 58, 3, 8, -2, 57, -58, -60, -59, -57, -3, 60, 59, -14, 3, 14}
},{
- // MapTab7
- 2, // _eobSym
- 38, // _escSym
- // run table
- {1, 1, 0, 2, 2, 1, 1, 3, 3, 4, 4, 5, 5, 1, 1, 6,
- 6, 2, 2, 7, 7, 8, 8, 1, 1, 3, 3, 9, 9, 10, 10, 1,
- 1, 2, 2, 4, 4, 11, 0, 11, 12, 12, 13, 13, 1, 1, 5, 5,
- 14, 14, 15, 16, 15, 16, 3, 3, 1, 6, 1, 6, 2, 2, 7, 7,
- 8, 8, 17, 17, 1, 1, 4, 4, 18, 18, 2, 2, 1, 19, 1, 20,
- 19, 20, 21, 21, 3, 3, 22, 22, 5, 5, 24, 1, 1, 23, 9, 23,
- 24, 9, 2, 2, 10, 1, 1, 10, 6, 6, 25, 4, 4, 25, 7, 7,
- 26, 8, 1, 8, 3, 1, 26, 3, 11, 11, 27, 27, 2, 28, 1, 2,
- 28, 1, 12, 12, 5, 5, 29, 13, 13, 29, 32, 1, 1, 33, 31, 30,
- 32, 4, 30, 33, 4, 31, 3, 14, 1, 1, 3, 34, 34, 2, 2, 14,
- 6, 6, 35, 36, 35, 36, 1, 15, 1, 16, 16, 15, 7, 9, 7, 9,
- 37, 8, 8, 37, 1, 1, 39, 2, 38, 39, 2, 40, 5, 38, 40, 5,
- 3, 3, 4, 4, 10, 10, 1, 1, 1, 1, 41, 2, 41, 2, 6, 6,
- 1, 1, 11, 42, 11, 43, 3, 42, 3, 17, 4, 43, 1, 17, 7, 1,
- 8, 44, 4, 7, 44, 5, 8, 2, 5, 1, 2, 48, 45, 1, 12, 45,
- 12, 48, 13, 13, 1, 9, 9, 46, 1, 46, 47, 47, 49, 18, 18, 49},
-
- // value table
- { 1, -1, 0, 1, -1, 2, -2, 1, -1, 1, -1, 1, -1, 3, -3, 1,
- -1, -2, 2, 1, -1, 1, -1, 4, -4, -2, 2, 1, -1, 1, -1, 5,
- -5, -3, 3, 2, -2, 1, 0, -1, 1, -1, 1, -1, 6, -6, 2, -2,
- 1, -1, 1, 1, -1, -1, -3, 3, 7, 2, -7, -2, -4, 4, 2, -2,
- 2, -2, 1, -1, 8, -8, 3, -3, 1, -1, -5, 5, 9, 1, -9, 1,
- -1, -1, 1, -1, -4, 4, 1, -1, 3, -3, 1, -10, 10, 1, 2, -1,
- -1, -2, 6, -6, 2, 11, -11, -2, 3, -3, 1, -4, 4, -1, 3, -3,
- 1, 3, 12, -3, -5, -12, -1, 5, 2, -2, 1, -1, -7, 1, 13, 7,
- -1, -13, 2, -2, 4, -4, 1, 2, -2, -1, 1, 14, -14, 1, 1, 1,
- -1, -5, -1, -1, 5, -1, -6, 2, -15, 15, 6, 1, -1, -8, 8, -2,
- -4, 4, 1, 1, -1, -1, 16, 2, -16, -2, 2, -2, 4, 3, -4, -3,
- -1, -4, 4, 1, -17, 17, -1, -9, 1, 1, 9, 1, -5, -1, -1, 5,
- -7, 7, 6, -6, 3, -3, 18, -18, 19, -19, 1, -10, -1, 10, -5, 5,
- 20, -20, -3, 1, 3, 1, 8, -1, -8, 2, 7, -1, -21, -2, 5, 21,
- 5, -1, -7, -5, 1, -6, -5, -11, 6, 22, 11, 1, 1, -22, -3, -1,
- 3, -1, 3, -3, -23, 4, -4, 1, 23, -1, 1, -1, 1, -2, 2, -1}
+ // MapTab7
+ 2, // _eobSym
+ 38, // _escSym
+ // run table
+ {1, 1, 0, 2, 2, 1, 1, 3, 3, 4, 4, 5, 5, 1, 1, 6,
+ 6, 2, 2, 7, 7, 8, 8, 1, 1, 3, 3, 9, 9, 10, 10, 1,
+ 1, 2, 2, 4, 4, 11, 0, 11, 12, 12, 13, 13, 1, 1, 5, 5,
+ 14, 14, 15, 16, 15, 16, 3, 3, 1, 6, 1, 6, 2, 2, 7, 7,
+ 8, 8, 17, 17, 1, 1, 4, 4, 18, 18, 2, 2, 1, 19, 1, 20,
+ 19, 20, 21, 21, 3, 3, 22, 22, 5, 5, 24, 1, 1, 23, 9, 23,
+ 24, 9, 2, 2, 10, 1, 1, 10, 6, 6, 25, 4, 4, 25, 7, 7,
+ 26, 8, 1, 8, 3, 1, 26, 3, 11, 11, 27, 27, 2, 28, 1, 2,
+ 28, 1, 12, 12, 5, 5, 29, 13, 13, 29, 32, 1, 1, 33, 31, 30,
+ 32, 4, 30, 33, 4, 31, 3, 14, 1, 1, 3, 34, 34, 2, 2, 14,
+ 6, 6, 35, 36, 35, 36, 1, 15, 1, 16, 16, 15, 7, 9, 7, 9,
+ 37, 8, 8, 37, 1, 1, 39, 2, 38, 39, 2, 40, 5, 38, 40, 5,
+ 3, 3, 4, 4, 10, 10, 1, 1, 1, 1, 41, 2, 41, 2, 6, 6,
+ 1, 1, 11, 42, 11, 43, 3, 42, 3, 17, 4, 43, 1, 17, 7, 1,
+ 8, 44, 4, 7, 44, 5, 8, 2, 5, 1, 2, 48, 45, 1, 12, 45,
+ 12, 48, 13, 13, 1, 9, 9, 46, 1, 46, 47, 47, 49, 18, 18, 49},
+
+ // value table
+ { 1, -1, 0, 1, -1, 2, -2, 1, -1, 1, -1, 1, -1, 3, -3, 1,
+ -1, -2, 2, 1, -1, 1, -1, 4, -4, -2, 2, 1, -1, 1, -1, 5,
+ -5, -3, 3, 2, -2, 1, 0, -1, 1, -1, 1, -1, 6, -6, 2, -2,
+ 1, -1, 1, 1, -1, -1, -3, 3, 7, 2, -7, -2, -4, 4, 2, -2,
+ 2, -2, 1, -1, 8, -8, 3, -3, 1, -1, -5, 5, 9, 1, -9, 1,
+ -1, -1, 1, -1, -4, 4, 1, -1, 3, -3, 1, -10, 10, 1, 2, -1,
+ -1, -2, 6, -6, 2, 11, -11, -2, 3, -3, 1, -4, 4, -1, 3, -3,
+ 1, 3, 12, -3, -5, -12, -1, 5, 2, -2, 1, -1, -7, 1, 13, 7,
+ -1, -13, 2, -2, 4, -4, 1, 2, -2, -1, 1, 14, -14, 1, 1, 1,
+ -1, -5, -1, -1, 5, -1, -6, 2, -15, 15, 6, 1, -1, -8, 8, -2,
+ -4, 4, 1, 1, -1, -1, 16, 2, -16, -2, 2, -2, 4, 3, -4, -3,
+ -1, -4, 4, 1, -17, 17, -1, -9, 1, 1, 9, 1, -5, -1, -1, 5,
+ -7, 7, 6, -6, 3, -3, 18, -18, 19, -19, 1, -10, -1, 10, -5, 5,
+ 20, -20, -3, 1, 3, 1, 8, -1, -8, 2, 7, -1, -21, -2, 5, 21,
+ 5, -1, -7, -5, 1, -6, -5, -11, 6, 22, 11, 1, 1, -22, -3, -1,
+ 3, -1, 3, -3, -23, 4, -4, 1, 23, -1, 1, -1, 1, -2, 2, -1}
},{
- // MapTab8
- 4, // _eobSym
- 11, // _escSym
- // run table
- {1, 1, 1, 1, 0, 2, 2, 1, 1, 3, 3, 0, 1, 1, 2, 2,
- 4, 4, 1, 1, 5, 5, 1, 1, 2, 2, 3, 3, 6, 6, 1, 1,
- 7, 7, 8, 1, 8, 2, 2, 1, 4, 4, 1, 3, 1, 3, 9, 9,
- 2, 2, 1, 5, 1, 5, 10, 10, 1, 1, 11, 11, 3, 6, 3, 4,
- 4, 6, 2, 2, 1, 12, 1, 12, 7, 13, 7, 13, 1, 1, 8, 8,
- 2, 2, 14, 14, 16, 15, 16, 5, 5, 1, 3, 15, 1, 3, 4, 4,
- 1, 1, 17, 17, 2, 2, 6, 6, 1, 18, 1, 18, 22, 21, 22, 21,
- 25, 24, 25, 19, 9, 20, 9, 23, 19, 24, 20, 3, 23, 7, 3, 1,
- 1, 7, 28, 26, 29, 5, 28, 26, 5, 8, 29, 4, 8, 27, 2, 2,
- 4, 27, 1, 1, 10, 36, 10, 33, 33, 36, 30, 1, 32, 32, 1, 30,
- 6, 31, 31, 35, 3, 6, 11, 11, 3, 2, 35, 2, 34, 1, 34, 1,
- 37, 37, 12, 7, 12, 5, 41, 5, 4, 7, 1, 8, 13, 4, 1, 41,
- 13, 38, 8, 38, 9, 1, 40, 40, 9, 1, 39, 2, 2, 49, 39, 42,
- 3, 3, 14, 16, 49, 14, 16, 42, 43, 43, 6, 6, 15, 1, 1, 15,
- 44, 44, 1, 1, 50, 48, 4, 5, 4, 7, 5, 2, 10, 10, 48, 7,
- 50, 45, 2, 1, 45, 8, 8, 1, 46, 46, 3, 47, 47, 3, 1, 1},
-
- // value table
- { 1, -1, 2, -2, 0, 1, -1, 3, -3, 1, -1, 0, 4, -4, 2, -2,
- 1, -1, 5, -5, 1, -1, 6, -6, 3, -3, 2, -2, 1, -1, 7, -7,
- 1, -1, 1, 8, -1, 4, -4, -8, 2, -2, 9, 3, -9, -3, 1, -1,
- 5, -5, 10, 2, -10, -2, 1, -1, 11, -11, 1, -1, -4, 2, 4, 3,
- -3, -2, 6, -6, 12, 1, -12, -1, 2, 1, -2, -1, 13, -13, 2, -2,
- 7, -7, 1, -1, 1, 1, -1, 3, -3, 14, 5, -1, -14, -5, 4, -4,
- 15, -15, 1, -1, 8, -8, -3, 3, 16, 1, -16, -1, 1, 1, -1, -1,
- 1, 1, -1, 1, 2, 1, -2, 1, -1, -1, -1, 6, -1, 3, -6, 17,
- -17, -3, 1, 1, 1, 4, -1, -1, -4, 3, -1, 5, -3, -1, -9, 9,
- -5, 1, 18, -18, 2, 1, -2, 1, -1, -1, 1, 19, -1, 1, -19, -1,
- 4, 1, -1, 1, 7, -4, -2, 2, -7, 10, -1, -10, 1, 20, -1, -20,
- 1, -1, 2, 4, -2, 5, 1, -5, 6, -4, 21, 4, 2, -6, -21, -1,
- -2, 1, -4, -1, -3, 22, -1, 1, 3, -22, -1, 11, -11, 1, 1, 1,
- 8, -8, 2, 2, -1, -2, -2, -1, 1, -1, -5, 5, 2, 23, -23, -2,
- 1, -1, 24, -24, -1, -1, 7, 6, -7, 5, -6, 12, -3, 3, 1, -5,
- 1, 1, -12, 25, -1, -5, 5, -25, -1, 1, 9, 1, -1, -9, 26, -26}
+ // MapTab8
+ 4, // _eobSym
+ 11, // _escSym
+ // run table
+ {1, 1, 1, 1, 0, 2, 2, 1, 1, 3, 3, 0, 1, 1, 2, 2,
+ 4, 4, 1, 1, 5, 5, 1, 1, 2, 2, 3, 3, 6, 6, 1, 1,
+ 7, 7, 8, 1, 8, 2, 2, 1, 4, 4, 1, 3, 1, 3, 9, 9,
+ 2, 2, 1, 5, 1, 5, 10, 10, 1, 1, 11, 11, 3, 6, 3, 4,
+ 4, 6, 2, 2, 1, 12, 1, 12, 7, 13, 7, 13, 1, 1, 8, 8,
+ 2, 2, 14, 14, 16, 15, 16, 5, 5, 1, 3, 15, 1, 3, 4, 4,
+ 1, 1, 17, 17, 2, 2, 6, 6, 1, 18, 1, 18, 22, 21, 22, 21,
+ 25, 24, 25, 19, 9, 20, 9, 23, 19, 24, 20, 3, 23, 7, 3, 1,
+ 1, 7, 28, 26, 29, 5, 28, 26, 5, 8, 29, 4, 8, 27, 2, 2,
+ 4, 27, 1, 1, 10, 36, 10, 33, 33, 36, 30, 1, 32, 32, 1, 30,
+ 6, 31, 31, 35, 3, 6, 11, 11, 3, 2, 35, 2, 34, 1, 34, 1,
+ 37, 37, 12, 7, 12, 5, 41, 5, 4, 7, 1, 8, 13, 4, 1, 41,
+ 13, 38, 8, 38, 9, 1, 40, 40, 9, 1, 39, 2, 2, 49, 39, 42,
+ 3, 3, 14, 16, 49, 14, 16, 42, 43, 43, 6, 6, 15, 1, 1, 15,
+ 44, 44, 1, 1, 50, 48, 4, 5, 4, 7, 5, 2, 10, 10, 48, 7,
+ 50, 45, 2, 1, 45, 8, 8, 1, 46, 46, 3, 47, 47, 3, 1, 1},
+
+ // value table
+ { 1, -1, 2, -2, 0, 1, -1, 3, -3, 1, -1, 0, 4, -4, 2, -2,
+ 1, -1, 5, -5, 1, -1, 6, -6, 3, -3, 2, -2, 1, -1, 7, -7,
+ 1, -1, 1, 8, -1, 4, -4, -8, 2, -2, 9, 3, -9, -3, 1, -1,
+ 5, -5, 10, 2, -10, -2, 1, -1, 11, -11, 1, -1, -4, 2, 4, 3,
+ -3, -2, 6, -6, 12, 1, -12, -1, 2, 1, -2, -1, 13, -13, 2, -2,
+ 7, -7, 1, -1, 1, 1, -1, 3, -3, 14, 5, -1, -14, -5, 4, -4,
+ 15, -15, 1, -1, 8, -8, -3, 3, 16, 1, -16, -1, 1, 1, -1, -1,
+ 1, 1, -1, 1, 2, 1, -2, 1, -1, -1, -1, 6, -1, 3, -6, 17,
+ -17, -3, 1, 1, 1, 4, -1, -1, -4, 3, -1, 5, -3, -1, -9, 9,
+ -5, 1, 18, -18, 2, 1, -2, 1, -1, -1, 1, 19, -1, 1, -19, -1,
+ 4, 1, -1, 1, 7, -4, -2, 2, -7, 10, -1, -10, 1, 20, -1, -20,
+ 1, -1, 2, 4, -2, 5, 1, -5, 6, -4, 21, 4, 2, -6, -21, -1,
+ -2, 1, -4, -1, -3, 22, -1, 1, 3, -22, -1, 11, -11, 1, 1, 1,
+ 8, -8, 2, 2, -1, -2, -2, -1, 1, -1, -5, 5, 2, 23, -23, -2,
+ 1, -1, 24, -24, -1, -1, 7, 6, -7, 5, -6, 12, -3, 3, 1, -5,
+ 1, 1, -12, 25, -1, -5, 5, -25, -1, 1, 9, 1, -1, -9, 26, -26}
}
};
diff --git a/image/codecs/indeo/indeo.h b/image/codecs/indeo/indeo.h
index bff5501..3b0b185 100644
--- a/image/codecs/indeo/indeo.h
+++ b/image/codecs/indeo/indeo.h
@@ -46,18 +46,18 @@ namespace Indeo {
* Indeo 4 frame types.
*/
enum {
- IVI4_FRAMETYPE_INTRA = 0,
- IVI4_FRAMETYPE_INTRA1 = 1, ///< intra frame with slightly different bitstream coding
- IVI4_FRAMETYPE_INTER = 2, ///< non-droppable P-frame
- IVI4_FRAMETYPE_BIDIR = 3, ///< bidirectional frame
- IVI4_FRAMETYPE_INTER_NOREF = 4, ///< droppable P-frame
- IVI4_FRAMETYPE_NULL_FIRST = 5, ///< empty frame with no data
- IVI4_FRAMETYPE_NULL_LAST = 6 ///< empty frame with no data
+ IVI4_FRAMETYPE_INTRA = 0,
+ IVI4_FRAMETYPE_INTRA1 = 1, ///< intra frame with slightly different bitstream coding
+ IVI4_FRAMETYPE_INTER = 2, ///< non-droppable P-frame
+ IVI4_FRAMETYPE_BIDIR = 3, ///< bidirectional frame
+ IVI4_FRAMETYPE_INTER_NOREF = 4, ///< droppable P-frame
+ IVI4_FRAMETYPE_NULL_FIRST = 5, ///< empty frame with no data
+ IVI4_FRAMETYPE_NULL_LAST = 6 ///< empty frame with no data
};
enum {
- IVI_MB_HUFF = 0, /// Huffman table is used for coding macroblocks
- IVI_BLK_HUFF = 1 /// Huffman table is used for coding blocks
+ IVI_MB_HUFF = 0, /// Huffman table is used for coding macroblocks
+ IVI_BLK_HUFF = 1 /// Huffman table is used for coding blocks
};
/**
@@ -83,16 +83,16 @@ typedef void (*IviMCAvgFunc)(int16 *buf, const int16 *refBuf1, const int16 *refB
* calculate number of macroblocks in a tile
*/
#define IVI_MBs_PER_TILE(tileWidth, tileHeight, mbSize) \
- ((((tileWidth) + (mbSize) - 1) / (mbSize)) * (((tileHeight) + (mbSize) - 1) / (mbSize)))
+ ((((tileWidth) + (mbSize) - 1) / (mbSize)) * (((tileHeight) + (mbSize) - 1) / (mbSize)))
/**
* huffman codebook descriptor
*/
struct IVIHuffDesc {
- int32 _numRows;
- uint8 _xBits[16];
+ int32 _numRows;
+ uint8 _xBits[16];
- /*
+ /**
* Generate a huffman codebook from the given descriptor
* and convert it into the FFmpeg VLC table.
*
@@ -102,7 +102,7 @@ struct IVIHuffDesc {
*/
int createHuffFromDesc(VLC *vlc, bool flag) const;
- /*
+ /**
* Compare two huffman codebook descriptors.
*
* @param[in] desc2 Ptr to the 2nd descriptor to compare
@@ -110,7 +110,7 @@ struct IVIHuffDesc {
*/
bool huffDescCompare(const IVIHuffDesc *desc2) const;
- /*
+ /**
* Copy huffman codebook descriptors.
*
* @param[in] src ptr to the source descriptor
@@ -127,11 +127,11 @@ struct IVIHuffTab {
public:
int32 _tabSel; /// index of one of the predefined tables
/// or "7" for custom one
- VLC * _tab; /// pointer to the table associated with tab_sel
+ VLC * _tab; /// pointer to the table associated with tab_sel
- /// the following are used only when tab_sel == 7
- IVIHuffDesc _custDesc; /// custom Huffman codebook descriptor
- VLC _custTab; /// vlc table for custom codebook
+ /// the following are used only when tab_sel == 7
+ IVIHuffDesc _custDesc; /// custom Huffman codebook descriptor
+ VLC _custTab; /// vlc table for custom codebook
/**
* Constructor
@@ -154,26 +154,26 @@ public:
* run-value (RLE) table descriptor
*/
struct RVMapDesc {
- uint8 _eobSym; ///< end of block symbol
- uint8 _escSym; ///< escape symbol
- uint8 _runtab[256];
- int8 _valtab[256];
+ uint8 _eobSym; ///< end of block symbol
+ uint8 _escSym; ///< escape symbol
+ uint8 _runtab[256];
+ int8 _valtab[256];
};
/**
* information for Indeo macroblock (16x16, 8x8 or 4x4)
*/
struct IVIMbInfo {
- int16 _xPos;
- int16 _yPos;
- uint32 _bufOffs; ///< address in the output buffer for this mb
- uint8 _type; ///< macroblock type: 0 - INTRA, 1 - INTER
- uint8 _cbp; ///< coded block pattern
- int8 _qDelta; ///< quant delta
- int8 _mvX; ///< motion vector (x component)
- int8 _mvY; ///< motion vector (y component)
- int8 _bMvX; ///< second motion vector (x component)
- int8 _bMvY; ///< second motion vector (y component)
+ int16 _xPos;
+ int16 _yPos;
+ uint32 _bufOffs; ///< address in the output buffer for this mb
+ uint8 _type; ///< macroblock type: 0 - INTRA, 1 - INTER
+ uint8 _cbp; ///< coded block pattern
+ int8 _qDelta; ///< quant delta
+ int8 _mvX; ///< motion vector (x component)
+ int8 _mvY; ///< motion vector (y component)
+ int8 _bMvX; ///< second motion vector (x component)
+ int8 _bMvY; ///< second motion vector (y component)
IVIMbInfo();
};
@@ -182,16 +182,16 @@ struct IVIMbInfo {
* information for Indeo tile
*/
struct IVITile {
- int _xPos;
- int _yPos;
- int _width;
- int _height;
- int _mbSize;
- bool _isEmpty;
- int _dataSize; ///< size of the data in bytes
- int _numMBs; ///< number of macroblocks in this tile
- IVIMbInfo * _mbs; ///< array of macroblock descriptors
- IVIMbInfo * _refMbs; ///< ptr to the macroblock descriptors of the reference tile
+ int _xPos;
+ int _yPos;
+ int _width;
+ int _height;
+ int _mbSize;
+ bool _isEmpty;
+ int _dataSize; ///< size of the data in bytes
+ int _numMBs; ///< number of macroblocks in this tile
+ IVIMbInfo * _mbs; ///< array of macroblock descriptors
+ IVIMbInfo * _refMbs; ///< ptr to the macroblock descriptors of the reference tile
IVITile();
};
@@ -200,49 +200,49 @@ struct IVITile {
* information for Indeo wavelet band
*/
struct IVIBandDesc {
- int _plane; ///< plane number this band belongs to
- int _bandNum; ///< band number
- int _width;
- int _height;
- int _aHeight; ///< aligned band height
- const uint8 * _dataPtr; ///< ptr to the first byte of the band data
- int _dataSize; ///< size of the band data
- int16 * _buf; ///< pointer to the output buffer for this band
- int16 * _refBuf; ///< pointer to the reference frame buffer (for motion compensation)
- int16 * _bRefBuf; ///< pointer to the second reference frame buffer (for motion compensation)
- int16 * _bufs[4]; ///< array of pointers to the band buffers
- int _pitch; ///< _pitch associated with the buffers above
- bool _isEmpty;
- int _mbSize; ///< macroblock size
- int _blkSize; ///< block size
- uint8 _isHalfpel; ///< precision of the motion compensation: 0 - fullpel, 1 - halfpel
- bool _inheritMv; ///< tells if motion vector is inherited from reference macroblock
- bool _inheritQDelta; ///< tells if quantiser delta is inherited from reference macroblock
- bool _qdeltaPresent; ///< tells if Qdelta signal is present in the bitstream (Indeo5 only)
- int _quantMat; ///< dequant matrix index
- int _globQuant; ///< quant base for this band
- const uint8 * _scan; ///< ptr to the scan pattern
- int _scanSize; ///< size of the scantable
-
- IVIHuffTab _blkVlc; ///< vlc table for decoding block data
-
- int _numCorr; ///< number of correction entries
- uint8 _corr[61 * 2]; ///< rvmap correction pairs
- int _rvmapSel; ///< rvmap table selector
- RVMapDesc * _rvMap; ///< ptr to the RLE table for this band
- int _numTiles; ///< number of tiles in this band
- IVITile * _tiles; ///< array of tile descriptors
- InvTransformPtr *_invTransform;
- int _transformSize;
- DCTransformPtr *_dcTransform;
- bool _is2dTrans;
- int32 _checksum; ///< for debug purposes
- int _checksumPresent;
- int _bufSize; ///< band buffer size in bytes
- const uint16 * _intraBase; ///< quantization matrix for intra blocks
- const uint16 * _interBase; ///< quantization matrix for inter blocks
- const uint8 * _intraScale; ///< quantization coefficient for intra blocks
- const uint8 * _interScale; ///< quantization coefficient for inter blocks
+ int _plane; ///< plane number this band belongs to
+ int _bandNum; ///< band number
+ int _width;
+ int _height;
+ int _aHeight; ///< aligned band height
+ const uint8 * _dataPtr; ///< ptr to the first byte of the band data
+ int _dataSize; ///< size of the band data
+ int16 * _buf; ///< pointer to the output buffer for this band
+ int16 * _refBuf; ///< pointer to the reference frame buffer (for motion compensation)
+ int16 * _bRefBuf; ///< pointer to the second reference frame buffer (for motion compensation)
+ int16 * _bufs[4]; ///< array of pointers to the band buffers
+ int _pitch; ///< _pitch associated with the buffers above
+ bool _isEmpty;
+ int _mbSize; ///< macroblock size
+ int _blkSize; ///< block size
+ uint8 _isHalfpel; ///< precision of the motion compensation: 0 - fullpel, 1 - halfpel
+ bool _inheritMv; ///< tells if motion vector is inherited from reference macroblock
+ bool _inheritQDelta; ///< tells if quantiser delta is inherited from reference macroblock
+ bool _qdeltaPresent; ///< tells if Qdelta signal is present in the bitstream (Indeo5 only)
+ int _quantMat; ///< dequant matrix index
+ int _globQuant; ///< quant base for this band
+ const uint8 * _scan; ///< ptr to the scan pattern
+ int _scanSize; ///< size of the scantable
+
+ IVIHuffTab _blkVlc; ///< vlc table for decoding block data
+
+ int _numCorr; ///< number of correction entries
+ uint8 _corr[61 * 2]; ///< rvmap correction pairs
+ int _rvmapSel; ///< rvmap table selector
+ RVMapDesc * _rvMap; ///< ptr to the RLE table for this band
+ int _numTiles; ///< number of tiles in this band
+ IVITile * _tiles; ///< array of tile descriptors
+ InvTransformPtr *_invTransform;
+ int _transformSize;
+ DCTransformPtr *_dcTransform;
+ bool _is2dTrans;
+ int32 _checksum; ///< for debug purposes
+ int _checksumPresent;
+ int _bufSize; ///< band buffer size in bytes
+ const uint16 * _intraBase; ///< quantization matrix for intra blocks
+ const uint16 * _interBase; ///< quantization matrix for inter blocks
+ const uint8 * _intraScale; ///< quantization coefficient for intra blocks
+ const uint8 * _interScale; ///< quantization coefficient for inter blocks
IVIBandDesc();
@@ -250,14 +250,14 @@ struct IVIBandDesc {
};
struct IVIPicConfig {
- uint16 _picWidth;
- uint16 _picHeight;
- uint16 _chromaWidth;
- uint16 _chromaHeight;
- uint16 _tileWidth;
- uint16 _tileHeight;
- uint8 _lumaBands;
- uint8 _chromaBands;
+ uint16 _picWidth;
+ uint16 _picHeight;
+ uint16 _chromaWidth;
+ uint16 _chromaHeight;
+ uint16 _tileWidth;
+ uint16 _tileHeight;
+ uint8 _lumaBands;
+ uint8 _chromaBands;
IVIPicConfig();
@@ -271,10 +271,10 @@ struct IVIPicConfig {
* color plane (luma or chroma) information
*/
struct IVIPlaneDesc {
- uint16 _width;
- uint16 _height;
- uint8 _numBands; ///< number of bands this plane subdivided into
- IVIBandDesc * _bands; ///< array of band descriptors
+ uint16 _width;
+ uint16 _height;
+ uint8 _numBands; ///< number of bands this plane subdivided into
+ IVIBandDesc * _bands; ///< array of band descriptors
IVIPlaneDesc();
@@ -282,7 +282,7 @@ struct IVIPlaneDesc {
static int initTiles(IVIPlaneDesc *planes, int tileWidth, int tileHeight);
- /*
+ /**
* Free planes, bands and macroblocks buffers.
*
* @param[in] planes pointer to the array of the plane descriptors
@@ -309,35 +309,35 @@ struct AVFrame {
#define AV_NUM_DATA_POINTERS 3
/**
- * pointer to the picture/channel planes.
- * This might be different from the first allocated byte
- *
- * Some decoders access areas outside 0,0 - width,height, please
- * see avcodec_align_dimensions2(). Some filters and swscale can read
- * up to 16 bytes beyond the planes, if these filters are to be used,
- * then 16 extra bytes must be allocated.
- *
- * NOTE: Except for hwaccel formats, pointers not needed by the format
- * MUST be set to NULL.
- */
+ * pointer to the picture/channel planes.
+ * This might be different from the first allocated byte
+ *
+ * Some decoders access areas outside 0,0 - width,height, please
+ * see avcodec_align_dimensions2(). Some filters and swscale can read
+ * up to 16 bytes beyond the planes, if these filters are to be used,
+ * then 16 extra bytes must be allocated.
+ *
+ * NOTE: Except for hwaccel formats, pointers not needed by the format
+ * MUST be set to NULL.
+ */
uint8 *_data[AV_NUM_DATA_POINTERS];
- /**
- * For video, size in bytes of each picture line.
- * For audio, size in bytes of each plane.
- *
- * For audio, only linesize[0] may be set. For planar audio, each channel
- * plane must be the same size.
- *
- * For video the linesizes should be multiples of the CPUs alignment
- * preference, this is 16 or 32 for modern desktop CPUs.
- * Some code requires such alignment other code can be slower without
- * correct alignment, for yet other it makes no difference.
- *
- * @note The linesize may be larger than the size of usable data -- there
- * may be extra padding present for performance reasons.
- */
- int _linesize[AV_NUM_DATA_POINTERS];
+ /**
+ * For video, size in bytes of each picture line.
+ * For audio, size in bytes of each plane.
+ *
+ * For audio, only linesize[0] may be set. For planar audio, each channel
+ * plane must be the same size.
+ *
+ * For video the linesizes should be multiples of the CPUs alignment
+ * preference, this is 16 or 32 for modern desktop CPUs.
+ * Some code requires such alignment other code can be slower without
+ * correct alignment, for yet other it makes no difference.
+ *
+ * @note The linesize may be larger than the size of usable data -- there
+ * may be extra padding present for performance reasons.
+ */
+ int _linesize[AV_NUM_DATA_POINTERS];
/**
* Constructor
@@ -372,56 +372,56 @@ private:
VLC _iviMbVlcTabs[8]; ///< static macroblock Huffman tables
VLC _iviBlkVlcTabs[8]; ///< static block Huffman tables
public:
- GetBits * _gb;
- RVMapDesc _rvmapTabs[9]; ///< local corrected copy of the static rvmap tables
-
- uint32 _frameNum;
- int _frameType;
- int _prevFrameType; ///< frame type of the previous frame
- uint32 _dataSize; ///< size of the frame data in bytes from picture header
- int _isScalable;
- const uint8 * _frameData; ///< input frame data pointer
- int _interScal; ///< signals a sequence of scalable inter frames
- uint32 _frameSize; ///< frame size in bytes
- uint32 _picHdrSize; ///< picture header size in bytes
- uint8 _frameFlags;
- uint16 _checksum; ///< frame _checksum
-
- IVIPicConfig _picConf;
- IVIPlaneDesc _planes[3]; ///< color planes
-
- int _bufSwitch; ///< used to switch between three buffers
- int _dstBuf; ///< buffer index for the currently decoded frame
- int _refBuf; ///< inter frame reference buffer index
- int _ref2Buf; ///< temporal storage for switching buffers
- int _bRefBuf; ///< second reference frame buffer index
-
- IVIHuffTab _mbVlc; ///< current macroblock table descriptor
- IVIHuffTab _blkVlc; ///< current block table descriptor
-
- uint8 _rvmapSel;
- bool _inImf;
- bool _inQ; ///< flag for explicitly stored quantiser delta
- uint8 _picGlobQuant;
- uint8 _unknown1;
-
- uint16 _gopHdrSize;
- uint8 _gopFlags;
- uint32 _lockWord;
-
- bool _hasBFrames;
- bool _hasTransp; ///< transparency mode enabled
- bool _usesTiling;
- bool _usesHaar;
- bool _usesFullpel;
-
- bool _gopInvalid;
- int _bufInvalid[4];
-
- bool _isIndeo4;
-
- AVFrame * _pFrame;
- bool _gotPFrame;
+ GetBits * _gb;
+ RVMapDesc _rvmapTabs[9]; ///< local corrected copy of the static rvmap tables
+
+ uint32 _frameNum;
+ int _frameType;
+ int _prevFrameType; ///< frame type of the previous frame
+ uint32 _dataSize; ///< size of the frame data in bytes from picture header
+ int _isScalable;
+ const uint8 * _frameData; ///< input frame data pointer
+ int _interScal; ///< signals a sequence of scalable inter frames
+ uint32 _frameSize; ///< frame size in bytes
+ uint32 _picHdrSize; ///< picture header size in bytes
+ uint8 _frameFlags;
+ uint16 _checksum; ///< frame _checksum
+
+ IVIPicConfig _picConf;
+ IVIPlaneDesc _planes[3]; ///< color planes
+
+ int _bufSwitch; ///< used to switch between three buffers
+ int _dstBuf; ///< buffer index for the currently decoded frame
+ int _refBuf; ///< inter frame reference buffer index
+ int _ref2Buf; ///< temporal storage for switching buffers
+ int _bRefBuf; ///< second reference frame buffer index
+
+ IVIHuffTab _mbVlc; ///< current macroblock table descriptor
+ IVIHuffTab _blkVlc; ///< current block table descriptor
+
+ uint8 _rvmapSel;
+ bool _inImf;
+ bool _inQ; ///< flag for explicitly stored quantiser delta
+ uint8 _picGlobQuant;
+ uint8 _unknown1;
+
+ uint16 _gopHdrSize;
+ uint8 _gopFlags;
+ uint32 _lockWord;
+
+ bool _hasBFrames;
+ bool _hasTransp; ///< transparency mode enabled
+ bool _usesTiling;
+ bool _usesHaar;
+ bool _usesFullpel;
+
+ bool _gopInvalid;
+ int _bufInvalid[4];
+
+ bool _isIndeo4;
+
+ AVFrame * _pFrame;
+ bool _gotPFrame;
IVI45DecContext();
private:
diff --git a/image/codecs/indeo/indeo_dsp.cpp b/image/codecs/indeo/indeo_dsp.cpp
index d4803b8..15626e9 100644
--- a/image/codecs/indeo/indeo_dsp.cpp
+++ b/image/codecs/indeo/indeo_dsp.cpp
@@ -35,597 +35,597 @@ namespace Indeo {
* butterfly operation for the inverse Haar transform
*/
#define IVI_HAAR_BFLY(s1, s2, o1, o2, t) \
- t = ((s1) - (s2)) >> 1;\
- o1 = ((s1) + (s2)) >> 1;\
- o2 = (t);\
+ t = ((s1) - (s2)) >> 1;\
+ o1 = ((s1) + (s2)) >> 1;\
+ o2 = (t);\
/**
* inverse 8-point Haar transform
*/
#define INV_HAAR8(s1, s5, s3, s7, s2, s4, s6, s8,\
- d1, d2, d3, d4, d5, d6, d7, d8,\
- t0, t1, t2, t3, t4, t5, t6, t7, t8) {\
- t1 = (s1) << 1; t5 = (s5) << 1;\
- IVI_HAAR_BFLY(t1, t5, t1, t5, t0); IVI_HAAR_BFLY(t1, s3, t1, t3, t0);\
- IVI_HAAR_BFLY(t5, s7, t5, t7, t0); IVI_HAAR_BFLY(t1, s2, t1, t2, t0);\
- IVI_HAAR_BFLY(t3, s4, t3, t4, t0); IVI_HAAR_BFLY(t5, s6, t5, t6, t0);\
- IVI_HAAR_BFLY(t7, s8, t7, t8, t0);\
- d1 = COMPENSATE(t1);\
- d2 = COMPENSATE(t2);\
- d3 = COMPENSATE(t3);\
- d4 = COMPENSATE(t4);\
- d5 = COMPENSATE(t5);\
- d6 = COMPENSATE(t6);\
- d7 = COMPENSATE(t7);\
- d8 = COMPENSATE(t8); }
+ d1, d2, d3, d4, d5, d6, d7, d8,\
+ t0, t1, t2, t3, t4, t5, t6, t7, t8) {\
+ t1 = (s1) << 1; t5 = (s5) << 1;\
+ IVI_HAAR_BFLY(t1, t5, t1, t5, t0); IVI_HAAR_BFLY(t1, s3, t1, t3, t0);\
+ IVI_HAAR_BFLY(t5, s7, t5, t7, t0); IVI_HAAR_BFLY(t1, s2, t1, t2, t0);\
+ IVI_HAAR_BFLY(t3, s4, t3, t4, t0); IVI_HAAR_BFLY(t5, s6, t5, t6, t0);\
+ IVI_HAAR_BFLY(t7, s8, t7, t8, t0);\
+ d1 = COMPENSATE(t1);\
+ d2 = COMPENSATE(t2);\
+ d3 = COMPENSATE(t3);\
+ d4 = COMPENSATE(t4);\
+ d5 = COMPENSATE(t5);\
+ d6 = COMPENSATE(t6);\
+ d7 = COMPENSATE(t7);\
+ d8 = COMPENSATE(t8); }
/**
* inverse 4-point Haar transform
*/
#define INV_HAAR4(s1, s3, s5, s7, d1, d2, d3, d4, t0, t1, t2, t3, t4) {\
- IVI_HAAR_BFLY(s1, s3, t0, t1, t4);\
- IVI_HAAR_BFLY(t0, s5, t2, t3, t4);\
- d1 = COMPENSATE(t2);\
- d2 = COMPENSATE(t3);\
- IVI_HAAR_BFLY(t1, s7, t2, t3, t4);\
- d3 = COMPENSATE(t2);\
- d4 = COMPENSATE(t3); }
+ IVI_HAAR_BFLY(s1, s3, t0, t1, t4);\
+ IVI_HAAR_BFLY(t0, s5, t2, t3, t4);\
+ d1 = COMPENSATE(t2);\
+ d2 = COMPENSATE(t3);\
+ IVI_HAAR_BFLY(t1, s7, t2, t3, t4);\
+ d3 = COMPENSATE(t2);\
+ d4 = COMPENSATE(t3); }
void IndeoDSP::ffIviInverseHaar8x8(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags) {
- int i, shift, sp1, sp2, sp3, sp4;
- const int32 *src;
- int32 * dst;
- int tmp[64];
- int t0, t1, t2, t3, t4, t5, t6, t7, t8;
-
- // apply the InvHaar8 to all columns
+ const uint8 *flags) {
+ int i, shift, sp1, sp2, sp3, sp4;
+ const int32 *src;
+ int32 * dst;
+ int tmp[64];
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+
+ // apply the InvHaar8 to all columns
#define COMPENSATE(x) (x)
- src = in;
- dst = tmp;
- for (i = 0; i < 8; i++) {
- if (flags[i]) {
- // pre-scaling
- shift = !(i & 4);
- sp1 = src[ 0] << shift;
- sp2 = src[ 8] << shift;
- sp3 = src[16] << shift;
- sp4 = src[24] << shift;
- INV_HAAR8( sp1, sp2, sp3, sp4,
- src[32], src[40], src[48], src[56],
- dst[ 0], dst[ 8], dst[16], dst[24],
- dst[32], dst[40], dst[48], dst[56],
- t0, t1, t2, t3, t4, t5, t6, t7, t8);
- } else {
- dst[ 0] = dst[ 8] = dst[16] = dst[24] =
- dst[32] = dst[40] = dst[48] = dst[56] = 0;
+ src = in;
+ dst = tmp;
+ for (i = 0; i < 8; i++) {
+ if (flags[i]) {
+ // pre-scaling
+ shift = !(i & 4);
+ sp1 = src[ 0] << shift;
+ sp2 = src[ 8] << shift;
+ sp3 = src[16] << shift;
+ sp4 = src[24] << shift;
+ INV_HAAR8( sp1, sp2, sp3, sp4,
+ src[32], src[40], src[48], src[56],
+ dst[ 0], dst[ 8], dst[16], dst[24],
+ dst[32], dst[40], dst[48], dst[56],
+ t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ } else {
+ dst[ 0] = dst[ 8] = dst[16] = dst[24] =
+ dst[32] = dst[40] = dst[48] = dst[56] = 0;
}
- src++;
- dst++;
- }
+ src++;
+ dst++;
+ }
#undef COMPENSATE
- // apply the InvHaar8 to all rows
+ // apply the InvHaar8 to all rows
#define COMPENSATE(x) (x)
- src = tmp;
- for (i = 0; i < 8; i++) {
- if ( !src[0] && !src[1] && !src[2] && !src[3]
- && !src[4] && !src[5] && !src[6] && !src[7]) {
- memset(out, 0, 8 * sizeof(out[0]));
- } else {
- INV_HAAR8(src[0], src[1], src[2], src[3],
- src[4], src[5], src[6], src[7],
- out[0], out[1], out[2], out[3],
- out[4], out[5], out[6], out[7],
- t0, t1, t2, t3, t4, t5, t6, t7, t8);
- }
- src += 8;
- out += pitch;
- }
+ src = tmp;
+ for (i = 0; i < 8; i++) {
+ if ( !src[0] && !src[1] && !src[2] && !src[3]
+ && !src[4] && !src[5] && !src[6] && !src[7]) {
+ memset(out, 0, 8 * sizeof(out[0]));
+ } else {
+ INV_HAAR8(src[0], src[1], src[2], src[3],
+ src[4], src[5], src[6], src[7],
+ out[0], out[1], out[2], out[3],
+ out[4], out[5], out[6], out[7],
+ t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ }
+ src += 8;
+ out += pitch;
+ }
#undef COMPENSATE
}
void IndeoDSP::ffIviRowHaar8(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags) {
- int i;
- int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+ const uint8 *flags) {
+ int i;
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
- // apply the InvHaar8 to all rows
+ // apply the InvHaar8 to all rows
#define COMPENSATE(x) (x)
- for (i = 0; i < 8; i++) {
- if ( !in[0] && !in[1] && !in[2] && !in[3]
- && !in[4] && !in[5] && !in[6] && !in[7]) {
- memset(out, 0, 8 * sizeof(out[0]));
- } else {
- INV_HAAR8(in[0], in[1], in[2], in[3],
- in[4], in[5], in[6], in[7],
- out[0], out[1], out[2], out[3],
- out[4], out[5], out[6], out[7],
- t0, t1, t2, t3, t4, t5, t6, t7, t8);
- }
- in += 8;
- out += pitch;
- }
+ for (i = 0; i < 8; i++) {
+ if ( !in[0] && !in[1] && !in[2] && !in[3]
+ && !in[4] && !in[5] && !in[6] && !in[7]) {
+ memset(out, 0, 8 * sizeof(out[0]));
+ } else {
+ INV_HAAR8(in[0], in[1], in[2], in[3],
+ in[4], in[5], in[6], in[7],
+ out[0], out[1], out[2], out[3],
+ out[4], out[5], out[6], out[7],
+ t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ }
+ in += 8;
+ out += pitch;
+ }
#undef COMPENSATE
}
void IndeoDSP::ffIviColHaar8(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags) {
- int i;
- int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+ const uint8 *flags) {
+ int i;
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
- // apply the InvHaar8 to all columns
+ // apply the InvHaar8 to all columns
#define COMPENSATE(x) (x)
- for (i = 0; i < 8; i++) {
- if (flags[i]) {
- INV_HAAR8(in[ 0], in[ 8], in[16], in[24],
- in[32], in[40], in[48], in[56],
- out[0 * pitch], out[1 * pitch],
- out[2 * pitch], out[3 * pitch],
- out[4 * pitch], out[5 * pitch],
- out[6 * pitch], out[7 * pitch],
- t0, t1, t2, t3, t4, t5, t6, t7, t8);
- } else {
- out[0 * pitch] = out[1 * pitch] =
- out[2 * pitch] = out[3 * pitch] =
- out[4 * pitch] = out[5 * pitch] =
- out[6 * pitch] = out[7 * pitch] = 0;
+ for (i = 0; i < 8; i++) {
+ if (flags[i]) {
+ INV_HAAR8(in[ 0], in[ 8], in[16], in[24],
+ in[32], in[40], in[48], in[56],
+ out[0 * pitch], out[1 * pitch],
+ out[2 * pitch], out[3 * pitch],
+ out[4 * pitch], out[5 * pitch],
+ out[6 * pitch], out[7 * pitch],
+ t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ } else {
+ out[0 * pitch] = out[1 * pitch] =
+ out[2 * pitch] = out[3 * pitch] =
+ out[4 * pitch] = out[5 * pitch] =
+ out[6 * pitch] = out[7 * pitch] = 0;
}
- in++;
- out++;
- }
+ in++;
+ out++;
+ }
#undef COMPENSATE
}
void IndeoDSP::ffIviInverseHaar4x4(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags) {
- int i, shift, sp1, sp2;
- const int32 *src;
- int32 * dst;
- int tmp[16];
- int t0, t1, t2, t3, t4;
-
- // apply the InvHaar4 to all columns
+ const uint8 *flags) {
+ int i, shift, sp1, sp2;
+ const int32 *src;
+ int32 * dst;
+ int tmp[16];
+ int t0, t1, t2, t3, t4;
+
+ // apply the InvHaar4 to all columns
#define COMPENSATE(x) (x)
- src = in;
- dst = tmp;
- for (i = 0; i < 4; i++) {
- if (flags[i]) {
- // pre-scaling
- shift = !(i & 2);
- sp1 = src[0] << shift;
- sp2 = src[4] << shift;
- INV_HAAR4( sp1, sp2, src[8], src[12],
- dst[0], dst[4], dst[8], dst[12],
- t0, t1, t2, t3, t4);
- } else {
- dst[0] = dst[4] = dst[8] = dst[12] = 0;
+ src = in;
+ dst = tmp;
+ for (i = 0; i < 4; i++) {
+ if (flags[i]) {
+ // pre-scaling
+ shift = !(i & 2);
+ sp1 = src[0] << shift;
+ sp2 = src[4] << shift;
+ INV_HAAR4( sp1, sp2, src[8], src[12],
+ dst[0], dst[4], dst[8], dst[12],
+ t0, t1, t2, t3, t4);
+ } else {
+ dst[0] = dst[4] = dst[8] = dst[12] = 0;
}
- src++;
- dst++;
- }
+ src++;
+ dst++;
+ }
#undef COMPENSATE
- // apply the InvHaar8 to all rows
+ // apply the InvHaar8 to all rows
#define COMPENSATE(x) (x)
- src = tmp;
- for (i = 0; i < 4; i++) {
- if (!src[0] && !src[1] && !src[2] && !src[3]) {
- memset(out, 0, 4 * sizeof(out[0]));
- } else {
- INV_HAAR4(src[0], src[1], src[2], src[3],
- out[0], out[1], out[2], out[3],
- t0, t1, t2, t3, t4);
- }
- src += 4;
- out += pitch;
- }
+ src = tmp;
+ for (i = 0; i < 4; i++) {
+ if (!src[0] && !src[1] && !src[2] && !src[3]) {
+ memset(out, 0, 4 * sizeof(out[0]));
+ } else {
+ INV_HAAR4(src[0], src[1], src[2], src[3],
+ out[0], out[1], out[2], out[3],
+ t0, t1, t2, t3, t4);
+ }
+ src += 4;
+ out += pitch;
+ }
#undef COMPENSATE
}
void IndeoDSP::ffIviRowHaar4(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags) {
- int i;
- int t0, t1, t2, t3, t4;
+ const uint8 *flags) {
+ int i;
+ int t0, t1, t2, t3, t4;
- // apply the InvHaar4 to all rows
+ // apply the InvHaar4 to all rows
#define COMPENSATE(x) (x)
- for (i = 0; i < 4; i++) {
- if (!in[0] && !in[1] && !in[2] && !in[3]) {
- memset(out, 0, 4 * sizeof(out[0]));
- } else {
- INV_HAAR4(in[0], in[1], in[2], in[3],
- out[0], out[1], out[2], out[3],
- t0, t1, t2, t3, t4);
- }
- in += 4;
- out += pitch;
- }
+ for (i = 0; i < 4; i++) {
+ if (!in[0] && !in[1] && !in[2] && !in[3]) {
+ memset(out, 0, 4 * sizeof(out[0]));
+ } else {
+ INV_HAAR4(in[0], in[1], in[2], in[3],
+ out[0], out[1], out[2], out[3],
+ t0, t1, t2, t3, t4);
+ }
+ in += 4;
+ out += pitch;
+ }
#undef COMPENSATE
}
void IndeoDSP::ffIviColHaar4(const int32 *in, int16 *out, uint32 pitch,
- const uint8 *flags) {
- int i;
- int t0, t1, t2, t3, t4;
+ const uint8 *flags) {
+ int i;
+ int t0, t1, t2, t3, t4;
- // apply the InvHaar8 to all columns
+ // apply the InvHaar8 to all columns
#define COMPENSATE(x) (x)
- for (i = 0; i < 4; i++) {
- if (flags[i]) {
- INV_HAAR4(in[0], in[4], in[8], in[12],
- out[0 * pitch], out[1 * pitch],
- out[2 * pitch], out[3 * pitch],
- t0, t1, t2, t3, t4);
- } else {
- out[0 * pitch] = out[1 * pitch] =
- out[2 * pitch] = out[3 * pitch] = 0;
+ for (i = 0; i < 4; i++) {
+ if (flags[i]) {
+ INV_HAAR4(in[0], in[4], in[8], in[12],
+ out[0 * pitch], out[1 * pitch],
+ out[2 * pitch], out[3 * pitch],
+ t0, t1, t2, t3, t4);
+ } else {
+ out[0 * pitch] = out[1 * pitch] =
+ out[2 * pitch] = out[3 * pitch] = 0;
}
- in++;
- out++;
- }
+ in++;
+ out++;
+ }
#undef COMPENSATE
}
void IndeoDSP::ffIviDcHaar2d(const int32 *in, int16 *out, uint32 pitch,
- int blkSize) {
- int x, y;
- int16 dcCoeff;
+ int blkSize) {
+ int x, y;
+ int16 dcCoeff;
- dcCoeff = (*in + 0) >> 3;
+ dcCoeff = (*in + 0) >> 3;
- for (y = 0; y < blkSize; out += pitch, y++) {
- for (x = 0; x < blkSize; x++)
- out[x] = dcCoeff;
- }
+ for (y = 0; y < blkSize; out += pitch, y++) {
+ for (x = 0; x < blkSize; x++)
+ out[x] = dcCoeff;
+ }
}
//* butterfly operation for the inverse slant transform
#define IVI_SLANT_BFLY(s1, s2, o1, o2, t) \
- t = (s1) - (s2);\
- o1 = (s1) + (s2);\
- o2 = (t);\
+ t = (s1) - (s2);\
+ o1 = (s1) + (s2);\
+ o2 = (t);\
//* This is a reflection a,b = 1/2, 5/4 for the inverse slant transform
#define IVI_IREFLECT(s1, s2, o1, o2, t) \
- t = (((s1) + (s2)*2 + 2) >> 2) + (s1);\
- o2 = (((s1)*2 - (s2) + 2) >> 2) - (s2);\
- o1 = (t);\
+ t = (((s1) + (s2)*2 + 2) >> 2) + (s1);\
+ o2 = (((s1)*2 - (s2) + 2) >> 2) - (s2);\
+ o1 = (t);\
//* This is a reflection a,b = 1/2, 7/8 for the inverse slant transform
#define IVI_SLANT_PART4(s1, s2, o1, o2, t) \
- t = (s2) + (((s1)*4 - (s2) + 4) >> 3);\
- o2 = (s1) + ((-(s1) - (s2)*4 + 4) >> 3);\
- o1 = (t);\
+ t = (s2) + (((s1)*4 - (s2) + 4) >> 3);\
+ o2 = (s1) + ((-(s1) - (s2)*4 + 4) >> 3);\
+ o1 = (t);\
//* inverse slant8 transform
#define IVI_INV_SLANT8(s1, s4, s8, s5, s2, s6, s3, s7,\
- d1, d2, d3, d4, d5, d6, d7, d8,\
- t0, t1, t2, t3, t4, t5, t6, t7, t8) {\
- IVI_SLANT_PART4(s4, s5, t4, t5, t0);\
+ d1, d2, d3, d4, d5, d6, d7, d8,\
+ t0, t1, t2, t3, t4, t5, t6, t7, t8) {\
+ IVI_SLANT_PART4(s4, s5, t4, t5, t0);\
\
- IVI_SLANT_BFLY(s1, t5, t1, t5, t0); IVI_SLANT_BFLY(s2, s6, t2, t6, t0);\
- IVI_SLANT_BFLY(s7, s3, t7, t3, t0); IVI_SLANT_BFLY(t4, s8, t4, t8, t0);\
+ IVI_SLANT_BFLY(s1, t5, t1, t5, t0); IVI_SLANT_BFLY(s2, s6, t2, t6, t0);\
+ IVI_SLANT_BFLY(s7, s3, t7, t3, t0); IVI_SLANT_BFLY(t4, s8, t4, t8, t0);\
\
- IVI_SLANT_BFLY(t1, t2, t1, t2, t0); IVI_IREFLECT (t4, t3, t4, t3, t0);\
- IVI_SLANT_BFLY(t5, t6, t5, t6, t0); IVI_IREFLECT (t8, t7, t8, t7, t0);\
- IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\
- IVI_SLANT_BFLY(t5, t8, t5, t8, t0); IVI_SLANT_BFLY(t6, t7, t6, t7, t0);\
- d1 = COMPENSATE(t1);\
- d2 = COMPENSATE(t2);\
- d3 = COMPENSATE(t3);\
- d4 = COMPENSATE(t4);\
- d5 = COMPENSATE(t5);\
- d6 = COMPENSATE(t6);\
- d7 = COMPENSATE(t7);\
- d8 = COMPENSATE(t8);}
+ IVI_SLANT_BFLY(t1, t2, t1, t2, t0); IVI_IREFLECT (t4, t3, t4, t3, t0);\
+ IVI_SLANT_BFLY(t5, t6, t5, t6, t0); IVI_IREFLECT (t8, t7, t8, t7, t0);\
+ IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\
+ IVI_SLANT_BFLY(t5, t8, t5, t8, t0); IVI_SLANT_BFLY(t6, t7, t6, t7, t0);\
+ d1 = COMPENSATE(t1);\
+ d2 = COMPENSATE(t2);\
+ d3 = COMPENSATE(t3);\
+ d4 = COMPENSATE(t4);\
+ d5 = COMPENSATE(t5);\
+ d6 = COMPENSATE(t6);\
+ d7 = COMPENSATE(t7);\
+ d8 = COMPENSATE(t8);}
//* inverse slant4 transform
#define IVI_INV_SLANT4(s1, s4, s2, s3, d1, d2, d3, d4, t0, t1, t2, t3, t4) {\
- IVI_SLANT_BFLY(s1, s2, t1, t2, t0); IVI_IREFLECT (s4, s3, t4, t3, t0);\
+ IVI_SLANT_BFLY(s1, s2, t1, t2, t0); IVI_IREFLECT (s4, s3, t4, t3, t0);\
\
- IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\
- d1 = COMPENSATE(t1);\
- d2 = COMPENSATE(t2);\
- d3 = COMPENSATE(t3);\
- d4 = COMPENSATE(t4);}
+ IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\
+ d1 = COMPENSATE(t1);\
+ d2 = COMPENSATE(t2);\
+ d3 = COMPENSATE(t3);\
+ d4 = COMPENSATE(t4);}
void IndeoDSP::ffIviInverseSlant8x8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) {
- int i;
- const int32 *src;
- int32 * dst;
- int tmp[64];
- int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+ int i;
+ const int32 *src;
+ int32 * dst;
+ int tmp[64];
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
#define COMPENSATE(x) (x)
- src = in;
- dst = tmp;
- for (i = 0; i < 8; i++) {
- if (flags[i]) {
- IVI_INV_SLANT8(src[0], src[8], src[16], src[24], src[32], src[40], src[48], src[56],
- dst[0], dst[8], dst[16], dst[24], dst[32], dst[40], dst[48], dst[56],
- t0, t1, t2, t3, t4, t5, t6, t7, t8);
- } else {
- dst[0] = dst[8] = dst[16] = dst[24] = dst[32] = dst[40] = dst[48] = dst[56] = 0;
+ src = in;
+ dst = tmp;
+ for (i = 0; i < 8; i++) {
+ if (flags[i]) {
+ IVI_INV_SLANT8(src[0], src[8], src[16], src[24], src[32], src[40], src[48], src[56],
+ dst[0], dst[8], dst[16], dst[24], dst[32], dst[40], dst[48], dst[56],
+ t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ } else {
+ dst[0] = dst[8] = dst[16] = dst[24] = dst[32] = dst[40] = dst[48] = dst[56] = 0;
}
src++;
- dst++;
- }
+ dst++;
+ }
#undef COMPENSATE
#define COMPENSATE(x) (((x) + 1)>>1)
- src = tmp;
- for (i = 0; i < 8; i++) {
- if (!src[0] && !src[1] && !src[2] && !src[3] && !src[4] && !src[5] && !src[6] && !src[7]) {
- memset(out, 0, 8*sizeof(out[0]));
- } else {
- IVI_INV_SLANT8(src[0], src[1], src[2], src[3], src[4], src[5], src[6], src[7],
- out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7],
- t0, t1, t2, t3, t4, t5, t6, t7, t8);
- }
- src += 8;
- out += pitch;
- }
+ src = tmp;
+ for (i = 0; i < 8; i++) {
+ if (!src[0] && !src[1] && !src[2] && !src[3] && !src[4] && !src[5] && !src[6] && !src[7]) {
+ memset(out, 0, 8*sizeof(out[0]));
+ } else {
+ IVI_INV_SLANT8(src[0], src[1], src[2], src[3], src[4], src[5], src[6], src[7],
+ out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7],
+ t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ }
+ src += 8;
+ out += pitch;
+ }
#undef COMPENSATE
}
void IndeoDSP::ffIviInverseSlant4x4(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) {
- int i;
- const int32 *src;
- int32 * dst;
- int tmp[16];
- int t0, t1, t2, t3, t4;
+ int i;
+ const int32 *src;
+ int32 * dst;
+ int tmp[16];
+ int t0, t1, t2, t3, t4;
#define COMPENSATE(x) (x)
- src = in;
- dst = tmp;
- for (i = 0; i < 4; i++) {
- if (flags[i]) {
- IVI_INV_SLANT4(src[0], src[4], src[8], src[12],
- dst[0], dst[4], dst[8], dst[12],
- t0, t1, t2, t3, t4);
- } else {
- dst[0] = dst[4] = dst[8] = dst[12] = 0;
+ src = in;
+ dst = tmp;
+ for (i = 0; i < 4; i++) {
+ if (flags[i]) {
+ IVI_INV_SLANT4(src[0], src[4], src[8], src[12],
+ dst[0], dst[4], dst[8], dst[12],
+ t0, t1, t2, t3, t4);
+ } else {
+ dst[0] = dst[4] = dst[8] = dst[12] = 0;
}
src++;
dst++;
- }
+ }
#undef COMPENSATE
#define COMPENSATE(x) (((x) + 1)>>1)
- src = tmp;
- for (i = 0; i < 4; i++) {
- if (!src[0] && !src[1] && !src[2] && !src[3]) {
- out[0] = out[1] = out[2] = out[3] = 0;
- } else {
- IVI_INV_SLANT4(src[0], src[1], src[2], src[3],
- out[0], out[1], out[2], out[3],
- t0, t1, t2, t3, t4);
- }
- src += 4;
- out += pitch;
- }
+ src = tmp;
+ for (i = 0; i < 4; i++) {
+ if (!src[0] && !src[1] && !src[2] && !src[3]) {
+ out[0] = out[1] = out[2] = out[3] = 0;
+ } else {
+ IVI_INV_SLANT4(src[0], src[1], src[2], src[3],
+ out[0], out[1], out[2], out[3],
+ t0, t1, t2, t3, t4);
+ }
+ src += 4;
+ out += pitch;
+ }
#undef COMPENSATE
}
void IndeoDSP::ffIviDcSlant2d(const int32 *in, int16 *out, uint32 pitch,
int blkSize) {
- int x, y;
- int16 dcCoeff;
+ int x, y;
+ int16 dcCoeff;
- dcCoeff = (*in + 1) >> 1;
+ dcCoeff = (*in + 1) >> 1;
- for (y = 0; y < blkSize; out += pitch, y++) {
- for (x = 0; x < blkSize; x++)
- out[x] = dcCoeff;
- }
+ for (y = 0; y < blkSize; out += pitch, y++) {
+ for (x = 0; x < blkSize; x++)
+ out[x] = dcCoeff;
+ }
}
void IndeoDSP::ffIviRowSlant8(const int32 *in, int16 *out, uint32 pitch,
const uint8 *flags) {
- int i;
- int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+ int i;
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
#define COMPENSATE(x) (((x) + 1)>>1)
- for (i = 0; i < 8; i++) {
- if (!in[0] && !in[1] && !in[2] && !in[3] && !in[4] && !in[5] && !in[6] && !in[7]) {
- memset(out, 0, 8*sizeof(out[0]));
- } else {
- IVI_INV_SLANT8( in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7],
- out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7],
- t0, t1, t2, t3, t4, t5, t6, t7, t8);
- }
- in += 8;
- out += pitch;
- }
+ for (i = 0; i < 8; i++) {
+ if (!in[0] && !in[1] && !in[2] && !in[3] && !in[4] && !in[5] && !in[6] && !in[7]) {
+ memset(out, 0, 8*sizeof(out[0]));
+ } else {
+ IVI_INV_SLANT8( in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7],
+ out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7],
+ t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ }
+ in += 8;
+ out += pitch;
+ }
#undef COMPENSATE
}
void IndeoDSP::ffIviDcRowSlant(const int32 *in, int16 *out, uint32 pitch, int blkSize) {
- int x, y;
- int16 dcCoeff;
+ int x, y;
+ int16 dcCoeff;
- dcCoeff = (*in + 1) >> 1;
+ dcCoeff = (*in + 1) >> 1;
- for (x = 0; x < blkSize; x++)
- out[x] = dcCoeff;
+ for (x = 0; x < blkSize; x++)
+ out[x] = dcCoeff;
- out += pitch;
+ out += pitch;
- for (y = 1; y < blkSize; out += pitch, y++) {
- for (x = 0; x < blkSize; x++)
- out[x] = 0;
- }
+ for (y = 1; y < blkSize; out += pitch, y++) {
+ for (x = 0; x < blkSize; x++)
+ out[x] = 0;
+ }
}
void IndeoDSP::ffIviColSlant8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) {
- int i, row2, row4, row8;
- int t0, t1, t2, t3, t4, t5, t6, t7, t8;
+ int i, row2, row4, row8;
+ int t0, t1, t2, t3, t4, t5, t6, t7, t8;
- row2 = pitch << 1;
- row4 = pitch << 2;
- row8 = pitch << 3;
+ row2 = pitch << 1;
+ row4 = pitch << 2;
+ row8 = pitch << 3;
#define COMPENSATE(x) (((x) + 1)>>1)
- for (i = 0; i < 8; i++) {
- if (flags[i]) {
- IVI_INV_SLANT8(in[0], in[8], in[16], in[24], in[32], in[40], in[48], in[56],
- out[0], out[pitch], out[row2], out[row2 + pitch], out[row4],
- out[row4 + pitch], out[row4 + row2], out[row8 - pitch],
- t0, t1, t2, t3, t4, t5, t6, t7, t8);
- } else {
- out[0] = out[pitch] = out[row2] = out[row2 + pitch] = out[row4] =
- out[row4 + pitch] = out[row4 + row2] = out[row8 - pitch] = 0;
- }
-
- in++;
- out++;
- }
+ for (i = 0; i < 8; i++) {
+ if (flags[i]) {
+ IVI_INV_SLANT8(in[0], in[8], in[16], in[24], in[32], in[40], in[48], in[56],
+ out[0], out[pitch], out[row2], out[row2 + pitch], out[row4],
+ out[row4 + pitch], out[row4 + row2], out[row8 - pitch],
+ t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ } else {
+ out[0] = out[pitch] = out[row2] = out[row2 + pitch] = out[row4] =
+ out[row4 + pitch] = out[row4 + row2] = out[row8 - pitch] = 0;
+ }
+
+ in++;
+ out++;
+ }
#undef COMPENSATE
}
void IndeoDSP::ffIviDcColSlant(const int32 *in, int16 *out, uint32 pitch, int blkSize) {
- int x, y;
- int16 dcCoeff;
+ int x, y;
+ int16 dcCoeff;
- dcCoeff = (*in + 1) >> 1;
+ dcCoeff = (*in + 1) >> 1;
- for (y = 0; y < blkSize; out += pitch, y++) {
- out[0] = dcCoeff;
- for (x = 1; x < blkSize; x++)
- out[x] = 0;
- }
+ for (y = 0; y < blkSize; out += pitch, y++) {
+ out[0] = dcCoeff;
+ for (x = 1; x < blkSize; x++)
+ out[x] = 0;
+ }
}
void IndeoDSP::ffIviRowSlant4(const int32 *in, int16 *out,
uint32 pitch, const uint8 *flags) {
- int i;
- int t0, t1, t2, t3, t4;
+ int i;
+ int t0, t1, t2, t3, t4;
#define COMPENSATE(x) (((x) + 1)>>1)
- for (i = 0; i < 4; i++) {
- if (!in[0] && !in[1] && !in[2] && !in[3]) {
- memset(out, 0, 4*sizeof(out[0]));
- } else {
- IVI_INV_SLANT4( in[0], in[1], in[2], in[3],
- out[0], out[1], out[2], out[3],
- t0, t1, t2, t3, t4);
- }
- in += 4;
- out += pitch;
- }
+ for (i = 0; i < 4; i++) {
+ if (!in[0] && !in[1] && !in[2] && !in[3]) {
+ memset(out, 0, 4*sizeof(out[0]));
+ } else {
+ IVI_INV_SLANT4( in[0], in[1], in[2], in[3],
+ out[0], out[1], out[2], out[3],
+ t0, t1, t2, t3, t4);
+ }
+ in += 4;
+ out += pitch;
+ }
#undef COMPENSATE
}
void IndeoDSP::ffIviColSlant4(const int32 *in, int16 *out, uint32 pitch,
const uint8 *flags) {
- int i, row2;
- int t0, t1, t2, t3, t4;
+ int i, row2;
+ int t0, t1, t2, t3, t4;
- row2 = pitch << 1;
+ row2 = pitch << 1;
#define COMPENSATE(x) (((x) + 1)>>1)
- for (i = 0; i < 4; i++) {
- if (flags[i]) {
- IVI_INV_SLANT4(in[0], in[4], in[8], in[12],
- out[0], out[pitch], out[row2], out[row2 + pitch],
- t0, t1, t2, t3, t4);
- } else {
- out[0] = out[pitch] = out[row2] = out[row2 + pitch] = 0;
- }
-
- in++;
- out++;
- }
+ for (i = 0; i < 4; i++) {
+ if (flags[i]) {
+ IVI_INV_SLANT4(in[0], in[4], in[8], in[12],
+ out[0], out[pitch], out[row2], out[row2 + pitch],
+ t0, t1, t2, t3, t4);
+ } else {
+ out[0] = out[pitch] = out[row2] = out[row2 + pitch] = 0;
+ }
+
+ in++;
+ out++;
+ }
#undef COMPENSATE
}
void IndeoDSP::ffIviPutPixels8x8(const int32 *in, int16 *out, uint32 pitch,
const uint8 *flags) {
- int x, y;
+ int x, y;
- for (y = 0; y < 8; out += pitch, in += 8, y++)
- for (x = 0; x < 8; x++)
- out[x] = in[x];
+ for (y = 0; y < 8; out += pitch, in += 8, y++)
+ for (x = 0; x < 8; x++)
+ out[x] = in[x];
}
void IndeoDSP::ffIviPutDcPixel8x8(const int32 *in, int16 *out, uint32 pitch,
int blkSize) {
- int y;
+ int y;
- out[0] = in[0];
- memset(out + 1, 0, 7*sizeof(out[0]));
- out += pitch;
+ out[0] = in[0];
+ memset(out + 1, 0, 7*sizeof(out[0]));
+ out += pitch;
- for (y = 1; y < 8; out += pitch, y++)
- memset(out, 0, 8*sizeof(out[0]));
+ for (y = 1; y < 8; out += pitch, y++)
+ memset(out, 0, 8*sizeof(out[0]));
}
#define IVI_MC_TEMPLATE(size, suffix, OP) \
static void iviMc ## size ##x## size ## suffix(int16 *buf, \
- uint32 dpitch, \
- const int16 *refBuf, \
- uint32 pitch, int mcType) \
+ uint32 dpitch, \
+ const int16 *refBuf, \
+ uint32 pitch, int mcType) \
{ \
- int i, j; \
- const int16 *wptr; \
+ int i, j; \
+ const int16 *wptr; \
\
- switch (mcType) { \
- case 0: /* fullpel (no interpolation) */ \
- for (i = 0; i < size; i++, buf += dpitch, refBuf += pitch) { \
- for (j = 0; j < size; j++) {\
- OP(buf[j], refBuf[j]); \
- } \
- } \
- break; \
- case 1: /* horizontal halfpel interpolation */ \
- for (i = 0; i < size; i++, buf += dpitch, refBuf += pitch) \
- for (j = 0; j < size; j++) \
- OP(buf[j], (refBuf[j] + refBuf[j+1]) >> 1); \
- break; \
- case 2: /* vertical halfpel interpolation */ \
- wptr = refBuf + pitch; \
- for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, refBuf += pitch) \
- for (j = 0; j < size; j++) \
- OP(buf[j], (refBuf[j] + wptr[j]) >> 1); \
- break; \
- case 3: /* vertical and horizontal halfpel interpolation */ \
- wptr = refBuf + pitch; \
- for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, refBuf += pitch) \
- for (j = 0; j < size; j++) \
- OP(buf[j], (refBuf[j] + refBuf[j+1] + wptr[j] + wptr[j+1]) >> 2); \
- break; \
- } \
+ switch (mcType) { \
+ case 0: /* fullpel (no interpolation) */ \
+ for (i = 0; i < size; i++, buf += dpitch, refBuf += pitch) { \
+ for (j = 0; j < size; j++) {\
+ OP(buf[j], refBuf[j]); \
+ } \
+ } \
+ break; \
+ case 1: /* horizontal halfpel interpolation */ \
+ for (i = 0; i < size; i++, buf += dpitch, refBuf += pitch) \
+ for (j = 0; j < size; j++) \
+ OP(buf[j], (refBuf[j] + refBuf[j+1]) >> 1); \
+ break; \
+ case 2: /* vertical halfpel interpolation */ \
+ wptr = refBuf + pitch; \
+ for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, refBuf += pitch) \
+ for (j = 0; j < size; j++) \
+ OP(buf[j], (refBuf[j] + wptr[j]) >> 1); \
+ break; \
+ case 3: /* vertical and horizontal halfpel interpolation */ \
+ wptr = refBuf + pitch; \
+ for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, refBuf += pitch) \
+ for (j = 0; j < size; j++) \
+ OP(buf[j], (refBuf[j] + refBuf[j+1] + wptr[j] + wptr[j+1]) >> 2); \
+ break; \
+ } \
} \
\
void IndeoDSP::ffIviMc ## size ##x## size ## suffix(int16 *buf, const int16 *refBuf, \
- uint32 pitch, int mcType) \
+ uint32 pitch, int mcType) \
{ \
- iviMc ## size ##x## size ## suffix(buf, pitch, refBuf, pitch, mcType); \
+ iviMc ## size ##x## size ## suffix(buf, pitch, refBuf, pitch, mcType); \
}
#define IVI_MC_AVG_TEMPLATE(size, suffix, OP) \
void IndeoDSP::ffIviMcAvg ## size ##x## size ## suffix(int16 *buf, \
- const int16 *refBuf, \
- const int16 *refBuf2, \
- uint32 pitch, \
- int mcType, int mcType2) \
+ const int16 *refBuf, \
+ const int16 *refBuf2, \
+ uint32 pitch, \
+ int mcType, int mcType2) \
{ \
- int16 tmp[size * size]; \
- int i, j; \
+ int16 tmp[size * size]; \
+ int i, j; \
\
- iviMc ## size ##x## size ## NoDelta(tmp, size, refBuf, pitch, mcType); \
- iviMc ## size ##x## size ## Delta(tmp, size, refBuf2, pitch, mcType2); \
- for (i = 0; i < size; i++, buf += pitch) { \
- for (j = 0; j < size; j++) {\
- OP(buf[j], tmp[i * size + j] >> 1); \
- } \
- } \
+ iviMc ## size ##x## size ## NoDelta(tmp, size, refBuf, pitch, mcType); \
+ iviMc ## size ##x## size ## Delta(tmp, size, refBuf2, pitch, mcType2); \
+ for (i = 0; i < size; i++, buf += pitch) { \
+ for (j = 0; j < size; j++) {\
+ OP(buf[j], tmp[i * size + j] >> 1); \
+ } \
+ } \
}
#define OP_PUT(a, b) (a) = (b)
diff --git a/image/codecs/indeo/indeo_dsp.h b/image/codecs/indeo/indeo_dsp.h
index 5f4b04f..8ea223b 100644
--- a/image/codecs/indeo/indeo_dsp.h
+++ b/image/codecs/indeo/indeo_dsp.h
@@ -20,8 +20,6 @@
*
*/
-#include "common/scummsys.h"
-
/* VLC code
*
* Original copyright note:
diff --git a/image/codecs/indeo/mem.cpp b/image/codecs/indeo/mem.cpp
index 326729b..77a5fab 100644
--- a/image/codecs/indeo/mem.cpp
+++ b/image/codecs/indeo/mem.cpp
@@ -71,14 +71,14 @@ const uint8 ffZigZagDirect[64] = {
* @return 0 on success, AVERROR(EINVAL) on overflow
*/
static inline int avSizeMult(size_t a, size_t b, size_t *r) {
- size_t t = a * b;
-
- // Hack inspired from glibc: don't try the division if nelem and elsize
- // are both less than sqrt(SIZE_MAX).
- if ((a | b) >= ((size_t)1 << (sizeof(size_t) * 4)) && a && t / a != b)
- return -1;
- *r = t;
- return 0;
+ size_t t = a * b;
+
+ // Hack inspired from glibc: don't try the division if nelem and elsize
+ // are both less than sqrt(SIZE_MAX).
+ if ((a | b) >= ((size_t)1 << (sizeof(size_t) * 4)) && a && t / a != b)
+ return -1;
+ *r = t;
+ return 0;
}
/*------------------------------------------------------------------------*/
@@ -96,9 +96,9 @@ void *avMallocZ(size_t size) {
}
void *avMallocArray(size_t nmemb, size_t size) {
- if (!size || nmemb >= MAX_INTEGER / size)
- return nullptr;
- return malloc(nmemb * size);
+ if (!size || nmemb >= MAX_INTEGER / size)
+ return nullptr;
+ return malloc(nmemb * size);
}
void *avMallocZArray(size_t nmemb, size_t size) {
diff --git a/image/codecs/indeo/vlc.cpp b/image/codecs/indeo/vlc.cpp
index e526a09..5b9e96c 100644
--- a/image/codecs/indeo/vlc.cpp
+++ b/image/codecs/indeo/vlc.cpp
@@ -41,97 +41,97 @@ namespace Indeo {
* happen with non constructed input.
*/
#define AV_QSORT(p, num, type, cmp) do {\
- void *stack[64][2];\
- 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);\
- if(cmp(start, end) > 0) {\
- 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) { \
- SWAP(*mid, *end);\
- checksort = 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)\
- right--;\
- if (left <= right) {\
- SWAP(*left, *right);\
- left++;\
- right--;\
- }\
- }\
- 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;\
- end = right;\
- }\
- } else {\
- if (cmp(start, end) > 0)\
- SWAP(*start, *end);\
- break;\
- }\
- }\
- }\
+ void *stack[64][2];\
+ 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);\
+ if(cmp(start, end) > 0) {\
+ 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) { \
+ SWAP(*mid, *end);\
+ checksort = 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)\
+ right--;\
+ if (left <= right) {\
+ SWAP(*left, *right);\
+ left++;\
+ right--;\
+ }\
+ }\
+ 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;\
+ end = right;\
+ }\
+ } else {\
+ if (cmp(start, end) > 0)\
+ SWAP(*start, *end);\
+ break;\
+ }\
+ }\
+ }\
} while (0)
#define COPY(condition)\
- for (i = 0; i < nbCodes; i++) { \
- buf[j].bits = getData(p_bits, i, bitsWrap, bitsSize); \
- if (!(condition)) \
- continue; \
- 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, 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); \
- else \
- buf[j].code <<= 32 - buf[j].bits; \
- if (symbols) \
- buf[j].symbol = getData(symbols, i, symbolsWrap, symbolsSize); \
- else \
- buf[j].symbol = i; \
- j++; \
- }
+ for (i = 0; i < nbCodes; i++) { \
+ buf[j].bits = getData(p_bits, i, bitsWrap, bitsSize); \
+ if (!(condition)) \
+ continue; \
+ 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, 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); \
+ else \
+ buf[j].code <<= 32 - buf[j].bits; \
+ if (symbols) \
+ buf[j].symbol = getData(symbols, i, symbolsWrap, symbolsSize); \
+ else \
+ buf[j].symbol = i; \
+ j++; \
+ }
/*------------------------------------------------------------------------*/
@@ -313,20 +313,23 @@ int VLC::allocTable(int size, int useStatic) {
memset(vlc->_table + vlc->_tableAllocated - (1 << vlc->_bits), 0, sizeof(VLC_TYPE) * 2 << vlc->_bits);
}
+
return index;
}
uint VLC::getData(const void *table, uint idx, uint wrap, uint size) {
- const uint8 *ptr = (const uint8 *)table + idx * wrap;
+ const uint8 *ptr = (const uint8 *)table + idx * wrap;
switch(size) {
case 1:
return *(const uint8 *)ptr;
+
case 2:
return *(const uint16 *)ptr;
+
default:
return *(const uint32 *)ptr;
- }
+ }
}
} // End of namespace Indeo
diff --git a/image/codecs/indeo/vlc.h b/image/codecs/indeo/vlc.h
index 51e887d..a6dd692 100644
--- a/image/codecs/indeo/vlc.h
+++ b/image/codecs/indeo/vlc.h
@@ -67,9 +67,9 @@ private:
*/
static uint getData(const void *table, uint idx, uint wrap, uint size);
public:
- int _bits;
- VLC_TYPE (*_table)[2]; ///< code, bits
- int _tableSize, _tableAllocated;
+ int _bits;
+ VLC_TYPE (*_table)[2]; ///< code, bits
+ int _tableSize, _tableAllocated;
VLC();
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index 7daecf4..c8376ea 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -20,19 +20,14 @@
*
*/
-#include "common/scummsys.h"
-
/* Intel Indeo 4 decompressor, derived from ffmpeg.
*
* Original copyright note: * Intel Indeo 3 (IV41, IV42, etc.) video decoder for ffmpeg
* written, produced, and directed by Alan Smithee
*/
-#include "common/endian.h"
#include "common/memstream.h"
-#include "common/stream.h"
#include "common/textconsole.h"
-#include "common/util.h"
#include "graphics/yuv_to_rgb.h"
#include "image/codecs/indeo4.h"
#include "image/codecs/indeo/indeo_dsp.h"
@@ -698,253 +693,253 @@ const uint8 *const Indeo4Decoder::_scan_index_to_tab[15] = {
*/
const uint16 Indeo4Decoder::_ivi4_quant_8x8_intra[9][64] = {
{
- 43, 342, 385, 470, 555, 555, 598, 726,
- 342, 342, 470, 513, 555, 598, 726, 769,
- 385, 470, 555, 555, 598, 726, 726, 811,
- 470, 470, 555, 555, 598, 726, 769, 854,
- 470, 555, 555, 598, 683, 726, 854, 1025,
- 555, 555, 598, 683, 726, 854, 1025, 1153,
- 555, 555, 598, 726, 811, 982, 1195, 1451,
- 555, 598, 726, 811, 982, 1195, 1451, 1793
+ 43, 342, 385, 470, 555, 555, 598, 726,
+ 342, 342, 470, 513, 555, 598, 726, 769,
+ 385, 470, 555, 555, 598, 726, 726, 811,
+ 470, 470, 555, 555, 598, 726, 769, 854,
+ 470, 555, 555, 598, 683, 726, 854, 1025,
+ 555, 555, 598, 683, 726, 854, 1025, 1153,
+ 555, 555, 598, 726, 811, 982, 1195, 1451,
+ 555, 598, 726, 811, 982, 1195, 1451, 1793
},
{
- 86, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
- 1195, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
- 2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
- 2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
- 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
- 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
- 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
- 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827
+ 86, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
+ 1195, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
+ 2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
+ 2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
+ 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
+ 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
+ 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
+ 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827
},
{
- 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
- 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
- 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
- 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
- 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
- 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
- 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
- 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835
+ 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
+ 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
+ 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
+ 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
+ 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
+ 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
+ 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
+ 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835
},
{
- 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
- 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
- 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
- 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
- 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
- 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
- 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
- 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414
+ 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
+ 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
+ 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
+ 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
+ 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
+ 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
+ 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
+ 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414
},
{
- 897, 897, 897, 897, 897, 897, 897, 897,
- 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067,
- 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
- 1409, 1409, 1409, 1409, 1409, 1409, 1409, 1409,
- 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579,
- 1750, 1750, 1750, 1750, 1750, 1750, 1750, 1750,
- 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921,
- 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091
+ 897, 897, 897, 897, 897, 897, 897, 897,
+ 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067,
+ 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
+ 1409, 1409, 1409, 1409, 1409, 1409, 1409, 1409,
+ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579,
+ 1750, 1750, 1750, 1750, 1750, 1750, 1750, 1750,
+ 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921,
+ 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091
},
{
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
- 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
- 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
- 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
- 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
- 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
+ 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
+ 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
+ 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
+ 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
+ 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414
},
{
- 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
- 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
- 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
- 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
- 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
- 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
- 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
- 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390
+ 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
+ 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
+ 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
+ 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
+ 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
+ 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
+ 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
+ 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390
},
{
- 22, 171, 214, 257, 257, 299, 299, 342,
- 171, 171, 257, 257, 299, 299, 342, 385,
- 214, 257, 257, 299, 299, 342, 342, 385,
- 257, 257, 257, 299, 299, 342, 385, 427,
- 257, 257, 299, 299, 342, 385, 427, 513,
- 257, 299, 299, 342, 385, 427, 513, 598,
- 299, 299, 299, 385, 385, 470, 598, 726,
- 299, 299, 385, 385, 470, 598, 726, 897
+ 22, 171, 214, 257, 257, 299, 299, 342,
+ 171, 171, 257, 257, 299, 299, 342, 385,
+ 214, 257, 257, 299, 299, 342, 342, 385,
+ 257, 257, 257, 299, 299, 342, 385, 427,
+ 257, 257, 299, 299, 342, 385, 427, 513,
+ 257, 299, 299, 342, 385, 427, 513, 598,
+ 299, 299, 299, 385, 385, 470, 598, 726,
+ 299, 299, 385, 385, 470, 598, 726, 897
},
{
- 86, 598, 1195, 1195, 2390, 2390, 2390, 2390,
- 598, 598, 1195, 1195, 2390, 2390, 2390, 2390,
- 1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
- 1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
- 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
- 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
- 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
- 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414
+ 86, 598, 1195, 1195, 2390, 2390, 2390, 2390,
+ 598, 598, 1195, 1195, 2390, 2390, 2390, 2390,
+ 1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
+ 1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
+ 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
+ 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
+ 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
+ 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414
}
};
const uint16 Indeo4Decoder::_ivi4_quant_8x8_inter[9][64] = {
{
- 427, 427, 470, 427, 427, 427, 470, 470,
- 427, 427, 470, 427, 427, 427, 470, 470,
- 470, 470, 470, 470, 470, 470, 470, 470,
- 427, 427, 470, 470, 427, 427, 470, 470,
- 427, 427, 470, 427, 427, 427, 470, 470,
- 427, 427, 470, 427, 427, 427, 470, 470,
- 470, 470, 470, 470, 470, 470, 470, 470,
- 470, 470, 470, 470, 470, 470, 470, 470
+ 427, 427, 470, 427, 427, 427, 470, 470,
+ 427, 427, 470, 427, 427, 427, 470, 470,
+ 470, 470, 470, 470, 470, 470, 470, 470,
+ 427, 427, 470, 470, 427, 427, 470, 470,
+ 427, 427, 470, 427, 427, 427, 470, 470,
+ 427, 427, 470, 427, 427, 427, 470, 470,
+ 470, 470, 470, 470, 470, 470, 470, 470,
+ 470, 470, 470, 470, 470, 470, 470, 470
},
{
- 1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
- 1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
- 2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
- 2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
- 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
- 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
- 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
- 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414
+ 1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
+ 1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
+ 2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
+ 2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
+ 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
+ 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
+ 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
+ 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414
},
{
- 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
- 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
- 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
- 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
- 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
- 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
- 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
- 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281
+ 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
+ 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
+ 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
+ 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
+ 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
+ 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
+ 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
+ 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281
},
{
- 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
- 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
- 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
- 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
- 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
- 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
- 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
- 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433
+ 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
+ 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
+ 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
+ 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
+ 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
+ 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
+ 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
+ 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433
},
{
- 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
- 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
- 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
- 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
- 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
- 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
- 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
- 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281
+ 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
+ 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
+ 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
+ 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
+ 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
+ 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
+ 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
+ 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281
},
{
- 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
- 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
- 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
- 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
- 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
- 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
- 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
- 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433
+ 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
+ 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
+ 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
+ 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
+ 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
+ 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
+ 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
+ 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433
},
{
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
+ 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707
},
{
- 86, 171, 171, 214, 214, 214, 214, 257,
- 171, 171, 214, 214, 214, 214, 257, 257,
- 171, 214, 214, 214, 214, 257, 257, 257,
- 214, 214, 214, 214, 257, 257, 257, 299,
- 214, 214, 214, 257, 257, 257, 299, 299,
- 214, 214, 257, 257, 257, 299, 299, 299,
- 214, 257, 257, 257, 299, 299, 299, 342,
- 257, 257, 257, 299, 299, 299, 342, 342
+ 86, 171, 171, 214, 214, 214, 214, 257,
+ 171, 171, 214, 214, 214, 214, 257, 257,
+ 171, 214, 214, 214, 214, 257, 257, 257,
+ 214, 214, 214, 214, 257, 257, 257, 299,
+ 214, 214, 214, 257, 257, 257, 299, 299,
+ 214, 214, 257, 257, 257, 299, 299, 299,
+ 214, 257, 257, 257, 299, 299, 299, 342,
+ 257, 257, 257, 299, 299, 299, 342, 342
},
{
- 854, 854, 1195, 1195, 1707, 1707, 1707, 1707,
- 854, 854, 1195, 1195, 1707, 1707, 1707, 1707,
- 1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
- 1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
- 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
- 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
- 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
- 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707
+ 854, 854, 1195, 1195, 1707, 1707, 1707, 1707,
+ 854, 854, 1195, 1195, 1707, 1707, 1707, 1707,
+ 1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
+ 1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
+ 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
+ 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
+ 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
+ 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707
}
};
const uint16 Indeo4Decoder::_ivi4_quant_4x4_intra[5][16] = {
{
- 22, 214, 257, 299,
- 214, 257, 299, 342,
- 257, 299, 342, 427,
- 299, 342, 427, 513
+ 22, 214, 257, 299,
+ 214, 257, 299, 342,
+ 257, 299, 342, 427,
+ 299, 342, 427, 513
},
{
- 129, 1025, 1451, 1451,
- 1025, 1025, 1451, 1451,
- 1451, 1451, 2049, 2049,
- 1451, 1451, 2049, 2049
+ 129, 1025, 1451, 1451,
+ 1025, 1025, 1451, 1451,
+ 1451, 1451, 2049, 2049,
+ 1451, 1451, 2049, 2049
},
{
- 43, 171, 171, 171,
- 43, 171, 171, 171,
- 43, 171, 171, 171,
- 43, 171, 171, 171
+ 43, 171, 171, 171,
+ 43, 171, 171, 171,
+ 43, 171, 171, 171,
+ 43, 171, 171, 171
},
{
- 43, 43, 43, 43,
- 171, 171, 171, 171,
- 171, 171, 171, 171,
- 171, 171, 171, 171
+ 43, 43, 43, 43,
+ 171, 171, 171, 171,
+ 171, 171, 171, 171,
+ 171, 171, 171, 171
},
{
- 43, 43, 43, 43,
- 43, 43, 43, 43,
- 43, 43, 43, 43,
- 43, 43, 43, 43
+ 43, 43, 43, 43,
+ 43, 43, 43, 43,
+ 43, 43, 43, 43,
+ 43, 43, 43, 43
}
};
const uint16 Indeo4Decoder::_ivi4_quant_4x4_inter[5][16] = {
{
- 107, 214, 257, 299,
- 214, 257, 299, 299,
- 257, 299, 299, 342,
- 299, 299, 342, 342
+ 107, 214, 257, 299,
+ 214, 257, 299, 299,
+ 257, 299, 299, 342,
+ 299, 299, 342, 342
},
{
- 513, 1025, 1238, 1238,
- 1025, 1025, 1238, 1238,
- 1238, 1238, 1451, 1451,
- 1238, 1238, 1451, 1451
+ 513, 1025, 1238, 1238,
+ 1025, 1025, 1238, 1238,
+ 1238, 1238, 1451, 1451,
+ 1238, 1238, 1451, 1451
},
{
- 43, 171, 171, 171,
- 43, 171, 171, 171,
- 43, 171, 171, 171,
- 43, 171, 171, 171
+ 43, 171, 171, 171,
+ 43, 171, 171, 171,
+ 43, 171, 171, 171,
+ 43, 171, 171, 171
},
{
- 43, 43, 43, 43,
- 171, 171, 171, 171,
- 171, 171, 171, 171,
- 171, 171, 171, 171
+ 43, 43, 43, 43,
+ 171, 171, 171, 171,
+ 171, 171, 171, 171,
+ 171, 171, 171, 171
},
{
- 43, 43, 43, 43,
- 43, 43, 43, 43,
- 43, 43, 43, 43,
- 43, 43, 43, 43
+ 43, 43, 43, 43,
+ 43, 43, 43, 43,
+ 43, 43, 43, 43,
+ 43, 43, 43, 43
}
};
diff --git a/image/codecs/indeo5.cpp b/image/codecs/indeo5.cpp
index 147bf44..00ca032 100644
--- a/image/codecs/indeo5.cpp
+++ b/image/codecs/indeo5.cpp
@@ -20,19 +20,14 @@
*
*/
-#include "common/scummsys.h"
-
/* Intel Indeo 5 decompressor, derived from ffmpeg.
*
* Original copyright note: * Intel Indeo 3 (IV41, IV42, etc.) video decoder for ffmpeg
* written, produced, and directed by Alan Smithee
*/
-#include "common/endian.h"
#include "common/memstream.h"
-#include "common/stream.h"
#include "common/textconsole.h"
-#include "common/util.h"
#include "graphics/yuv_to_rgb.h"
#include "image/codecs/indeo5.h"
#include "image/codecs/indeo/indeo_dsp.h"
@@ -44,11 +39,11 @@ namespace Image {
* Indeo5 frame types.
*/
enum {
- FRAMETYPE_INTRA = 0,
- FRAMETYPE_INTER = 1, ///< non-droppable P-frame
- FRAMETYPE_INTER_SCAL = 2, ///< droppable P-frame used in the scalability mode
- FRAMETYPE_INTER_NOREF = 3, ///< droppable P-frame
- FRAMETYPE_NULL = 4 ///< empty frame with no data
+ FRAMETYPE_INTRA = 0,
+ FRAMETYPE_INTER = 1, ///< non-droppable P-frame
+ FRAMETYPE_INTER_SCAL = 2, ///< droppable P-frame used in the scalability mode
+ FRAMETYPE_INTER_NOREF = 3, ///< droppable P-frame
+ FRAMETYPE_NULL = 4 ///< empty frame with no data
};
#define IVI5_PIC_SIZE_ESC 15
@@ -638,114 +633,114 @@ const uint8 Indeo5Decoder::_commonPicSizes[30] = {
};
const uint16 Indeo5Decoder::_baseQuant8x8Inter[5][64] = {
- {0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a, 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e,
- 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62, 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66,
- 0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a, 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e,
- 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x72, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76,
- },
- {0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a, 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e,
- 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62, 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66,
- 0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a, 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e,
- 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x72, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76,
- },
- {0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
- 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
- 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
- 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
- },
- {0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
- 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4,
- 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2,
- 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2,
- },
- {0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
- 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
- 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
- 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
- }
+ {0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a, 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e,
+ 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62, 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66,
+ 0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a, 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e,
+ 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x72, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76,
+ },
+ {0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a, 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e,
+ 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62, 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66,
+ 0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a, 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e,
+ 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x72, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76,
+ },
+ {0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
+ 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
+ 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
+ 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
+ },
+ {0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4,
+ 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2,
+ 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2,
+ },
+ {0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
+ 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
+ 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
+ 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
+ }
};
const uint16 Indeo5Decoder::_baseQuant8x8Intra[5][64] = {
- {0x1a, 0x2e, 0x36, 0x42, 0x46, 0x4a, 0x4e, 0x5a, 0x2e, 0x32, 0x3e, 0x42, 0x46, 0x4e, 0x56, 0x6a,
- 0x36, 0x3e, 0x3e, 0x44, 0x4a, 0x54, 0x66, 0x72, 0x42, 0x42, 0x44, 0x4a, 0x52, 0x62, 0x6c, 0x7a,
- 0x46, 0x46, 0x4a, 0x52, 0x5e, 0x66, 0x72, 0x8e, 0x4a, 0x4e, 0x54, 0x62, 0x66, 0x6e, 0x86, 0xa6,
- 0x4e, 0x56, 0x66, 0x6c, 0x72, 0x86, 0x9a, 0xca, 0x5a, 0x6a, 0x72, 0x7a, 0x8e, 0xa6, 0xca, 0xfe,
- },
- {0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a, 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e,
- 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62, 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66,
- 0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a, 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e,
- 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x72, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76,
- },
- {0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
- 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
- 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
- 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
- },
- {0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
- 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4,
- 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2,
- 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2,
- },
- {0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
- 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
- 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
- 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
- }
+ {0x1a, 0x2e, 0x36, 0x42, 0x46, 0x4a, 0x4e, 0x5a, 0x2e, 0x32, 0x3e, 0x42, 0x46, 0x4e, 0x56, 0x6a,
+ 0x36, 0x3e, 0x3e, 0x44, 0x4a, 0x54, 0x66, 0x72, 0x42, 0x42, 0x44, 0x4a, 0x52, 0x62, 0x6c, 0x7a,
+ 0x46, 0x46, 0x4a, 0x52, 0x5e, 0x66, 0x72, 0x8e, 0x4a, 0x4e, 0x54, 0x62, 0x66, 0x6e, 0x86, 0xa6,
+ 0x4e, 0x56, 0x66, 0x6c, 0x72, 0x86, 0x9a, 0xca, 0x5a, 0x6a, 0x72, 0x7a, 0x8e, 0xa6, 0xca, 0xfe,
+ },
+ {0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a, 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e,
+ 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62, 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66,
+ 0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a, 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e,
+ 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x72, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76,
+ },
+ {0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
+ 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
+ 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
+ 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
+ },
+ {0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4,
+ 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2,
+ 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2,
+ },
+ {0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
+ 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
+ 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
+ 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
+ }
};
const uint16 Indeo5Decoder::_baseQuant4x4Inter[16] = {
- 0x1e, 0x3e, 0x4a, 0x52, 0x3e, 0x4a, 0x52, 0x56, 0x4a, 0x52, 0x56, 0x5e, 0x52, 0x56, 0x5e, 0x66
+ 0x1e, 0x3e, 0x4a, 0x52, 0x3e, 0x4a, 0x52, 0x56, 0x4a, 0x52, 0x56, 0x5e, 0x52, 0x56, 0x5e, 0x66
};
const uint16 Indeo5Decoder::_baseQuant4x4Intra[16] = {
- 0x1e, 0x3e, 0x4a, 0x52, 0x3e, 0x4a, 0x52, 0x5e, 0x4a, 0x52, 0x5e, 0x7a, 0x52, 0x5e, 0x7a, 0x92
+ 0x1e, 0x3e, 0x4a, 0x52, 0x3e, 0x4a, 0x52, 0x5e, 0x4a, 0x52, 0x5e, 0x7a, 0x52, 0x5e, 0x7a, 0x92
};
const uint8 Indeo5Decoder::_scaleQuant8x8Inter[5][24] = {
- {0x0b, 0x11, 0x13, 0x14, 0x15, 0x16, 0x18, 0x1a, 0x1b, 0x1d, 0x20, 0x22,
- 0x23, 0x25, 0x28, 0x2a, 0x2e, 0x32, 0x35, 0x39, 0x3d, 0x41, 0x44, 0x4a,
- },
- {0x07, 0x14, 0x16, 0x18, 0x1b, 0x1e, 0x22, 0x25, 0x29, 0x2d, 0x31, 0x35,
- 0x3a, 0x3f, 0x44, 0x4a, 0x50, 0x56, 0x5c, 0x63, 0x6a, 0x71, 0x78, 0x7e,
- },
- {0x15, 0x25, 0x28, 0x2d, 0x30, 0x34, 0x3a, 0x3d, 0x42, 0x48, 0x4c, 0x51,
- 0x56, 0x5b, 0x60, 0x65, 0x6b, 0x70, 0x76, 0x7c, 0x82, 0x88, 0x8f, 0x97,
- },
- {0x13, 0x1f, 0x20, 0x22, 0x25, 0x28, 0x2b, 0x2d, 0x30, 0x33, 0x36, 0x39,
- 0x3c, 0x3f, 0x42, 0x45, 0x48, 0x4b, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x62,
- },
- {0x3c, 0x52, 0x58, 0x5d, 0x63, 0x68, 0x68, 0x6d, 0x73, 0x78, 0x7c, 0x80,
- 0x84, 0x89, 0x8e, 0x93, 0x98, 0x9d, 0xa3, 0xa9, 0xad, 0xb1, 0xb5, 0xba,
- },
+ {0x0b, 0x11, 0x13, 0x14, 0x15, 0x16, 0x18, 0x1a, 0x1b, 0x1d, 0x20, 0x22,
+ 0x23, 0x25, 0x28, 0x2a, 0x2e, 0x32, 0x35, 0x39, 0x3d, 0x41, 0x44, 0x4a,
+ },
+ {0x07, 0x14, 0x16, 0x18, 0x1b, 0x1e, 0x22, 0x25, 0x29, 0x2d, 0x31, 0x35,
+ 0x3a, 0x3f, 0x44, 0x4a, 0x50, 0x56, 0x5c, 0x63, 0x6a, 0x71, 0x78, 0x7e,
+ },
+ {0x15, 0x25, 0x28, 0x2d, 0x30, 0x34, 0x3a, 0x3d, 0x42, 0x48, 0x4c, 0x51,
+ 0x56, 0x5b, 0x60, 0x65, 0x6b, 0x70, 0x76, 0x7c, 0x82, 0x88, 0x8f, 0x97,
+ },
+ {0x13, 0x1f, 0x20, 0x22, 0x25, 0x28, 0x2b, 0x2d, 0x30, 0x33, 0x36, 0x39,
+ 0x3c, 0x3f, 0x42, 0x45, 0x48, 0x4b, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x62,
+ },
+ {0x3c, 0x52, 0x58, 0x5d, 0x63, 0x68, 0x68, 0x6d, 0x73, 0x78, 0x7c, 0x80,
+ 0x84, 0x89, 0x8e, 0x93, 0x98, 0x9d, 0xa3, 0xa9, 0xad, 0xb1, 0xb5, 0xba,
+ },
};
const uint8 Indeo5Decoder::_scaleQuant8x8Intra[5][24] = {
- {0x0b, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x17, 0x18, 0x1a, 0x1c, 0x1e, 0x20,
- 0x22, 0x24, 0x27, 0x28, 0x2a, 0x2d, 0x2f, 0x31, 0x34, 0x37, 0x39, 0x3c,
- },
- {0x01, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1b, 0x1e, 0x22, 0x25, 0x28, 0x2c,
- 0x30, 0x34, 0x38, 0x3d, 0x42, 0x47, 0x4c, 0x52, 0x58, 0x5e, 0x65, 0x6c,
- },
- {0x13, 0x22, 0x27, 0x2a, 0x2d, 0x33, 0x36, 0x3c, 0x41, 0x45, 0x49, 0x4e,
- 0x53, 0x58, 0x5d, 0x63, 0x69, 0x6f, 0x75, 0x7c, 0x82, 0x88, 0x8e, 0x95,
- },
- {0x13, 0x1f, 0x21, 0x24, 0x27, 0x29, 0x2d, 0x2f, 0x34, 0x37, 0x3a, 0x3d,
- 0x40, 0x44, 0x48, 0x4c, 0x4f, 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6b,
- },
- {0x31, 0x42, 0x47, 0x47, 0x4d, 0x52, 0x58, 0x58, 0x5d, 0x63, 0x67, 0x6b,
- 0x6f, 0x73, 0x78, 0x7c, 0x80, 0x84, 0x89, 0x8e, 0x93, 0x98, 0x9d, 0xa4,
- }
+ {0x0b, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x17, 0x18, 0x1a, 0x1c, 0x1e, 0x20,
+ 0x22, 0x24, 0x27, 0x28, 0x2a, 0x2d, 0x2f, 0x31, 0x34, 0x37, 0x39, 0x3c,
+ },
+ {0x01, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1b, 0x1e, 0x22, 0x25, 0x28, 0x2c,
+ 0x30, 0x34, 0x38, 0x3d, 0x42, 0x47, 0x4c, 0x52, 0x58, 0x5e, 0x65, 0x6c,
+ },
+ {0x13, 0x22, 0x27, 0x2a, 0x2d, 0x33, 0x36, 0x3c, 0x41, 0x45, 0x49, 0x4e,
+ 0x53, 0x58, 0x5d, 0x63, 0x69, 0x6f, 0x75, 0x7c, 0x82, 0x88, 0x8e, 0x95,
+ },
+ {0x13, 0x1f, 0x21, 0x24, 0x27, 0x29, 0x2d, 0x2f, 0x34, 0x37, 0x3a, 0x3d,
+ 0x40, 0x44, 0x48, 0x4c, 0x4f, 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6b,
+ },
+ {0x31, 0x42, 0x47, 0x47, 0x4d, 0x52, 0x58, 0x58, 0x5d, 0x63, 0x67, 0x6b,
+ 0x6f, 0x73, 0x78, 0x7c, 0x80, 0x84, 0x89, 0x8e, 0x93, 0x98, 0x9d, 0xa4,
+ }
};
const uint8 Indeo5Decoder::_scaleQuant4x4Inter[24] = {
- 0x0b, 0x0d, 0x0d, 0x0e, 0x11, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
+ 0x0b, 0x0d, 0x0d, 0x0e, 0x11, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
};
const uint8 Indeo5Decoder::_scaleQuant4x4Intra[24] = {
- 0x01, 0x0b, 0x0b, 0x0d, 0x0d, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x13, 0x14,
- 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20
+ 0x01, 0x0b, 0x0b, 0x0d, 0x0d, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x13, 0x14,
+ 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20
};
} // End of namespace Image
Commit: 08143af48293b007027d11271d3f66f7ad3107e6
https://github.com/scummvm/scummvm/commit/08143af48293b007027d11271d3f66f7ad3107e6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-11T09:42:12-04:00
Commit Message:
IMAGE: Further formatting of Indeo decoders
Changed paths:
image/codecs/indeo/indeo.cpp
image/codecs/indeo/mem.cpp
image/codecs/indeo/mem.h
image/codecs/indeo4.cpp
image/codecs/indeo5.cpp
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index 12b7b1f..2bc699e 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -86,9 +86,9 @@ static const IVIHuffDesc ivi_blk_huff_desc[8] = {
/*------------------------------------------------------------------------*/
int IVIHuffDesc::createHuffFromDesc(VLC *vlc, bool flag) const {
- int pos, i, j, codesPerRow, prefix, notLastRow;
- uint16 codewords[256];
- uint8 bits[256];
+ int pos, i, j, codesPerRow, prefix, notLastRow;
+ uint16 codewords[256];
+ uint8 bits[256];
pos = 0; // current position = 0
@@ -268,8 +268,7 @@ IVIPlaneDesc::IVIPlaneDesc() : _width(0), _height(0), _numBands(0), _bands(nullp
int IVIPlaneDesc::initPlanes(IVIPlaneDesc *planes, const IVIPicConfig *cfg, bool isIndeo4) {
int p, b;
- uint32 b_width, b_height, align_fac, width_aligned,
- height_aligned, bufSize;
+ uint32 b_width, b_height, align_fac, width_aligned, height_aligned, bufSize;
IVIBandDesc *band;
freeBuffers(planes);
@@ -430,8 +429,8 @@ int AVFrame::getBuffer(int flags) {
_data[0] = (uint8 *)avMallocZ(_width * _height);
// UV Chroma Channels
- _data[1] = (uint8 *)avMalloc(_width * _height);
- _data[2] = (uint8 *)avMalloc(_width * _height);
+ _data[1] = (uint8 *)malloc(_width * _height);
+ _data[2] = (uint8 *)malloc(_width * _height);
Common::fill(_data[1], _data[1] + _width * _height, 0x80);
Common::fill(_data[2], _data[2] + _width * _height, 0x80);
@@ -603,8 +602,8 @@ int IndeoDecoderBase::decodeIndeoFrame() {
}
int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
- int result, i, t, idx1, idx2, pos;
- IVITile * tile;
+ int result, i, t, idx1, idx2, pos;
+ IVITile *tile;
band->_buf = band->_bufs[_ctx._dstBuf];
if (!band->_buf) {
@@ -711,12 +710,12 @@ int IndeoDecoderBase::decode_band(IVIBandDesc *band) {
void IndeoDecoderBase::recomposeHaar(const IVIPlaneDesc *_plane,
uint8 *dst, const int dstPitch) {
- int x, y, indx, b0, b1, b2, b3, p0, p1, p2, p3;
- const short * b0Ptr, *b1Ptr, *b2Ptr, *b3Ptr;
- int32 _pitch;
+ int x, y, indx, b0, b1, b2, b3, p0, p1, p2, p3;
+ const short *b0Ptr, *b1Ptr, *b2Ptr, *b3Ptr;
+ int32 pitch;
// all bands should have the same _pitch
- _pitch = _plane->_bands[0]._pitch;
+ pitch = _plane->_bands[0]._pitch;
// get pointers to the wavelet bands
b0Ptr = _plane->_bands[0]._buf;
@@ -747,22 +746,22 @@ void IndeoDecoderBase::recomposeHaar(const IVIPlaneDesc *_plane,
dst += dstPitch << 1;
- b0Ptr += _pitch;
- b1Ptr += _pitch;
- b2Ptr += _pitch;
- b3Ptr += _pitch;
+ b0Ptr += pitch;
+ b1Ptr += pitch;
+ b2Ptr += pitch;
+ b3Ptr += pitch;
}// for y
}
void IndeoDecoderBase::recompose53(const IVIPlaneDesc *_plane,
uint8 *dst, const int dstPitch) {
- int x, y, indx;
- int32 p0, p1, p2, p3, tmp0, tmp1, tmp2;
- int32 b0_1, b0_2, b1_1, b1_2, b1_3, b2_1, b2_2, b2_3, b2_4, b2_5, b2_6;
- int32 b3_1, b3_2, b3_3, b3_4, b3_5, b3_6, b3_7, b3_8, b3_9;
- int32 _pitch, back_pitch;
- const short * b0Ptr, *b1Ptr, *b2Ptr, *b3Ptr;
- const int _numBands = 4;
+ int x, y, indx;
+ int32 p0, p1, p2, p3, tmp0, tmp1, tmp2;
+ int32 b0_1, b0_2, b1_1, b1_2, b1_3, b2_1, b2_2, b2_3, b2_4, b2_5, b2_6;
+ int32 b3_1, b3_2, b3_3, b3_4, b3_5, b3_6, b3_7, b3_8, b3_9;
+ int32 _pitch, back_pitch;
+ const short *b0Ptr, *b1Ptr, *b2Ptr, *b3Ptr;
+ const int numBands = 4;
// all bands should have the same _pitch
_pitch = _plane->_bands[0]._pitch;
@@ -781,25 +780,25 @@ void IndeoDecoderBase::recompose53(const IVIPlaneDesc *_plane,
if (y + 2 >= _plane->_height)
_pitch = 0;
// load storage variables with values
- if (_numBands > 0) {
+ if (numBands > 0) {
b0_1 = b0Ptr[0];
b0_2 = b0Ptr[_pitch];
}
- if (_numBands > 1) {
+ if (numBands > 1) {
b1_1 = b1Ptr[back_pitch];
b1_2 = b1Ptr[0];
b1_3 = b1_1 - b1_2 * 6 + b1Ptr[_pitch];
}
- if (_numBands > 2) {
+ if (numBands > 2) {
b2_2 = b2Ptr[0]; // b2[x, y ]
b2_3 = b2_2; // b2[x+1,y ] = b2[x,y]
b2_5 = b2Ptr[_pitch]; // b2[x ,y+1]
b2_6 = b2_5; // b2[x+1,y+1] = b2[x,y+1]
}
- if (_numBands > 3) {
+ if (numBands > 3) {
b3_2 = b3Ptr[back_pitch]; // b3[x ,y-1]
b3_3 = b3_2; // b3[x+1,y-1] = b3[x ,y-1]
b3_5 = b3Ptr[0]; // b3[x ,y ]
@@ -832,7 +831,7 @@ void IndeoDecoderBase::recompose53(const IVIPlaneDesc *_plane,
p0 = p1 = p2 = p3 = 0;
// process the LL-band by applying LPF both vertically and horizontally
- if (_numBands > 0) {
+ if (numBands > 0) {
tmp0 = b0_1;
tmp2 = b0_2;
b0_1 = b0Ptr[indx + 1];
@@ -846,7 +845,7 @@ void IndeoDecoderBase::recompose53(const IVIPlaneDesc *_plane,
}
// process the HL-band by applying HPF vertically and LPF horizontally
- if (_numBands > 1) {
+ if (numBands > 1) {
tmp0 = b1_2;
tmp1 = b1_1;
b1_2 = b1Ptr[indx + 1];
@@ -862,7 +861,7 @@ void IndeoDecoderBase::recompose53(const IVIPlaneDesc *_plane,
}
// process the LH-band by applying LPF vertically and HPF horizontally
- if (_numBands > 2) {
+ if (numBands > 2) {
b2_3 = b2Ptr[indx + 1];
b2_6 = b2Ptr[_pitch + indx + 1];
@@ -876,7 +875,7 @@ void IndeoDecoderBase::recompose53(const IVIPlaneDesc *_plane,
}
// process the HH-band by applying HPF both vertically and horizontally
- if (_numBands > 3) {
+ if (numBands > 3) {
b3_6 = b3Ptr[indx + 1]; // b3[x+1,y ]
b3_3 = b3Ptr[back_pitch + indx + 1]; // b3[x+1,y-1]
@@ -911,9 +910,9 @@ void IndeoDecoderBase::recompose53(const IVIPlaneDesc *_plane,
}
void IndeoDecoderBase::outputPlane(IVIPlaneDesc *_plane, uint8 *dst, int dstPitch) {
- int x, y;
- const int16 * src = _plane->_bands[0]._buf;
- uint32 pitch = _plane->_bands[0]._pitch;
+ int x, y;
+ const int16 *src = _plane->_bands[0]._buf;
+ uint32 pitch = _plane->_bands[0]._pitch;
if (!src)
return;
@@ -928,12 +927,12 @@ void IndeoDecoderBase::outputPlane(IVIPlaneDesc *_plane, uint8 *dst, int dstPitc
int IndeoDecoderBase::processEmptyTile(IVIBandDesc *band,
IVITile *tile, int32 mvScale) {
- int x, y, needMc, mbn, blk, numBlocks, mvX, mvY, mcType;
- int offs, mbOffset, rowOffset, ret;
- IVIMbInfo *mb, *refMb;
- const int16 * src;
- int16 * dst;
- IviMCFunc mcNoDeltaFunc;
+ int x, y, needMc, mbn, blk, numBlocks, mvX, mvY, mcType;
+ int offs, mbOffset, rowOffset, ret;
+ IVIMbInfo *mb, *refMb;
+ const int16 *src;
+ int16 *dst;
+ IviMCFunc mcNoDeltaFunc;
if (tile->_numMBs != IVI_MBs_PER_TILE(tile->_width, tile->_height, band->_mbSize)) {
warning("Allocated tile size %d mismatches "
@@ -1237,7 +1236,7 @@ int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
IviMCFunc mc, IviMCAvgFunc mcAvg, int mvX, int mvY,
int mvX2, int mvY2, int *prevDc, int isIntra,
int mcType, int mcType2, uint32 quant, int offs) {
- const uint16 *base_tab = isIntra ? band->_intraBase : band->_interBase;
+ const uint16 *baseTab = isIntra ? band->_intraBase : band->_interBase;
RVMapDesc *rvmap = band->_rvMap;
uint8 colFlags[8];
int32 trvec[64];
@@ -1295,7 +1294,7 @@ int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
if (!val)
warning("Val = 0 encountered!");
- q = (base_tab[pos] * quant) >> 9;
+ q = (baseTab[pos] * quant) >> 9;
if (q > 1)
val = val * q + FFSIGN(val) * (((q ^ 1) - 1) >> 1);
trvec[pos] = val;
diff --git a/image/codecs/indeo/mem.cpp b/image/codecs/indeo/mem.cpp
index 77a5fab..9db37ec 100644
--- a/image/codecs/indeo/mem.cpp
+++ b/image/codecs/indeo/mem.cpp
@@ -83,12 +83,8 @@ static inline int avSizeMult(size_t a, size_t b, size_t *r) {
/*------------------------------------------------------------------------*/
-void *avMalloc(size_t size) {
- return malloc(size);
-}
-
void *avMallocZ(size_t size) {
- void *ptr = avMalloc(size);
+ void *ptr = malloc(size);
if (ptr)
memset(ptr, 0, size);
@@ -96,22 +92,15 @@ void *avMallocZ(size_t size) {
}
void *avMallocArray(size_t nmemb, size_t size) {
- if (!size || nmemb >= MAX_INTEGER / size)
- return nullptr;
+ assert(size && nmemb < MAX_INTEGER / size);
return malloc(nmemb * size);
}
void *avMallocZArray(size_t nmemb, size_t size) {
- if (!size || nmemb >= MAX_INTEGER / size)
- return NULL;
-
+ assert(size && nmemb < MAX_INTEGER / size);
return avMallocZ(nmemb * size);
}
-void avFree(void *ptr) {
- free(ptr);
-}
-
void avFreeP(void *arg) {
void **ptr = (void **)arg;
free(*ptr);
@@ -127,12 +116,12 @@ void *avReallocF(void *ptr, size_t nelem, size_t elsize) {
void *r;
if (avSizeMult(elsize, nelem, &size)) {
- avFree(ptr);
+ free(ptr);
return nullptr;
}
r = avRealloc(ptr, size);
if (!r)
- avFree(ptr);
+ free(ptr);
return r;
}
diff --git a/image/codecs/indeo/mem.h b/image/codecs/indeo/mem.h
index c94cc78..8e889e5 100644
--- a/image/codecs/indeo/mem.h
+++ b/image/codecs/indeo/mem.h
@@ -41,17 +41,6 @@ namespace Indeo {
/**
* Allocate a memory block with alignment suitable for all memory accesses
- * (including vectors if available on the CPU).
- *
- * @param size Size in bytes for the memory block to be allocated
- * @return Pointer to the allocated block, or `NULL` if the block cannot
- * be allocated
- * @see av_mallocz()
- */
-extern void *avMalloc(size_t size);
-
-/**
- * Allocate a memory block with alignment suitable for all memory accesses
* (including vectors if available on the CPU) and zero all the bytes of the
* block.
*
@@ -91,19 +80,6 @@ extern void *avMallocZArray(size_t nmemb, size_t size);
/**
* Free a memory block which has been allocated with a function of av_malloc()
- * or av_realloc() family.
- *
- * @param ptr Pointer to the memory block which should be freed.
- *
- * @note `ptr = NULL` is explicitly allowed.
- * @note It is recommended that you use av_freep() instead, to prevent leaving
- * behind dangling pointers.
- * @see av_freep()
- */
-extern void avFree(void *ptr);
-
-/**
- * Free a memory block which has been allocated with a function of av_malloc()
* or av_realloc() family, and set the pointer pointing to it to `NULL`.
*
* @param ptr Pointer to the pointer to the memory block which should be freed
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index c8376ea..3e4c37b 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -89,8 +89,8 @@ const Graphics::Surface *Indeo4Decoder::decodeFrame(Common::SeekableReadStream &
}
int Indeo4Decoder::decodePictureHeader() {
- int pic_size_indx, i, p;
- IVIPicConfig _picConf;
+ int pic_size_indx, i, p;
+ IVIPicConfig picConf;
if (_ctx._gb->getBits(18) != 0x3FFF8) {
warning("Invalid picture start code!");
@@ -133,21 +133,21 @@ int Indeo4Decoder::decodePictureHeader() {
pic_size_indx = _ctx._gb->getBits(3);
if (pic_size_indx == IVI4_PIC_SIZE_ESC) {
- _picConf._picHeight = _ctx._gb->getBits(16);
- _picConf._picWidth = _ctx._gb->getBits(16);
+ picConf._picHeight = _ctx._gb->getBits(16);
+ picConf._picWidth = _ctx._gb->getBits(16);
} else {
- _picConf._picHeight = _ivi4_common_pic_sizes[pic_size_indx * 2 + 1];
- _picConf._picWidth = _ivi4_common_pic_sizes[pic_size_indx * 2];
+ picConf._picHeight = _ivi4_common_pic_sizes[pic_size_indx * 2 + 1];
+ picConf._picWidth = _ivi4_common_pic_sizes[pic_size_indx * 2];
}
// Decode tile dimensions.
_ctx._usesTiling = _ctx._gb->getBit();
if (_ctx._usesTiling) {
- _picConf._tileHeight = scaleTileSize(_picConf._picHeight, _ctx._gb->getBits(4));
- _picConf._tileWidth = scaleTileSize(_picConf._picWidth, _ctx._gb->getBits(4));
+ picConf._tileHeight = scaleTileSize(picConf._picHeight, _ctx._gb->getBits(4));
+ picConf._tileWidth = scaleTileSize(picConf._picWidth, _ctx._gb->getBits(4));
} else {
- _picConf._tileHeight = _picConf._picHeight;
- _picConf._tileWidth = _picConf._picWidth;
+ picConf._tileHeight = picConf._picHeight;
+ picConf._tileWidth = picConf._picWidth;
}
// Decode chroma subsampling. We support only 4:4 aka YVU9.
@@ -155,34 +155,34 @@ int Indeo4Decoder::decodePictureHeader() {
warning("Only YVU9 picture format is supported!");
return -1;
}
- _picConf._chromaHeight = (_picConf._picHeight + 3) >> 2;
- _picConf._chromaWidth = (_picConf._picWidth + 3) >> 2;
+ picConf._chromaHeight = (picConf._picHeight + 3) >> 2;
+ picConf._chromaWidth = (picConf._picWidth + 3) >> 2;
// decode subdivision of the planes
- _picConf._lumaBands = decodePlaneSubdivision();
- _picConf._chromaBands = 0;
- if (_picConf._lumaBands)
- _picConf._chromaBands = decodePlaneSubdivision();
- _ctx._isScalable = _picConf._lumaBands != 1 || _picConf._chromaBands != 1;
- if (_ctx._isScalable && (_picConf._lumaBands != 4 || _picConf._chromaBands != 1)) {
+ picConf._lumaBands = decodePlaneSubdivision();
+ picConf._chromaBands = 0;
+ if (picConf._lumaBands)
+ picConf._chromaBands = decodePlaneSubdivision();
+ _ctx._isScalable = picConf._lumaBands != 1 || picConf._chromaBands != 1;
+ if (_ctx._isScalable && (picConf._lumaBands != 4 || picConf._chromaBands != 1)) {
warning("Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d",
- _picConf._lumaBands, _picConf._chromaBands);
+ picConf._lumaBands, picConf._chromaBands);
return -1;
}
// check if picture layout was changed and reallocate buffers
- if (_picConf.ivi_pic_config_cmp(_ctx._picConf)) {
- if (IVIPlaneDesc::initPlanes(_ctx._planes, &_picConf, 1)) {
+ if (picConf.ivi_pic_config_cmp(_ctx._picConf)) {
+ if (IVIPlaneDesc::initPlanes(_ctx._planes, &picConf, 1)) {
warning("Couldn't reallocate color planes!");
_ctx._picConf._lumaBands = 0;
return -2;
}
- _ctx._picConf = _picConf;
+ _ctx._picConf = picConf;
// set default macroblock/block dimensions
for (p = 0; p <= 2; p++) {
- for (i = 0; i < (!p ? _picConf._lumaBands : _picConf._chromaBands); i++) {
+ for (i = 0; i < (!p ? picConf._lumaBands : picConf._chromaBands); i++) {
_ctx._planes[p]._bands[i]._mbSize = !p ? (!_ctx._isScalable ? 16 : 8) : 4;
_ctx._planes[p]._bands[i]._blkSize = !p ? 8 : 4;
}
@@ -233,13 +233,13 @@ int Indeo4Decoder::decodePictureHeader() {
}
void Indeo4Decoder::switchBuffers() {
- int is_prev_ref = 0, is_ref = 0;
+ int isPrevRef = 0, isRef = 0;
switch (_ctx._prevFrameType) {
case IVI4_FRAMETYPE_INTRA:
case IVI4_FRAMETYPE_INTRA1:
case IVI4_FRAMETYPE_INTER:
- is_prev_ref = 1;
+ isPrevRef = 1;
break;
}
@@ -247,16 +247,16 @@ void Indeo4Decoder::switchBuffers() {
case IVI4_FRAMETYPE_INTRA:
case IVI4_FRAMETYPE_INTRA1:
case IVI4_FRAMETYPE_INTER:
- is_ref = 1;
+ isRef = 1;
break;
default:
break;
}
- if (is_prev_ref && is_ref) {
+ if (isPrevRef && isRef) {
SWAP(_ctx._dstBuf, _ctx._refBuf);
- } else if (is_prev_ref) {
+ } else if (isPrevRef) {
SWAP(_ctx._refBuf, _ctx._bRefBuf);
SWAP(_ctx._dstBuf, _ctx._refBuf);
}
@@ -443,13 +443,13 @@ int Indeo4Decoder::decodeBandHeader(IVIBandDesc *band) {
}
int Indeo4Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
- int x, y, mvX, mvY, mvDelta, offs, mbOffset, blksPerMb,
+ int x, y, mvX, mvY, mvDelta, offs, mbOffset, blksPerMb,
mvScale, mbTypeBits, s;
- IVIMbInfo *mb, *ref_mb;
- int row_offset = band->_mbSize * band->_pitch;
+ IVIMbInfo *mb, *refMb;
+ int row_offset = band->_mbSize * band->_pitch;
mb = tile->_mbs;
- ref_mb = tile->_refMbs;
+ refMb = tile->_refMbs;
offs = tile->_yPos * band->_pitch + tile->_xPos;
blksPerMb = band->_mbSize != band->_blkSize ? 4 : 1;
@@ -489,24 +489,24 @@ int Indeo4Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
}
mb->_mvX = mb->_mvY = 0; // no motion vector coded
- if (band->_inheritMv && ref_mb) {
+ if (band->_inheritMv && refMb) {
// motion vector inheritance
if (mvScale) {
- mb->_mvX = scaleMV(ref_mb->_mvX, mvScale);
- mb->_mvY = scaleMV(ref_mb->_mvY, mvScale);
+ mb->_mvX = scaleMV(refMb->_mvX, mvScale);
+ mb->_mvY = scaleMV(refMb->_mvY, mvScale);
} else {
- mb->_mvX = ref_mb->_mvX;
- mb->_mvY = ref_mb->_mvY;
+ mb->_mvX = refMb->_mvX;
+ mb->_mvY = refMb->_mvY;
}
}
} else {
if (band->_inheritMv) {
// copy mb_type from corresponding reference mb
- if (!ref_mb) {
- warning("ref_mb unavailable");
+ if (!refMb) {
+ warning("refMb unavailable");
return -1;
}
- mb->_type = ref_mb->_type;
+ mb->_type = refMb->_type;
} else if (_ctx._frameType == IVI4_FRAMETYPE_INTRA ||
_ctx._frameType == IVI4_FRAMETYPE_INTRA1) {
mb->_type = 0; // mb_type is always INTRA for intra-frames
@@ -518,7 +518,7 @@ int Indeo4Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
mb->_qDelta = 0;
if (band->_inheritQDelta) {
- if (ref_mb) mb->_qDelta = ref_mb->_qDelta;
+ if (refMb) mb->_qDelta = refMb->_qDelta;
} else if (mb->_cbp || (!band->_plane && !band->_bandNum &&
_ctx._inQ)) {
mb->_qDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
@@ -530,14 +530,14 @@ int Indeo4Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
mb->_mvX = mb->_mvY = 0; // there is no motion vector in intra-macroblocks
} else {
if (band->_inheritMv) {
- if (ref_mb) {
+ if (refMb) {
// motion vector inheritance
if (mvScale) {
- mb->_mvX = scaleMV(ref_mb->_mvX, mvScale);
- mb->_mvY = scaleMV(ref_mb->_mvY, mvScale);
+ mb->_mvX = scaleMV(refMb->_mvX, mvScale);
+ mb->_mvY = scaleMV(refMb->_mvY, mvScale);
} else {
- mb->_mvX = ref_mb->_mvX;
- mb->_mvY = ref_mb->_mvY;
+ mb->_mvX = refMb->_mvX;
+ mb->_mvY = refMb->_mvY;
}
}
} else {
@@ -582,8 +582,8 @@ int Indeo4Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
}
mb++;
- if (ref_mb)
- ref_mb++;
+ if (refMb)
+ refMb++;
mbOffset += band->_mbSize;
}
diff --git a/image/codecs/indeo5.cpp b/image/codecs/indeo5.cpp
index 00ca032..d5ce571 100644
--- a/image/codecs/indeo5.cpp
+++ b/image/codecs/indeo5.cpp
@@ -100,8 +100,7 @@ const Graphics::Surface *Indeo5Decoder::decodeFrame(Common::SeekableReadStream &
}
int Indeo5Decoder::decodePictureHeader() {
- IVIPicConfig picConf;
-
+ IVIPicConfig picConf;
int ret;
if (_ctx._gb->getBits(5) != 0x1F) {
@@ -201,8 +200,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);
@@ -259,10 +258,9 @@ int Indeo5Decoder::decodeBandHeader(IVIBandDesc *band) {
}
int Indeo5Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
- int x, y, mvX, mvY, mvDelta, offs, mbOffset,
- mvScale, blksPerMb, s;
- IVIMbInfo *mb, *refMb;
- int rowOffset = band->_mbSize * band->_pitch;
+ int x, y, mvX, mvY, mvDelta, offs, mbOffset, mvScale, blksPerMb, s;
+ IVIMbInfo *mb, *refMb;
+ int rowOffset = band->_mbSize * band->_pitch;
mb = tile->_mbs;
refMb = tile->_refMbs;
@@ -386,11 +384,11 @@ int Indeo5Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
}
int Indeo5Decoder::decode_gop_header() {
- int result, i, p, tileSize, picSizeIndx, mbSize, blkSize, isScalable;
- int quantMat;
- bool blkSizeChanged = false;
- IVIBandDesc *band, *band1, *band2;
- IVIPicConfig picConf;
+ int result, i, p, tileSize, picSizeIndx, mbSize, blkSize, isScalable;
+ int quantMat;
+ bool blkSizeChanged = false;
+ IVIBandDesc *band, *band1, *band2;
+ IVIPicConfig picConf;
_ctx._gopFlags = _ctx._gb->getBits(8);
Commit: 0733cf65ba8f6babdf35547b49cd2d57c9daf646
https://github.com/scummvm/scummvm/commit/0733cf65ba8f6babdf35547b49cd2d57c9daf646
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-09-11T16:58:54+02:00
Commit Message:
Merge pull request #826 from dreammaster/indeo
IMAGE: Indeo 4 & 5 decoders
Changed paths:
A image/codecs/indeo/get_bits.cpp
A image/codecs/indeo/get_bits.h
A image/codecs/indeo/indeo.cpp
A image/codecs/indeo/indeo.h
A image/codecs/indeo/indeo_dsp.cpp
A image/codecs/indeo/indeo_dsp.h
A image/codecs/indeo/mem.cpp
A image/codecs/indeo/mem.h
A image/codecs/indeo/vlc.cpp
A image/codecs/indeo/vlc.h
A image/codecs/indeo4.cpp
A image/codecs/indeo4.h
A image/codecs/indeo5.cpp
A image/codecs/indeo5.h
common/bitstream.h
engines/macventure/text.cpp
image/codecs/codec.cpp
image/module.mk
video/bink_decoder.cpp
video/smk_decoder.cpp
More information about the Scummvm-git-logs
mailing list