From 5f0962696f97df2cce27d065d99b04243de59334 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 5 Sep 2016 23:00:08 -0400 Subject: IMAGE: Added Indeo4Decoder decodePictureHeader, and lots of dependencies --- image/codecs/indeo/vlc.h | 138 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 image/codecs/indeo/vlc.h (limited to 'image/codecs/indeo/vlc.h') diff --git a/image/codecs/indeo/vlc.h b/image/codecs/indeo/vlc.h new file mode 100644 index 0000000000..682be66e4a --- /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 -- cgit v1.2.3 From 400661182efae9659e664fec0e81c7ed8c3a10ec Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 7 Sep 2016 21:30:26 -0400 Subject: IMAGE: Indeo4 header now being successfully loaded --- image/codecs/indeo/vlc.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'image/codecs/indeo/vlc.h') diff --git a/image/codecs/indeo/vlc.h b/image/codecs/indeo/vlc.h index 682be66e4a..01c7b1160b 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(). -- cgit v1.2.3 From 2f7da2d3d9a6c9ef998a8e1b91a4554e6d1b9d74 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 10 Sep 2016 21:05:49 -0400 Subject: IMAGE: Miscellaneous cleanup for Indeo decompressors --- image/codecs/indeo/vlc.h | 45 ++++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) (limited to 'image/codecs/indeo/vlc.h') diff --git a/image/codecs/indeo/vlc.h b/image/codecs/indeo/vlc.h index 01c7b1160b..51e887d3ae 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 -- cgit v1.2.3 From a5f43663875e789baa8b7d9e79d5da4b3362f04a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 10 Sep 2016 22:18:05 -0400 Subject: IMAGE: Fix leading spaces into tabs in Indeo decoders --- image/codecs/indeo/vlc.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'image/codecs/indeo/vlc.h') diff --git a/image/codecs/indeo/vlc.h b/image/codecs/indeo/vlc.h index 51e887d3ae..a6dd692732 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(); -- cgit v1.2.3