fixed various minor warnings occuring under icc9 and bcc32, added MSVC project and compiler directives to build a 'standard' WIN32 DLL

This commit is contained in:
Freeimage 2006-01-31 21:26:11 +00:00
parent 74c1b3637e
commit 355b88c15d
18 changed files with 432 additions and 61 deletions

View File

@ -7,8 +7,10 @@ What's New for OpenJPEG
January 31, 2006
* [Mathieu Malaterre] Fix compilation using default openjpeg.dsw
* [Herve Drolon] fixed various minor warnings occuring under icc9 and bcc32
- [Mathieu Malaterre] Remove all references to OPJ_EXPORT, no declspec in header file anymore
+ [Mathieu Malaterre] Add a def.in file which is a template for Module Definition
+ [Herve Drolon] added MSVC project and compiler directives to build a 'standard' WIN32 DLL
January 27, 2006
* [Antonin Descampe] fixed a two initialization problems in t1.c and tcd.c

277
DllOpenJPEG.dsp Normal file
View File

@ -0,0 +1,277 @@
# Microsoft Developer Studio Project File - Name="DllOpenJPEG" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=DllOpenJPEG - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "DllOpenJPEG.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "DllOpenJPEG.mak" CFG="DllOpenJPEG - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "DllOpenJPEG - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "DllOpenJPEG - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "DllOpenJPEG - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DLLOPENJPEG_EXPORTS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OPJ_EXPORTS" /FD /c
# SUBTRACT CPP /YX /Yc /Yu
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release/OpenJPEG.dll"
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Cmds=if not exist dist mkdir dist copy libopenjpeg\openjpeg.h dist copy Release\OpenJPEG.dll dist copy Release\OpenJPEG.lib dist
# End Special Build Tool
!ELSEIF "$(CFG)" == "DllOpenJPEG - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DLLOPENJPEG_EXPORTS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OPJ_EXPORTS" /FD /GZ /c
# SUBTRACT CPP /YX /Yc /Yu
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x40c /d "_DEBUG"
# ADD RSC /l 0x40c /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Debug/OpenJPEGd.dll" /pdbtype:sept
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Cmds=if not exist dist mkdir dist copy libopenjpeg\openjpeg.h dist copy Debug\OpenJPEGd.dll dist copy Debug\OpenJPEGd.lib dist
# End Special Build Tool
!ENDIF
# Begin Target
# Name "DllOpenJPEG - Win32 Release"
# Name "DllOpenJPEG - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\libopenjpeg\bio.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\cio.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\dwt.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\event.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\fix.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\image.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\int.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\j2k.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\j2k_lib.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\jp2.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\jpt.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\mct.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\mqc.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\openjpeg.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\pi.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\raw.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\t1.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\t2.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\tcd.c
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\tgt.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\libopenjpeg\bio.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\cio.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\dwt.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\event.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\fix.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\image.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\int.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\j2k.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\j2k_lib.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\jp2.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\jpt.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\mct.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\mqc.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\openjpeg.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\opj_includes.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\pi.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\raw.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\t1.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\t2.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\tcd.h
# End Source File
# Begin Source File
SOURCE=.\libopenjpeg\tgt.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@ -41,7 +41,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "OPJ_STATIC" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
@ -53,7 +53,7 @@ LIB32=link.exe -lib
# ADD LIB32 /nologo
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Cmds=copy Release\LibOpenJPEG.lib dist copy libopenjpeg\openjpeg.h dist
PostBuild_Cmds=if not exist dist mkdir dist copy Release\LibOpenJPEG.lib dist copy libopenjpeg\openjpeg.h dist
# End Special Build Tool
!ELSEIF "$(CFG)" == "LibOpenJPEG - Win32 Debug"
@ -69,7 +69,7 @@ PostBuild_Cmds=copy Release\LibOpenJPEG.lib dist copy libopenjpeg\openjpeg.h dis
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "OPJ_STATIC" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x40c /d "_DEBUG"
# ADD RSC /l 0x40c /d "_DEBUG"
@ -78,10 +78,10 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
# ADD LIB32 /nologo /out:"Debug\LibOpenJPEGd.lib"
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Cmds=copy Debug\LibOpenJPEG.lib dist copy libopenjpeg\openjpeg.h dist
PostBuild_Cmds=if not exist dist mkdir dist copy Debug\LibOpenJPEGd.lib dist copy libopenjpeg\openjpeg.h dist
# End Special Build Tool
!ENDIF

