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/mem.h | 145 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 image/codecs/indeo/mem.h (limited to 'image/codecs/indeo/mem.h') diff --git a/image/codecs/indeo/mem.h b/image/codecs/indeo/mem.h new file mode 100644 index 0000000000..4f9ebf016d --- /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 -- cgit v1.2.3 From 9e774af4d91cb3adddfb6acc2024653620e725db Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 6 Sep 2016 22:13:56 -0400 Subject: IMAGE: Further implementation of Indeo image decoding --- image/codecs/indeo/mem.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'image/codecs/indeo/mem.h') diff --git a/image/codecs/indeo/mem.h b/image/codecs/indeo/mem.h index 4f9ebf016d..d3755d652c 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 -- cgit v1.2.3 From 9c7b9e166746a903dc0b7e87967ec257967e1359 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 10 Sep 2016 10:43:23 -0400 Subject: IMAGE: Compilation fixes for Indeo4 decoder --- image/codecs/indeo/mem.h | 1 + 1 file changed, 1 insertion(+) (limited to 'image/codecs/indeo/mem.h') diff --git a/image/codecs/indeo/mem.h b/image/codecs/indeo/mem.h index d3755d652c..cc927e613a 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 -- cgit v1.2.3 From 9c6a55a2a660d2c59e9c0e22402e4d16e08ef987 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 10 Sep 2016 18:07:13 -0400 Subject: IMAGE: Cleanup of miscellaneous methods and arrays in Indeo decoders --- image/codecs/indeo/mem.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'image/codecs/indeo/mem.h') diff --git a/image/codecs/indeo/mem.h b/image/codecs/indeo/mem.h index cc927e613a..7fadb147cb 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 -- 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/mem.h | 1 - 1 file changed, 1 deletion(-) (limited to 'image/codecs/indeo/mem.h') diff --git a/image/codecs/indeo/mem.h b/image/codecs/indeo/mem.h index 7fadb147cb..c94cc78ee6 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 -- cgit v1.2.3 From 08143af48293b007027d11271d3f66f7ad3107e6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 11 Sep 2016 09:42:12 -0400 Subject: IMAGE: Further formatting of Indeo decoders --- image/codecs/indeo/mem.h | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'image/codecs/indeo/mem.h') diff --git a/image/codecs/indeo/mem.h b/image/codecs/indeo/mem.h index c94cc78ee6..8e889e5cbf 100644 --- a/image/codecs/indeo/mem.h +++ b/image/codecs/indeo/mem.h @@ -39,17 +39,6 @@ namespace Indeo { #define FFSIGN(a) ((a) > 0 ? 1 : -1) #define MAX_INTEGER 0x7ffffff -/** - * 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 @@ -89,19 +78,6 @@ extern void *avMallocArray(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() - * 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`. -- cgit v1.2.3