From d08a96e2517c545b8ff2d7b89c7778eb5b1fd4ba Mon Sep 17 00:00:00 2001 From: Antonin Descampe Date: Wed, 8 Dec 2010 11:06:41 +0000 Subject: (thanks to Winfried for his help) * [antonin] changed remaining "WIN32" to "_WIN32" ! [antonin] libopenjpeg has no more dependency on LCMS lib. Everything concerning color (icc profile, conversion to rgb, etc) has been put outside libopenjpeg and is used in j2k_to_image.c and mj2_to_frames.c. - [antonin] removed "opj_convert{.c,.h}" + [antonin] added a directory "common/" that contains "getopt{.c,.h}" (previously in "codec/compat"). + [antonin] added files "color{.c,.h}" in "common/" that define the code for icc profile management and sycc_to_rgb conversion + [antonin] added "common/format_defs.h" that contains common definitions used in image_to_j2k, j2k_to_image, j2k_dump. --- codec/CMakeLists.txt | 6 ++++-- codec/Makefile.am | 9 +++++---- codec/Makefile.nix | 9 +++++---- codec/convert.c | 8 ++++---- codec/image_to_j2k.c | 38 +++++++++++++---------------------- codec/j2k_dump.c | 43 +++++++++++++++++----------------------- codec/j2k_to_image.c | 56 +++++++++++++++++++++++++++++++--------------------- 7 files changed, 84 insertions(+), 85 deletions(-) (limited to 'codec') diff --git a/codec/CMakeLists.txt b/codec/CMakeLists.txt index 5ad89589..6fd128f7 100644 --- a/codec/CMakeLists.txt +++ b/codec/CMakeLists.txt @@ -1,16 +1,17 @@ -# Build the demo app, small examples + # Build the demo app, small examples # First thing define the common source: SET(common_SRCS convert.c index.c + ${PROJECT_SOURCE_DIR}/common/color.c ) # If not getopt was found then add it to the lib: IF(DONT_HAVE_GETOPT) SET(common_SRCS ${common_SRCS} - compat/getopt.c + ${PROJECT_SOURCE_DIR}/common/getopt.c ) ENDIF(DONT_HAVE_GETOPT) @@ -18,6 +19,7 @@ ENDIF(DONT_HAVE_GETOPT) INCLUDE_DIRECTORIES( ${OPENJPEG_SOURCE_DIR}/libopenjpeg ${LCMS_INCLUDE_DIR} + ${OPENJPEG_SOURCE_DIR}/common ) IF(PNG_FOUND) INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR}) diff --git a/codec/Makefile.am b/codec/Makefile.am index 43d54506..5db41850 100644 --- a/codec/Makefile.am +++ b/codec/Makefile.am @@ -1,6 +1,6 @@ COMPILERFLAGS = -Wall -static USERLIBS = -lm -INCLUDES = -I.. -I. -I../libopenjpeg +INCLUDES = -I.. -I. -I../libopenjpeg -I../common if with_libtiff INCLUDES += @tiffincludes@ @@ -27,11 +27,12 @@ bin_PROGRAMS = j2k_to_image image_to_j2k j2k_dump CFLAGS = $(COMPILERFLAGS) $(INCLUDES) LDADD = $(USERLIBS) ../libopenjpeg/libopenjpeg.la -j2k_to_image_SOURCES = compat/getopt.c index.c convert.c j2k_to_image.c +j2k_to_image_SOURCES = ../common/getopt.c index.c convert.c \ + ../common/color.c j2k_to_image.c -image_to_j2k_SOURCES = compat/getopt.c index.c convert.c image_to_j2k.c +image_to_j2k_SOURCES = ../common/getopt.c index.c convert.c image_to_j2k.c -j2k_dump_SOURCES = compat/getopt.c index.c j2k_dump.c +j2k_dump_SOURCES = ../common/getopt.c index.c j2k_dump.c REPBIN=$(bin_PROGRAMS) diff --git a/codec/Makefile.nix b/codec/Makefile.nix index 129b2a4b..ace579a3 100644 --- a/codec/Makefile.nix +++ b/codec/Makefile.nix @@ -5,7 +5,7 @@ CFLAGS = -Wall INSTALL_BIN = $(prefix)/bin -INCLUDE = -I.. -I. -I../libopenjpeg +INCLUDE = -I.. -I. -I../libopenjpeg -I../common USERLIBS = -lm ifeq ($(WITH_TIFF),yes) @@ -35,15 +35,16 @@ all: j2k_to_image image_to_j2k j2k_dump install j2k_to_image image_to_j2k j2k_dump ../bin j2k_to_image: j2k_to_image.c ../libopenjpeg.a - $(CC) $(CFLAGS) compat/getopt.c index.c convert.c j2k_to_image.c \ + $(CC) $(CFLAGS) ../common/getopt.c index.c convert.c \ + ../common/color.c j2k_to_image.c \ -o j2k_to_image ../libopenjpeg.a $(USERLIBS) image_to_j2k: image_to_j2k.c ../libopenjpeg.a - $(CC) $(CFLAGS) compat/getopt.c index.c convert.c image_to_j2k.c \ + $(CC) $(CFLAGS) ../common/getopt.c index.c convert.c image_to_j2k.c \ -o image_to_j2k ../libopenjpeg.a $(USERLIBS) j2k_dump: j2k_dump.c ../libopenjpeg.a - $(CC) $(CFLAGS) compat/getopt.c index.c j2k_dump.c \ + $(CC) $(CFLAGS) ../common/getopt.c index.c j2k_dump.c \ -o j2k_dump ../libopenjpeg.a $(USERLIBS) clean: diff --git a/codec/convert.c b/codec/convert.c index de08e4c7..25e715bf 100644 --- a/codec/convert.c +++ b/codec/convert.c @@ -36,19 +36,19 @@ #include #ifdef HAVE_LIBTIFF -#ifdef WIN32 +#ifdef _WIN32 #include "../libs/libtiff/tiffio.h" #else #include -#endif /* WIN32 */ +#endif /* _WIN32 */ #endif /* HAVE_LIBTIFF */ #ifdef HAVE_LIBPNG -#ifdef WIN32 +#ifdef _WIN32 #include "../libs/png/png.h" #else #include -#endif /* WIN32 */ +#endif /* _WIN32 */ #endif /* HAVE_LIBPNG */ #include "../libopenjpeg/openjpeg.h" diff --git a/codec/image_to_j2k.c b/codec/image_to_j2k.c index a223adb8..443d4e07 100644 --- a/codec/image_to_j2k.c +++ b/codec/image_to_j2k.c @@ -35,38 +35,28 @@ #include #include -#include "opj_config.h" -#include "openjpeg.h" -#include "compat/getopt.h" -#include "convert.h" -#ifdef WIN32 +#ifdef _WIN32 #include "windirent.h" #else #include -#endif /* WIN32 */ -#include "index.h" +#endif /* _WIN32 */ -#ifndef WIN32 +#ifdef _WIN32 +#include +#else #include #define _stricmp strcasecmp #define _strnicmp strncasecmp -#endif +#endif /* _WIN32 */ + +#include "opj_config.h" +#include "openjpeg.h" +#include "getopt.h" +#include "convert.h" +#include "index.h" + +#include "format_defs.h" -/* ----------------------------------------------------------------------- */ - -#define J2K_CFMT 0 -#define JP2_CFMT 1 -#define JPT_CFMT 2 - -#define PXM_DFMT 10 -#define PGX_DFMT 11 -#define BMP_DFMT 12 -#define YUV_DFMT 13 -#define TIF_DFMT 14 -#define RAW_DFMT 15 -#define TGA_DFMT 16 -#define PNG_DFMT 17 -/* ----------------------------------------------------------------------- */ #define CINEMA_24_CS 1302083 /*Codestream length for 24fps*/ #define CINEMA_48_CS 651041 /*Codestream length for 48fps*/ #define COMP_24_CS 1041666 /*Maximum size per color component for 2K & 4K @ 24fps*/ diff --git a/codec/j2k_dump.c b/codec/j2k_dump.c index 83fc1c94..3c3e8d91 100644 --- a/codec/j2k_dump.c +++ b/codec/j2k_dump.c @@ -29,40 +29,29 @@ #include #include -#include "opj_config.h" -#include "openjpeg.h" -#include "../libopenjpeg/j2k.h" -#include "../libopenjpeg/jp2.h" -#include "compat/getopt.h" -#include "convert.h" -#ifdef WIN32 +#ifdef _WIN32 #include "windirent.h" #else #include -#endif /* WIN32 */ -#include "index.h" +#endif /* _WIN32 */ -#ifndef WIN32 +#ifdef _WIN32 +#include +#else #include #define _stricmp strcasecmp #define _strnicmp strncasecmp -#endif +#endif /* _WIN32 */ -/* ----------------------------------------------------------------------- */ - -#define J2K_CFMT 0 -#define JP2_CFMT 1 -#define JPT_CFMT 2 +#include "opj_config.h" +#include "openjpeg.h" +#include "../libopenjpeg/j2k.h" +#include "../libopenjpeg/jp2.h" +#include "getopt.h" +#include "convert.h" +#include "index.h" -#define PXM_DFMT 10 -#define PGX_DFMT 11 -#define BMP_DFMT 12 -#define YUV_DFMT 13 -#define TIF_DFMT 14 -#define RAW_DFMT 15 -#define TGA_DFMT 16 -#define PNG_DFMT 17 -/* ----------------------------------------------------------------------- */ +#include "format_defs.h" typedef struct dircnt{ /** Buffer for holding images read from Directory*/ @@ -477,6 +466,10 @@ int main(int argc, char *argv[]) return 1; } /* dump image */ + if(image->icc_profile_buf) + { + free(image->icc_profile_buf); image->icc_profile_buf = NULL; + } j2k_dump_image(stdout, image); /* dump cp */ diff --git a/codec/j2k_to_image.c b/codec/j2k_to_image.c index bbf40ad9..ff6141ee 100644 --- a/codec/j2k_to_image.c +++ b/codec/j2k_to_image.c @@ -35,38 +35,35 @@ #include #include -#include "opj_config.h" -#include "openjpeg.h" -#include "compat/getopt.h" -#include "convert.h" -#ifdef WIN32 +#ifdef _WIN32 #include "windirent.h" #else #include -#endif /* WIN32 */ -#include "index.h" +#endif /* _WIN32 */ -#ifndef WIN32 +#ifdef _WIN32 +#include +#else #include #define _stricmp strcasecmp #define _strnicmp strncasecmp -#endif +#endif /* _WIN32 */ -/* ----------------------------------------------------------------------- */ +#include "opj_config.h" +#include "openjpeg.h" +#include "getopt.h" +#include "convert.h" +#include "index.h" -#define J2K_CFMT 0 -#define JP2_CFMT 1 -#define JPT_CFMT 2 +#ifdef HAVE_LIBLCMS2 +#include +#endif +#ifdef HAVE_LIBLCMS1 +#include +#endif +#include "color.h" -#define PXM_DFMT 10 -#define PGX_DFMT 11 -#define BMP_DFMT 12 -#define YUV_DFMT 13 -#define TIF_DFMT 14 -#define RAW_DFMT 15 -#define TGA_DFMT 16 -#define PNG_DFMT 17 -/* ----------------------------------------------------------------------- */ +#include "format_defs.h" typedef struct dircnt{ /** Buffer for holding images read from Directory*/ @@ -740,6 +737,21 @@ int main(int argc, char **argv) { free(src); src = NULL; + if(image->color_space == CLRSPC_SYCC) + { + color_sycc_to_rgb(image); + } + + if(image->icc_profile_buf) + { +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + color_apply_icc_profile(image); +#endif + + free(image->icc_profile_buf); + image->icc_profile_buf = NULL; image->icc_profile_len = 0; + } + /* create output image */ /* ------------------- */ switch (parameters.cod_format) { -- cgit v1.2.3