View File

@ -3,6 +3,18 @@ Microsoft Developer Studio Workspace File, Format Version 6.00
###############################################################################
Project: "DllOpenJPEG"=.\DllOpenJPEG.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "LibOpenJPEG"=.\LibOpenJPEG.dsp - Package Owner=<4>
Package=<5>

40
README.msvc Normal file
View File

@ -0,0 +1,40 @@
How to compile the library under MS VC++ 6.0
--------------------------------------------
The library comes in two versions :
- a static library that can be linked against any C/C++ program
- a Dynamic Link Library (Windows DLL) that can be used in any C/C++ program and in most interpreted languages (e.g. VB, C#, ...).
In order to compile the library version *or* the DLL version, you will have to :
1) Open the MSVC project named LibOpenJPEG.dsw
2) Set the choosen target as the active project, that means :
a) Go to the Menu 'Build -> Set Active Configuration'
b) Choose one of the following configuration :
- DllOpenJPEG - Win32 Release => creates a DLL in release mode named OpenJPEG.dll
- DllOpenJPEG - Win32 Debug => creates a DLL in debug mode named OpenJPEGd.dll
- LibOpenJPEG - Win32 Release => creates a static library in release mode named LibOpenJPEG.lib
- LibOpenJPEG - Win32 Debug => creates a static library in debug mode named LibOpenJPEGd.lib
3) Build the project : Menu -> Build -> Rebuild All
The build process will create a directory named 'dist' that will contain all you need in order to use the library.
Simple codec compilation
------------------------
Once you've built the library, you might want to test it with a basic codec. To do this, go to the codec directory and use one of the following projects to build an encoder and decoder respectively:
- image_to_j2k.dsw
- j2k_to_image.dsw
IMPORTANT NOTE :
----------------
The encoder and decoder samples are configured to use the static version of the library. A link to the LibOpenJPEG static project is included in these projects so that you can build both a codec and the library in a single pass.
However, you MUST NOTE that in order to use LibOpenJPEG as a static library in your program, you NEED to add the following compiler directive to your project : OPJ_STATIC
Look at the menu 'Project -> Settings -> C/C++ tab -> preprocessor definition' to see how this is configured.
When using OpenJPEG as a DLL, this compiler directive MUST NOT be used.

View File

@ -2,6 +2,7 @@ rd Release /s /q
rd Debug /s /q
rd codec\Debug /s /q
rd codec\Release /s /q
rd dist /s /q
del *.pch /s /q
del *.ncb /s /q
del *.opt /s /q

View File

@ -417,7 +417,6 @@ opj_image_t* bmptoimage(char *filename, opj_cparameters_t *parameters) {
opj_image_destroy(image);
fclose(IN);
return NULL;
break;
default:
for (i = 0; i < v; i++) {
v2 = getc(IN);

View File

@ -239,7 +239,6 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
"!! Unrecognized format for infile : %s [accept only *.pnm, *.pgm, *.ppm, *.pgx or *.bmp] !!\n\n",
infile);
return 1;
break;
}
strncpy(parameters->infile, infile, MAX_PATH);
}
@ -258,7 +257,6 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
default:
fprintf(stderr, "Unknown output format image %s [only *.j2k, *.jp2]!! \n", outfile);
return 1;
break;
}
strncpy(parameters->outfile, outfile, MAX_PATH);
}
@ -451,11 +449,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ----------------------------------------------------- */
case 'h': /* display an help description */
{
encode_help_display();
return 1;
}
break;
/* ----------------------------------------------------- */

View File

@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x40c /d "_DEBUG"
# ADD RSC /l 0x40c /d "_DEBUG"

View File

