summaryrefslogtreecommitdiff
path: root/src/lib/openmj2
diff options
context:
space:
mode:
authorMathieu Malaterre <mathieu.malaterre@gmail.com>2012-10-15 09:44:34 +0000
committerMathieu Malaterre <mathieu.malaterre@gmail.com>2012-10-15 09:44:34 +0000
commitdff377a741ec87f8737002cf112ae12655881777 (patch)
tree24fec645259014dc1e60f393d5d39c2b36aa603c /src/lib/openmj2
parentb24cf8d1574c00915c568314d3e0e011ca77ba89 (diff)
[trunk] Fix compilation:
- using mingw32 compiler (missing exported symbols) - using -fvisibility=hidden (gcc on UNIX)
Diffstat (limited to 'src/lib/openmj2')
-rw-r--r--src/lib/openmj2/CMakeLists.txt17
-rw-r--r--src/lib/openmj2/cio.c6
-rw-r--r--src/lib/openmj2/cio.h6
-rw-r--r--src/lib/openmj2/j2k_lib.c2
-rw-r--r--src/lib/openmj2/j2k_lib.h2
-rw-r--r--src/lib/openmj2/mj2.c23
-rw-r--r--src/lib/openmj2/mj2.h22
-rw-r--r--src/lib/openmj2/mj2_convert.c12
-rw-r--r--src/lib/openmj2/mj2_convert.h10
-rw-r--r--src/lib/openmj2/openjpeg.h8
10 files changed, 57 insertions, 51 deletions
diff --git a/src/lib/openmj2/CMakeLists.txt b/src/lib/openmj2/CMakeLists.txt
index c2efe7e4..775c9318 100644
--- a/src/lib/openmj2/CMakeLists.txt
+++ b/src/lib/openmj2/CMakeLists.txt
@@ -1,4 +1,10 @@
+# openmj2:
set(OPENMJ2_LIBRARY_NAME openmj2)
+
+include_directories(
+ ${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
+ )
+
set(OPENMJ2_SRCS
mj2.c
mj2_convert.c
@@ -27,15 +33,10 @@ set(OPENMJ2_SRCS
if(WIN32)
if(BUILD_SHARED_LIBS)
add_definitions(-DOPJ_EXPORTS)
- else(BUILD_SHARED_LIBS)
+ else()
add_definitions(-DOPJ_STATIC)
- endif(BUILD_SHARED_LIBS)
-endif(WIN32)
-
-include_directories(
- ${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
- #${OPENJPEG_SOURCE_DIR}/src/lib/openjp2
- )
+ endif()
+endif()
# build mj2 lib:
add_library(${OPENMJ2_LIBRARY_NAME} ${OPENMJ2_SRCS})
diff --git a/src/lib/openmj2/cio.c b/src/lib/openmj2/cio.c
index c0cb0282..56de6145 100644
--- a/src/lib/openmj2/cio.c
+++ b/src/lib/openmj2/cio.c
@@ -152,7 +152,7 @@ unsigned char cio_bytein(opj_cio_t *cio) {
* v : value to write
* n : number of bytes to write
*/
-unsigned int cio_write(opj_cio_t *cio, unsigned int64 v, int n) {
+unsigned int OPJ_CALLCONV cio_write(opj_cio_t *cio, unsigned int64 v, int n) {
int i;
for (i = n - 1; i >= 0; i--) {
if( !cio_byteout(cio, (unsigned char) ((v >> (i << 3)) & 0xff)) )
@@ -168,7 +168,7 @@ unsigned int cio_write(opj_cio_t *cio, unsigned int64 v, int n) {
*
* return : value of the n bytes read
*/
-unsigned int cio_read(opj_cio_t *cio, int n) {
+unsigned int OPJ_CALLCONV cio_read(opj_cio_t *cio, int n) {
int i;
unsigned int v;
v = 0;
@@ -183,7 +183,7 @@ unsigned int cio_read(opj_cio_t *cio, int n) {
*
* n : number of bytes to skip
*/
-void cio_skip(opj_cio_t *cio, int n) {
+void OPJ_CALLCONV cio_skip(opj_cio_t *cio, int n) {
cio->bp += n;
}
diff --git a/src/lib/openmj2/cio.h b/src/lib/openmj2/cio.h
index e6274314..d37a6532 100644
--- a/src/lib/openmj2/cio.h
+++ b/src/lib/openmj2/cio.h
@@ -70,20 +70,20 @@ Write some bytes
@param n Number of bytes to write
@return Returns the number of bytes written or 0 if an error occured
*/
-unsigned int cio_write(opj_cio_t *cio, unsigned int64 v, int n);
+OPJ_API unsigned int OPJ_CALLCONV cio_write(opj_cio_t *cio, unsigned int64 v, int n);
/**
Read some bytes
@param cio CIO handle
@param n Number of bytes to read
@return Returns the value of the n bytes read
*/
-unsigned int cio_read(opj_cio_t *cio, int n);
+OPJ_API unsigned int OPJ_CALLCONV cio_read(opj_cio_t *cio, int n);
/**
Skip some bytes
@param cio CIO handle
@param n Number of bytes to skip
*/
-void cio_skip(opj_cio_t *cio, int n);
+OPJ_API void OPJ_CALLCONV cio_skip(opj_cio_t *cio, int n);
/* ----------------------------------------------------------------------- */
/*@}*/
diff --git a/src/lib/openmj2/j2k_lib.c b/src/lib/openmj2/j2k_lib.c
index a66e31e9..a792bb7e 100644
--- a/src/lib/openmj2/j2k_lib.c
+++ b/src/lib/openmj2/j2k_lib.c
@@ -33,7 +33,7 @@
#endif /* _WIN32 */
#include "opj_includes.h"
-double opj_clock(void) {
+double OPJ_CALLCONV opj_clock(void) {
#ifdef _WIN32
/* _WIN32: use QueryPerformance (very accurate) */
LARGE_INTEGER freq , t ;
diff --git a/src/lib/openmj2/j2k_lib.h b/src/lib/openmj2/j2k_lib.h
index 5f3406e5..d657b434 100644
--- a/src/lib/openmj2/j2k_lib.h
+++ b/src/lib/openmj2/j2k_lib.h
@@ -43,7 +43,7 @@ The functions in J2K_LIB.C are internal utilities mainly used for timing.
Difference in successive opj_clock() calls tells you the elapsed time
@return Returns time in seconds
*/
-double opj_clock(void);
+OPJ_API double OPJ_CALLCONV opj_clock(void);
/* ----------------------------------------------------------------------- */
/*@}*/
diff --git a/src/lib/openmj2/mj2.c b/src/lib/openmj2/mj2.c
index 4d87d7b8..68afb489 100644
--- a/src/lib/openmj2/mj2.c
+++ b/src/lib/openmj2/mj2.c
@@ -78,7 +78,7 @@ int mj2_read_boxhdr(mj2_box_t * box, opj_cio_t *cio)
*
*/
-int mj2_init_stdmovie(opj_mj2_t * movie)
+int OPJ_CALLCONV mj2_init_stdmovie(opj_mj2_t * movie)
{
mj2_tk_t *tk0;
int i, w, h, prec;
@@ -300,7 +300,7 @@ void mj2_stco_decompact(mj2_tk_t * tk)
* JP Signature box
*
*/
-void mj2_write_jp(opj_cio_t *cio)
+void OPJ_CALLCONV mj2_write_jp(opj_cio_t *cio)
{
mj2_box_t box;
box.init_pos = cio_tell(cio);
@@ -348,7 +348,7 @@ int mj2_read_jp(opj_cio_t *cio)
* File type box
*
*/
-void mj2_write_ftyp(opj_mj2_t * movie, opj_cio_t *cio)
+void OPJ_CALLCONV mj2_write_ftyp(opj_mj2_t * movie, opj_cio_t *cio)
{
int i;
mj2_box_t box;
@@ -2536,7 +2536,7 @@ int mj2_read_mvhd(opj_mj2_t * movie, opj_cio_t *cio)
* Movie Box
*
*/
-void mj2_write_moov(opj_mj2_t * movie, opj_cio_t *cio)
+void OPJ_CALLCONV mj2_write_moov(opj_mj2_t * movie, opj_cio_t *cio)
{
int i;
mj2_box_t box;
@@ -2608,7 +2608,7 @@ int mj2_read_moov(opj_mj2_t * movie, opj_image_t * img, opj_cio_t *cio)
return 0;
}
-int mj2_read_struct(FILE *file, opj_mj2_t *movie) {
+int OPJ_CALLCONV mj2_read_struct(FILE *file, opj_mj2_t *movie) {
mj2_box_t box;
opj_image_t img;
unsigned char * src;
@@ -2721,7 +2721,7 @@ int mj2_read_struct(FILE *file, opj_mj2_t *movie) {
/* MJ2 decoder interface */
/* ----------------------------------------------------------------------- */
-opj_dinfo_t* mj2_create_decompress() {
+opj_dinfo_t* OPJ_CALLCONV mj2_create_decompress() {
opj_mj2_t* mj2;
opj_dinfo_t *dinfo = (opj_dinfo_t*) opj_calloc(1, sizeof(opj_dinfo_t));
if(!dinfo) return NULL;
@@ -2739,7 +2739,7 @@ opj_dinfo_t* mj2_create_decompress() {
return dinfo;
}
-void mj2_setup_decoder(opj_mj2_t *movie, mj2_dparameters_t *mj2_parameters) {
+void OPJ_CALLCONV mj2_setup_decoder(opj_mj2_t *movie, mj2_dparameters_t *mj2_parameters) {
movie->num_vtk=0;
movie->num_stk=0;
movie->num_htk=0;
@@ -2750,7 +2750,7 @@ void mj2_setup_decoder(opj_mj2_t *movie, mj2_dparameters_t *mj2_parameters) {
}
-void mj2_destroy_decompress(opj_mj2_t *movie) {
+void OPJ_CALLCONV mj2_destroy_decompress(opj_mj2_t *movie) {
if(movie) {
int i;
mj2_tk_t *tk=NULL;
@@ -2799,8 +2799,7 @@ void mj2_destroy_decompress(opj_mj2_t *movie) {
/* MJ2 encoder interface */
/* ----------------------------------------------------------------------- */
-
-opj_cinfo_t* mj2_create_compress() {
+opj_cinfo_t* OPJ_CALLCONV mj2_create_compress() {
opj_mj2_t* mj2;
opj_cinfo_t *cinfo = (opj_cinfo_t*) opj_calloc(1, sizeof(opj_cinfo_t));
if(!cinfo) return NULL;
@@ -2817,7 +2816,7 @@ opj_cinfo_t* mj2_create_compress() {
return cinfo;
}
-void mj2_setup_encoder(opj_mj2_t *movie, mj2_cparameters_t *parameters) {
+void OPJ_CALLCONV mj2_setup_encoder(opj_mj2_t *movie, mj2_cparameters_t *parameters) {
if(movie && parameters) {
opj_jp2_t *jp2_struct;
@@ -2868,7 +2867,7 @@ void mj2_setup_encoder(opj_mj2_t *movie, mj2_cparameters_t *parameters) {
}
}
-void mj2_destroy_compress(opj_mj2_t *movie) {
+void OPJ_CALLCONV mj2_destroy_compress(opj_mj2_t *movie) {
if(movie) {
int i;
mj2_tk_t *tk=NULL;
diff --git a/src/lib/openmj2/mj2.h b/src/lib/openmj2/mj2.h
index 15e0ed23..611e6350 100644
--- a/src/lib/openmj2/mj2.h
+++ b/src/lib/openmj2/mj2.h
@@ -306,30 +306,30 @@ typedef struct mj2_cparameters {
/**
Write the JP box
*/
-void mj2_write_jp(opj_cio_t *cio);
+OPJ_API void OPJ_CALLCONV mj2_write_jp(opj_cio_t *cio);
/**
Write the FTYP box
@param movie MJ2 movie
@param cio Output buffer stream
*/
-void mj2_write_ftyp(opj_mj2_t *movie, opj_cio_t *cio);
+OPJ_API void OPJ_CALLCONV mj2_write_ftyp(opj_mj2_t *movie, opj_cio_t *cio);
/**
Creates an MJ2 decompression structure
@return Returns a handle to a MJ2 decompressor if successful, returns NULL otherwise
*/
-opj_dinfo_t* mj2_create_decompress();
+OPJ_API opj_dinfo_t* OPJ_CALLCONV mj2_create_decompress();
/**
Destroy a MJ2 decompressor handle
@param movie MJ2 decompressor handle to destroy
*/
-void mj2_destroy_decompress(opj_mj2_t *movie);
+OPJ_API void OPJ_CALLCONV mj2_destroy_decompress(opj_mj2_t *movie);
/**
Setup the decoder decoding parameters using user parameters.
Decoding parameters are returned in mj2->j2k->cp.
@param movie MJ2 decompressor handle
@param mj2_parameters decompression parameters
*/
-void mj2_setup_decoder(opj_mj2_t *movie, mj2_dparameters_t *mj2_parameters);
+OPJ_API void OPJ_CALLCONV mj2_setup_decoder(opj_mj2_t *movie, mj2_dparameters_t *mj2_parameters);
/**
Decode an image from a JPEG-2000 file stream
@param movie MJ2 decompressor handle
@@ -341,19 +341,19 @@ opj_image_t* mj2_decode(opj_mj2_t *movie, opj_cio_t *cio);
Creates a MJ2 compression structure
@return Returns a handle to a MJ2 compressor if successful, returns NULL otherwise
*/
-opj_cinfo_t* mj2_create_compress();
+OPJ_API opj_cinfo_t* OPJ_CALLCONV mj2_create_compress();
/**
Destroy a MJ2 compressor handle
@param movie MJ2 compressor handle to destroy
*/
-void mj2_destroy_compress(opj_mj2_t *movie);
+OPJ_API void OPJ_CALLCONV mj2_destroy_compress(opj_mj2_t *movie);
/**
Setup the encoder parameters using the current image and using user parameters.
Coding parameters are returned in mj2->j2k->cp.
@param movie MJ2 compressor handle
@param parameters compression parameters
*/
-void mj2_setup_encoder(opj_mj2_t *movie, mj2_cparameters_t *parameters);
+OPJ_API void OPJ_CALLCONV mj2_setup_encoder(opj_mj2_t *movie, mj2_cparameters_t *parameters);
/**
Encode an image into a JPEG-2000 file stream
@param movie MJ2 compressor handle
@@ -369,20 +369,20 @@ Init a Standard MJ2 movie
@param movie MJ2 Movie
@return Returns 0 if successful, returns 1 otherwise
*/
-int mj2_init_stdmovie(opj_mj2_t *movie);
+OPJ_API int OPJ_CALLCONV mj2_init_stdmovie(opj_mj2_t *movie);
/**
Read the structure of an MJ2 file
@param file MJ2 input File
@param mj2 J2 movie structure
@return Returns 0 if successful, returns 1 otherwise
*/
-int mj2_read_struct(FILE *file, opj_mj2_t *mj2);
+OPJ_API int OPJ_CALLCONV mj2_read_struct(FILE *file, opj_mj2_t *mj2);
/**
Write the the MOOV box to an output buffer stream
@param movie MJ2 movie structure
@param cio Output buffer stream
*/
-void mj2_write_moov(opj_mj2_t *movie, opj_cio_t *cio);
+OPJ_API void OPJ_CALLCONV mj2_write_moov(opj_mj2_t *movie, opj_cio_t *cio);
/* ----------------------------------------------------------------------- */
diff --git a/src/lib/openmj2/mj2_convert.c b/src/lib/openmj2/mj2_convert.c
index ed823f8b..436ac7ed 100644
--- a/src/lib/openmj2/mj2_convert.c
+++ b/src/lib/openmj2/mj2_convert.c
@@ -27,7 +27,7 @@
*/
#include "opj_includes.h"
-#include "mj2.h"
+#include "mj2_convert.h"
/* ----------------------- */
/* */
@@ -37,7 +37,7 @@
/* */
/* ----------------------- */
-unsigned int yuv_num_frames(mj2_tk_t * tk, char *infile)
+unsigned int OPJ_CALLCONV yuv_num_frames(mj2_tk_t * tk, char *infile)
{
unsigned int prec_size;
long end_of_f, frame_size;
@@ -74,7 +74,7 @@ unsigned int yuv_num_frames(mj2_tk_t * tk, char *infile)
/* */
/* ----------------------- */
-opj_image_t *mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters)
+opj_image_t * OPJ_CALLCONV mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters)
{
opj_image_cmptparm_t cmptparm[3];
opj_image_t * img;
@@ -99,7 +99,7 @@ opj_image_t *mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters)
return img;
}
-char yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters_t *parameters, char* infile)
+char OPJ_CALLCONV yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters_t *parameters, char* infile)
{
int i, compno;
int offset, size, max, prec_bytes, is_16, v;
@@ -177,7 +177,7 @@ char yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters
/* ----------------------- */
-opj_bool imagetoyuv(opj_image_t * img, char *outfile)
+opj_bool OPJ_CALLCONV imagetoyuv(opj_image_t * img, char *outfile)
{
FILE *f;
int *data;
@@ -270,7 +270,7 @@ opj_bool imagetoyuv(opj_image_t * img, char *outfile)
/* */
/* ----------------------- */
-int imagetobmp(opj_image_t * img, char *outfile) {
+int OPJ_CALLCONV imagetobmp(opj_image_t * img, char *outfile) {
int w,wr,h,hr,i,pad;
FILE *f;
diff --git a/src/lib/openmj2/mj2_convert.h b/src/lib/openmj2/mj2_convert.h
index 736ef80c..073731b3 100644
--- a/src/lib/openmj2/mj2_convert.h
+++ b/src/lib/openmj2/mj2_convert.h
@@ -31,15 +31,15 @@
#ifndef __MJ2_CONVERT_H
#define __MJ2_CONVERT_H
-int imagetoyuv(opj_image_t * img, char *outfile);
+OPJ_API int OPJ_CALLCONV imagetoyuv(opj_image_t * img, char *outfile);
-int imagetobmp(opj_image_t * img, char *outfile);
+OPJ_API int OPJ_CALLCONV imagetobmp(opj_image_t * img, char *outfile);
-opj_image_t *mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters);
+OPJ_API opj_image_t * OPJ_CALLCONV mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters);
-char yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters_t *parameters, char* infile);
+OPJ_API char OPJ_CALLCONV yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters_t *parameters, char* infile);
-unsigned int yuv_num_frames(mj2_tk_t * tk, char *infile);
+OPJ_API unsigned int OPJ_CALLCONV yuv_num_frames(mj2_tk_t * tk, char *infile);
#endif
diff --git a/src/lib/openmj2/openjpeg.h b/src/lib/openmj2/openjpeg.h
index d77df6ca..defed5a3 100644
--- a/src/lib/openmj2/openjpeg.h
+++ b/src/lib/openmj2/openjpeg.h
@@ -33,7 +33,6 @@
#ifndef OPENJPEG_H
#define OPENJPEG_H
-
/*
==========================================================
Compiler directives
@@ -41,7 +40,14 @@
*/
#if defined(OPJ_STATIC) || !defined(_WIN32)
+/* http://gcc.gnu.org/wiki/Visibility */
+#if __GNUC__ >= 4
+#define OPJ_API __attribute__ ((visibility ("default")))
+#define OPJ_LOCAL __attribute__ ((visibility ("hidden")))
+#else
#define OPJ_API
+#define OPJ_LOCAL
+#endif
#define OPJ_CALLCONV
#else
#define OPJ_CALLCONV __stdcall