removed old readme and Makefile

This commit is contained in:
Antonin Descampe 2005-12-08 09:27:26 +00:00
parent 2dc3ca544d
commit e45e87cfb7
12 changed files with 1831 additions and 2017 deletions

View File

@ -1,94 +0,0 @@
# $Id$
#
# makefile for OpenJPEG codec
OPENJPEG_DIR = ../libopenjpeg
ifndef DEBUG
LDFLAGS = -s -lm
else
LDFLAGS = -lm
endif
CFLAGS = -Wall -O3 -fno-strength-reduce -fomit-frame-pointer -I$(OPENJPEG_DIR)
OBJ_DIR_W32 = obj.w32
BIN_DIR_W32 = bin.w32
LIB_DIR_W32 = $(OPENJPEG_DIR)/lib.w32
ifdef MINGW32
CC = i386-mingw32-gcc
CFLAGS += -DDONT_HAVE_GETOPT
OBJ_DIR = $(OBJ_DIR_W32)
BIN_DIR = $(BIN_DIR_W32)
LIB_DIR = lib.w32
all: $(BIN_DIR) $(OBJ_DIR) $(LIB_DIR) \
$(addprefix $(BIN_DIR)/,j2k_to_image.exe image_to_j2k.exe)
else
CC = gcc
OBJ_DIR = obj
BIN_DIR = bin
LIB_DIR = lib
all: $(BIN_DIR) $(OBJ_DIR) $(LIB_DIR) \
$(addprefix $(BIN_DIR)/,j2k_to_image image_to_j2k)
endif
ifdef DYNAMIC
ifdef MINGW32
LIB_OPENJPEG = $(LIB_DIR)/libopenjpeg.dll
LDFLAGS += -L$(LIB_DIR) -lopenjpeg
else
LIB_OPENJPEG = $(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.so
LDFLAGS += -L$(OPENJPEG_DIR)/$(LIB_DIR) -lopenjpeg
endif
else
LIB_OPENJPEG = $(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.a
LDFLAGS += $(LIB_OPENJPEG)
endif
$(BIN_DIR):
mkdir $(BIN_DIR)
$(OBJ_DIR):
mkdir $(OBJ_DIR)
$(LIB_DIR):
mkdir $(LIB_DIR)
$(LIB_DIR)/libopenjpeg.dll: $(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.dll
ln -sf ../$< $@
$(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.dll:
cd $(OPENJPEG_DIR) && \
$(MAKE) $(OBJ_DIR) $(LIB_DIR) $(LIB_DIR)/libopenjpeg.dll
$(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.a:
cd $(OPENJPEG_DIR) && \
$(MAKE) $(OBJ_DIR) $(LIB_DIR) $(LIB_DIR)/libopenjpeg.a
$(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.so:
cd $(OPENJPEG_DIR) && \
$(MAKE) $(LIB_DIR) $(LIB_DIR)/libopenjpeg.so
$(OBJ_DIR)/%.o:
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
$(OBJ_DIR)/getopt.o: compat/getopt.c
$(OBJ_DIR)/convert.o: convert.c
$(OBJ_DIR)/j2k_to_image.o: j2k_to_image.c
$(OBJ_DIR)/image_to_j2k.o: image_to_j2k.c convert.h
J2I_OBJS = $(addprefix $(OBJ_DIR)/,j2k_to_image.o)
I2J_OBJS = $(addprefix $(OBJ_DIR)/,image_to_j2k.o convert.o)
$(BIN_DIR)/j2k_to_image: $(J2I_OBJS) $(LIB_OPENJPEG)
${CC} -o $@ $(J2I_OBJS) ${LDFLAGS}
$(BIN_DIR)/image_to_j2k: $(I2J_OBJS) $(LIB_OPENJPEG)
${CC} -o $@ $(I2J_OBJS) ${LDFLAGS}
$(BIN_DIR)/j2k_to_image.exe: $(J2I_OBJS) $(LIB_OPENJPEG)
${CC} -o $@ $(J2I_OBJS) ${LDFLAGS}
$(BIN_DIR)/image_to_j2k.exe: $(I2J_OBJS) $(LIB_OPENJPEG) $(OBJ_DIR)/getopt.o
${CC} -o $@ $(I2J_OBJS) ${LDFLAGS} $(OBJ_DIR)/getopt.o
clean:
rm -f $(BIN_DIR_W32)/* $(BIN_DIR)/* $(OBJ_DIR_W32)/* $(OBJ_DIR)/*

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1987, 1993, 1994
* The Regents of the University of California. All rights reserved.
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -12,8 +12,8 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
@ -34,44 +34,44 @@
/* last review : october 29th, 2002 */
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
#endif /* LIBC_SCCS and not lint */
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int opterr = 1, /* if error message should be printed */
optind = 1, /* index into parent argv vector */
optopt, /* character checked for validity */
optreset; /* reset getopt */
char *optarg; /* argument associated with option */
int opterr = 1, /* if error message should be printed */
optind = 1, /* index into parent argv vector */
optopt, /* character checked for validity */
optreset; /* reset getopt */
char *optarg; /* argument associated with option */
#define BADCH (int)'?'
#define BADARG (int)':'
#define EMSG ""
#define BADCH (int)'?'
#define BADARG (int)':'
#define EMSG ""
/*
* getopt --
* Parse argc/argv argument vector.
* Parse argc/argv argument vector.
*/
int getopt(int nargc, char *const *nargv, const char *ostr) {
# define __progname nargv[0]
static char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
static char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
if (optreset || !*place) { /* update scanning pointer */
if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
if (optind >= nargc || *(place = nargv[optind]) != '-') {
place = EMSG;
return (-1);
}
if (place[1] && *++place == '-') { /* found "--" */
if (place[1] && *++place == '-') { /* found "--" */
++optind;
place = EMSG;
return (-1);
}
} /* option letter okay? */
} /* option letter okay? */
if ((optopt = (int) *place++) == (int) ':' ||
!(oli = strchr(ostr, optopt))) {
/*
@ -84,29 +84,29 @@ int getopt(int nargc, char *const *nargv, const char *ostr) {
++optind;
if (opterr && *ostr != ':')
(void) fprintf(stderr,
"%s: illegal option -- %c\n", __progname, optopt);
"%s: illegal option -- %c\n", __progname, optopt);
return (BADCH);
}
if (*++oli != ':') { /* don't need argument */
if (*++oli != ':') { /* don't need argument */
optarg = NULL;
if (!*place)
++optind;
} else { /* need an argument */
if (*place) /* no white space */
} else { /* need an argument */
if (*place) /* no white space */
optarg = place;
else if (nargc <= ++optind) { /* no arg */
else if (nargc <= ++optind) { /* no arg */
place = EMSG;
if (*ostr == ':')
return (BADARG);
return (BADARG);
if (opterr)
(void) fprintf(stderr,
"%s: option requires an argument -- %c\n",
__progname, optopt);
(void) fprintf(stderr,
"%s: option requires an argument -- %c\n",
__progname, optopt);
return (BADCH);
} else /* white space */
} else /* white space */
optarg = nargv[optind];
place = EMSG;
++optind;
}
return (optopt); /* dump back option letter */
return (optopt); /* dump back option letter */
}

View File

@ -11,4 +11,4 @@ extern char *optarg;
extern int getopt(int nargc, char *const *nargv, const char *ostr);
#endif /* _GETOPT_H_ */
#endif /* _GETOPT_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -27,8 +27,6 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __J2K_CONVERT_H
#define __J2K_CONVERT_H

File diff suppressed because it is too large Load Diff

View File

@ -39,9 +39,11 @@ RSC=rc.exe
# 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 /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" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe
@ -64,7 +66,8 @@ 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" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x40c /d "_DEBUG"
# ADD RSC /l 0x40c /d "_DEBUG"
BSC32=bscmake.exe

View File

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

View File

@ -35,6 +35,13 @@
#include "compat/getopt.h"
#include "convert.h"
#ifndef WIN32
#define stricmp strcasecmp
#define strnicmp strncasecmp
#endif
/* ----------------------------------------------------------------------- */
#define J2K_CFMT 0
#define JP2_CFMT 1
#define JPT_CFMT 2
@ -47,147 +54,147 @@
/* ----------------------------------------------------------------------- */
void decode_help_display() {
fprintf(stdout,"HELP\n----\n\n");
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
fprintf(stdout,"HELP\n----\n\n");
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
fprintf(stdout,"List of parameters for the JPEG 2000 encoder:\n");
fprintf(stdout,"\n");
fprintf(stdout," -i <compressed file>\n");
fprintf(stdout," REQUIRED\n");
fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
fprintf(stdout," is identified based on its suffix.\n");
fprintf(stdout," -o <decompressed file>\n");
fprintf(stdout," REQUIRED\n");
fprintf(stdout," Currently accepts PGM-files, PPM-files, PNM-files, PGX-files and\n");
fprintf(stdout," BMP-files. Binary data is written to the file (not ascii). If a PGX\n");
fprintf(stdout," filename is given, there will be as many output files as there are\n");
fprintf(stdout," components: an indice starting from 0 will then be appended to the\n");
fprintf(stdout," output filename, just before the \"pgx\" extension. If a PGM filename\n");
fprintf(stdout," is given and there are more than one component, only the first component\n");
fprintf(stdout," will be written to the file.\n");
fprintf(stdout," -r <reduce factor>\n");
fprintf(stdout," Set the number of highest resolution levels to be discarded. The\n");
fprintf(stdout," image resolution is effectively divided by 2 to the power of the\n");
fprintf(stdout," number of discarded levels. The reduce factor is limited by the\n");
fprintf(stdout," smallest total number of decomposition levels among tiles.\n");
fprintf(stdout," -l <number of quality layers to decode>\n");
fprintf(stdout," Set the maximum number of quality layers to decode. If there are\n");
fprintf(stdout," less quality layers than the specified number, all the quality layers\n");
fprintf(stdout," are decoded.\n");
fprintf(stdout,"\n");
fprintf(stdout,"List of parameters for the JPEG 2000 encoder:\n");
fprintf(stdout,"\n");
fprintf(stdout," -i <compressed file>\n");
fprintf(stdout," REQUIRED\n");
fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
fprintf(stdout," is identified based on its suffix.\n");
fprintf(stdout," -o <decompressed file>\n");
fprintf(stdout," REQUIRED\n");
fprintf(stdout," Currently accepts PGM-files, PPM-files, PNM-files, PGX-files and\n");
fprintf(stdout," BMP-files. Binary data is written to the file (not ascii). If a PGX\n");
fprintf(stdout," filename is given, there will be as many output files as there are\n");
fprintf(stdout," components: an indice starting from 0 will then be appended to the\n");
fprintf(stdout," output filename, just before the \"pgx\" extension. If a PGM filename\n");
fprintf(stdout," is given and there are more than one component, only the first component\n");
fprintf(stdout," will be written to the file.\n");
fprintf(stdout," -r <reduce factor>\n");
fprintf(stdout," Set the number of highest resolution levels to be discarded. The\n");
fprintf(stdout," image resolution is effectively divided by 2 to the power of the\n");
fprintf(stdout," number of discarded levels. The reduce factor is limited by the\n");
fprintf(stdout," smallest total number of decomposition levels among tiles.\n");
fprintf(stdout," -l <number of quality layers to decode>\n");
fprintf(stdout," Set the maximum number of quality layers to decode. If there are\n");
fprintf(stdout," less quality layers than the specified number, all the quality layers\n");
fprintf(stdout," are decoded.\n");
fprintf(stdout,"\n");
}
/* -------------------------------------------------------------------------- */
int get_file_format(char *filename) {
int i;
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp", "j2k", "jp2", "jpt" };
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT };
char * ext = strrchr(filename, '.') + 1;
if(ext) {
for(i = 0; i < sizeof(format); i++) {
if(strnicmp(ext, extension[i], 3) == 0) {
return format[i];
}
}
}
int i;
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp", "j2k", "jp2", "jpt" };
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT };
char * ext = strrchr(filename, '.') + 1;
if(ext) {
for(i = 0; i < sizeof(format); i++) {
if(strnicmp(ext, extension[i], 3) == 0) {
return format[i];
}
}
}
return -1;
return -1;
}
/* -------------------------------------------------------------------------- */
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters) {
/* parse the command line */
/* parse the command line */
while (1) {
int c = getopt(argc, argv, "i:o:r:q:f:t:n:c:b:x:p:s:d:h:P:S:E:M:R:T:C:I");
if (c == -1)
break;
switch (c) {
case 'i': /* input file */
{
char *infile = optarg;
parameters->decod_format = get_file_format(infile);
switch(parameters->decod_format) {
case J2K_CFMT:
case JP2_CFMT:
case JPT_CFMT:
break;
default:
fprintf(stderr,
"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
infile);
return 1;
break;
}
strncpy(parameters->infile, infile, MAX_PATH);
}
break;
while (1) {
int c = getopt(argc, argv, "i:o:r:q:f:t:n:c:b:x:p:s:d:h:P:S:E:M:R:T:C:I");
if (c == -1)
break;
switch (c) {
case 'i': /* input file */
{
char *infile = optarg;
parameters->decod_format = get_file_format(infile);
switch(parameters->decod_format) {
case J2K_CFMT:
case JP2_CFMT:
case JPT_CFMT:
break;
default:
fprintf(stderr,
"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
infile);
return 1;
break;
}
strncpy(parameters->infile, infile, MAX_PATH);
}
break;
/* ----------------------------------------------------- */
/* ----------------------------------------------------- */
case 'o': /* output file */
{
char *outfile = optarg;
parameters->cod_format = get_file_format(outfile);
switch(parameters->cod_format) {
case PGX_DFMT:
case PXM_DFMT:
case BMP_DFMT:
break;
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);
}
break;
case 'o': /* output file */
{
char *outfile = optarg;
parameters->cod_format = get_file_format(outfile);
switch(parameters->cod_format) {
case PGX_DFMT:
case PXM_DFMT:
case BMP_DFMT:
break;
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);
}
break;
/* ----------------------------------------------------- */
/* ----------------------------------------------------- */
case 'r': /* reduce option */
{
sscanf(optarg, "%d", &parameters->cp_reduce);
}
break;
case 'r': /* reduce option */
{
sscanf(optarg, "%d", &parameters->cp_reduce);
}
break;
/* ----------------------------------------------------- */
/* ----------------------------------------------------- */
case 'l': /* layering option */
{
sscanf(optarg, "%d", &parameters->cp_layer);
}
break;
case 'l': /* layering option */
{
sscanf(optarg, "%d", &parameters->cp_layer);
}
break;
/* ----------------------------------------------------- */
/* ----------------------------------------------------- */
case 'h': /* display an help description */
{
decode_help_display();
return 1;
}
break;
case 'h': /* display an help description */
{
decode_help_display();
return 1;
}
break;
/* ----------------------------------------------------- */
/* ----------------------------------------------------- */
default:
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
break;
}
}
default:
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
break;
}
}
/* check for possible errors */
/* check for possible errors */
if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
fprintf(stderr,"ERROR -> At least one required argument is missing\nCheck j2k_to_image -h for usage information\n");
return 1;
}
if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
fprintf(stderr,"ERROR -> At least one required argument is missing\nCheck j2k_to_image -h for usage information\n");
return 1;
}
return 0;
return 0;
}
/* -------------------------------------------------------------------------- */
@ -196,194 +203,194 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
sample error callback expecting a FILE* client object
*/
void error_callback(const char *msg, void *client_data) {
FILE *stream = (FILE*)client_data;
fprintf(stream, "[ERROR] %s", msg);
FILE *stream = (FILE*)client_data;
fprintf(stream, "[ERROR] %s", msg);
}
/**
sample warning callback expecting a FILE* client object
*/
void warning_callback(const char *msg, void *client_data) {
FILE *stream = (FILE*)client_data;
fprintf(stream, "[WARNING] %s", msg);
FILE *stream = (FILE*)client_data;
fprintf(stream, "[WARNING] %s", msg);
}
/**
sample debug callback expecting no client object
*/
void info_callback(const char *msg, void *client_data) {
fprintf(stdout, "[INFO] %s", msg);
fprintf(stdout, "[INFO] %s", msg);
}
/* -------------------------------------------------------------------------- */
int main(int argc, char **argv) {
opj_dparameters_t parameters; /* decompression parameters */
opj_event_mgr_t event_mgr; /* event manager */
opj_image_t *image = NULL;
FILE *fsrc = NULL;
unsigned char *src = NULL;
int file_length;
opj_dparameters_t parameters; /* decompression parameters */
opj_event_mgr_t event_mgr; /* event manager */
opj_image_t *image = NULL;
FILE *fsrc = NULL;
unsigned char *src = NULL;
int file_length;
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
opj_cio_t *cio = NULL;
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
opj_cio_t *cio = NULL;
/* configure the event callbacks (not required) */
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
event_mgr.error_handler = error_callback;
event_mgr.warning_handler = warning_callback;
event_mgr.info_handler = info_callback;
/* configure the event callbacks (not required) */
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
event_mgr.error_handler = error_callback;
event_mgr.warning_handler = warning_callback;
event_mgr.info_handler = info_callback;
/* set decoding parameters to default values */
opj_set_default_decoder_parameters(&parameters);
/* set decoding parameters to default values */
opj_set_default_decoder_parameters(&parameters);
/* parse input and get user decoding parameters */
if(parse_cmdline_decoder(argc, argv, &parameters) == 1) {
return 0;
}
/* parse input and get user decoding parameters */
if(parse_cmdline_decoder(argc, argv, &parameters) == 1) {
return 0;
}
/* read the input file and put it in memory */
/* ---------------------------------------- */
fsrc = fopen(parameters.infile, "rb");
if (!fsrc) {
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
return 1;
}
fseek(fsrc, 0, SEEK_END);
file_length = ftell(fsrc);
fseek(fsrc, 0, SEEK_SET);
src = (unsigned char *) malloc(file_length);
fread(src, 1, file_length, fsrc);
fclose(fsrc);
/* read the input file and put it in memory */
/* ---------------------------------------- */
fsrc = fopen(parameters.infile, "rb");
if (!fsrc) {
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
return 1;
}
fseek(fsrc, 0, SEEK_END);
file_length = ftell(fsrc);
fseek(fsrc, 0, SEEK_SET);
src = (unsigned char *) malloc(file_length);
fread(src, 1, file_length, fsrc);
fclose(fsrc);
/* decode the code-stream */
/* ---------------------- */
/* decode the code-stream */
/* ---------------------- */
switch(parameters.decod_format) {
case J2K_CFMT:
{
/* JPEG-2000 codestream */
case J2K_CFMT:
{
/* JPEG-2000 codestream */
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_J2K);
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_J2K);
/* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
/* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
/* setup the decoder decoding parameters using user parameters */
opj_setup_decoder(dinfo, &parameters);
/* setup the decoder decoding parameters using user parameters */
opj_setup_decoder(dinfo, &parameters);
/* open a byte stream */
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* open a byte stream */
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */
image = opj_decode(dinfo, cio);
if(!image) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
opj_destroy_decompress(dinfo);
opj_cio_close(cio);
return 1;
}
/* decode the stream and fill the image structure */
image = opj_decode(dinfo, cio);
if(!image) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
opj_destroy_decompress(dinfo);
opj_cio_close(cio);
return 1;
}
/* close the byte stream */
opj_cio_close(cio);
}
break;
/* close the byte stream */
opj_cio_close(cio);
}
break;
case JP2_CFMT:
{
/* JPEG 2000 compressed image data */
case JP2_CFMT:
{
/* JPEG 2000 compressed image data */
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_JP2);
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_JP2);
/* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
/* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
/* setup the decoder decoding parameters using the current image and using user parameters */
opj_setup_decoder(dinfo, &parameters);
/* setup the decoder decoding parameters using the current image and using user parameters */
opj_setup_decoder(dinfo, &parameters);
/* open a byte stream */
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* open a byte stream */
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */
image = opj_decode(dinfo, cio);
if(!image) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
opj_destroy_decompress(dinfo);
opj_cio_close(cio);
return 1;
}
/* decode the stream and fill the image structure */
image = opj_decode(dinfo, cio);
if(!image) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
opj_destroy_decompress(dinfo);
opj_cio_close(cio);
return 1;
}
/* close the byte stream */
opj_cio_close(cio);
/* close the byte stream */
opj_cio_close(cio);
}
break;
}
break;
case JPT_CFMT:
{
/* JPEG 2000, JPIP */
case JPT_CFMT:
{
/* JPEG 2000, JPIP */
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_JPT);
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_JPT);
/* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
/* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
/* setup the decoder decoding parameters using user parameters */
opj_setup_decoder(dinfo, &parameters);
/* setup the decoder decoding parameters using user parameters */
opj_setup_decoder(dinfo, &parameters);
/* open a byte stream */
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* open a byte stream */
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */
image = opj_decode(dinfo, cio);
if(!image) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
opj_destroy_decompress(dinfo);
opj_cio_close(cio);
return 1;
}
/* decode the stream and fill the image structure */
image = opj_decode(dinfo, cio);
if(!image) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
opj_destroy_decompress(dinfo);
opj_cio_close(cio);
return 1;
}
/* close the byte stream */
opj_cio_close(cio);
}
break;
/* close the byte stream */
opj_cio_close(cio);
}
break;
default:
fprintf(stderr, "ERROR -> j2k_to_image : Unknown input image format\n");
return 1;
break;
}
default:
fprintf(stderr, "ERROR -> j2k_to_image : Unknown input image format\n");
return 1;
break;
}
/* free the memory containing the code-stream */
free(src);
src = NULL;
/* free the memory containing the code-stream */
free(src);
src = NULL;
/* create output image */
/* ------------------- */
/* create output image */
/* ------------------- */
switch (parameters.cod_format) {
case PXM_DFMT: /* PNM PGM PPM */
imagetopnm(image, parameters.outfile);
break;
switch (parameters.cod_format) {
case PXM_DFMT: /* PNM PGM PPM */
imagetopnm(image, parameters.outfile);
break;
case PGX_DFMT: /* PGX */
imagetopgx(image, parameters.outfile);
break;
case PGX_DFMT: /* PGX */
imagetopgx(image, parameters.outfile);
break;
case BMP_DFMT: /* BMP */
imagetobmp(image, parameters.outfile);
break;
}
case BMP_DFMT: /* BMP */
imagetobmp(image, parameters.outfile);
break;
}
/* free remaining structures */
if(dinfo) {
opj_destroy_decompress(dinfo);
}
/* free remaining structures */
if(dinfo) {
opj_destroy_decompress(dinfo);
}
/* free image data structure */
opj_image_destroy(image);
/* free image data structure */
opj_image_destroy(image);
return 0;
return 0;
}

