summaryrefslogtreecommitdiff
path: root/codec
diff options
context:
space:
mode:
authorAntonin Descampe <antonin@gmail.com>2010-12-08 11:06:41 +0000
committerAntonin Descampe <antonin@gmail.com>2010-12-08 11:06:41 +0000
commitd08a96e2517c545b8ff2d7b89c7778eb5b1fd4ba (patch)
tree16f839d4499afc2ead2b759b22907a50bd012de3 /codec
parent59d9b97ffe35f17c71b25a749b885054cb4727d9 (diff)
(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.
Diffstat (limited to 'codec')
-rw-r--r--codec/CMakeLists.txt6
-rw-r--r--codec/Makefile.am9
-rw-r--r--codec/Makefile.nix9
-rw-r--r--codec/convert.c8
-rw-r--r--codec/image_to_j2k.c38
-rw-r--r--codec/j2k_dump.c43
-rw-r--r--codec/j2k_to_image.c56
7 files changed, 84 insertions, 85 deletions
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 <string.h>
#ifdef HAVE_LIBTIFF
-#ifdef WIN32
+#ifdef _WIN32
#include "../libs/libtiff/tiffio.h"
#else
#include <tiffio.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#endif /* HAVE_LIBTIFF */
#ifdef HAVE_LIBPNG
-#ifdef WIN32
+#ifdef _WIN32
#include "../libs/png/png.h"
#else
#include <png.h>
-#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 <stdlib.h>
#include <math.h>
-#include "opj_config.h"
-#include "openjpeg.h"
-#include "compat/getopt.h"
-#include "convert.h"
-#ifdef WIN32
+#ifdef _WIN32
#include "windirent.h"
#else
#include <dirent.h>
-#endif /* WIN32 */
-#include "index.h"
+#endif /* _WIN32 */
-#ifndef WIN32
+#ifdef _WIN32
+#include <windows.h>
+#else
#include <strings.h>
#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 <stdlib.h>
#include <math.h>
-#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 <dirent.h>
-#endif /* WIN32 */
-#include "index.h"
+#endif /* _WIN32 */
-#ifndef WIN32
+#ifdef _WIN32
+#include <windows.h>
+#else
#include <strings.h>
#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 <stdlib.h>
#include <math.h>
-#include "opj_config.h"
-#include "openjpeg.h"
-#include "compat/getopt.h"
-#include "convert.h"
-#ifdef WIN32
+#ifdef _WIN32
#include "windirent.h"
#else
#include <dirent.h>
-#endif /* WIN32 */
-#include "index.h"
+#endif /* _WIN32 */
-#ifndef WIN32
+#ifdef _WIN32
+#include <windows.h>
+#else
#include <strings.h>
#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 <lcms2.h>
+#endif
+#ifdef HAVE_LIBLCMS1
+#include <lcms.h>
+#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) {