@ -126,7 +126,6 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
infile);
return 1;
break;
}
strncpy(parameters->infile, infile, MAX_PATH);
}
@ -146,7 +145,6 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
default:
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx or *.bmp]!! \n", outfile);
return 1;
break;
}
strncpy(parameters->outfile, outfile, MAX_PATH);
}
@ -173,11 +171,8 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
/* ----------------------------------------------------- */
case 'h': /* display an help description */
{
decode_help_display();
return 1;
}
break;
return 1;
/* ----------------------------------------------------- */
@ -360,7 +355,6 @@ int main(int argc, char **argv) {
default:
fprintf(stderr, "ERROR -> j2k_to_image : Unknown input image format\n");
return 1;
break;
}
/* free the memory containing the code-stream */

View File

@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /YX /FD /GZ /c
# ADD BASE RSC /l 0x40c /d "_DEBUG"
# ADD RSC /l 0x40c /d "_DEBUG"
BSC32=bscmake.exe

View File

@ -32,7 +32,7 @@
/* ----------------------------------------------------------------------- */
opj_cio_t* opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length) {
opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length) {
opj_cp_t *cp = NULL;
opj_cio_t *cio = (opj_cio_t*)opj_malloc(sizeof(opj_cio_t));
if(!cio) return NULL;
@ -77,7 +77,7 @@ opj_cio_t* opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length)
return cio;
}
void opj_cio_close(opj_cio_t *cio) {
void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio) {
if(cio) {
if(cio->openmode == OPJ_STREAM_WRITE) {
/* destroy the allocated buffer */
@ -94,7 +94,7 @@ void opj_cio_close(opj_cio_t *cio) {
/*
* Get position in byte stream.
*/
int cio_tell(opj_cio_t *cio) {
int OPJ_CALLCONV cio_tell(opj_cio_t *cio) {
return cio->bp - cio->start;
}
@ -103,7 +103,7 @@ int cio_tell(opj_cio_t *cio) {
*
* pos : position, in number of bytes, from the beginning of the stream
*/
void cio_seek(opj_cio_t *cio, int pos) {
void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos) {
cio->bp = cio->start + pos;
}

View File

@ -61,7 +61,7 @@ _itoa(int i, char *a, int r) {
/* ----------------------------------------------------------------------- */
opj_event_mgr_t* opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context) {
opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context) {
if(cinfo) {
opj_event_mgr_t *previous = cinfo->event_mgr;
cinfo->event_mgr = event_mgr;

View File

@ -31,7 +31,7 @@ opj_image_t* opj_image_create0() {
return image;
}
opj_image_t *opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) {
opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) {
int compno;
opj_image_t *image = NULL;
@ -68,7 +68,7 @@ opj_image_t *opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ
return image;
}
void opj_image_destroy(opj_image_t *image) {
void OPJ_CALLCONV opj_image_destroy(opj_image_t *image) {
int i;
if(image) {
if(image->comps) {

View File

@ -24,13 +24,40 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef WIN32
#include <windows.h>
#endif /* WIN32 */
#include "opj_includes.h"
const char * opj_version() {
/* ---------------------------------------------------------------------- */
#ifdef WIN32
#ifndef OPJ_STATIC
BOOL APIENTRY
DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH :
break;
case DLL_PROCESS_DETACH :
break;
case DLL_THREAD_ATTACH :
case DLL_THREAD_DETACH :
break;
}
return TRUE;
}
#endif /* OPJ_STATIC */
#endif /* WIN32 */
/* ---------------------------------------------------------------------- */
const char* OPJ_CALLCONV opj_version() {
return OPENJPEG_VERSION;
}
opj_dinfo_t* opj_create_decompress(OPJ_CODEC_FORMAT format) {
opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) {
opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_malloc(sizeof(opj_dinfo_t));
if(!dinfo) return NULL;
dinfo->is_decompressor = true;
@ -63,7 +90,7 @@ opj_dinfo_t* opj_create_decompress(OPJ_CODEC_FORMAT format) {
return dinfo;
}
void opj_destroy_decompress(opj_dinfo_t *dinfo) {
void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo) {
if(dinfo) {
/* destroy the codec */
switch(dinfo->codec_format) {
@ -83,7 +110,7 @@ void opj_destroy_decompress(opj_dinfo_t *dinfo) {
}
}
void opj_set_default_decoder_parameters(opj_dparameters_t *parameters) {
void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters) {
if(parameters) {
memset(parameters, 0, sizeof(opj_dparameters_t));
/* default decoding parameters */
@ -95,7 +122,7 @@ void opj_set_default_decoder_parameters(opj_dparameters_t *parameters) {
}
}
void opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters) {
void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters) {
if(dinfo && parameters) {
switch(dinfo->codec_format) {
case CODEC_J2K:
@ -112,7 +139,7 @@ void opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters) {
}
}
opj_image_t* opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio) {
opj_image_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio) {
if(dinfo && cio) {
switch(dinfo->codec_format) {
case CODEC_J2K:
@ -121,13 +148,16 @@ opj_image_t* opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio) {
return j2k_decode_jpt_stream((opj_j2k_t*)dinfo->j2k_handle, cio);
case CODEC_JP2:
return jp2_decode((opj_jp2_t*)dinfo->jp2_handle, cio);
case CODEC_UNKNOWN:
default:
break;
}
}
return NULL;
}
opj_cinfo_t* opj_create_compress(OPJ_CODEC_FORMAT format) {
opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) {
opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_malloc(sizeof(opj_cinfo_t));
if(!cinfo) return NULL;
cinfo->is_decompressor = false;
@ -160,7 +190,7 @@ opj_cinfo_t* opj_create_compress(OPJ_CODEC_FORMAT format) {
return cinfo;
}
void opj_destroy_compress(opj_cinfo_t *cinfo) {
void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo) {
if(cinfo) {
/* destroy the codec */
switch(cinfo->codec_format) {
@ -180,7 +210,7 @@ void opj_destroy_compress(opj_cinfo_t *cinfo) {
}
}
void opj_set_default_encoder_parameters(opj_cparameters_t *parameters) {
void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters) {
if(parameters) {
memset(parameters, 0, sizeof(opj_cparameters_t));
/* default coding parameters */
@ -197,7 +227,7 @@ void opj_set_default_encoder_parameters(opj_cparameters_t *parameters) {
}
}
void opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image) {
void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image) {
if(cinfo && parameters && image) {
switch(cinfo->codec_format) {
case CODEC_J2K:
@ -214,7 +244,7 @@ void opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_im
}
}
bool opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index) {
bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index) {
if(cinfo && cio && image) {
switch(cinfo->codec_format) {
case CODEC_J2K:

View File

@ -37,6 +37,27 @@
Compiler directives
==========================================================
*/
#if defined(OPJ_STATIC) || !(defined(WIN32) || defined(__WIN32__))
#define OPJ_API
#define OPJ_CALLCONV
#else
#define OPJ_CALLCONV __stdcall
/*
The following ifdef block is the standard way of creating macros which make exporting
from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
symbol defined on the command line. this symbol should not be defined on any project
that uses this DLL. This way any other project whose source files include this file see
OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols
defined with this macro as being exported.
*/
#ifdef OPJ_EXPORTS
#define OPJ_API __declspec(dllexport)
#else
#define OPJ_API __declspec(dllimport)
#endif /* OPJ_EXPORTS */
#endif /* !OPJ_STATIC || !WIN32 */
#ifndef __cplusplus
#if defined(HAVE_STDBOOL_H)
/*
@ -446,7 +467,7 @@ extern "C" {
==========================================================
*/
const char * opj_version();
OPJ_API const char * OPJ_CALLCONV opj_version();
/*
==========================================================
@ -461,13 +482,13 @@ Create an image
@param clrspc image color space
@return returns a new image structure if successful, returns NULL otherwise
*/
opj_image_t *opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
/**
Deallocate any resources associated with an image
@param image image to be destroyed
*/
void opj_image_destroy(opj_image_t *image);
OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image);
/*
==========================================================
@ -486,26 +507,26 @@ to contain encoded data.
@param length Reading: buffer length. Writing: 0
@return Returns a CIO handle if successful, returns NULL otherwise
*/
opj_cio_t* opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length);
OPJ_API opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length);
/**
Close and free a CIO handle
@param cio CIO handle to free
*/
void opj_cio_close(opj_cio_t *cio);
OPJ_API void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio);
/**
Get position in byte stream
@param cio CIO handle
@return Returns the position in bytes
*/
int cio_tell(opj_cio_t *cio);
OPJ_API int OPJ_CALLCONV cio_tell(opj_cio_t *cio);
/**
Set position in byte stream
@param cio CIO handle
@param pos Position, in number of bytes, from the beginning of the stream
*/
void cio_seek(opj_cio_t *cio, int pos);
OPJ_API void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos);
/*
==========================================================
@ -513,7 +534,7 @@ void cio_seek(opj_cio_t *cio, int pos);
==========================================================
*/
opj_event_mgr_t* opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context);
OPJ_API opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context);
/*
==========================================================
@ -525,42 +546,42 @@ Creates a J2K/JPT/JP2 decompression structure
@param format Decoder to select
@return Returns a handle to a decompressor if successful, returns NULL otherwise
*/
opj_dinfo_t* opj_create_decompress(OPJ_CODEC_FORMAT format);
OPJ_API opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format);
/**
Destroy a decompressor handle
@param dinfo decompressor handle to destroy
*/
void opj_destroy_decompress(opj_dinfo_t *dinfo);
OPJ_API void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo);
/**
Set decoding parameters to default values
@param parameters Decompression parameters
*/
void opj_set_default_decoder_parameters(opj_dparameters_t *parameters);
OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters);
/**
Setup the decoder decoding parameters using user parameters.
Decoding parameters are returned in j2k->cp.
@param dinfo decompressor handle
@param parameters decompression parameters
*/
void opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters);
OPJ_API void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters);
/**
Decode an image from a JPEG-2000 codestream
@param dinfo decompressor handle
@param cio Input buffer stream
@return Returns a decoded image if successful, returns NULL otherwise
*/
opj_image_t* opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio);
OPJ_API opj_image_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio);
/**
Creates a J2K/JP2 compression structure
@param format Coder to select
@return Returns a handle to a compressor if successful, returns NULL otherwise
*/
opj_cinfo_t* opj_create_compress(OPJ_CODEC_FORMAT format);
OPJ_API opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
/**
Destroy a compressor handle
@param cinfo compressor handle to destroy
*/
void opj_destroy_compress(opj_cinfo_t *cinfo);
OPJ_API void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo);
/**
Set encoding parameters to default values, that means :
<ul>
@ -582,14 +603,14 @@ Set encoding parameters to default values, that means :
</ul>
@param parameters Compression parameters
*/
void opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
/**
Setup the encoder parameters using the current image and using user parameters.
@param cinfo compressor handle
@param parameters compression parameters
@param image input filled image
*/
void opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image);
OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image);
/**
Encode an image into a JPEG-2000 codestream
@param cinfo compressor handle
@ -598,7 +619,7 @@ Encode an image into a JPEG-2000 codestream
@param index Name of the index file if required, NULL otherwise
@return Returns true if successful, returns false otherwise
*/
bool opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
OPJ_API bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
#ifdef __cplusplus
}

View File

@ -73,7 +73,7 @@ Decode a packet of a tile from a source buffer
@param pi Packet identity
@return
*/
int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterator_t *pi);
static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterator_t *pi);
/*@}*/
@ -308,7 +308,7 @@ static void t2_init_seg(opj_tcd_seg_t * seg, int cblksty, int first) {
}
}
int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterator_t *pi) {
static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterator_t *pi) {
int bandno, cblkno;
unsigned char *c = src;

View File

@ -945,7 +945,7 @@ void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final) {
dd = pass->distortiondec - cblk->passes[n - 1].distortiondec;
}
if (!dr) {
if (dd)
if (dd != 0)
n = passno + 1;
continue;
}