View File

@ -42,7 +42,8 @@ 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" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe

View File

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

View File

@ -1,105 +0,0 @@
List of parameters for the coder JPEG 2000 :
Date : June the 25th, 2003
Author : Yannick Verschueren
Contact : verschueren@tele.ucl.ac.be
- the option -help displays the readme.txt file on screen
- The markers COD and QCD are writed both of two in the main_header and never appear in the tile_header. The markers in the main header are : SOC SIZ COD QCD COM.
- This coder can encode mega image, a test was made on a 24000x24000 pixels color image. You need enough disk space memory (twice the original) to encode the image. (i.e. for a 1.5 Gb image you need a minimum of 3Gb of disk memory)
REMARKS :
---------
* the value of rate enter in the code line is the compression factor !
exemple :
-r 20,10,1 means quality 1 : compress 20x, quality 2 : compress 10x and quality 3 : compress 1x = lossless
* The number of resolution can be modified by the program in view to respect profile-0 conditions (Taubman, Marcelin (2002), "JPEG2000, image compression fundamentals, standards and practice", p700)
By default :
------------
* lossless
* 1 tile
* size of precinct 2^15 x 2^15 (means 1 precinct)
* size of code-block 64 x 64
* Number of resolution : 6
* No SOP marker in the codestream
* No EPH marker in the codestream
* No sub-sampling in x and y direction
* No mode switch activated
* progression order : LRCP
* No index file
* No ROI upshifted
* No offset of the origin of the image
* No offset of the origin of the tiles
* Reversible DWT 5-3
Parameters :
------------
-i : source file (-i source.pnm also *.pgm, *.ppm) "required"
-o : destination file (-o dest.j2k) "required"
-r : different rates (-r 20,10,5) "optional"
-n : Number of resolution (-n 3) "optional"
-b : size of code block (-b 32,32) "optional"
-c : size of precinct (-c 128,128) "optional"
-t : size of tile (-t 512,512) "optional"
-p : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] "optional"
-s : subsampling factor (-s 2,2) [-s X,Y] "optional"
-SOP : write SOP marker before each packet "optional"
-EPH : write EPH marker after each header packet "optional"
-M : mode switch (-M 3) [1= BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL) 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)] "optional"
for several mode switch you have to add the value of each mode you want
ex : RESTART(4) + RESET(2) + SEGMARK(32) = -M 38
-x : Create an index file *.Idx (-x index_name.Idx) "optional"
-ROI:c=%d,U=%d : quantization indices upshifted for component c=%d [%d = 0,1,2]
with a value of U=%d [0 <= %d <= 37] (i.e. -ROI:c=0,U=25) "optional"
-d : offset of the origin of the image (-d 150,300) "optional"
-T : offset of the origin of the tiles (-T 100,75) "optional"
-I : Use the irreversible DWT 9-7 (-I) "optional"
IMPORTANT :
-----------
* subsampling bigger than 2 can produce error
The index file respect the structure below :
---------------------------------------------
Image_height Image_width
progression order
Tiles_size_X Tiles_size_Y
Components_nb
Layers_nb
decomposition_levels
Precincts_size_X Precincts_size_Y
Main_header_end_position
Codestream_size
Tile0 start_pos end_Theader end_pos
Tile1 " " "
...
TileN " " "
Tpacket_0 Tile layer res. comp. prec. start_pos end_pos
...
Tpacket_M " " " " " " "