backport r898 to r907 in openjpeg-1.5 branch
This commit is contained in:
parent
e89eb575ac
commit
9a89e2f162
10
CHANGES
10
CHANGES
|
@ -5,6 +5,16 @@ What's New for OpenJPEG
|
||||||
! : changed
|
! : changed
|
||||||
+ : added
|
+ : added
|
||||||
|
|
||||||
|
September 1st, 2011
|
||||||
|
! [antonin] renamed getopt.{c/h} to opj_getopt.{c/h} and forced the use of these files rather than the system ones. This fixed issue 78. Credit to Winfried.
|
||||||
|
|
||||||
|
August 31, 2011
|
||||||
|
* [mickael] fixed a segfault with fgets return value for some cases inside test function compare_dump_file()
|
||||||
|
+ [mickael] enhance the encoding test suite and remove unsued CONFIGURE_FILE into a CMakeList
|
||||||
|
|
||||||
|
August 30, 2011
|
||||||
|
+ [mickael] added first version of the encoding tests suite
|
||||||
|
|
||||||
August 16, 2011
|
August 16, 2011
|
||||||
+ [antonin] added NEWS, AUTHORS and THANKS files. Cosmetic changes in autotools files.
|
+ [antonin] added NEWS, AUTHORS and THANKS files. Cosmetic changes in autotools files.
|
||||||
- [antonin] removed obsolete testing directory and *.nix files
|
- [antonin] removed obsolete testing directory and *.nix files
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#
|
#
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000)
|
||||||
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
|
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
|
||||||
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 2000)
|
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 2000)
|
||||||
|
|
||||||
|
@ -25,7 +26,9 @@ SET(CTEST_CUSTOM_COVERAGE_EXCLUDE
|
||||||
|
|
||||||
# Exclude files from the Testing directories
|
# Exclude files from the Testing directories
|
||||||
".*/tests/.*"
|
".*/tests/.*"
|
||||||
".*/Testing/.*"
|
|
||||||
|
# Exclude files from the ThirdParty Utilities directories
|
||||||
|
".*/thirdparty/.*"
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(CTEST_CUSTOM_WARNING_EXCEPTION
|
SET(CTEST_CUSTOM_WARNING_EXCEPTION
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
# Check if getopt is present:
|
|
||||||
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
|
||||||
SET(DONT_HAVE_GETOPT 1)
|
|
||||||
IF(UNIX) #I am pretty sure only *nix sys have this anyway
|
|
||||||
CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
|
|
||||||
# Seems like we need the contrary:
|
|
||||||
IF(CMAKE_HAVE_GETOPT_H)
|
|
||||||
SET(DONT_HAVE_GETOPT 0)
|
|
||||||
ENDIF(CMAKE_HAVE_GETOPT_H)
|
|
||||||
ENDIF(UNIX)
|
|
||||||
|
|
||||||
IF(DONT_HAVE_GETOPT)
|
|
||||||
ADD_DEFINITIONS(-DDONT_HAVE_GETOPT)
|
|
||||||
ENDIF(DONT_HAVE_GETOPT)
|
|
||||||
|
|
|
@ -110,10 +110,6 @@ ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||||
# Test for some required system information.
|
# Test for some required system information.
|
||||||
INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
|
INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# Test for getopt being available in this system
|
|
||||||
INCLUDE (${OPENJPEG_SOURCE_DIR}/CMake/CheckHaveGetopt.cmake )
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Setup file for setting custom ctest vars
|
# Setup file for setting custom ctest vars
|
||||||
CONFIGURE_FILE(
|
CONFIGURE_FILE(
|
||||||
|
@ -243,18 +239,19 @@ IF(BUILD_TESTING)
|
||||||
ENABLE_TESTING()
|
ENABLE_TESTING()
|
||||||
INCLUDE(CTest)
|
INCLUDE(CTest)
|
||||||
|
|
||||||
# Add repository where to find tests
|
|
||||||
ADD_SUBDIRECTORY(tests)
|
|
||||||
|
|
||||||
# Search openjpeg data needed for the tests
|
# Search openjpeg data needed for the tests
|
||||||
# They could be found via svn on the OpenJPEG google code project
|
# They could be found via svn on the OpenJPEG google code project
|
||||||
# svn checkout http://openjpeg.googlecode.com/svn/data (about 70 Mo)
|
# svn checkout http://openjpeg.googlecode.com/svn/data (about 70 Mo)
|
||||||
FIND_PATH(OPJ_DATA_ROOT README-OPJ-Data
|
FIND_PATH(OPJ_DATA_ROOT README-OPJ-Data
|
||||||
PATHS $ENV{OPJ_DATA_ROOT} ${CMAKE_SOURCE_DIR}/../data)
|
PATHS $ENV{OPJ_DATA_ROOT} ${CMAKE_SOURCE_DIR}/../data)
|
||||||
|
|
||||||
SET (REF_DECODER_BIN_PATH "NOT-FOUND" CACHE PATH "Single directory where find the reference encoder binaries to enable encoding test suite.")
|
# For encoding tests we need the path to the ref decoder exe/lib (kakadu)
|
||||||
|
SET (REF_DECODER_BIN_PATH "NOTFOUND" CACHE PATH "Single directory where find the reference decoder binaries to enable encoding test suite.")
|
||||||
MARK_AS_ADVANCED(REF_DECODER_BIN_PATH)
|
MARK_AS_ADVANCED(REF_DECODER_BIN_PATH)
|
||||||
|
|
||||||
|
# Add repository where to find tests
|
||||||
|
ADD_SUBDIRECTORY(tests)
|
||||||
|
|
||||||
ELSE(BUILD_CODEC)
|
ELSE(BUILD_CODEC)
|
||||||
message(FATAL_ERROR "You need build codec to run the tests")
|
message(FATAL_ERROR "You need build codec to run the tests")
|
||||||
ENDIF(BUILD_CODEC)
|
ENDIF(BUILD_CODEC)
|
||||||
|
|
|
@ -4,16 +4,9 @@
|
||||||
SET(common_SRCS
|
SET(common_SRCS
|
||||||
../codec/convert.c
|
../codec/convert.c
|
||||||
../codec/index.c
|
../codec/index.c
|
||||||
|
../common/opj_getopt.c
|
||||||
)
|
)
|
||||||
|
|
||||||
# If not getopt was found then add it to the lib:
|
|
||||||
IF(DONT_HAVE_GETOPT)
|
|
||||||
SET(common_SRCS
|
|
||||||
${common_SRCS}
|
|
||||||
../common/getopt.c
|
|
||||||
)
|
|
||||||
ENDIF(DONT_HAVE_GETOPT)
|
|
||||||
|
|
||||||
|
|
||||||
# Headers file are located here:
|
# Headers file are located here:
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "openjpeg.h"
|
#include "openjpeg.h"
|
||||||
#include "getopt.h"
|
#include "opj_getopt.h"
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
#include "dirent.h"
|
#include "dirent.h"
|
||||||
|
@ -492,7 +492,7 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_
|
||||||
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
img_fol_t *img_fol, char *indexfilename) {
|
img_fol_t *img_fol, char *indexfilename) {
|
||||||
int i, j,totlen;
|
int i, j,totlen;
|
||||||
option_t long_option[]={
|
opj_option_t long_option[]={
|
||||||
{"cinema2K",REQ_ARG, NULL ,'w'},
|
{"cinema2K",REQ_ARG, NULL ,'w'},
|
||||||
{"cinema4K",NO_ARG, NULL ,'y'},
|
{"cinema4K",NO_ARG, NULL ,'y'},
|
||||||
{"ImgDir",REQ_ARG, NULL ,'z'},
|
{"ImgDir",REQ_ARG, NULL ,'z'},
|
||||||
|
@ -523,7 +523,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
reset_options_reading();
|
reset_options_reading();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int c = getopt_long(argc, argv, optlist,long_option,totlen);
|
int c = opj_getopt_long(argc, argv, optlist,long_option,totlen);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -532,7 +532,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'o': /* output file */
|
case 'o': /* output file */
|
||||||
{
|
{
|
||||||
char *outfile = optarg;
|
char *outfile = opj_optarg;
|
||||||
parameters->cod_format = get_file_format(outfile);
|
parameters->cod_format = get_file_format(outfile);
|
||||||
switch(parameters->cod_format) {
|
switch(parameters->cod_format) {
|
||||||
case J2K_CFMT:
|
case J2K_CFMT:
|
||||||
|
@ -550,14 +550,14 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
case 'O': /* output format */
|
case 'O': /* output format */
|
||||||
{
|
{
|
||||||
char outformat[50];
|
char outformat[50];
|
||||||
char *of = optarg;
|
char *of = opj_optarg;
|
||||||
sprintf(outformat,".%s",of);
|
sprintf(outformat,".%s",of);
|
||||||
img_fol->set_out_format = 1;
|
img_fol->set_out_format = 1;
|
||||||
parameters->cod_format = get_file_format(outformat);
|
parameters->cod_format = get_file_format(outformat);
|
||||||
switch(parameters->cod_format) {
|
switch(parameters->cod_format) {
|
||||||
case J2K_CFMT:
|
case J2K_CFMT:
|
||||||
case JP2_CFMT:
|
case JP2_CFMT:
|
||||||
img_fol->out_format = optarg;
|
img_fol->out_format = opj_optarg;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unknown output format image [only j2k, j2c, jp2]!! \n");
|
fprintf(stderr, "Unknown output format image [only j2k, j2c, jp2]!! \n");
|
||||||
|
@ -572,7 +572,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'r': /* rates rates/distorsion */
|
case 'r': /* rates rates/distorsion */
|
||||||
{
|
{
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
while (sscanf(s, "%f", ¶meters->tcp_rates[parameters->tcp_numlayers]) == 1) {
|
while (sscanf(s, "%f", ¶meters->tcp_rates[parameters->tcp_numlayers]) == 1) {
|
||||||
parameters->tcp_numlayers++;
|
parameters->tcp_numlayers++;
|
||||||
while (*s && *s != ',') {
|
while (*s && *s != ',') {
|
||||||
|
@ -590,7 +590,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'q': /* add fixed_quality */
|
case 'q': /* add fixed_quality */
|
||||||
{
|
{
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
while (sscanf(s, "%f", ¶meters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
|
while (sscanf(s, "%f", ¶meters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
|
||||||
parameters->tcp_numlayers++;
|
parameters->tcp_numlayers++;
|
||||||
while (*s && *s != ',') {
|
while (*s && *s != ',') {
|
||||||
|
@ -612,7 +612,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
int *row = NULL, *col = NULL;
|
int *row = NULL, *col = NULL;
|
||||||
int numlayers = 0, numresolution = 0, matrix_width = 0;
|
int numlayers = 0, numresolution = 0, matrix_width = 0;
|
||||||
|
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
sscanf(s, "%d", &numlayers);
|
sscanf(s, "%d", &numlayers);
|
||||||
s++;
|
s++;
|
||||||
if (numlayers > 9)
|
if (numlayers > 9)
|
||||||
|
@ -656,7 +656,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 't': /* tiles */
|
case 't': /* tiles */
|
||||||
{
|
{
|
||||||
sscanf(optarg, "%d,%d", ¶meters->cp_tdx, ¶meters->cp_tdy);
|
sscanf(opj_optarg, "%d,%d", ¶meters->cp_tdx, ¶meters->cp_tdy);
|
||||||
parameters->tile_size_on = true;
|
parameters->tile_size_on = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -665,7 +665,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'n': /* resolution */
|
case 'n': /* resolution */
|
||||||
{
|
{
|
||||||
sscanf(optarg, "%d", ¶meters->numresolution);
|
sscanf(opj_optarg, "%d", ¶meters->numresolution);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -675,7 +675,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
char sep;
|
char sep;
|
||||||
int res_spec = 0;
|
int res_spec = 0;
|
||||||
|
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
do {
|
do {
|
||||||
sep = 0;
|
sep = 0;
|
||||||
sscanf(s, "[%d,%d]%c", ¶meters->prcw_init[res_spec],
|
sscanf(s, "[%d,%d]%c", ¶meters->prcw_init[res_spec],
|
||||||
|
@ -694,7 +694,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
case 'b': /* code-block dimension */
|
case 'b': /* code-block dimension */
|
||||||
{
|
{
|
||||||
int cblockw_init = 0, cblockh_init = 0;
|
int cblockw_init = 0, cblockh_init = 0;
|
||||||
sscanf(optarg, "%d,%d", &cblockw_init, &cblockh_init);
|
sscanf(opj_optarg, "%d,%d", &cblockw_init, &cblockh_init);
|
||||||
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|
||||||
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
|
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -711,7 +711,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'x': /* creation of index file */
|
case 'x': /* creation of index file */
|
||||||
{
|
{
|
||||||
char *index = optarg;
|
char *index = opj_optarg;
|
||||||
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -722,7 +722,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
{
|
{
|
||||||
char progression[4];
|
char progression[4];
|
||||||
|
|
||||||
strncpy(progression, optarg, 4);
|
strncpy(progression, opj_optarg, 4);
|
||||||
parameters->prog_order = give_progression(progression);
|
parameters->prog_order = give_progression(progression);
|
||||||
if (parameters->prog_order == -1) {
|
if (parameters->prog_order == -1) {
|
||||||
fprintf(stderr, "Unrecognized progression order "
|
fprintf(stderr, "Unrecognized progression order "
|
||||||
|
@ -736,7 +736,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 's': /* subsampling factor */
|
case 's': /* subsampling factor */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "%d,%d", ¶meters->subsampling_dx,
|
if (sscanf(opj_optarg, "%d,%d", ¶meters->subsampling_dx,
|
||||||
¶meters->subsampling_dy) != 2) {
|
¶meters->subsampling_dy) != 2) {
|
||||||
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
|
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -748,7 +748,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'd': /* coordonnate of the reference grid */
|
case 'd': /* coordonnate of the reference grid */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "%d,%d", ¶meters->image_offset_x0,
|
if (sscanf(opj_optarg, "%d,%d", ¶meters->image_offset_x0,
|
||||||
¶meters->image_offset_y0) != 2) {
|
¶meters->image_offset_y0) != 2) {
|
||||||
fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
|
fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
|
||||||
"error !! [-d x0,y0]\n");
|
"error !! [-d x0,y0]\n");
|
||||||
|
@ -770,7 +770,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
int numpocs = 0; /* number of progression order change (POC) default 0 */
|
int numpocs = 0; /* number of progression order change (POC) default 0 */
|
||||||
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
|
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
|
||||||
|
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
POC = parameters->POC;
|
POC = parameters->POC;
|
||||||
|
|
||||||
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
|
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
|
||||||
|
@ -812,7 +812,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
case 'M': /* Mode switch pas tous au point !! */
|
case 'M': /* Mode switch pas tous au point !! */
|
||||||
{
|
{
|
||||||
int value = 0;
|
int value = 0;
|
||||||
if (sscanf(optarg, "%d", &value) == 1) {
|
if (sscanf(opj_optarg, "%d", &value) == 1) {
|
||||||
for (i = 0; i <= 5; i++) {
|
for (i = 0; i <= 5; i++) {
|
||||||
int cache = value & (1 << i);
|
int cache = value & (1 << i);
|
||||||
if (cache)
|
if (cache)
|
||||||
|
@ -826,7 +826,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'R': /* ROI */
|
case 'R': /* ROI */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "c=%d,U=%d", ¶meters->roi_compno,
|
if (sscanf(opj_optarg, "c=%d,U=%d", ¶meters->roi_compno,
|
||||||
¶meters->roi_shift) != 2) {
|
¶meters->roi_shift) != 2) {
|
||||||
fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n");
|
fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -838,7 +838,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'T': /* Tile offset */
|
case 'T': /* Tile offset */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "%d,%d", ¶meters->cp_tx0, ¶meters->cp_ty0) != 2) {
|
if (sscanf(opj_optarg, "%d,%d", ¶meters->cp_tx0, ¶meters->cp_ty0) != 2) {
|
||||||
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
|
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -849,9 +849,9 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'C': /* add a comment */
|
case 'C': /* add a comment */
|
||||||
{
|
{
|
||||||
parameters->cp_comment = (char*)malloc(strlen(optarg) + 1);
|
parameters->cp_comment = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
if(parameters->cp_comment) {
|
if(parameters->cp_comment) {
|
||||||
strcpy(parameters->cp_comment, optarg);
|
strcpy(parameters->cp_comment, opj_optarg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -869,7 +869,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'v': /* Tile part generation*/
|
case 'v': /* Tile part generation*/
|
||||||
{
|
{
|
||||||
parameters->tp_flag = optarg[0];
|
parameters->tp_flag = opj_optarg[0];
|
||||||
parameters->tp_on = 1;
|
parameters->tp_on = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -878,8 +878,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'z': /* Image Directory path */
|
case 'z': /* Image Directory path */
|
||||||
{
|
{
|
||||||
img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
|
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
strcpy(img_fol->imgdirpath,optarg);
|
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||||
img_fol->set_imgdir=1;
|
img_fol->set_imgdir=1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -889,7 +889,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
case 'w': /* Digital Cinema 2K profile compliance*/
|
case 'w': /* Digital Cinema 2K profile compliance*/
|
||||||
{
|
{
|
||||||
int fps=0;
|
int fps=0;
|
||||||
sscanf(optarg,"%d",&fps);
|
sscanf(opj_optarg,"%d",&fps);
|
||||||
if(fps == 24){
|
if(fps == 24){
|
||||||
parameters->cp_cinema = CINEMA2K_24;
|
parameters->cp_cinema = CINEMA2K_24;
|
||||||
}else if(fps == 48 ){
|
}else if(fps == 48 ){
|
||||||
|
@ -933,7 +933,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
/* search for different protection methods */
|
/* search for different protection methods */
|
||||||
|
|
||||||
/* break the option in comma points and parse the result */
|
/* break the option in comma points and parse the result */
|
||||||
token = strtok(optarg, ",");
|
token = strtok(opj_optarg, ",");
|
||||||
while(token != NULL) {
|
while(token != NULL) {
|
||||||
|
|
||||||
/* search header error protection method */
|
/* search header error protection method */
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "openjpeg.h"
|
#include "openjpeg.h"
|
||||||
#include "getopt.h"
|
#include "opj_getopt.h"
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
#include "dirent.h"
|
#include "dirent.h"
|
||||||
#include "org_openJpeg_OpenJPEGJavaDecoder.h"
|
#include "org_openJpeg_OpenJPEGJavaDecoder.h"
|
||||||
|
@ -206,7 +206,7 @@ int get_file_format(char *filename) {
|
||||||
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
|
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
|
||||||
/* parse the command line */
|
/* parse the command line */
|
||||||
int totlen;
|
int totlen;
|
||||||
option_t long_option[]={
|
opj_option_t long_option[]={
|
||||||
{"ImgDir",REQ_ARG, NULL ,'y'},
|
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||||
{"OutFor",REQ_ARG, NULL ,'O'},
|
{"OutFor",REQ_ARG, NULL ,'O'},
|
||||||
};
|
};
|
||||||
|
@ -229,13 +229,13 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
reset_options_reading();
|
reset_options_reading();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int c = getopt_long(argc, argv,optlist,long_option,totlen);
|
int c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'i': /* input file */
|
case 'i': /* input file */
|
||||||
{
|
{
|
||||||
char *infile = optarg;
|
char *infile = opj_optarg;
|
||||||
parameters->decod_format = get_file_format(infile);
|
parameters->decod_format = get_file_format(infile);
|
||||||
switch(parameters->decod_format) {
|
switch(parameters->decod_format) {
|
||||||
case J2K_CFMT:
|
case J2K_CFMT:
|
||||||
|
@ -256,7 +256,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
|
|
||||||
case 'o': /* output file */
|
case 'o': /* output file */
|
||||||
{
|
{
|
||||||
char *outfile = optarg;
|
char *outfile = opj_optarg;
|
||||||
parameters->cod_format = get_file_format(outfile);
|
parameters->cod_format = get_file_format(outfile);
|
||||||
switch(parameters->cod_format) {
|
switch(parameters->cod_format) {
|
||||||
case PGX_DFMT:
|
case PGX_DFMT:
|
||||||
|
@ -279,7 +279,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
case 'O': /* output format */
|
case 'O': /* output format */
|
||||||
{
|
{
|
||||||
char outformat[50];
|
char outformat[50];
|
||||||
char *of = optarg;
|
char *of = opj_optarg;
|
||||||
sprintf(outformat,".%s",of);
|
sprintf(outformat,".%s",of);
|
||||||
img_fol->set_out_format = 1;
|
img_fol->set_out_format = 1;
|
||||||
parameters->cod_format = get_file_format(outformat);
|
parameters->cod_format = get_file_format(outformat);
|
||||||
|
@ -315,7 +315,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
|
|
||||||
case 'r': /* reduce option */
|
case 'r': /* reduce option */
|
||||||
{
|
{
|
||||||
sscanf(optarg, "%d", ¶meters->cp_reduce);
|
sscanf(opj_optarg, "%d", ¶meters->cp_reduce);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
|
|
||||||
case 'l': /* layering option */
|
case 'l': /* layering option */
|
||||||
{
|
{
|
||||||
sscanf(optarg, "%d", ¶meters->cp_layer);
|
sscanf(opj_optarg, "%d", ¶meters->cp_layer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -338,8 +338,8 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
|
|
||||||
case 'y': /* Image Directory path */
|
case 'y': /* Image Directory path */
|
||||||
{
|
{
|
||||||
img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
|
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
strcpy(img_fol->imgdirpath,optarg);
|
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||||
img_fol->set_imgdir=1;
|
img_fol->set_imgdir=1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -351,7 +351,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
{
|
{
|
||||||
char *token = NULL;
|
char *token = NULL;
|
||||||
|
|
||||||
token = strtok(optarg, ",");
|
token = strtok(opj_optarg, ",");
|
||||||
while(token != NULL) {
|
while(token != NULL) {
|
||||||
|
|
||||||
/* search expected number of components */
|
/* search expected number of components */
|
||||||
|
@ -418,7 +418,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
|
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ CFLAGS = -O3 -lstdc++ # -g -p -pg
|
||||||
all: j2k_to_image image_to_j2k
|
all: j2k_to_image image_to_j2k
|
||||||
|
|
||||||
j2k_to_image: j2k_to_image.c ../libopenjpeg.a
|
j2k_to_image: j2k_to_image.c ../libopenjpeg.a
|
||||||
gcc $(CFLAGS) ../common/getopt.c convert.c j2k_to_image.c -o j2k_to_image -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
|
gcc $(CFLAGS) ../common/opj_getopt.c convert.c j2k_to_image.c -o j2k_to_image -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
|
||||||
|
|
||||||
image_to_j2k: image_to_j2k.c ../libopenjpeg.a
|
image_to_j2k: image_to_j2k.c ../libopenjpeg.a
|
||||||
gcc $(CFLAGS) ../common/getopt.c convert.c image_to_j2k.c -o image_to_j2k -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
|
gcc $(CFLAGS) ../common/opj_getopt.c convert.c image_to_j2k.c -o image_to_j2k -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f j2k_to_image image_to_j2k
|
rm -f j2k_to_image image_to_j2k
|
||||||
|
|
|
@ -15,5 +15,5 @@ CMakeLists.txt \
|
||||||
common/color.c \
|
common/color.c \
|
||||||
common/color.h \
|
common/color.h \
|
||||||
common/format_defs.h \
|
common/format_defs.h \
|
||||||
common/getopt.c \
|
common/opj_getopt.c \
|
||||||
common/getopt.h
|
common/opj_getopt.h
|
||||||
|
|
|
@ -5,16 +5,9 @@ SET(common_SRCS
|
||||||
convert.c
|
convert.c
|
||||||
index.c
|
index.c
|
||||||
${OPENJPEG_SOURCE_DIR}/applications/common/color.c
|
${OPENJPEG_SOURCE_DIR}/applications/common/color.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c
|
||||||
)
|
)
|
||||||
|
|
||||||
# If not getopt was found then add it to the lib:
|
|
||||||
IF(DONT_HAVE_GETOPT)
|
|
||||||
SET(common_SRCS
|
|
||||||
${common_SRCS}
|
|
||||||
${OPENJPEG_SOURCE_DIR}/applications/common/getopt.c
|
|
||||||
)
|
|
||||||
ENDIF(DONT_HAVE_GETOPT)
|
|
||||||
|
|
||||||
# Headers file are located here:
|
# Headers file are located here:
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||||
|
|
|
@ -22,7 +22,7 @@ j2k_to_image_CFLAGS =
|
||||||
j2k_to_image_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @LCMS1_LIBS@ @LCMS2_LIBS@ @TIFF_LIBS@ @PNG_LIBS@ -lm
|
j2k_to_image_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @LCMS1_LIBS@ @LCMS2_LIBS@ @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||||
j2k_to_image_SOURCES = \
|
j2k_to_image_SOURCES = \
|
||||||
../common/color.c \
|
../common/color.c \
|
||||||
../common/getopt.c \
|
../common/opj_getopt.c \
|
||||||
convert.c \
|
convert.c \
|
||||||
index.c \
|
index.c \
|
||||||
j2k_to_image.c \
|
j2k_to_image.c \
|
||||||
|
@ -41,7 +41,7 @@ image_to_j2k_CPPFLAGS = \
|
||||||
image_to_j2k_CFLAGS =
|
image_to_j2k_CFLAGS =
|
||||||
image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @TIFF_LIBS@ @PNG_LIBS@ -lm
|
image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||||
image_to_j2k_SOURCES = \
|
image_to_j2k_SOURCES = \
|
||||||
../common/getopt.c \
|
../common/opj_getopt.c \
|
||||||
convert.c \
|
convert.c \
|
||||||
index.c \
|
index.c \
|
||||||
image_to_j2k.c \
|
image_to_j2k.c \
|
||||||
|
@ -60,10 +60,10 @@ j2k_dump_CPPFLAGS = \
|
||||||
j2k_dump_CFLAGS =
|
j2k_dump_CFLAGS =
|
||||||
j2k_dump_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la -lm
|
j2k_dump_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la -lm
|
||||||
j2k_dump_SOURCES = \
|
j2k_dump_SOURCES = \
|
||||||
../common/getopt.c \
|
../common/opj_getopt.c \
|
||||||
index.c \
|
index.c \
|
||||||
j2k_dump.c \
|
j2k_dump.c \
|
||||||
../common/getopt.h \
|
../common/opj_getopt.h \
|
||||||
index.h
|
index.h
|
||||||
|
|
||||||
JPWL_j2k_to_image_CPPFLAGS = \
|
JPWL_j2k_to_image_CPPFLAGS = \
|
||||||
|
@ -81,7 +81,7 @@ JPWL_j2k_to_image_CFLAGS =
|
||||||
JPWL_j2k_to_image_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @LCMS1_LIBS@ @LCMS2_LIBS@ @TIFF_LIBS@ @PNG_LIBS@
|
JPWL_j2k_to_image_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @LCMS1_LIBS@ @LCMS2_LIBS@ @TIFF_LIBS@ @PNG_LIBS@
|
||||||
JPWL_j2k_to_image_SOURCES = \
|
JPWL_j2k_to_image_SOURCES = \
|
||||||
../common/color.c \
|
../common/color.c \
|
||||||
../common/getopt.c \
|
../common/opj_getopt.c \
|
||||||
index.c \
|
index.c \
|
||||||
convert.c \
|
convert.c \
|
||||||
j2k_to_image.c
|
j2k_to_image.c
|
||||||
|
@ -99,7 +99,7 @@ JPWL_image_to_j2k_CFLAGS =
|
||||||
JPWL_image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @TIFF_LIBS@ @PNG_LIBS@
|
JPWL_image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @TIFF_LIBS@ @PNG_LIBS@
|
||||||
|
|
||||||
JPWL_image_to_j2k_SOURCES = \
|
JPWL_image_to_j2k_SOURCES = \
|
||||||
../common/getopt.c \
|
../common/opj_getopt.c \
|
||||||
index.c \
|
index.c \
|
||||||
convert.c \
|
convert.c \
|
||||||
image_to_j2k.c
|
image_to_j2k.c
|
||||||
|
|
|
@ -67,9 +67,9 @@ static int int_floorlog2(int a) {
|
||||||
|
|
||||||
<<-- <<-- <<-- <<-- */
|
<<-- <<-- <<-- <<-- */
|
||||||
|
|
||||||
|
#ifdef INFORMATION_ONLY
|
||||||
// TGA header definition.
|
// TGA header definition.
|
||||||
#pragma pack(push,1) // Pack structure byte aligned
|
struct tga_header
|
||||||
typedef struct tga_header
|
|
||||||
{
|
{
|
||||||
unsigned char id_length; /* Image id field length */
|
unsigned char id_length; /* Image id field length */
|
||||||
unsigned char colour_map_type; /* Colour map type */
|
unsigned char colour_map_type; /* Colour map type */
|
||||||
|
@ -89,35 +89,66 @@ typedef struct tga_header
|
||||||
unsigned short image_height; /* Image height */
|
unsigned short image_height; /* Image height */
|
||||||
unsigned char pixel_depth; /* Pixel depth */
|
unsigned char pixel_depth; /* Pixel depth */
|
||||||
unsigned char image_desc; /* Image descriptor */
|
unsigned char image_desc; /* Image descriptor */
|
||||||
} tga_header;
|
};
|
||||||
#pragma pack(pop) // Return to normal structure packing alignment.
|
#endif /* INFORMATION_ONLY */
|
||||||
|
|
||||||
|
static unsigned short get_ushort(unsigned short val) {
|
||||||
|
|
||||||
|
#ifdef ORDER_BIGENDIAN
|
||||||
|
return( ((val & 0xff) << 8) + (val >> 8) );
|
||||||
|
#else
|
||||||
|
return( val );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#define TGA_HEADER_SIZE 18
|
||||||
|
|
||||||
int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
|
int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
|
||||||
unsigned int *width, unsigned int *height, int *flip_image)
|
unsigned int *width, unsigned int *height, int *flip_image)
|
||||||
{
|
{
|
||||||
int palette_size;
|
int palette_size;
|
||||||
tga_header tga ;
|
unsigned char *tga ;
|
||||||
|
unsigned char id_len, cmap_type, image_type;
|
||||||
|
unsigned char pixel_depth, image_desc;
|
||||||
|
unsigned short cmap_index, cmap_len, cmap_entry_size;
|
||||||
|
unsigned short x_origin, y_origin, image_w, image_h;
|
||||||
|
|
||||||
if (!bits_per_pixel || !width || !height || !flip_image)
|
if (!bits_per_pixel || !width || !height || !flip_image)
|
||||||
return 0;
|
return 0;
|
||||||
|
tga = (unsigned char*)malloc(18);
|
||||||
|
|
||||||
// Read TGA header
|
if ( fread(tga, TGA_HEADER_SIZE, 1, fp) != 1 )
|
||||||
if ( fread((unsigned char*)&tga, sizeof(tga_header), 1, fp) != 1 )
|
|
||||||
{
|
{
|
||||||
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
|
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
|
id_len = (unsigned char)tga[0];
|
||||||
|
cmap_type = (unsigned char)tga[1];
|
||||||
|
image_type = (unsigned char)tga[2];
|
||||||
|
cmap_index = get_ushort(*(unsigned short*)(&tga[3]));
|
||||||
|
cmap_len = get_ushort(*(unsigned short*)(&tga[5]));
|
||||||
|
cmap_entry_size = (unsigned char)tga[7];
|
||||||
|
|
||||||
*bits_per_pixel = tga.pixel_depth;
|
|
||||||
|
|
||||||
*width = tga.image_width;
|
x_origin = get_ushort(*(unsigned short*)(&tga[8]));
|
||||||
*height = tga.image_height ;
|
y_origin = get_ushort(*(unsigned short*)(&tga[10]));
|
||||||
|
image_w = get_ushort(*(unsigned short*)(&tga[12]));
|
||||||
|
image_h = get_ushort(*(unsigned short*)(&tga[14]));
|
||||||
|
pixel_depth = (unsigned char)tga[16];
|
||||||
|
image_desc = (unsigned char)tga[17];
|
||||||
|
|
||||||
|
free(tga);
|
||||||
|
|
||||||
|
*bits_per_pixel = (unsigned int)pixel_depth;
|
||||||
|
*width = (unsigned int)image_w;
|
||||||
|
*height = (unsigned int)image_h;
|
||||||
|
|
||||||
// Ignore tga identifier, if present ...
|
// Ignore tga identifier, if present ...
|
||||||
if (tga.id_length)
|
if (id_len)
|
||||||
{
|
{
|
||||||
unsigned char *id = (unsigned char *) malloc(tga.id_length);
|
unsigned char *id = (unsigned char *) malloc(id_len);
|
||||||
if ( !fread(id, tga.id_length, 1, fp) )
|
if ( !fread(id, id_len, 1, fp) )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
|
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
|
||||||
free(id);
|
free(id);
|
||||||
|
@ -129,16 +160,16 @@ int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
|
||||||
// Test for compressed formats ... not yet supported ...
|
// Test for compressed formats ... not yet supported ...
|
||||||
// Note :- 9 - RLE encoded palettized.
|
// Note :- 9 - RLE encoded palettized.
|
||||||
// 10 - RLE encoded RGB.
|
// 10 - RLE encoded RGB.
|
||||||
if (tga.image_type > 8)
|
if (image_type > 8)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Sorry, compressed tga files are not currently supported.\n");
|
fprintf(stderr, "Sorry, compressed tga files are not currently supported.\n");
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
*flip_image = !(tga.image_desc & 32);
|
*flip_image = !(image_desc & 32);
|
||||||
|
|
||||||
// Palettized formats are not yet supported, skip over the palette, if present ...
|
// Palettized formats are not yet supported, skip over the palette, if present ...
|
||||||
palette_size = tga.colour_map_length * (tga.colour_map_entry_size/8);
|
palette_size = cmap_len * (cmap_entry_size/8);
|
||||||
|
|
||||||
if (palette_size>0)
|
if (palette_size>0)
|
||||||
{
|
{
|
||||||
|
@ -151,31 +182,56 @@ int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
|
||||||
int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height,
|
int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height,
|
||||||
opj_bool flip_image)
|
opj_bool flip_image)
|
||||||
{
|
{
|
||||||
tga_header tga;
|
unsigned short image_w, image_h, us0;
|
||||||
|
unsigned char uc0, image_type;
|
||||||
|
unsigned char pixel_depth, image_desc;
|
||||||
|
|
||||||
if (!bits_per_pixel || !width || !height)
|
if (!bits_per_pixel || !width || !height)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
memset(&tga, 0, sizeof(tga_header));
|
pixel_depth = 0;
|
||||||
|
|
||||||
if ( bits_per_pixel < 256 )
|
if ( bits_per_pixel < 256 )
|
||||||
tga.pixel_depth = (unsigned char)bits_per_pixel;
|
pixel_depth = (unsigned char)bits_per_pixel;
|
||||||
else{
|
else{
|
||||||
fprintf(stderr,"ERROR: Wrong bits per pixel inside tga_header");
|
fprintf(stderr,"ERROR: Wrong bits per pixel inside tga_header");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
tga.image_width = (unsigned short)width;
|
uc0 = 0;
|
||||||
tga.image_height = (unsigned short)height;
|
|
||||||
tga.image_type = 2; // Uncompressed.
|
if(fwrite(&uc0, 1, 1, fp) != 1) goto fails; // id_length
|
||||||
tga.image_desc = 8; // 8 bits per component.
|
if(fwrite(&uc0, 1, 1, fp) != 1) goto fails; // colour_map_type
|
||||||
|
|
||||||
|
image_type = 2; // Uncompressed.
|
||||||
|
if(fwrite(&image_type, 1, 1, fp) != 1) goto fails;
|
||||||
|
|
||||||
|
us0 = 0;
|
||||||
|
if(fwrite(&us0, 2, 1, fp) != 1) goto fails; // colour_map_index
|
||||||
|
if(fwrite(&us0, 2, 1, fp) != 1) goto fails; // colour_map_length
|
||||||
|
if(fwrite(&uc0, 1, 1, fp) != 1) goto fails; // colour_map_entry_size
|
||||||
|
|
||||||
|
if(fwrite(&us0, 2, 1, fp) != 1) goto fails; // x_origin
|
||||||
|
if(fwrite(&us0, 2, 1, fp) != 1) goto fails; // y_origin
|
||||||
|
|
||||||
|
image_w = (unsigned short)width;
|
||||||
|
image_h = (unsigned short) height;
|
||||||
|
|
||||||
|
if(fwrite(&image_w, 2, 1, fp) != 1) goto fails;
|
||||||
|
if(fwrite(&image_h, 2, 1, fp) != 1) goto fails;
|
||||||
|
|
||||||
|
if(fwrite(&pixel_depth, 1, 1, fp) != 1) goto fails;
|
||||||
|
|
||||||
|
image_desc = 8; // 8 bits per component.
|
||||||
|
|
||||||
if (flip_image)
|
if (flip_image)
|
||||||
tga.image_desc |= 32;
|
image_desc |= 32;
|
||||||
|
if(fwrite(&image_desc, 1, 1, fp) != 1) goto fails;
|
||||||
// Write TGA header
|
|
||||||
fwrite((unsigned char*)&tga, sizeof(tga_header), 1, fp);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
fails:
|
||||||
|
fputs("\nwrite_tgaheader: write ERROR\n", stderr);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) {
|
opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) {
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
#include "opj_config.h"
|
#include "opj_config.h"
|
||||||
#include "openjpeg.h"
|
#include "openjpeg.h"
|
||||||
#include "getopt.h"
|
#include "opj_getopt.h"
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
|
|
||||||
|
@ -574,7 +574,7 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_
|
||||||
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
img_fol_t *img_fol, raw_cparameters_t *raw_cp, char *indexfilename) {
|
img_fol_t *img_fol, raw_cparameters_t *raw_cp, char *indexfilename) {
|
||||||
int i, j, totlen, c;
|
int i, j, totlen, c;
|
||||||
option_t long_option[]={
|
opj_option_t long_option[]={
|
||||||
{"cinema2K",REQ_ARG, NULL ,'w'},
|
{"cinema2K",REQ_ARG, NULL ,'w'},
|
||||||
{"cinema4K",NO_ARG, NULL ,'y'},
|
{"cinema4K",NO_ARG, NULL ,'y'},
|
||||||
{"ImgDir",REQ_ARG, NULL ,'z'},
|
{"ImgDir",REQ_ARG, NULL ,'z'},
|
||||||
|
@ -598,13 +598,13 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
raw_cp->rawWidth = 0;
|
raw_cp->rawWidth = 0;
|
||||||
|
|
||||||
do{
|
do{
|
||||||
c = getopt_long(argc, argv, optlist,long_option,totlen);
|
c = opj_getopt_long(argc, argv, optlist,long_option,totlen);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'i': /* input file */
|
case 'i': /* input file */
|
||||||
{
|
{
|
||||||
char *infile = optarg;
|
char *infile = opj_optarg;
|
||||||
parameters->decod_format = get_file_format(infile);
|
parameters->decod_format = get_file_format(infile);
|
||||||
switch(parameters->decod_format) {
|
switch(parameters->decod_format) {
|
||||||
case PGX_DFMT:
|
case PGX_DFMT:
|
||||||
|
@ -630,7 +630,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'o': /* output file */
|
case 'o': /* output file */
|
||||||
{
|
{
|
||||||
char *outfile = optarg;
|
char *outfile = opj_optarg;
|
||||||
parameters->cod_format = get_file_format(outfile);
|
parameters->cod_format = get_file_format(outfile);
|
||||||
switch(parameters->cod_format) {
|
switch(parameters->cod_format) {
|
||||||
case J2K_CFMT:
|
case J2K_CFMT:
|
||||||
|
@ -648,14 +648,14 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
case 'O': /* output format */
|
case 'O': /* output format */
|
||||||
{
|
{
|
||||||
char outformat[50];
|
char outformat[50];
|
||||||
char *of = optarg;
|
char *of = opj_optarg;
|
||||||
sprintf(outformat,".%s",of);
|
sprintf(outformat,".%s",of);
|
||||||
img_fol->set_out_format = 1;
|
img_fol->set_out_format = 1;
|
||||||
parameters->cod_format = get_file_format(outformat);
|
parameters->cod_format = get_file_format(outformat);
|
||||||
switch(parameters->cod_format) {
|
switch(parameters->cod_format) {
|
||||||
case J2K_CFMT:
|
case J2K_CFMT:
|
||||||
case JP2_CFMT:
|
case JP2_CFMT:
|
||||||
img_fol->out_format = optarg;
|
img_fol->out_format = opj_optarg;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unknown output format image [only j2k, j2c, jp2]!! \n");
|
fprintf(stderr, "Unknown output format image [only j2k, j2c, jp2]!! \n");
|
||||||
|
@ -670,7 +670,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'r': /* rates rates/distorsion */
|
case 'r': /* rates rates/distorsion */
|
||||||
{
|
{
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
parameters->tcp_numlayers = 0;
|
parameters->tcp_numlayers = 0;
|
||||||
while (sscanf(s, "%f", ¶meters->tcp_rates[parameters->tcp_numlayers]) == 1) {
|
while (sscanf(s, "%f", ¶meters->tcp_rates[parameters->tcp_numlayers]) == 1) {
|
||||||
parameters->tcp_numlayers++;
|
parameters->tcp_numlayers++;
|
||||||
|
@ -691,7 +691,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
case 'F': /* Raw image format parameters */
|
case 'F': /* Raw image format parameters */
|
||||||
{
|
{
|
||||||
char signo;
|
char signo;
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
if (sscanf(s, "%d,%d,%d,%d,%c", &raw_cp->rawWidth, &raw_cp->rawHeight, &raw_cp->rawComp, &raw_cp->rawBitDepth, &signo) == 5) {
|
if (sscanf(s, "%d,%d,%d,%d,%c", &raw_cp->rawWidth, &raw_cp->rawHeight, &raw_cp->rawComp, &raw_cp->rawBitDepth, &signo) == 5) {
|
||||||
if (signo == 's') {
|
if (signo == 's') {
|
||||||
raw_cp->rawSigned = OPJ_TRUE;
|
raw_cp->rawSigned = OPJ_TRUE;
|
||||||
|
@ -724,7 +724,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'q': /* add fixed_quality */
|
case 'q': /* add fixed_quality */
|
||||||
{
|
{
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
while (sscanf(s, "%f", ¶meters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
|
while (sscanf(s, "%f", ¶meters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
|
||||||
parameters->tcp_numlayers++;
|
parameters->tcp_numlayers++;
|
||||||
while (*s && *s != ',') {
|
while (*s && *s != ',') {
|
||||||
|
@ -746,7 +746,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
int *row = NULL, *col = NULL;
|
int *row = NULL, *col = NULL;
|
||||||
int numlayers = 0, numresolution = 0, matrix_width = 0;
|
int numlayers = 0, numresolution = 0, matrix_width = 0;
|
||||||
|
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
sscanf(s, "%d", &numlayers);
|
sscanf(s, "%d", &numlayers);
|
||||||
s++;
|
s++;
|
||||||
if (numlayers > 9)
|
if (numlayers > 9)
|
||||||
|
@ -790,7 +790,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 't': /* tiles */
|
case 't': /* tiles */
|
||||||
{
|
{
|
||||||
sscanf(optarg, "%d,%d", ¶meters->cp_tdx, ¶meters->cp_tdy);
|
sscanf(opj_optarg, "%d,%d", ¶meters->cp_tdx, ¶meters->cp_tdy);
|
||||||
parameters->tile_size_on = OPJ_TRUE;
|
parameters->tile_size_on = OPJ_TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -799,7 +799,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'n': /* resolution */
|
case 'n': /* resolution */
|
||||||
{
|
{
|
||||||
sscanf(optarg, "%d", ¶meters->numresolution);
|
sscanf(opj_optarg, "%d", ¶meters->numresolution);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -809,7 +809,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
char sep;
|
char sep;
|
||||||
int res_spec = 0;
|
int res_spec = 0;
|
||||||
|
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
do {
|
do {
|
||||||
sep = 0;
|
sep = 0;
|
||||||
sscanf(s, "[%d,%d]%c", ¶meters->prcw_init[res_spec],
|
sscanf(s, "[%d,%d]%c", ¶meters->prcw_init[res_spec],
|
||||||
|
@ -828,7 +828,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
case 'b': /* code-block dimension */
|
case 'b': /* code-block dimension */
|
||||||
{
|
{
|
||||||
int cblockw_init = 0, cblockh_init = 0;
|
int cblockw_init = 0, cblockh_init = 0;
|
||||||
sscanf(optarg, "%d,%d", &cblockw_init, &cblockh_init);
|
sscanf(opj_optarg, "%d,%d", &cblockw_init, &cblockh_init);
|
||||||
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|
||||||
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
|
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -845,7 +845,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'x': /* creation of index file */
|
case 'x': /* creation of index file */
|
||||||
{
|
{
|
||||||
char *index = optarg;
|
char *index = opj_optarg;
|
||||||
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -856,7 +856,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
{
|
{
|
||||||
char progression[4];
|
char progression[4];
|
||||||
|
|
||||||
strncpy(progression, optarg, 4);
|
strncpy(progression, opj_optarg, 4);
|
||||||
parameters->prog_order = give_progression(progression);
|
parameters->prog_order = give_progression(progression);
|
||||||
if (parameters->prog_order == -1) {
|
if (parameters->prog_order == -1) {
|
||||||
fprintf(stderr, "Unrecognized progression order "
|
fprintf(stderr, "Unrecognized progression order "
|
||||||
|
@ -870,7 +870,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 's': /* subsampling factor */
|
case 's': /* subsampling factor */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "%d,%d", ¶meters->subsampling_dx,
|
if (sscanf(opj_optarg, "%d,%d", ¶meters->subsampling_dx,
|
||||||
¶meters->subsampling_dy) != 2) {
|
¶meters->subsampling_dy) != 2) {
|
||||||
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
|
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -882,7 +882,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'd': /* coordonnate of the reference grid */
|
case 'd': /* coordonnate of the reference grid */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "%d,%d", ¶meters->image_offset_x0,
|
if (sscanf(opj_optarg, "%d,%d", ¶meters->image_offset_x0,
|
||||||
¶meters->image_offset_y0) != 2) {
|
¶meters->image_offset_y0) != 2) {
|
||||||
fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
|
fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
|
||||||
"error !! [-d x0,y0]\n");
|
"error !! [-d x0,y0]\n");
|
||||||
|
@ -904,7 +904,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
int numpocs = 0; /* number of progression order change (POC) default 0 */
|
int numpocs = 0; /* number of progression order change (POC) default 0 */
|
||||||
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
|
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
|
||||||
|
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
POC = parameters->POC;
|
POC = parameters->POC;
|
||||||
|
|
||||||
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
|
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
|
||||||
|
@ -946,7 +946,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
case 'M': /* Mode switch pas tous au point !! */
|
case 'M': /* Mode switch pas tous au point !! */
|
||||||
{
|
{
|
||||||
int value = 0;
|
int value = 0;
|
||||||
if (sscanf(optarg, "%d", &value) == 1) {
|
if (sscanf(opj_optarg, "%d", &value) == 1) {
|
||||||
for (i = 0; i <= 5; i++) {
|
for (i = 0; i <= 5; i++) {
|
||||||
int cache = value & (1 << i);
|
int cache = value & (1 << i);
|
||||||
if (cache)
|
if (cache)
|
||||||
|
@ -960,7 +960,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'R': /* ROI */
|
case 'R': /* ROI */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "c=%d,U=%d", ¶meters->roi_compno,
|
if (sscanf(opj_optarg, "c=%d,U=%d", ¶meters->roi_compno,
|
||||||
¶meters->roi_shift) != 2) {
|
¶meters->roi_shift) != 2) {
|
||||||
fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n");
|
fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -972,7 +972,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'T': /* Tile offset */
|
case 'T': /* Tile offset */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "%d,%d", ¶meters->cp_tx0, ¶meters->cp_ty0) != 2) {
|
if (sscanf(opj_optarg, "%d,%d", ¶meters->cp_tx0, ¶meters->cp_ty0) != 2) {
|
||||||
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
|
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -983,9 +983,9 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'C': /* add a comment */
|
case 'C': /* add a comment */
|
||||||
{
|
{
|
||||||
parameters->cp_comment = (char*)malloc(strlen(optarg) + 1);
|
parameters->cp_comment = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
if(parameters->cp_comment) {
|
if(parameters->cp_comment) {
|
||||||
strcpy(parameters->cp_comment, optarg);
|
strcpy(parameters->cp_comment, opj_optarg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1003,7 +1003,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'v': /* Tile part generation*/
|
case 'v': /* Tile part generation*/
|
||||||
{
|
{
|
||||||
parameters->tp_flag = optarg[0];
|
parameters->tp_flag = opj_optarg[0];
|
||||||
parameters->tp_on = 1;
|
parameters->tp_on = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1012,8 +1012,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
|
|
||||||
case 'z': /* Image Directory path */
|
case 'z': /* Image Directory path */
|
||||||
{
|
{
|
||||||
img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
|
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
strcpy(img_fol->imgdirpath,optarg);
|
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||||
img_fol->set_imgdir=1;
|
img_fol->set_imgdir=1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1023,7 +1023,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
case 'w': /* Digital Cinema 2K profile compliance*/
|
case 'w': /* Digital Cinema 2K profile compliance*/
|
||||||
{
|
{
|
||||||
int fps=0;
|
int fps=0;
|
||||||
sscanf(optarg,"%d",&fps);
|
sscanf(opj_optarg,"%d",&fps);
|
||||||
if(fps == 24){
|
if(fps == 24){
|
||||||
parameters->cp_cinema = CINEMA2K_24;
|
parameters->cp_cinema = CINEMA2K_24;
|
||||||
}else if(fps == 48 ){
|
}else if(fps == 48 ){
|
||||||
|
@ -1067,7 +1067,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
/* search for different protection methods */
|
/* search for different protection methods */
|
||||||
|
|
||||||
/* break the option in comma points and parse the result */
|
/* break the option in comma points and parse the result */
|
||||||
token = strtok(optarg, ",");
|
token = strtok(opj_optarg, ",");
|
||||||
while(token != NULL) {
|
while(token != NULL) {
|
||||||
|
|
||||||
/* search header error protection method */
|
/* search header error protection method */
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
#include "openjpeg.h"
|
#include "openjpeg.h"
|
||||||
#include "j2k.h"
|
#include "j2k.h"
|
||||||
#include "jp2.h"
|
#include "jp2.h"
|
||||||
#include "getopt.h"
|
#include "opj_getopt.h"
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparamet
|
||||||
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
|
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
|
||||||
/* parse the command line */
|
/* parse the command line */
|
||||||
int totlen, c;
|
int totlen, c;
|
||||||
option_t long_option[]={
|
opj_option_t long_option[]={
|
||||||
{"ImgDir",REQ_ARG, NULL ,'y'},
|
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||||
};
|
};
|
||||||
const char optlist[] = "i:o:h";
|
const char optlist[] = "i:o:h";
|
||||||
|
@ -207,13 +207,13 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
totlen=sizeof(long_option);
|
totlen=sizeof(long_option);
|
||||||
img_fol->set_out_format = 0;
|
img_fol->set_out_format = 0;
|
||||||
do {
|
do {
|
||||||
c = getopt_long(argc, argv,optlist,long_option,totlen);
|
c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'i': /* input file */
|
case 'i': /* input file */
|
||||||
{
|
{
|
||||||
char *infile = optarg;
|
char *infile = opj_optarg;
|
||||||
parameters->decod_format = get_file_format(infile);
|
parameters->decod_format = get_file_format(infile);
|
||||||
switch(parameters->decod_format) {
|
switch(parameters->decod_format) {
|
||||||
case J2K_CFMT:
|
case J2K_CFMT:
|
||||||
|
@ -234,7 +234,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
|
|
||||||
case 'o': /* output file */
|
case 'o': /* output file */
|
||||||
{
|
{
|
||||||
char *outfile = optarg;
|
char *outfile = opj_optarg;
|
||||||
strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
|
strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -249,8 +249,8 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
|
|
||||||
case 'y': /* Image Directory path */
|
case 'y': /* Image Directory path */
|
||||||
{
|
{
|
||||||
img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
|
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
strcpy(img_fol->imgdirpath,optarg);
|
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||||
img_fol->set_imgdir=1;
|
img_fol->set_imgdir=1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -258,7 +258,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
|
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}while(c != -1);
|
}while(c != -1);
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
#include "opj_config.h"
|
#include "opj_config.h"
|
||||||
#include "openjpeg.h"
|
#include "openjpeg.h"
|
||||||
#include "getopt.h"
|
#include "opj_getopt.h"
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparamet
|
||||||
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
|
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
|
||||||
/* parse the command line */
|
/* parse the command line */
|
||||||
int totlen, c;
|
int totlen, c;
|
||||||
option_t long_option[]={
|
opj_option_t long_option[]={
|
||||||
{"ImgDir",REQ_ARG, NULL ,'y'},
|
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||||
{"OutFor",REQ_ARG, NULL ,'O'},
|
{"OutFor",REQ_ARG, NULL ,'O'},
|
||||||
};
|
};
|
||||||
|
@ -254,13 +254,13 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
totlen=sizeof(long_option);
|
totlen=sizeof(long_option);
|
||||||
img_fol->set_out_format = 0;
|
img_fol->set_out_format = 0;
|
||||||
do {
|
do {
|
||||||
c = getopt_long(argc, argv,optlist,long_option,totlen);
|
c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'i': /* input file */
|
case 'i': /* input file */
|
||||||
{
|
{
|
||||||
char *infile = optarg;
|
char *infile = opj_optarg;
|
||||||
parameters->decod_format = get_file_format(infile);
|
parameters->decod_format = get_file_format(infile);
|
||||||
switch(parameters->decod_format) {
|
switch(parameters->decod_format) {
|
||||||
case J2K_CFMT:
|
case J2K_CFMT:
|
||||||
|
@ -281,7 +281,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
|
|
||||||
case 'o': /* output file */
|
case 'o': /* output file */
|
||||||
{
|
{
|
||||||
char *outfile = optarg;
|
char *outfile = opj_optarg;
|
||||||
parameters->cod_format = get_file_format(outfile);
|
parameters->cod_format = get_file_format(outfile);
|
||||||
switch(parameters->cod_format) {
|
switch(parameters->cod_format) {
|
||||||
case PGX_DFMT:
|
case PGX_DFMT:
|
||||||
|
@ -305,7 +305,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
case 'O': /* output format */
|
case 'O': /* output format */
|
||||||
{
|
{
|
||||||
char outformat[50];
|
char outformat[50];
|
||||||
char *of = optarg;
|
char *of = opj_optarg;
|
||||||
sprintf(outformat,".%s",of);
|
sprintf(outformat,".%s",of);
|
||||||
img_fol->set_out_format = 1;
|
img_fol->set_out_format = 1;
|
||||||
parameters->cod_format = get_file_format(outformat);
|
parameters->cod_format = get_file_format(outformat);
|
||||||
|
@ -344,7 +344,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
|
|
||||||
case 'r': /* reduce option */
|
case 'r': /* reduce option */
|
||||||
{
|
{
|
||||||
sscanf(optarg, "%d", ¶meters->cp_reduce);
|
sscanf(opj_optarg, "%d", ¶meters->cp_reduce);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
|
|
||||||
case 'l': /* layering option */
|
case 'l': /* layering option */
|
||||||
{
|
{
|
||||||
sscanf(optarg, "%d", ¶meters->cp_layer);
|
sscanf(opj_optarg, "%d", ¶meters->cp_layer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -367,15 +367,15 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
|
|
||||||
case 'y': /* Image Directory path */
|
case 'y': /* Image Directory path */
|
||||||
{
|
{
|
||||||
img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
|
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
strcpy(img_fol->imgdirpath,optarg);
|
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||||
img_fol->set_imgdir=1;
|
img_fol->set_imgdir=1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
case 'x': /* Creation of index file */
|
case 'x': /* Creation of index file */
|
||||||
{
|
{
|
||||||
char *index = optarg;
|
char *index = opj_optarg;
|
||||||
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -387,7 +387,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
{
|
{
|
||||||
char *token = NULL;
|
char *token = NULL;
|
||||||
|
|
||||||
token = strtok(optarg, ",");
|
token = strtok(opj_optarg, ",");
|
||||||
while(token != NULL) {
|
while(token != NULL) {
|
||||||
|
|
||||||
/* search expected number of components */
|
/* search expected number of components */
|
||||||
|
@ -454,7 +454,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
|
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}while(c != -1);
|
}while(c != -1);
|
||||||
|
|
|
@ -124,7 +124,7 @@
|
||||||
# error "not implemented"
|
# error "not implemented"
|
||||||
# elif defined(__sgi) /* Silicon Graphics */
|
# elif defined(__sgi) /* Silicon Graphics */
|
||||||
# define HAVE_DIRENT_H
|
# define HAVE_DIRENT_H
|
||||||
# elif defined(sun) || defined(_sun) /* Sun Solaris */
|
# elif defined(sun) || defined(__sun) /* Sun Solaris */
|
||||||
# define HAVE_DIRENT_H
|
# define HAVE_DIRENT_H
|
||||||
# elif defined(__FreeBSD__) /* FreeBSD */
|
# elif defined(__FreeBSD__) /* FreeBSD */
|
||||||
# define HAVE_DIRENT_H
|
# define HAVE_DIRENT_H
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
/* last review : october 29th, 2002 */
|
|
||||||
|
|
||||||
#ifndef _GETOPT_H_
|
|
||||||
#define _GETOPT_H_
|
|
||||||
|
|
||||||
typedef struct option
|
|
||||||
{
|
|
||||||
const char *name;
|
|
||||||
int has_arg;
|
|
||||||
int *flag;
|
|
||||||
int val;
|
|
||||||
}option_t;
|
|
||||||
|
|
||||||
#define NO_ARG 0
|
|
||||||
#define REQ_ARG 1
|
|
||||||
#define OPT_ARG 2
|
|
||||||
|
|
||||||
extern int opterr;
|
|
||||||
extern int optind;
|
|
||||||
extern int optopt;
|
|
||||||
extern int optreset;
|
|
||||||
extern char *optarg;
|
|
||||||
|
|
||||||
extern int getopt(int nargc, char *const *nargv, const char *ostr);
|
|
||||||
extern int getopt_long(int argc, char * const argv[], const char *optstring,
|
|
||||||
const struct option *longopts, int totlen);
|
|
||||||
extern void reset_options_reading(void);
|
|
||||||
|
|
||||||
#endif /* _GETOPT_H_ */
|
|
|
@ -34,117 +34,110 @@
|
||||||
/* last review : october 29th, 2002 */
|
/* last review : october 29th, 2002 */
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
|
static char sccsid[] = "@(#)opj_getopt.c 8.3 (Berkeley) 4/27/95";
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "opj_getopt.h"
|
||||||
|
|
||||||
int opterr = 1, /* if error message should be printed */
|
int opj_opterr = 1, /* if error message should be printed */
|
||||||
optind = 1, /* index into parent argv vector */
|
opj_optind = 1, /* index into parent argv vector */
|
||||||
optopt, /* character checked for validity */
|
opj_optopt, /* character checked for validity */
|
||||||
optreset; /* reset getopt */
|
opj_optreset; /* reset getopt */
|
||||||
const char *optarg; /* argument associated with option */
|
char *opj_optarg; /* argument associated with option */
|
||||||
|
|
||||||
typedef struct option
|
|
||||||
{
|
|
||||||
const char *name;
|
|
||||||
int has_arg;
|
|
||||||
int *flag;
|
|
||||||
int val;
|
|
||||||
}option_t;
|
|
||||||
|
|
||||||
#define BADCH (int)'?'
|
#define BADCH (int)'?'
|
||||||
#define BADARG (int)':'
|
#define BADARG (int)':'
|
||||||
#define EMSG ""
|
static char EMSG[]={""};
|
||||||
|
|
||||||
/* As this class remembers its values from one Java call to the other, reset the values before each use */
|
/* As this class remembers its values from one Java call to the other, reset the values before each use */
|
||||||
void reset_options_reading(void) {
|
void reset_options_reading(void) {
|
||||||
opterr = 1;
|
opj_opterr = 1;
|
||||||
optind = 1;
|
opj_optind = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* getopt --
|
* getopt --
|
||||||
* Parse argc/argv argument vector.
|
* Parse argc/argv argument vector.
|
||||||
*/
|
*/
|
||||||
int getopt(int nargc, char *const *nargv, const char *ostr) {
|
int opj_getopt(int nargc, char *const *nargv, const char *ostr) {
|
||||||
# define __progname nargv[0]
|
# define __progname nargv[0]
|
||||||
static const char *place = EMSG; /* option letter processing */
|
static char *place = EMSG; /* option letter processing */
|
||||||
char *oli; /* option letter list index */
|
char *oli; /* option letter list index */
|
||||||
|
|
||||||
if (optreset || !*place) { /* update scanning pointer */
|
if (opj_optreset || !*place) { /* update scanning pointer */
|
||||||
optreset = 0;
|
opj_optreset = 0;
|
||||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
if (opj_optind >= nargc || *(place = nargv[opj_optind]) != '-') {
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (place[1] && *++place == '-') { /* found "--" */
|
if (place[1] && *++place == '-') { /* found "--" */
|
||||||
++optind;
|
++opj_optind;
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
} /* option letter okay? */
|
} /* option letter okay? */
|
||||||
if ((optopt = (int) *place++) == (int) ':' ||
|
if ((opj_optopt = (int) *place++) == (int) ':' ||
|
||||||
!(oli = strchr(ostr, optopt))) {
|
!(oli = strchr(ostr, opj_optopt))) {
|
||||||
/*
|
/*
|
||||||
* if the user didn't specify '-' as an option,
|
* if the user didn't specify '-' as an option,
|
||||||
* assume it means -1.
|
* assume it means -1.
|
||||||
*/
|
*/
|
||||||
if (optopt == (int) '-')
|
if (opj_optopt == (int) '-')
|
||||||
return (-1);
|
return (-1);
|
||||||
if (!*place)
|
if (!*place)
|
||||||
++optind;
|
++opj_optind;
|
||||||
if (opterr && *ostr != ':') {
|
if (opj_opterr && *ostr != ':') {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: illegal option -- %c\n", __progname, optopt);
|
"%s: illegal option -- %c\n", __progname, opj_optopt);
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*++oli != ':') { /* don't need argument */
|
if (*++oli != ':') { /* don't need argument */
|
||||||
optarg = NULL;
|
opj_optarg = NULL;
|
||||||
if (!*place)
|
if (!*place)
|
||||||
++optind;
|
++opj_optind;
|
||||||
} else { /* need an argument */
|
} else { /* need an argument */
|
||||||
if (*place) /* no white space */
|
if (*place) /* no white space */
|
||||||
optarg = place;
|
opj_optarg = place;
|
||||||
else if (nargc <= ++optind) { /* no arg */
|
else if (nargc <= ++opj_optind) { /* no arg */
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
if (*ostr == ':')
|
if (*ostr == ':')
|
||||||
return (BADARG);
|
return (BADARG);
|
||||||
if (opterr) {
|
if (opj_opterr) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: option requires an argument -- %c\n",
|
"%s: option requires an argument -- %c\n",
|
||||||
__progname, optopt);
|
__progname, opj_optopt);
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}
|
}
|
||||||
} else /* white space */
|
} else /* white space */
|
||||||
optarg = nargv[optind];
|
opj_optarg = nargv[opj_optind];
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
++optind;
|
++opj_optind;
|
||||||
}
|
}
|
||||||
return (optopt); /* dump back option letter */
|
return (opj_optopt); /* dump back option letter */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int getopt_long(int argc, char * const argv[], const char *optstring,
|
int opj_getopt_long(int argc, char * const argv[], const char *optstring,
|
||||||
const struct option *longopts, int totlen) {
|
const opj_option_t *longopts, int totlen) {
|
||||||
static int lastidx,lastofs;
|
static int lastidx,lastofs;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
int i,len;
|
int i,len;
|
||||||
char param = 1;
|
char param = 1;
|
||||||
|
|
||||||
again:
|
again:
|
||||||
if (optind >= argc || !argv[optind] || *argv[optind]!='-')
|
if (opj_optind >= argc || !argv[opj_optind] || *argv[opj_optind]!='-')
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (argv[optind][0]=='-' && argv[optind][1]==0) {
|
if (argv[opj_optind][0]=='-' && argv[opj_optind][1]==0) {
|
||||||
if(optind >= (argc - 1)){ /* no more input parameters */
|
if(opj_optind >= (argc - 1)){ /* no more input parameters */
|
||||||
param = 0;
|
param = 0;
|
||||||
}
|
}
|
||||||
else{ /* more input parameters */
|
else{ /* more input parameters */
|
||||||
if(argv[optind + 1][0] == '-'){
|
if(argv[opj_optind + 1][0] == '-'){
|
||||||
param = 0; /* Missing parameter after '-' */
|
param = 0; /* Missing parameter after '-' */
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -154,50 +147,50 @@ again:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param == 0) {
|
if (param == 0) {
|
||||||
++optind;
|
++opj_optind;
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argv[optind][0]=='-') { /* long option */
|
if (argv[opj_optind][0]=='-') { /* long option */
|
||||||
char* arg=argv[optind]+1;
|
char* arg=argv[opj_optind]+1;
|
||||||
const struct option* o;
|
const opj_option_t* o;
|
||||||
o=longopts;
|
o=longopts;
|
||||||
len=sizeof(longopts[0]);
|
len=sizeof(longopts[0]);
|
||||||
|
|
||||||
if (param > 1){
|
if (param > 1){
|
||||||
arg = argv[optind+1];
|
arg = argv[opj_optind+1];
|
||||||
optind++;
|
opj_optind++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
arg = argv[optind]+1;
|
arg = argv[opj_optind]+1;
|
||||||
|
|
||||||
if(strlen(arg)>1){
|
if(strlen(arg)>1){
|
||||||
for (i=0;i<totlen;i=i+len,o++) {
|
for (i=0;i<totlen;i=i+len,o++) {
|
||||||
if (!strcmp(o->name,arg)) { /* match */
|
if (!strcmp(o->name,arg)) { /* match */
|
||||||
if (o->has_arg == 0) {
|
if (o->has_arg == 0) {
|
||||||
if ((argv[optind+1])&&(!(argv[optind+1][0]=='-'))){
|
if ((argv[opj_optind+1])&&(!(argv[opj_optind+1][0]=='-'))){
|
||||||
fprintf(stderr,"%s: option does not require an argument. Ignoring %s\n",arg,argv[optind+1]);
|
fprintf(stderr,"%s: option does not require an argument. Ignoring %s\n",arg,argv[opj_optind+1]);
|
||||||
++optind;
|
++opj_optind;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
optarg=argv[optind+1];
|
opj_optarg=argv[opj_optind+1];
|
||||||
if(optarg){
|
if(opj_optarg){
|
||||||
if (optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
|
if (opj_optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
|
||||||
if (opterr) {
|
if (opj_opterr) {
|
||||||
fprintf(stderr,"%s: option requires an argument\n",arg);
|
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!optarg && o->has_arg==1) { /* no argument there */
|
if (!opj_optarg && o->has_arg==1) { /* no argument there */
|
||||||
if (opterr) {
|
if (opj_opterr) {
|
||||||
fprintf(stderr,"%s: option requires an argument \n",arg);
|
fprintf(stderr,"%s: option requires an argument \n",arg);
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++optind;
|
++opj_optind;
|
||||||
}
|
}
|
||||||
++optind;
|
++opj_optind;
|
||||||
if (o->flag)
|
if (o->flag)
|
||||||
*(o->flag)=o->val;
|
*(o->flag)=o->val;
|
||||||
else
|
else
|
||||||
|
@ -206,56 +199,56 @@ again:
|
||||||
}
|
}
|
||||||
}//(end for)String not found in the list
|
}//(end for)String not found in the list
|
||||||
fprintf(stderr,"Invalid option %s\n",arg);
|
fprintf(stderr,"Invalid option %s\n",arg);
|
||||||
++optind;
|
++opj_optind;
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}else{ /*Single character input parameter*/
|
}else{ /*Single character input parameter*/
|
||||||
if (*optstring==':') return ':';
|
if (*optstring==':') return ':';
|
||||||
if (lastidx!=optind) {
|
if (lastidx!=opj_optind) {
|
||||||
lastidx=optind; lastofs=0;
|
lastidx=opj_optind; lastofs=0;
|
||||||
}
|
}
|
||||||
optopt=argv[optind][lastofs+1];
|
opj_optopt=argv[opj_optind][lastofs+1];
|
||||||
if ((tmp=strchr(optstring,optopt))) {/*Found input parameter in list*/
|
if ((tmp=strchr(optstring,opj_optopt))) {/*Found input parameter in list*/
|
||||||
if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */
|
if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */
|
||||||
++optind;
|
++opj_optind;
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
if (tmp[1]==':') { /* argument expected */
|
if (tmp[1]==':') { /* argument expected */
|
||||||
if (tmp[2]==':' || argv[optind][lastofs+2]) { /* "-foo", return "oo" as optarg */
|
if (tmp[2]==':' || argv[opj_optind][lastofs+2]) { /* "-foo", return "oo" as opj_optarg */
|
||||||
if (!*(optarg=argv[optind]+lastofs+2)) optarg=0;
|
if (!*(opj_optarg=argv[opj_optind]+lastofs+2)) opj_optarg=0;
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
optarg=argv[optind+1];
|
opj_optarg=argv[opj_optind+1];
|
||||||
if(optarg){
|
if(opj_optarg){
|
||||||
if (optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
|
if (opj_optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
|
||||||
if (opterr) {
|
if (opj_opterr) {
|
||||||
fprintf(stderr,"%s: option requires an argument\n",arg);
|
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!optarg) { /* missing argument */
|
if (!opj_optarg) { /* missing argument */
|
||||||
if (opterr) {
|
if (opj_opterr) {
|
||||||
fprintf(stderr,"%s: option requires an argument\n",arg);
|
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++optind;
|
++opj_optind;
|
||||||
}else {/*Argument not expected*/
|
}else {/*Argument not expected*/
|
||||||
++lastofs;
|
++lastofs;
|
||||||
return optopt;
|
return opj_optopt;
|
||||||
}
|
}
|
||||||
found:
|
found:
|
||||||
++optind;
|
++opj_optind;
|
||||||
return optopt;
|
return opj_optopt;
|
||||||
} else { /* not found */
|
} else { /* not found */
|
||||||
fprintf(stderr,"Invalid option %s\n",arg);
|
fprintf(stderr,"Invalid option %s\n",arg);
|
||||||
++optind;
|
++opj_optind;
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}//end of not found
|
}//end of not found
|
||||||
|
|
||||||
}// end of single character
|
}// end of single character
|
||||||
}//end '-'
|
}//end '-'
|
||||||
fprintf(stderr,"Invalid option\n");
|
fprintf(stderr,"Invalid option\n");
|
||||||
++optind;
|
++opj_optind;
|
||||||
return (BADCH);;
|
return (BADCH);;
|
||||||
}//end function
|
}//end function
|
|
@ -0,0 +1,29 @@
|
||||||
|
/* last review : october 29th, 2002 */
|
||||||
|
|
||||||
|
#ifndef _GETOPT_H_
|
||||||
|
#define _GETOPT_H_
|
||||||
|
|
||||||
|
typedef struct opj_option
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
int has_arg;
|
||||||
|
int *flag;
|
||||||
|
int val;
|
||||||
|
}opj_option_t;
|
||||||
|
|
||||||
|
#define NO_ARG 0
|
||||||
|
#define REQ_ARG 1
|
||||||
|
#define OPT_ARG 2
|
||||||
|
|
||||||
|
extern int opj_opterr;
|
||||||
|
extern int opj_optind;
|
||||||
|
extern int opj_optopt;
|
||||||
|
extern int opj_optreset;
|
||||||
|
extern char *opj_optarg;
|
||||||
|
|
||||||
|
extern int opj_getopt(int nargc, char *const *nargv, const char *ostr);
|
||||||
|
extern int opj_getopt_long(int argc, char * const argv[], const char *optstring,
|
||||||
|
const opj_option_t *longopts, int totlen);
|
||||||
|
extern void reset_options_reading(void);
|
||||||
|
|
||||||
|
#endif /* _GETOPT_H_ */
|
|
@ -1,9 +1,6 @@
|
||||||
# Makefile for the MJ2 codecs of the OpenJPEG library: frames_to_mj2, mj2_to_frames, extract_j2k_from_mj2 and wrap_j2k_in_mj2
|
# Makefile for the MJ2 codecs of the OpenJPEG library: frames_to_mj2, mj2_to_frames, extract_j2k_from_mj2 and wrap_j2k_in_mj2
|
||||||
|
|
||||||
SET(common_SRCS "")
|
SET(common_SRCS ${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c)
|
||||||
IF(DONT_HAVE_GETOPT)
|
|
||||||
SET(common_SRCS ${OPENJPEG_SOURCE_DIR}/applications/common/getopt.c)
|
|
||||||
ENDIF(DONT_HAVE_GETOPT)
|
|
||||||
|
|
||||||
# While mj2 executables do not use the API correctly, we do not link with the library but rather compile the sources files.
|
# While mj2 executables do not use the API correctly, we do not link with the library but rather compile the sources files.
|
||||||
SET(OPJ_SRCS
|
SET(OPJ_SRCS
|
||||||
|
|
|
@ -37,7 +37,7 @@ frames_to_mj2_CFLAGS =
|
||||||
frames_to_mj2_LDADD = -lm
|
frames_to_mj2_LDADD = -lm
|
||||||
frames_to_mj2_SOURCES = \
|
frames_to_mj2_SOURCES = \
|
||||||
$(OPJ_SRC) \
|
$(OPJ_SRC) \
|
||||||
../common/getopt.c \
|
../common/opj_getopt.c \
|
||||||
mj2_convert.c \
|
mj2_convert.c \
|
||||||
mj2.c \
|
mj2.c \
|
||||||
frames_to_mj2.c \
|
frames_to_mj2.c \
|
||||||
|
@ -58,7 +58,7 @@ mj2_to_frames_LDADD = @LCMS2_LIBS@ @LCMS1_LIBS@
|
||||||
mj2_to_frames_SOURCES = \
|
mj2_to_frames_SOURCES = \
|
||||||
$(OPJ_SRC) \
|
$(OPJ_SRC) \
|
||||||
../common/color.c \
|
../common/color.c \
|
||||||
../common/getopt.c \
|
../common/opj_getopt.c \
|
||||||
mj2_convert.c \
|
mj2_convert.c \
|
||||||
mj2.c \
|
mj2.c \
|
||||||
mj2_to_frames.c \
|
mj2_to_frames.c \
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include "cio.h"
|
#include "cio.h"
|
||||||
#include "mj2.h"
|
#include "mj2.h"
|
||||||
#include "mj2_convert.h"
|
#include "mj2_convert.h"
|
||||||
#include "getopt.h"
|
#include "opj_getopt.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Size of memory first allocated for MOOV box
|
Size of memory first allocated for MOOV box
|
||||||
|
@ -289,15 +289,15 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int c = getopt(argc, argv,
|
int c = opj_getopt(argc, argv,
|
||||||
"i:o:r:q:f:t:n:c:b:p:s:d:P:S:E:M:R:T:C:I:W:F:D:h");
|
"i:o:r:q:f:t:n:c:b:p:s:d:P:S:E:M:R:T:C:I:W:F:D:h");
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'i': /* IN fill */
|
case 'i': /* IN fill */
|
||||||
{
|
{
|
||||||
char *infile = optarg;
|
char *infile = opj_optarg;
|
||||||
s = optarg;
|
s = opj_optarg;
|
||||||
while (*s) {
|
while (*s) {
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ int main(int argc, char **argv)
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
case 'o': /* OUT fill */
|
case 'o': /* OUT fill */
|
||||||
{
|
{
|
||||||
char *outfile = optarg;
|
char *outfile = opj_optarg;
|
||||||
while (*outfile) {
|
while (*outfile) {
|
||||||
outfile++;
|
outfile++;
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@ int main(int argc, char **argv)
|
||||||
outfile--;
|
outfile--;
|
||||||
S1 = *outfile;
|
S1 = *outfile;
|
||||||
|
|
||||||
outfile = optarg;
|
outfile = opj_optarg;
|
||||||
|
|
||||||
if ((S1 == 'm' && S2 == 'j' && S3 == '2')
|
if ((S1 == 'm' && S2 == 'j' && S3 == '2')
|
||||||
|| (S1 == 'M' && S2 == 'J' && S3 == '2'))
|
|| (S1 == 'M' && S2 == 'J' && S3 == '2'))
|
||||||
|
@ -353,7 +353,7 @@ int main(int argc, char **argv)
|
||||||
case 'r': /* rates rates/distorsion */
|
case 'r': /* rates rates/distorsion */
|
||||||
{
|
{
|
||||||
float rate;
|
float rate;
|
||||||
s = optarg;
|
s = opj_optarg;
|
||||||
while (sscanf(s, "%f", &rate) == 1) {
|
while (sscanf(s, "%f", &rate) == 1) {
|
||||||
j2k_parameters->tcp_rates[j2k_parameters->tcp_numlayers] = rate * 2;
|
j2k_parameters->tcp_rates[j2k_parameters->tcp_numlayers] = rate * 2;
|
||||||
j2k_parameters->tcp_numlayers++;
|
j2k_parameters->tcp_numlayers++;
|
||||||
|
@ -369,7 +369,7 @@ int main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
case 'q': /* add fixed_quality */
|
case 'q': /* add fixed_quality */
|
||||||
s = optarg;
|
s = opj_optarg;
|
||||||
while (sscanf(s, "%f", &j2k_parameters->tcp_distoratio[j2k_parameters->tcp_numlayers]) == 1) {
|
while (sscanf(s, "%f", &j2k_parameters->tcp_distoratio[j2k_parameters->tcp_numlayers]) == 1) {
|
||||||
j2k_parameters->tcp_numlayers++;
|
j2k_parameters->tcp_numlayers++;
|
||||||
while (*s && *s != ',') {
|
while (*s && *s != ',') {
|
||||||
|
@ -388,7 +388,7 @@ int main(int argc, char **argv)
|
||||||
int *row = NULL, *col = NULL;
|
int *row = NULL, *col = NULL;
|
||||||
int numlayers = 0, numresolution = 0, matrix_width = 0;
|
int numlayers = 0, numresolution = 0, matrix_width = 0;
|
||||||
|
|
||||||
s = optarg;
|
s = opj_optarg;
|
||||||
sscanf(s, "%d", &numlayers);
|
sscanf(s, "%d", &numlayers);
|
||||||
s++;
|
s++;
|
||||||
if (numlayers > 9)
|
if (numlayers > 9)
|
||||||
|
@ -429,12 +429,12 @@ int main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
case 't': /* tiles */
|
case 't': /* tiles */
|
||||||
sscanf(optarg, "%d,%d", &j2k_parameters->cp_tdx, &j2k_parameters->cp_tdy);
|
sscanf(opj_optarg, "%d,%d", &j2k_parameters->cp_tdx, &j2k_parameters->cp_tdy);
|
||||||
j2k_parameters->tile_size_on = OPJ_TRUE;
|
j2k_parameters->tile_size_on = OPJ_TRUE;
|
||||||
break;
|
break;
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
case 'n': /* resolution */
|
case 'n': /* resolution */
|
||||||
sscanf(optarg, "%d", &j2k_parameters->numresolution);
|
sscanf(opj_optarg, "%d", &j2k_parameters->numresolution);
|
||||||
break;
|
break;
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
case 'c': /* precinct dimension */
|
case 'c': /* precinct dimension */
|
||||||
|
@ -442,7 +442,7 @@ int main(int argc, char **argv)
|
||||||
char sep;
|
char sep;
|
||||||
int res_spec = 0;
|
int res_spec = 0;
|
||||||
|
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
do {
|
do {
|
||||||
sep = 0;
|
sep = 0;
|
||||||
sscanf(s, "[%d,%d]%c", &j2k_parameters->prcw_init[res_spec],
|
sscanf(s, "[%d,%d]%c", &j2k_parameters->prcw_init[res_spec],
|
||||||
|
@ -460,7 +460,7 @@ int main(int argc, char **argv)
|
||||||
case 'b': /* code-block dimension */
|
case 'b': /* code-block dimension */
|
||||||
{
|
{
|
||||||
int cblockw_init = 0, cblockh_init = 0;
|
int cblockw_init = 0, cblockh_init = 0;
|
||||||
sscanf(optarg, "%d,%d", &cblockw_init, &cblockh_init);
|
sscanf(opj_optarg, "%d,%d", &cblockw_init, &cblockh_init);
|
||||||
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|
||||||
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
|
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -477,7 +477,7 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char progression[5];
|
char progression[5];
|
||||||
|
|
||||||
strncpy(progression, optarg, 5);
|
strncpy(progression, opj_optarg, 5);
|
||||||
j2k_parameters->prog_order = give_progression(progression);
|
j2k_parameters->prog_order = give_progression(progression);
|
||||||
if (j2k_parameters->prog_order == -1) {
|
if (j2k_parameters->prog_order == -1) {
|
||||||
fprintf(stderr, "Unrecognized progression order "
|
fprintf(stderr, "Unrecognized progression order "
|
||||||
|
@ -489,7 +489,7 @@ int main(int argc, char **argv)
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
case 's': /* subsampling factor */
|
case 's': /* subsampling factor */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "%d,%d", &j2k_parameters->subsampling_dx,
|
if (sscanf(opj_optarg, "%d,%d", &j2k_parameters->subsampling_dx,
|
||||||
&j2k_parameters->subsampling_dy) != 2) {
|
&j2k_parameters->subsampling_dy) != 2) {
|
||||||
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
|
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -499,7 +499,7 @@ int main(int argc, char **argv)
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
case 'd': /* coordonnate of the reference grid */
|
case 'd': /* coordonnate of the reference grid */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "%d,%d", &j2k_parameters->image_offset_x0,
|
if (sscanf(opj_optarg, "%d,%d", &j2k_parameters->image_offset_x0,
|
||||||
&j2k_parameters->image_offset_y0) != 2) {
|
&j2k_parameters->image_offset_y0) != 2) {
|
||||||
fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
|
fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
|
||||||
"error !! [-d x0,y0]\n");
|
"error !! [-d x0,y0]\n");
|
||||||
|
@ -518,7 +518,7 @@ int main(int argc, char **argv)
|
||||||
int numpocs = 0; /* number of progression order change (POC) default 0 */
|
int numpocs = 0; /* number of progression order change (POC) default 0 */
|
||||||
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
|
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
|
||||||
|
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
POC = j2k_parameters->POC;
|
POC = j2k_parameters->POC;
|
||||||
|
|
||||||
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
|
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
|
||||||
|
@ -548,7 +548,7 @@ int main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
case 'M': /* Mode switch pas tous au point !! */
|
case 'M': /* Mode switch pas tous au point !! */
|
||||||
if (sscanf(optarg, "%d", &value) == 1) {
|
if (sscanf(opj_optarg, "%d", &value) == 1) {
|
||||||
for (i = 0; i <= 5; i++) {
|
for (i = 0; i <= 5; i++) {
|
||||||
int cache = value & (1 << i);
|
int cache = value & (1 << i);
|
||||||
if (cache)
|
if (cache)
|
||||||
|
@ -559,7 +559,7 @@ int main(int argc, char **argv)
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
case 'R': /* ROI */
|
case 'R': /* ROI */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "OI:c=%d,U=%d", &j2k_parameters->roi_compno,
|
if (sscanf(opj_optarg, "OI:c=%d,U=%d", &j2k_parameters->roi_compno,
|
||||||
&j2k_parameters->roi_shift) != 2) {
|
&j2k_parameters->roi_shift) != 2) {
|
||||||
fprintf(stderr, "ROI error !! [-ROI:c='compno',U='shift']\n");
|
fprintf(stderr, "ROI error !! [-ROI:c='compno',U='shift']\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -569,7 +569,7 @@ int main(int argc, char **argv)
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
case 'T': /* Tile offset */
|
case 'T': /* Tile offset */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "%d,%d", &j2k_parameters->cp_tx0, &j2k_parameters->cp_ty0) != 2) {
|
if (sscanf(opj_optarg, "%d,%d", &j2k_parameters->cp_tx0, &j2k_parameters->cp_ty0) != 2) {
|
||||||
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
|
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -578,9 +578,9 @@ int main(int argc, char **argv)
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
case 'C': /* Add a comment */
|
case 'C': /* Add a comment */
|
||||||
{
|
{
|
||||||
j2k_parameters->cp_comment = (char*)malloc(strlen(optarg) + 1);
|
j2k_parameters->cp_comment = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
if(j2k_parameters->cp_comment) {
|
if(j2k_parameters->cp_comment) {
|
||||||
strcpy(j2k_parameters->cp_comment, optarg);
|
strcpy(j2k_parameters->cp_comment, opj_optarg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -593,7 +593,7 @@ int main(int argc, char **argv)
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
case 'W': /* Width and Height and Cb and Cr subsampling in case of YUV format files */
|
case 'W': /* Width and Height and Cb and Cr subsampling in case of YUV format files */
|
||||||
if (sscanf
|
if (sscanf
|
||||||
(optarg, "%d,%d,%d,%d", &mj2_parameters.w, &mj2_parameters.h, &mj2_parameters.CbCr_subsampling_dx,
|
(opj_optarg, "%d,%d,%d,%d", &mj2_parameters.w, &mj2_parameters.h, &mj2_parameters.CbCr_subsampling_dx,
|
||||||
&mj2_parameters.CbCr_subsampling_dy) != 4) {
|
&mj2_parameters.CbCr_subsampling_dy) != 4) {
|
||||||
fprintf(stderr, "-W argument error");
|
fprintf(stderr, "-W argument error");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -601,14 +601,14 @@ int main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
case 'F': /* Video frame rate */
|
case 'F': /* Video frame rate */
|
||||||
if (sscanf(optarg, "%d", &mj2_parameters.frame_rate) != 1) {
|
if (sscanf(opj_optarg, "%d", &mj2_parameters.frame_rate) != 1) {
|
||||||
fprintf(stderr, "-F argument error");
|
fprintf(stderr, "-F argument error");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
case 'D': /* Depth: the precision */
|
case 'D': /* Depth: the precision */
|
||||||
if(sscanf(optarg, "%d", &prec) != 1) prec = 0;
|
if(sscanf(opj_optarg, "%d", &prec) != 1) prec = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -16,7 +16,7 @@ can be bound by the Open JPEG open-source license and disclaimer, expressed else
|
||||||
|
|
||||||
#include "mj2_to_metadata.h"
|
#include "mj2_to_metadata.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "getopt.h"
|
#include "opj_getopt.h"
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,7 @@
|
||||||
Name="MJ2 Header Files"
|
Name="MJ2 Header Files"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath="compat\getopt.h"
|
RelativePath="compat\opj_getopt.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
|
@ -232,7 +232,7 @@
|
||||||
Name="MJ2 Source Files"
|
Name="MJ2 Source Files"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath="compat\getopt.c"
|
RelativePath="compat\opj_getopt.c"
|
||||||
>
|
>
|
||||||
<FileConfiguration
|
<FileConfiguration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32"
|
||||||
|
|
|
@ -9,23 +9,11 @@ INCLUDE_DIRECTORIES(${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||||
)
|
)
|
||||||
|
|
||||||
# First thing define the common source:
|
# First thing define the common source:
|
||||||
SET(comparePGXimages_SRCS comparePGXimages.c ${OPENJPEG_SOURCE_DIR}/applications/codec/convert.c)
|
SET(comparePGXimages_SRCS comparePGXimages.c ${OPENJPEG_SOURCE_DIR}/applications/codec/convert.c ${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c)
|
||||||
|
|
||||||
SET(compare_dump_files_SRCS compare_dump_files.c)
|
SET(compare_dump_files_SRCS compare_dump_files.c ${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c)
|
||||||
|
|
||||||
# If not getopt was found then add it to the exe:
|
SET(compareRAWimages_SRCS compareRAWimages.c ${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c)
|
||||||
IF(DONT_HAVE_GETOPT)
|
|
||||||
message("dont have getopt, we will add it")
|
|
||||||
SET(comparePGXimages_SRCS
|
|
||||||
${comparePGXimages_SRCS}
|
|
||||||
${OPENJPEG_SOURCE_DIR}/applications/common/getopt.c
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(compare_dump_files_SRCS
|
|
||||||
${compare_dump_files_SRCS}
|
|
||||||
${OPENJPEG_SOURCE_DIR}/applications/common/getopt.c
|
|
||||||
)
|
|
||||||
ENDIF(DONT_HAVE_GETOPT)
|
|
||||||
|
|
||||||
ADD_EXECUTABLE(comparePGXimages ${comparePGXimages_SRCS})
|
ADD_EXECUTABLE(comparePGXimages ${comparePGXimages_SRCS})
|
||||||
TARGET_LINK_LIBRARIES(comparePGXimages ${OPENJPEG_LIBRARY_NAME}
|
TARGET_LINK_LIBRARIES(comparePGXimages ${OPENJPEG_LIBRARY_NAME}
|
||||||
|
@ -36,6 +24,8 @@ TARGET_LINK_LIBRARIES(comparePGXimages ${OPENJPEG_LIBRARY_NAME}
|
||||||
|
|
||||||
ADD_EXECUTABLE(compare_dump_files ${compare_dump_files_SRCS})
|
ADD_EXECUTABLE(compare_dump_files ${compare_dump_files_SRCS})
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(compareRAWimages ${compareRAWimages_SRCS})
|
||||||
|
|
||||||
# No image send to the dashboard if lib PNG is not available.
|
# No image send to the dashboard if lib PNG is not available.
|
||||||
IF(NOT HAVE_LIBPNG)
|
IF(NOT HAVE_LIBPNG)
|
||||||
MESSAGE(WARNING "Lib PNG seems to be not available: if you want run the non-regression tests with images reported to the dashboard, you need it (try BUILD_THIRDPARTY)")
|
MESSAGE(WARNING "Lib PNG seems to be not available: if you want run the non-regression tests with images reported to the dashboard, you need it (try BUILD_THIRDPARTY)")
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "opj_config.h"
|
#include "opj_config.h"
|
||||||
#include "getopt.h"
|
#include "opj_getopt.h"
|
||||||
|
|
||||||
#include "openjpeg.h"
|
#include "openjpeg.h"
|
||||||
#include "format_defs.h"
|
#include "format_defs.h"
|
||||||
|
@ -110,60 +110,60 @@ int parse_cmdline_cmp(int argc, char **argv, test_cmp_parameters* param)
|
||||||
param->tabPEAKvalues = NULL;
|
param->tabPEAKvalues = NULL;
|
||||||
param->nr_flag = 0;
|
param->nr_flag = 0;
|
||||||
|
|
||||||
opterr = 0;
|
opj_opterr = 0;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, optlist)) != -1)
|
while ((c = opj_getopt(argc, argv, optlist)) != -1)
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 'b':
|
case 'b':
|
||||||
sizemembasefile = (int)strlen(optarg)+1;
|
sizemembasefile = (int)strlen(opj_optarg)+1;
|
||||||
param->base_filename = (char*) malloc(sizemembasefile);
|
param->base_filename = (char*) malloc(sizemembasefile);
|
||||||
param->base_filename[0] = '\0';
|
param->base_filename[0] = '\0';
|
||||||
strncpy(param->base_filename, optarg, strlen(optarg));
|
strncpy(param->base_filename, opj_optarg, strlen(opj_optarg));
|
||||||
param->base_filename[strlen(optarg)] = '\0';
|
param->base_filename[strlen(opj_optarg)] = '\0';
|
||||||
//printf("param->base_filename = %s [%d / %d]\n", param->base_filename, strlen(param->base_filename), sizemembasefile );
|
//printf("param->base_filename = %s [%d / %d]\n", param->base_filename, strlen(param->base_filename), sizemembasefile );
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
sizememtestfile = (int) strlen(optarg) + 1;
|
sizememtestfile = (int) strlen(opj_optarg) + 1;
|
||||||
param->test_filename = (char*) malloc(sizememtestfile);
|
param->test_filename = (char*) malloc(sizememtestfile);
|
||||||
param->test_filename[0] = '\0';
|
param->test_filename[0] = '\0';
|
||||||
strncpy(param->test_filename, optarg, strlen(optarg));
|
strncpy(param->test_filename, opj_optarg, strlen(opj_optarg));
|
||||||
param->test_filename[strlen(optarg)] = '\0';
|
param->test_filename[strlen(opj_optarg)] = '\0';
|
||||||
//printf("param->test_filename = %s [%d / %d]\n", param->test_filename, strlen(param->test_filename), sizememtestfile);
|
//printf("param->test_filename = %s [%d / %d]\n", param->test_filename, strlen(param->test_filename), sizememtestfile);
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
param->nbcomp = atoi(optarg);
|
param->nbcomp = atoi(opj_optarg);
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
MSElistvalues = optarg;
|
MSElistvalues = opj_optarg;
|
||||||
flagM = 1;
|
flagM = 1;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
PEAKlistvalues = optarg;
|
PEAKlistvalues = opj_optarg;
|
||||||
flagP = 1;
|
flagP = 1;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
param->nr_flag = 1;
|
param->nr_flag = 1;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
separatorList = optarg;
|
separatorList = opj_optarg;
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
if ((optopt == 'b') || (optopt == 't') || (optopt == 'n') || (optopt == 'p') || (optopt == 'm') || (optopt
|
if ((opj_optopt == 'b') || (opj_optopt == 't') || (opj_optopt == 'n') || (opj_optopt == 'p') || (opj_optopt == 'm') || (opj_optopt
|
||||||
== 's'))
|
== 's'))
|
||||||
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
|
fprintf(stderr, "Option -%c requires an argument.\n", opj_optopt);
|
||||||
else
|
else
|
||||||
if (isprint(optopt)) fprintf(stderr, "Unknown option `-%c'.\n", optopt);
|
if (isprint(opj_optopt)) fprintf(stderr, "Unknown option `-%c'.\n", opj_optopt);
|
||||||
else fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
|
else fprintf(stderr, "Unknown option character `\\x%x'.\n", opj_optopt);
|
||||||
return 1;
|
return 1;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "WARNING -> this option is not valid \"-%c %s\"\n", c, optarg);
|
fprintf(stderr, "WARNING -> this option is not valid \"-%c %s\"\n", c, opj_optarg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind != argc)
|
if (opj_optind != argc)
|
||||||
{
|
{
|
||||||
for (index = optind; index < argc; index++)
|
for (index = opj_optind; index < argc; index++)
|
||||||
fprintf(stderr,"Non-option argument %s\n", argv[index]);
|
fprintf(stderr,"Non-option argument %s\n", argv[index]);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,192 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2011, Mickael Savinaud, Communications & Systemes <mickael.savinaud@c-s.fr>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* compareRAWimages.c
|
||||||
|
*
|
||||||
|
* Created on: 31 August 2011
|
||||||
|
* Author: mickael
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "opj_getopt.h"
|
||||||
|
|
||||||
|
void compareRAWimages_help_display(void);
|
||||||
|
|
||||||
|
typedef struct test_cmp_parameters
|
||||||
|
{
|
||||||
|
/** */
|
||||||
|
char* base_filename;
|
||||||
|
/** */
|
||||||
|
char* test_filename;
|
||||||
|
} test_cmp_parameters;
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Command line help function
|
||||||
|
*******************************************************************************/
|
||||||
|
void compareRAWimages_help_display(void) {
|
||||||
|
fprintf(stdout,"\nList of parameters for the comparePGX function \n");
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
fprintf(stdout," -b \t REQUIRED \t filename to the reference/baseline RAW image \n");
|
||||||
|
fprintf(stdout," -t \t REQUIRED \t filename to the test RAW image\n");
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Parse command line
|
||||||
|
*******************************************************************************/
|
||||||
|
int parse_cmdline_cmp(int argc, char **argv, test_cmp_parameters* param)
|
||||||
|
{
|
||||||
|
int sizemembasefile, sizememtestfile;
|
||||||
|
int index;
|
||||||
|
const char optlist[] = "b:t:";
|
||||||
|
int c;
|
||||||
|
|
||||||
|
// Init parameters
|
||||||
|
param->base_filename = NULL;
|
||||||
|
param->test_filename = NULL;
|
||||||
|
|
||||||
|
opj_opterr = 0;
|
||||||
|
while ((c = getopt(argc, argv, optlist)) != -1)
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case 'b':
|
||||||
|
sizemembasefile = (int)strlen(opj_optarg)+1;
|
||||||
|
param->base_filename = (char*) malloc(sizemembasefile);
|
||||||
|
param->base_filename[0] = '\0';
|
||||||
|
strncpy(param->base_filename, opj_optarg, strlen(opj_optarg));
|
||||||
|
param->base_filename[strlen(opj_optarg)] = '\0';
|
||||||
|
//printf("param->base_filename = %s [%d / %d]\n", param->base_filename, strlen(param->base_filename), sizemembasefile );
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
sizememtestfile = (int) strlen(opj_optarg) + 1;
|
||||||
|
param->test_filename = (char*) malloc(sizememtestfile);
|
||||||
|
param->test_filename[0] = '\0';
|
||||||
|
strncpy(param->test_filename, opj_optarg, strlen(opj_optarg));
|
||||||
|
param->test_filename[strlen(opj_optarg)] = '\0';
|
||||||
|
//printf("param->test_filename = %s [%d / %d]\n", param->test_filename, strlen(param->test_filename), sizememtestfile);
|
||||||
|
break;
|
||||||
|
case '?':
|
||||||
|
if ((opj_optopt == 'b') || (opj_optopt == 't'))
|
||||||
|
fprintf(stderr, "Option -%c requires an argument.\n", opj_optopt);
|
||||||
|
else
|
||||||
|
if (isprint(opj_optopt)) fprintf(stderr, "Unknown option `-%c'.\n", opj_optopt);
|
||||||
|
else fprintf(stderr, "Unknown option character `\\x%x'.\n", opj_optopt);
|
||||||
|
return 1;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "WARNING -> this option is not valid \"-%c %s\"\n", c, opj_optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opj_optind != argc) {
|
||||||
|
for (index = opj_optind; index < argc; index++)
|
||||||
|
fprintf(stderr,"Non-option argument %s\n", argv[index]);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* MAIN
|
||||||
|
*******************************************************************************/
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
test_cmp_parameters inParam;
|
||||||
|
FILE *file_test=NULL, *file_base=NULL;
|
||||||
|
unsigned char equal = 1;
|
||||||
|
|
||||||
|
// Get parameters from command line
|
||||||
|
if (parse_cmdline_cmp(argc, argv, &inParam) == EXIT_FAILURE)
|
||||||
|
{
|
||||||
|
compareRAWimages_help_display();
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
file_test = fopen(inParam.test_filename, "rb");
|
||||||
|
if (!file_test) {
|
||||||
|
fprintf(stderr, "Failed to open %s for reading !!\n", inParam.test_filename);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
file_base = fopen(inParam.base_filename, "rb");
|
||||||
|
if (!file_base) {
|
||||||
|
fprintf(stderr, "Failed to open %s for reading !!\n", inParam.base_filename);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read simultaneously the two files
|
||||||
|
while (equal)
|
||||||
|
{
|
||||||
|
unsigned char value_test = 0;
|
||||||
|
unsigned char eof_test = 0;
|
||||||
|
unsigned char value_base = 0;
|
||||||
|
unsigned char eof_base = 0;
|
||||||
|
|
||||||
|
// Read one byte
|
||||||
|
if (!fread(&value_test, 1, 1, file_test)) {
|
||||||
|
eof_test = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read one byte
|
||||||
|
if (!fread(&value_base, 1, 1, file_base)) {
|
||||||
|
eof_base = 1;;
|
||||||
|
}
|
||||||
|
|
||||||
|
// End of file reached by the two files?
|
||||||
|
if (eof_test && eof_base)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// End of file reached only by one file?
|
||||||
|
if (eof_test || eof_base)
|
||||||
|
{
|
||||||
|
fprintf(stdout,"Files have different sizes.\n");
|
||||||
|
equal = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Binary values are equal?
|
||||||
|
if (value_test != value_base)
|
||||||
|
{
|
||||||
|
fprintf(stdout,"Binary values read in the file are different.\n");
|
||||||
|
equal = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(file_test);
|
||||||
|
fclose(file_base);
|
||||||
|
|
||||||
|
if (equal)
|
||||||
|
{
|
||||||
|
fprintf(stdout,"---- TEST SUCCEED: Files are equal ----\n");
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
|
@ -37,7 +37,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "getopt.h"
|
#include "opj_getopt.h"
|
||||||
|
|
||||||
typedef struct test_cmp_parameters
|
typedef struct test_cmp_parameters
|
||||||
{
|
{
|
||||||
|
@ -71,42 +71,42 @@ int parse_cmdline_cmp(int argc, char **argv, test_cmp_parameters* param)
|
||||||
param->base_filename = NULL;
|
param->base_filename = NULL;
|
||||||
param->test_filename = NULL;
|
param->test_filename = NULL;
|
||||||
|
|
||||||
opterr = 0;
|
opj_opterr = 0;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, optlist)) != -1)
|
while ((c = opj_getopt(argc, argv, optlist)) != -1)
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 'b':
|
case 'b':
|
||||||
sizemembasefile = (int)strlen(optarg)+1;
|
sizemembasefile = (int)strlen(opj_optarg)+1;
|
||||||
param->base_filename = (char*) malloc(sizemembasefile);
|
param->base_filename = (char*) malloc(sizemembasefile);
|
||||||
param->base_filename[0] = '\0';
|
param->base_filename[0] = '\0';
|
||||||
strncpy(param->base_filename, optarg, strlen(optarg));
|
strncpy(param->base_filename, opj_optarg, strlen(opj_optarg));
|
||||||
param->base_filename[strlen(optarg)] = '\0';
|
param->base_filename[strlen(opj_optarg)] = '\0';
|
||||||
//printf("param->base_filename = %s [%d / %d]\n", param->base_filename, strlen(param->base_filename), sizemembasefile );
|
//printf("param->base_filename = %s [%d / %d]\n", param->base_filename, strlen(param->base_filename), sizemembasefile );
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
sizememtestfile = (int) strlen(optarg) + 1;
|
sizememtestfile = (int) strlen(opj_optarg) + 1;
|
||||||
param->test_filename = (char*) malloc(sizememtestfile);
|
param->test_filename = (char*) malloc(sizememtestfile);
|
||||||
param->test_filename[0] = '\0';
|
param->test_filename[0] = '\0';
|
||||||
strncpy(param->test_filename, optarg, strlen(optarg));
|
strncpy(param->test_filename, opj_optarg, strlen(opj_optarg));
|
||||||
param->test_filename[strlen(optarg)] = '\0';
|
param->test_filename[strlen(opj_optarg)] = '\0';
|
||||||
//printf("param->test_filename = %s [%d / %d]\n", param->test_filename, strlen(param->test_filename), sizememtestfile);
|
//printf("param->test_filename = %s [%d / %d]\n", param->test_filename, strlen(param->test_filename), sizememtestfile);
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
if ( (optopt == 'b') || (optopt == 't') )
|
if ( (opj_optopt == 'b') || (opj_optopt == 't') )
|
||||||
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
|
fprintf(stderr, "Option -%c requires an argument.\n", opj_optopt);
|
||||||
else
|
else
|
||||||
if (isprint(optopt)) fprintf(stderr, "Unknown option `-%c'.\n", optopt);
|
if (isprint(opj_optopt)) fprintf(stderr, "Unknown option `-%c'.\n", opj_optopt);
|
||||||
else fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
|
else fprintf(stderr, "Unknown option character `\\x%x'.\n", opj_optopt);
|
||||||
return 1;
|
return 1;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "WARNING -> this option is not valid \"-%c %s\"\n", c, optarg);
|
fprintf(stderr, "WARNING -> this option is not valid \"-%c %s\"\n", c, opj_optarg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind != argc)
|
if (opj_optind != argc)
|
||||||
{
|
{
|
||||||
for (index = optind; index < argc; index++)
|
for (index = opj_optind; index < argc; index++)
|
||||||
fprintf(stderr,"Non-option argument %s\n", argv[index]);
|
fprintf(stderr,"Non-option argument %s\n", argv[index]);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,6 @@ int main(int argc, char **argv)
|
||||||
size_t nbytes = 2048;
|
size_t nbytes = 2048;
|
||||||
int CRLF_shift=1;
|
int CRLF_shift=1;
|
||||||
char *strbase, *strtest, *strbase_d, *strtest_d;
|
char *strbase, *strtest, *strbase_d, *strtest_d;
|
||||||
char *return_value_fgets;
|
|
||||||
|
|
||||||
printf("Files differ at line %lu:\n", l);
|
printf("Files differ at line %lu:\n", l);
|
||||||
fseek(fbase,pos,SEEK_SET);
|
fseek(fbase,pos,SEEK_SET);
|
||||||
|
@ -207,16 +206,14 @@ int main(int argc, char **argv)
|
||||||
strbase = (char *) malloc(nbytes + 1);
|
strbase = (char *) malloc(nbytes + 1);
|
||||||
strtest = (char *) malloc(nbytes + 1);
|
strtest = (char *) malloc(nbytes + 1);
|
||||||
|
|
||||||
return_value_fgets = fgets(strbase, nbytes, fbase);
|
if (fgets(strbase, nbytes, fbase) == NULL)
|
||||||
if (!strcmp(return_value_fgets,strbase))
|
fprintf(stderr,"\nWARNING: fgets return a NULL value");
|
||||||
fprintf(stderr,"\nWARNING: fgets return a value different that the first argument");
|
else
|
||||||
free(return_value_fgets);
|
{
|
||||||
|
if (fgets(strtest, nbytes, ftest) == NULL)
|
||||||
return_value_fgets = fgets(strtest, nbytes, ftest);
|
fprintf(stderr,"\nWARNING: fgets return a NULL value");
|
||||||
if (!strcmp(return_value_fgets,strtest))
|
else
|
||||||
fprintf(stderr,"\nWARNING: fgets return a value different that the first argument");
|
{
|
||||||
free(return_value_fgets);
|
|
||||||
|
|
||||||
strbase_d = (char *) malloc(strlen(strbase)+1);
|
strbase_d = (char *) malloc(strlen(strbase)+1);
|
||||||
strtest_d = (char *) malloc(strlen(strtest)+1);
|
strtest_d = (char *) malloc(strlen(strtest)+1);
|
||||||
strncpy(strbase_d, strbase, strlen(strbase)-1);
|
strncpy(strbase_d, strbase, strlen(strbase)-1);
|
||||||
|
@ -224,10 +221,14 @@ int main(int argc, char **argv)
|
||||||
strbase_d[strlen(strbase)-1] = '\0';
|
strbase_d[strlen(strbase)-1] = '\0';
|
||||||
strtest_d[strlen(strtest)-CRLF_shift] = '\0';
|
strtest_d[strlen(strtest)-CRLF_shift] = '\0';
|
||||||
printf("<%s> vs. <%s>\n", strbase_d, strtest_d);
|
printf("<%s> vs. <%s>\n", strbase_d, strtest_d);
|
||||||
|
free(strbase_d);free(strtest_d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
free(strbase);free(strtest);
|
free(strbase);free(strtest);
|
||||||
free(strbase_d);free(strtest_d);
|
|
||||||
same = 0;
|
same = 0;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -51,4 +51,166 @@ FOREACH(filepath ${OPJ_DATA_NR_LIST})
|
||||||
# PROPERTIES DEPENDS
|
# PROPERTIES DEPENDS
|
||||||
# NR-${filename}-decode)
|
# NR-${filename}-decode)
|
||||||
|
|
||||||
|
<<<<<<< .working
|
||||||
|
ENDFOREACH(filepath)=======
|
||||||
ENDFOREACH(filepath)
|
ENDFOREACH(filepath)
|
||||||
|
|
||||||
|
|
||||||
|
# TEST ENCODER SUITE
|
||||||
|
# Read a input file to know which files processed and with which options.
|
||||||
|
|
||||||
|
IF (NOT WIN32)
|
||||||
|
CONFIGURE_FILE("opj_ref_decode_cmd.sh.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/opj_ref_decode_cmd.sh"
|
||||||
|
@ONLY)
|
||||||
|
ENDIF (NOT WIN32)
|
||||||
|
|
||||||
|
string(COMPARE EQUAL ${REF_DECODER_BIN_PATH} "NOTFOUND" REF_DECODER_NOTFOUND)
|
||||||
|
IF (REF_DECODER_NOTFOUND)
|
||||||
|
MESSAGE(STATUS "REF_DECODER_BIN_PATH not found, if you want all the encoding tests suite please provide a regular path")
|
||||||
|
ENDIF (REF_DECODER_NOTFOUND)
|
||||||
|
|
||||||
|
|
||||||
|
# Read the file into a list
|
||||||
|
FILE(STRINGS encoder_test_suite.txt OPJ_TEST_ENC_CMD_LINE_LIST)
|
||||||
|
|
||||||
|
SET(it_test 0)
|
||||||
|
|
||||||
|
FOREACH(OPJ_TEST_ENC_CMD_LINE ${OPJ_TEST_ENC_CMD_LINE_LIST})
|
||||||
|
math(EXPR it_test "${it_test}+1" )
|
||||||
|
|
||||||
|
#message(STATUS ${OPJ_TEST_ENC_CMD_LINE})
|
||||||
|
|
||||||
|
string(REPLACE " " ";" CMD_ARG_LIST ${OPJ_TEST_ENC_CMD_LINE})
|
||||||
|
|
||||||
|
#message(STATUS "list = ${CMD_ARG_LIST}")
|
||||||
|
|
||||||
|
list(GET CMD_ARG_LIST 0 EXE_NAME)
|
||||||
|
string(COMPARE EQUAL ${EXE_NAME} "image_to_j2k" EXE_NAME_FOUND)
|
||||||
|
IF(EXE_NAME_FOUND)
|
||||||
|
list(REMOVE_AT CMD_ARG_LIST 0)
|
||||||
|
ELSE(EXE_NAME_FOUND)
|
||||||
|
string(COMPARE EQUAL ${EXE_NAME} "#" IGNORE_LINE_FOUND)
|
||||||
|
IF(IGNORE_LINE_FOUND)
|
||||||
|
message( STATUS "Current line is ignored: ${OPJ_TEST_ENC_CMD_LINE}")
|
||||||
|
ELSE(IGNORE_LINE_FOUND)
|
||||||
|
message( FATAL_ERROR "${EXE_ARG} is not the right executable name to encode file (try to use image_to_j2k)")
|
||||||
|
ENDIF(IGNORE_LINE_FOUND)
|
||||||
|
ENDIF(EXE_NAME_FOUND)
|
||||||
|
|
||||||
|
IF(NOT IGNORE_LINE_FOUND)
|
||||||
|
SET(CMD_ARG_LIST_2 "")
|
||||||
|
SET(ARG_POS 0)
|
||||||
|
SET(INPUT_ARG_POS 0)
|
||||||
|
SET(OUTPUT_ARG_POS 0)
|
||||||
|
|
||||||
|
FOREACH(CMD_ARG_ELT ${CMD_ARG_LIST})
|
||||||
|
math(EXPR ARG_POS "${ARG_POS}+1" )
|
||||||
|
|
||||||
|
# Will work only with cmake version > 2.8.4
|
||||||
|
#message(STATUS "${CMD_ARG_ELT}")
|
||||||
|
#string(FIND "${CMD_ARG_ELT}" "-i input/" INPUT_ARG_FOUND)
|
||||||
|
#message(STATUS "pos = ${INPUT_ARG_FOUND}")
|
||||||
|
#IF(INPUT_ARG_FOUND)
|
||||||
|
# string(SUBSTRING ${CMD_ARG_ELT} INPUT_ARG_FOUND -1 filename_input)
|
||||||
|
# message(STATUS "filename = ${filename_input}")
|
||||||
|
#ELSE(INPUT_ARG_FOUND)
|
||||||
|
# message( FATAL_ERROR "Not found a input image into the list of arguments")
|
||||||
|
#ENDIF(INPUT_ARG_FOUND)
|
||||||
|
|
||||||
|
|
||||||
|
string(COMPARE EQUAL ${CMD_ARG_ELT} "-i" INPUT_ARG_FOUND)
|
||||||
|
IF(INPUT_ARG_FOUND)
|
||||||
|
SET(INPUT_ARG_POS ${ARG_POS})
|
||||||
|
SET(INPUT_ARG_FOUND 0)
|
||||||
|
ENDIF(INPUT_ARG_FOUND)
|
||||||
|
|
||||||
|
string(COMPARE EQUAL ${CMD_ARG_ELT} "-o" OUTPUT_ARG_FOUND)
|
||||||
|
IF(OUTPUT_ARG_FOUND)
|
||||||
|
SET(OUTPUT_ARG_POS ${ARG_POS})
|
||||||
|
SET(OUTPUT_ARG_FOUND 0)
|
||||||
|
ENDIF(OUTPUT_ARG_FOUND)
|
||||||
|
|
||||||
|
string(REPLACE "input/" "${INPUT_NR}/" CMD_ARG_ELT ${CMD_ARG_ELT})
|
||||||
|
string(REPLACE "temp/" "${TEMP}/" CMD_ARG_ELT ${CMD_ARG_ELT})
|
||||||
|
|
||||||
|
list (APPEND CMD_ARG_LIST_2 ${CMD_ARG_ELT})
|
||||||
|
|
||||||
|
ENDFOREACH(CMD_ARG_ELT)
|
||||||
|
|
||||||
|
list(GET CMD_ARG_LIST_2 ${INPUT_ARG_POS} INPUT_FILENAME)
|
||||||
|
get_filename_component(INPUT_FILENAME_NAME ${INPUT_FILENAME} NAME)
|
||||||
|
list(GET CMD_ARG_LIST_2 ${OUTPUT_ARG_POS} OUTPUT_FILENAME)
|
||||||
|
get_filename_component(OUTPUT_FILENAME_NAME_WE ${OUTPUT_FILENAME} NAME_WE)
|
||||||
|
|
||||||
|
|
||||||
|
# Encode an image into the jpeg2000 format
|
||||||
|
ADD_TEST(NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-encode
|
||||||
|
${EXECUTABLE_OUTPUT_PATH}/${EXE_NAME}
|
||||||
|
${CMD_ARG_LIST_2}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Dump the encoding file
|
||||||
|
ADD_TEST(NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-dump
|
||||||
|
${EXECUTABLE_OUTPUT_PATH}/j2k_dump
|
||||||
|
-i ${OUTPUT_FILENAME}
|
||||||
|
-o ${OUTPUT_FILENAME}-ENC-${it_test}.txt
|
||||||
|
)
|
||||||
|
SET_TESTS_PROPERTIES(NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-dump
|
||||||
|
PROPERTIES DEPENDS
|
||||||
|
NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-encode)
|
||||||
|
|
||||||
|
# Compare the dump file with the baseline
|
||||||
|
ADD_TEST(NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-compare_dump2base
|
||||||
|
${EXECUTABLE_OUTPUT_PATH}/compare_dump_files
|
||||||
|
-b ${BASELINE_NR}/opj_${OUTPUT_FILENAME_NAME_WE}-ENC-${it_test}.txt
|
||||||
|
-t ${OUTPUT_FILENAME}-ENC-${it_test}.txt
|
||||||
|
)
|
||||||
|
|
||||||
|
SET_TESTS_PROPERTIES(NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-compare_dump2base
|
||||||
|
PROPERTIES DEPENDS
|
||||||
|
NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-dump)
|
||||||
|
|
||||||
|
# Decode the encoding file with kakadu expand command
|
||||||
|
IF (NOT REF_DECODER_NOTFOUND)
|
||||||
|
IF (NOT WIN32)
|
||||||
|
# Need a bash script to export the path of the kakadu library into PATH
|
||||||
|
ADD_TEST( NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-decode-ref
|
||||||
|
bash ${CMAKE_CURRENT_BINARY_DIR}/opj_ref_decode_cmd.sh
|
||||||
|
-i ${OUTPUT_FILENAME}
|
||||||
|
-o ${OUTPUT_FILENAME}.raw
|
||||||
|
)
|
||||||
|
ELSE (NOT WIN32)
|
||||||
|
ADD_TEST(NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-decode-ref
|
||||||
|
${REF_DECODER_BIN_PATH}/kdu_expand
|
||||||
|
-i ${OUTPUT_FILENAME}
|
||||||
|
-o ${OUTPUT_FILENAME}.raw
|
||||||
|
)
|
||||||
|
ENDIF (NOT WIN32)
|
||||||
|
|
||||||
|
SET_TESTS_PROPERTIES(NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-decode-ref
|
||||||
|
PROPERTIES DEPENDS
|
||||||
|
NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-encode)
|
||||||
|
|
||||||
|
# Compare the decoding file with baseline generated from the kdu_expand and baseline.j2k
|
||||||
|
ADD_TEST(NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-compare_dec-ref-out2base
|
||||||
|
${EXECUTABLE_OUTPUT_PATH}/compareRAWimages
|
||||||
|
#-b ${BASELINE_NR}/opj_${OUTPUT_FILENAME_NAME_WE}-ENC-${it_test}.raw
|
||||||
|
-b ${BASELINE_NR}/opj_${OUTPUT_FILENAME_NAME_WE}-ENC-${it_test}.raw
|
||||||
|
-t ${OUTPUT_FILENAME}.raw
|
||||||
|
)
|
||||||
|
|
||||||
|
SET_TESTS_PROPERTIES(NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-compare_dec-ref-out2base
|
||||||
|
PROPERTIES DEPENDS
|
||||||
|
NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-decode-ref)
|
||||||
|
|
||||||
|
ENDIF (NOT REF_DECODER_NOTFOUND)
|
||||||
|
|
||||||
|
ENDIF(NOT IGNORE_LINE_FOUND)
|
||||||
|
|
||||||
|
ENDFOREACH(OPJ_TEST_ENC_CMD_LINE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
>>>>>>> .merge-right.r907
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
image_to_j2k -i input/Bretagne1.ppm -o temp/Bretagne1_0.j2k -r 200,50,10
|
||||||
|
image_to_j2k -i input/Bretagne1.ppm -o temp/Bretagne1_1.j2k -q 30,35,40 -n 2
|
||||||
|
image_to_j2k -i input/Bretagne1.ppm -o temp/Bretagne1_2.j2k -q 30,35,40 -b 16,16 -c [64,64]
|
||||||
|
image_to_j2k -i input/Bretagne2.ppm -o temp/Bretagne2_0.j2k -c [128,128],[128,128],[128,128] -r 100,20,2 -t 640,480 -b 32,32
|
||||||
|
image_to_j2k -i input/Bretagne2.ppm -o temp/Bretagne2_1.j2k -t 127,127 -p PCRL
|
||||||
|
image_to_j2k -i input/Bretagne2.ppm -o temp/Bretagne2_2.j2k -s 2,2 -SOP
|
||||||
|
image_to_j2k -i input/Bretagne2.ppm -o temp/Bretagne2_3.j2k -EPH -M 38
|
||||||
|
image_to_j2k -i input/Bretagne2.ppm -o temp/Bretagne2_4.j2k -d 150,300 -r 800
|
||||||
|
image_to_j2k -i input/Cevennes1.bmp -o temp/Cevennes1.j2k -r 10
|
||||||
|
image_to_j2k -i input/Cevennes2.ppm -o temp/Cevennes2.jp2 -r 50
|
||||||
|
image_to_j2k -i input/Rome.bmp -o temp/Rome.jp2 -q 30,35,50 -p LRCP -n 3
|
||||||
|
# image_to_j2k -i input/X_4_2K_24_185_CBR_WB_000.tif -o temp/X_4_2K_24_185_CBR_WB_000.j2k -cinema2K 24
|
||||||
|
# image_to_j2k -i input/X_5_2K_24_235_CBR_STEM24_000.tif -o temp/X_5_2K_24_235_CBR_STEM24_000.j2k -cinema2K 24
|
||||||
|
# image_to_j2k -i input/X_6_2K_24_FULL_CBR_CIRCLE_000.tif -o temp/X_6_2K_24_FULL_CBR_CIRCLE_000.j2k -cinema2K 24
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
export LD_LIBRARY_PATH="@REF_DECODER_BIN_PATH@"
|
||||||
|
echo run following command: @REF_DECODER_BIN_PATH@/kdu_expand $@
|
||||||
|
@REF_DECODER_BIN_PATH@/kdu_expand $@
|
Loading…
Reference in New Issue