Compare commits

..

34 Commits

Author SHA1 Message Date
Antonin Descampe
8030b4d6df [tag2.1] fixed typo in NEWS 2014-04-29 12:58:10 +00:00
Mathieu Malaterre
bcbca6e8cc [2.1] Add CHANGES file 2014-04-29 07:12:46 +00:00
Mathieu Malaterre
7134a8eb26 [2.1] Create tag for 2.1.0 release 2014-04-29 07:02:13 +00:00
Mathieu Malaterre
cf77ede84c [2.1] Create the 2.1 branch 2014-04-29 06:58:23 +00:00
Antonin Descampe
45313a8dfa [trunk] fixed warning in j2k.c about sign conversion 2014-04-28 09:38:44 +00:00
Mathieu Malaterre
b08135e7c1 [trunk] Finalize API for openjpeg 2.1
public header will only contains minimal information: major, minor and build version
Prefix has been changed from OPENJPEG to OPJ for consistency
SOVERSION has been removed from header (ABI vs API info)
OPJ_VERSION string has been removed, since it is accessible already (PACKAGE_VERSION)
Fixes issue 342
2014-04-28 09:17:31 +00:00
Mathieu Malaterre
4bac8488df [trunk] Properly handle failure to compress (remove file)
Fixes issue 323
2014-04-28 07:54:33 +00:00
Mathieu Malaterre
de04302c15 [trunk] Missing endianess setting
Fixes issue 337
2014-04-28 07:44:39 +00:00
Mathieu Malaterre
997758f91c [trunk] properly handle pkg-config on non-UNIX hosts
Fixes issue 340
2014-04-28 07:34:26 +00:00
Mathieu Malaterre
763214f7c0 [trunk] Provide #ifdef blockers for OpenJPEG Version
Fixes issue 342
2014-04-28 07:32:35 +00:00
Antonin Descampe
77e8dad503 [trunk] fixed typo in NEWS 2014-04-27 21:31:32 +00:00
Antonin Descampe
1758445a75 [trunk] updated NEWS for 2.1.0 2014-04-25 09:22:49 +00:00
Mathieu Malaterre
7a77a8047d [trunk] Make sure OpenJPIP compiles on WIN32 2014-04-24 11:24:56 +00:00
Antonin Descampe
d8767cbcb7 [trunk] fixed reference to opj_stream_set_user_data_v3 in jpip sources. 2014-04-24 08:51:29 +00:00
Antonin Descampe
7924d3a456 [trunk]removed '-x' option for index file as long as it's broken 2014-04-23 15:19:57 +00:00
Antonin Descampe
ec84bafcd8 [trunk]re-formatted help display in executables 2014-04-23 14:09:20 +00:00
Antonin Descampe
08c09b74cf [trunk]formatted some messages. Removed -version option to disambiguate
with -v(erbose) option, added version info in help display
2014-04-23 09:12:30 +00:00
Antonin Descampe
7aece5e8e7 [trunk]Replaced deprecated opj_stream_set_user_data function from API
with its 'v3' version, and removed all other 'v3' suffixes from API.
2014-04-23 07:46:11 +00:00
Antonin Descampe
8d93eae64a [trunk] fixed some warning and errors formatting and add a '-version'
option to opj_compress and opj_decompress binaries
2014-04-22 21:22:49 +00:00
Antonin Descampe
9a3d660d1b [trunk] fixed warning related to r2837 and move new field at the end of
parameters structure.
2014-04-17 09:54:38 +00:00
Antonin Descampe
7199d9b5d3 [trunk] refactoring of rsiz, profiles, and extensions management 2014-04-17 09:31:37 +00:00
Antonin Descampe
d19a4ab676 [trunk] updated copyright and added copyright notice required by ISO, in each file; updated AUTHORS, NEWS 2014-04-03 15:30:57 +00:00
Antonin Descampe
f105cb5471 [trunk] removed debug message in CMakeLists.txt 2014-04-02 16:37:07 +00:00
Antonin Descampe
4db4198722 [trunk] fixed a bug triggering SEGFAULT on debug mode (uninitialized
structure)
2014-04-02 16:25:40 +00:00
Mathieu Malaterre
616a3345c4 [trunk] Properly copy/paste code from the autotools
gcc correctly fails compiling this code, I needed to move the code outside the main function to get the error. This actually match the autotools (incorrect) code. We'll see how they fix this code in future release.
This make the code compatible with previous openjpeg version and remove C99 requirement.
Fixes issue 316
2014-03-27 15:07:58 +00:00
Mathieu Malaterre
1f8d84a562 [trunk] Make sure to use long long (this is not C89). However this should be ok on most compilers nowadays
Update issue 316
2014-03-26 16:20:13 +00:00
Antonin Descampe
a54d757a3e [trunk] fixed warnings triggered on linux related to r2802 2014-03-26 15:17:17 +00:00
Mathieu Malaterre
b5eb374fb9 [trunk] Run test suite on issue 316 dataset
Update issue 316
2014-03-26 15:16:24 +00:00
Antonin Descampe
f1d69068c7 [trunk] add ability in opj_compress to input subsampled images through
'-F' (aka raw option). Let the user input raw images with 444, 422, 420
(etc) subsampling. To be used in conjunction with '-mct 0' option to
compress subsampled YCC images.
2014-03-26 14:26:49 +00:00
Mathieu Malaterre
ee130e2306 [trunk] Add small utilities to extract JP2 files from PDF 2014-03-26 11:52:01 +00:00
Mathieu Malaterre
9ba6bc6042 [trunk] Make sure to test value not pointer
Update issue 302
2014-03-25 16:34:59 +00:00
Antonin Descampe
5e1a0fad08 [trunk] fixed bug related to r2791 2014-03-25 15:35:33 +00:00
Mathieu Malaterre
c05118dc49 [trunk] Add sentinel in case list empty.
I was getting a cmake error `list sub-command REMOVE_ITEM requires list to be present`
2014-03-25 15:29:19 +00:00
Mathieu Malaterre
1adf89d5d2 [trunk] Import change from 2.0 branch 2014-03-25 15:21:53 +00:00
30 changed files with 1876 additions and 604 deletions

1116
CHANGES Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -29,8 +29,8 @@ include_regular_expression("^.*$")
#-----------------------------------------------------------------------------
# OPENJPEG version number, useful for packaging and doxygen doc:
set(OPENJPEG_VERSION_MAJOR 2)
set(OPENJPEG_VERSION_MINOR 0)
set(OPENJPEG_VERSION_BUILD 1)
set(OPENJPEG_VERSION_MINOR 1)
set(OPENJPEG_VERSION_BUILD 0)
set(OPENJPEG_VERSION
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
set(PACKAGE_VERSION
@@ -48,6 +48,7 @@ set(PACKAGE_VERSION
# 1.5.1 | 5
# 2.0 | 6
# 2.0.1 | 6
# 2.1 | 7
# above is the recommendation by the OPJ team. If you really need to override this default,
# you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
# cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg
@@ -94,6 +95,8 @@ endif()
# --------------------------------------------------------------------------
# Install directories
# Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
option(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
string(TOLOWER ${PROJECT_NAME} projectname)
set(OPENJPEG_INSTALL_SUBDIR "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
@@ -118,6 +121,7 @@ if(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
set(OPENJPEG_INSTALL_INCLUDE_DIR "include/${OPENJPEG_INSTALL_SUBDIR}")
endif()
if(BUILD_DOC)
if(NOT OPENJPEG_INSTALL_MAN_DIR)
set(OPENJPEG_INSTALL_MAN_DIR "share/man/")
endif()
@@ -125,6 +129,7 @@ endif()
if(NOT OPENJPEG_INSTALL_DOC_DIR)
set(OPENJPEG_INSTALL_DOC_DIR "share/doc/${OPENJPEG_INSTALL_SUBDIR}")
endif()
endif()
if(NOT OPENJPEG_INSTALL_JNI_DIR)
if(WIN32)
@@ -264,8 +269,7 @@ configure_file(
)
#-----------------------------------------------------------------------------
# Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
option(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
# build documentation in doc subdir:
if(BUILD_DOC)
add_subdirectory(doc)
endif()
@@ -282,7 +286,7 @@ if(BUILD_TESTING)
# They could be found via svn on the OpenJPEG google code project
# svn checkout http://openjpeg.googlecode.com/svn/data (about 70 Mo)
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
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
)
@@ -307,16 +311,25 @@ install( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
#-----------------------------------------------------------------------------
# install CHANGES and LICENSE
if(BUILD_DOC)
if(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
install(FILES CHANGES DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
endif()
install(FILES LICENSE DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
endif()
include (cmake/OpenJPEGCPack.cmake)
#-----------------------------------------------------------------------------
# pkgconfig support
# enabled by default on Unix, disabled by default on other platforms
if(UNIX)
option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" ON)
else()
option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" OFF)
endif()
if(BUILD_PKGCONFIG_FILES)
# install in lib and not share (see multi-arch note above)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/libopenjp2.pc.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/libopenjp2.pc @ONLY)

26
NEWS
View File

@@ -2,7 +2,7 @@
OpenJPEG NEWS - user visible changes
====================================
Changes from OpenJPEG 2.0.0 to OpenJPEG 2.0.1
Changes from OpenJPEG 2.0.0 to OpenJPEG 2.1.0
----------------------------------------------
New Features:
@@ -11,17 +11,35 @@ New Features:
* New option to disable MCT if needed
* extended RAW support: it is now possible to input raw images
with subsampled color components (422, 420, etc)
* New way to deal with profiles
API/ABI modifications: (see abi_compat_report_2.0.1.html in dev-utils/scripts)
API/ABI modifications: (see abi_compat_report in dev-utils/scripts)
* No changes, API/ABI fully compatible with 2.0.0
* Removed deprecated functions
- opj_stream_create_default_file_stream(FILE*,...)
- opj_stream_create_file_stream(FILE*,...)
- opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data)
* Added
- opj_stream_create_default_file_stream(char*,...)
- opj_stream_create_file_stream(char*,...)
- opj_stream_destroy(opj_stream_t*)
- opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data,
... opj_stream_free_user_data_fn p_function)
- JPEG 2000 profiles and Part-2 extensions defined through '#define'
* Changed
- 'alpha' field added to 'opj_image_comp' structure
- 'OPJ_CLRSPC_EYCC' added to enum COLOR_SPACE
- 'OPJ_CLRSPC_CMYK' added to enum COLOR_SPACE
- 'OPJ_CODEC_JPP' and 'OPJ_CODEC_JPX' added to CODEC_FORMAT
(not yet used in use)
- 'max_cs_size' and 'rsiz' fields added to opj_cparameters_t
Misc:
* OpenJPEG is now officialy conformant with JPEG 2000 Part-1
and will soon become official reference software at the
JPEG committee.
* Huge amount of bug fixes. See CHANGES for details.
* Huge amount of bug fixes. See CHANGES for details.
Changes from OpenJPEG 1.5.x to OpenJPEG 2.0.0

View File

@@ -1,3 +1,5 @@
#include "opj_config_private.h"
/* create opj_apps_config.h for CMake */
#cmakedefine OPJ_HAVE_LIBPNG @HAVE_LIBPNG@

View File

@@ -52,6 +52,7 @@ foreach(exe opj_decompress opj_compress opj_dump)
)
endforeach()
if(BUILD_DOC)
# Install man pages
install(
FILES ${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_compress.1
@@ -59,3 +60,4 @@ install(
${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_dump.1
DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man1)
#
endif()

View File

@@ -2597,6 +2597,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
int has_alpha = 0;
unsigned short tiBps, tiPhoto, tiSf, tiSpp, tiPC;
unsigned int tiWidth, tiHeight;
OPJ_BOOL is_cinema = OPJ_IS_CINEMA(parameters->rsiz);
tif = TIFFOpen(filename, "r");
@@ -2669,7 +2670,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
*/
memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t));
if ((tiPhoto == PHOTOMETRIC_RGB) && (parameters->cp_cinema)) {
if ((tiPhoto == PHOTOMETRIC_RGB) && (is_cinema)) {
fprintf(stdout,"WARNING:\n"
"Input image bitdepth is %d bits\n"
"TIF conversion has automatically rescaled to 12-bits\n"
@@ -2685,7 +2686,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
/*#define USETILEMODE*/
for(j = 0; j < numcomps; j++)
{
if(parameters->cp_cinema)
if(is_cinema)
{
cmptparm[j].prec = 12;
cmptparm[j].bpp = 12;
@@ -2754,7 +2755,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
if(has_alpha)
image->comps[3].data[index] = ( dat8[i+7] << 8 ) | dat8[i+6];
if(parameters->cp_cinema)
if(is_cinema)
{
/* Rounding 16 to 12 bits
*/
@@ -2791,7 +2792,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
image->comps[3].data[index] = dat8[i+3];
#endif
if(parameters->cp_cinema)
if(is_cinema)
{
/* Rounding 8 to 12 bits
*/

View File

@@ -86,25 +86,12 @@ typedef struct img_folder{
}img_fol_t;
static void encode_help_display(void) {
fprintf(stdout,"HELP for opj_compress\n----\n\n");
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
fprintf(stdout,"\nThis is the opj_compress utility from the OpenJPEG project.\n"
"It compresses various image formats with the JPEG 2000 algorithm.\n"
"It has been compiled against openjp2 library v%s.\n\n",opj_version());
/* UniPG>> */
fprintf(stdout,"List of parameters for the JPEG 2000 "
#ifdef USE_JPWL
"+ JPWL "
#endif /* USE_JPWL */
"encoder:\n");
/* <<UniPG */
fprintf(stdout,"\n");
fprintf(stdout,"REMARKS:\n");
fprintf(stdout,"---------\n");
fprintf(stdout,"\n");
fprintf(stdout,"The markers written to the main_header are : SOC SIZ COD QCD COM.\n");
fprintf(stdout,"COD and QCD never appear in the tile_header.\n");
fprintf(stdout,"\n");
fprintf(stdout,"By default:\n");
fprintf(stdout,"------------\n");
fprintf(stdout,"Default encoding options:\n");
fprintf(stdout,"-------------------------\n");
fprintf(stdout,"\n");
fprintf(stdout," * Lossless\n");
fprintf(stdout," * 1 tile\n");
@@ -117,7 +104,9 @@ static void encode_help_display(void) {
fprintf(stdout," * No sub-sampling in x or y direction\n");
fprintf(stdout," * No mode switch activated\n");
fprintf(stdout," * Progression order: LRCP\n");
#ifdef FIXME_INDEX
fprintf(stdout," * No index file\n");
#endif /* FIXME_INDEX */
fprintf(stdout," * No ROI upshifted\n");
fprintf(stdout," * No offset of the origin of the image\n");
fprintf(stdout," * No offset of the origin of the tiles\n");
@@ -128,176 +117,204 @@ static void encode_help_display(void) {
#endif /* USE_JPWL */
/* <<UniPG */
fprintf(stdout,"\n");
fprintf(stdout,"Note:\n");
fprintf(stdout,"-----\n");
fprintf(stdout,"\n");
fprintf(stdout,"The markers written to the main_header are : SOC SIZ COD QCD COM.\n");
fprintf(stdout,"COD and QCD never appear in the tile_header.\n");
fprintf(stdout,"\n");
fprintf(stdout,"Parameters:\n");
fprintf(stdout,"------------\n");
fprintf(stdout,"-----------\n");
fprintf(stdout,"\n");
fprintf(stdout,"Required Parameters (except with -h):\n");
fprintf(stdout,"One of the two options -ImgDir or -i must be used\n");
fprintf(stdout,"\n");
fprintf(stdout,"-ImgDir : Image file Directory path (example ../Images) \n");
fprintf(stdout,"-i <file>\n");
fprintf(stdout," Input file\n");
fprintf(stdout," Known extensions are <PBM|PGM|PPM|PNM|PAM|PGX|PNG|BMP|TIF|RAW|RAWL|TGA>\n");
fprintf(stdout," If used, '-o <file>' must be provided\n");
fprintf(stdout,"-o <compressed file>\n");
fprintf(stdout," Output file (accepted extensions are j2k or jp2).\n");
fprintf(stdout,"-ImgDir <dir>\n");
fprintf(stdout," Image file Directory path (example ../Images) \n");
fprintf(stdout," When using this option -OutFor must be used\n");
fprintf(stdout,"\n");
fprintf(stdout,"-OutFor \n");
fprintf(stdout," REQUIRED only if -ImgDir is used\n");
fprintf(stdout," Need to specify only format without filename <BMP> \n");
fprintf(stdout," Currently accepts PBM, PGM, PPM, PNM, PAM, PGX, PNG, BMP, TIF, RAW (MSB), RAWL (LSB) and TGA formats\n");
fprintf(stdout,"\n");
fprintf(stdout,"-i : source file (-i source.pnm also *pbm, *.pgm, *.ppm, *.pam, *.pgx, *png, *.bmp, *.tif, *.raw, *.tga) \n");
fprintf(stdout," When using this option -o must be used\n");
fprintf(stdout,"\n");
fprintf(stdout,"-o : destination file (-o dest.j2k or .jp2) \n");
fprintf(stdout,"-OutFor <J2K|J2C|JP2>\n");
fprintf(stdout," Output format for compressed files.\n");
fprintf(stdout," Required only if -ImgDir is used\n");
fprintf(stdout,"-F <width>,<height>,<ncomp>,<bitdepth>,{s,u}@<dx1>x<dy1>:...:<dxn>x<dyn>\n");
fprintf(stdout," Characteristics of the raw input image\n");
fprintf(stdout," If subsampling is omitted, 1x1 is assumed for all components\n");
fprintf(stdout," Example: -F 512,512,3,8,u@1x1:2x2:2x2\n");
fprintf(stdout," for raw 512x512 image with 4:2:0 subsampling\n");
fprintf(stdout," Required only if RAW or RAWL input file is provided.\n");
fprintf(stdout,"\n");
fprintf(stdout,"Optional Parameters:\n");
fprintf(stdout,"\n");
fprintf(stdout,"-h : display the help information \n ");
fprintf(stdout,"\n");
fprintf(stdout,"-cinema2K : Digital Cinema 2K profile compliant codestream for 2K resolution.(-CINEMA2K 24 or 48) \n");
fprintf(stdout," Need to specify the frames per second for a 2K resolution. Only 24 or 48 fps is allowed\n");
fprintf(stdout,"\n");
fprintf(stdout,"-cinema4K : Digital Cinema 4K profile compliant codestream for 4K resolution \n");
fprintf(stdout," Frames per second not required. Default value is 24fps\n");
fprintf(stdout,"\n");
fprintf(stdout,"-r : different compression ratios for successive layers (-r 20,10,5)\n ");
fprintf(stdout," - The rate specified for each quality level is the desired \n");
fprintf(stdout," compression factor.\n");
fprintf(stdout," Example: -r 20,10,1 means quality 1: compress 20x, \n");
fprintf(stdout," quality 2: compress 10x and quality 3: compress lossless\n");
fprintf(stdout,"\n");
fprintf(stdout," (options -r and -q cannot be used together)\n ");
fprintf(stdout,"\n");
fprintf(stdout,"-q : different psnr for successive layers (-q 30,40,50) \n ");
fprintf(stdout," (options -r and -q cannot be used together)\n ");
fprintf(stdout,"\n");
fprintf(stdout,"-n : number of resolutions (-n 3) \n");
fprintf(stdout,"\n");
fprintf(stdout,"-b : size of code block (-b 32,32) \n");
fprintf(stdout,"\n");
fprintf(stdout,"-c : size of precinct (-c 128,128) \n");
fprintf(stdout,"\n");
fprintf(stdout,"-t : size of tile (-t 512,512) \n");
fprintf(stdout,"\n");
fprintf(stdout,"-p : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] \n");
fprintf(stdout,"\n");
fprintf(stdout,"-s : subsampling factor (-s 2,2) [-s X,Y] \n");
fprintf(stdout," Remark: subsampling bigger than 2 can produce error\n");
fprintf(stdout,"\n");
fprintf(stdout,"-POC : Progression order change (-POC T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL) \n");
fprintf(stdout," Example: T1=0,0,1,5,3,CPRL \n");
fprintf(stdout," : Ttilenumber=Resolution num start,Component num start,Layer num end,Resolution num end,Component num end,Progression order\n");
fprintf(stdout,"\n");
fprintf(stdout,"-SOP : write SOP marker before each packet \n");
fprintf(stdout,"\n");
fprintf(stdout,"-EPH : write EPH marker after each header packet \n");
fprintf(stdout,"\n");
fprintf(stdout,"-M : mode switch (-M 3) [1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL)\n");
fprintf(stdout," 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)] \n");
fprintf(stdout," Indicate multiple modes by adding their values. \n");
fprintf(stdout," ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
fprintf(stdout,"\n");
fprintf(stdout,"-TP : divide packets of every tile into tile-parts (-TP R) [R, L, C]\n");
fprintf(stdout,"\n");
fprintf(stdout,"-x : create an index file *.Idx (-x index_name.Idx) \n");
fprintf(stdout,"\n");
fprintf(stdout,"-ROI : c=%%d,U=%%d : quantization indices upshifted \n");
fprintf(stdout," for component c=%%d [%%d = 0,1,2]\n");
fprintf(stdout," with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI c=0,U=25) \n");
fprintf(stdout,"\n");
fprintf(stdout,"-d : offset of the origin of the image (-d 150,300) \n");
fprintf(stdout,"\n");
fprintf(stdout,"-T : offset of the origin of the tiles (-T 100,75) \n");
fprintf(stdout,"\n");
fprintf(stdout,"-I : use the irreversible DWT 9-7 (-I) \n");
fprintf(stdout,"\n");
fprintf(stdout,"-F : characteristics of the raw input image\n");
fprintf(stdout," -F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
fprintf(stdout," Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
fprintf(stdout,"\n");
fprintf(stdout,"-mct {0,1,2} : explicitely specifies if a Multiple Component Transform has to be used.\n");
fprintf(stdout," 0: no MCT ; 1: RGB->YCC conversion ; 2: custom MCT.\n");
fprintf(stdout," If custom MCT, \"-m\" option has to be used (see hereunder).\n");
fprintf(stdout," By default, RGB->YCC conversion is used if there are 3 components or more,\n");
fprintf(stdout," no conversion otherwise.\n");
fprintf(stdout,"-m <file> : use array-based MCT, values are coma separated, line by line\n");
fprintf(stdout," no specific separators between lines, no space allowed between values\n");
fprintf(stdout," If this option is used, it automatically sets \"-mct\" option to 2.\n");
fprintf(stdout,"-jpip : write jpip codestream index box in JP2 output file\n");
fprintf(stdout," NOTICE: currently supports only RPCL order\n");
fprintf(stdout,"\n");
fprintf(stdout,"-h\n");
fprintf(stdout," Display the help information.\n");
fprintf(stdout,"-r <compression ratio>,<compression ratio>,...\n");
fprintf(stdout," Different compression ratios for successive layers.\n");
fprintf(stdout," The rate specified for each quality level is the desired\n");
fprintf(stdout," compression factor.\n");
fprintf(stdout," Decreasing ratios required.\n");
fprintf(stdout," Example: -r 20,10,1 means \n");
fprintf(stdout," quality layer 1: compress 20x, \n");
fprintf(stdout," quality layer 2: compress 10x \n");
fprintf(stdout," quality layer 3: compress lossless\n");
fprintf(stdout," Options -r and -q cannot be used together.\n");
fprintf(stdout,"-q <psnr value>,<psnr value>,<psnr value>,...\n");
fprintf(stdout," Different psnr for successive layers (-q 30,40,50).\n");
fprintf(stdout," Increasing PSNR values required.\n");
fprintf(stdout," Options -r and -q cannot be used together.\n");
fprintf(stdout,"-n <number of resolutions>\n");
fprintf(stdout," Number of resolutions.\n");
fprintf(stdout," It corresponds to the number of DWT decompositions +1. \n");
fprintf(stdout," Default: 6.\n");
fprintf(stdout,"-b <cblk width>,<cblk height>\n");
fprintf(stdout," Code-block size. The dimension must respect the constraint \n");
fprintf(stdout," defined in the JPEG-2000 standard (no dimension smaller than 4 \n");
fprintf(stdout," or greater than 1024, no code-block with more than 4096 coefficients).\n");
fprintf(stdout," The maximum value authorized is 64x64. \n");
fprintf(stdout," Default: 64x64.\n");
fprintf(stdout,"-c [<prec width>,<prec height>],[<prec width>,<prec height>],...\n");
fprintf(stdout," Precinct size. Values specified must be power of 2. \n");
fprintf(stdout," Multiple records may be supplied, in which case the first record refers\n");
fprintf(stdout," to the highest resolution level and subsequent records to lower \n");
fprintf(stdout," resolution levels. The last specified record is right-shifted for each \n");
fprintf(stdout," remaining lower resolution levels.\n");
fprintf(stdout," Default: 215x215 at each resolution.\n");
fprintf(stdout,"-t <tile width>,<tile height>\n");
fprintf(stdout," Tile size.\n");
fprintf(stdout," Default: the dimension of the whole image, thus only one tile.\n");
fprintf(stdout,"-p <LRCP|RLCP|RPCL|PCRL|CPRL>\n");
fprintf(stdout," Progression order.\n");
fprintf(stdout," Default: LRCP.\n");
fprintf(stdout,"-s <subX,subY>\n");
fprintf(stdout," Subsampling factor.\n");
fprintf(stdout," Subsampling bigger than 2 can produce error\n");
fprintf(stdout," Default: no subsampling.\n");
fprintf(stdout,"-POC <progression order change>/<progression order change>/...\n");
fprintf(stdout," Progression order change.\n");
fprintf(stdout," The syntax of a progression order change is the following:\n");
fprintf(stdout," T<tile>=<resStart>,<compStart>,<layerEnd>,<resEnd>,<compEnd>,<progOrder>\n");
fprintf(stdout," Example: -POC T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL\n");
fprintf(stdout,"-SOP\n");
fprintf(stdout," Write SOP marker before each packet.\n");
fprintf(stdout,"-EPH\n");
fprintf(stdout," Write EPH marker after each header packet.\n");
fprintf(stdout,"-M <key value>\n");
fprintf(stdout," Mode switch.\n");
fprintf(stdout," [1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL)\n");
fprintf(stdout," 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)]\n");
fprintf(stdout," Indicate multiple modes by adding their values.\n");
fprintf(stdout," Example: RESTART(4) + RESET(2) + SEGMARK(32) => -M 38\n");
fprintf(stdout,"-TP <R|L|C>\n");
fprintf(stdout," Divide packets of every tile into tile-parts.\n");
fprintf(stdout," Division is made by grouping Resolutions (R), Layers (L)\n");
fprintf(stdout," or Components (C).\n");
#ifdef FIXME_INDEX
fprintf(stdout,"-x <index file>\n");
fprintf(stdout," Create an index file.\n");
#endif /*FIXME_INDEX*/
fprintf(stdout,"-ROI c=<component index>,U=<upshifting value>\n");
fprintf(stdout," Quantization indices upshifted for a component. \n");
fprintf(stdout," Warning: This option does not implement the usual ROI (Region of Interest).\n");
fprintf(stdout," It should be understood as a 'Component of Interest'. It offers the \n");
fprintf(stdout," possibility to upshift the value of a component during quantization step.\n");
fprintf(stdout," The value after c= is the component number [0, 1, 2, ...] and the value \n");
fprintf(stdout," after U= is the value of upshifting. U must be in the range [0, 37].\n");
fprintf(stdout,"-d <image offset X,image offset Y>\n");
fprintf(stdout," Offset of the origin of the image.\n");
fprintf(stdout,"-T <tile offset X,tile offset Y>\n");
fprintf(stdout," Offset of the origin of the tiles.\n");
fprintf(stdout,"-I\n");
fprintf(stdout," Use the irreversible DWT 9-7.\n");
fprintf(stdout,"-mct <0|1|2>\n");
fprintf(stdout," Explicitely specifies if a Multiple Component Transform has to be used.\n");
fprintf(stdout," 0: no MCT ; 1: RGB->YCC conversion ; 2: custom MCT.\n");
fprintf(stdout," If custom MCT, \"-m\" option has to be used (see hereunder).\n");
fprintf(stdout," By default, RGB->YCC conversion is used if there are 3 components or more,\n");
fprintf(stdout," no conversion otherwise.\n");
fprintf(stdout,"-m <file>\n");
fprintf(stdout," Use array-based MCT, values are coma separated, line by line\n");
fprintf(stdout," No specific separators between lines, no space allowed between values.\n");
fprintf(stdout," If this option is used, it automatically sets \"-mct\" option to 2.\n");
fprintf(stdout,"-cinema2K <24|48>\n");
fprintf(stdout," Digital Cinema 2K profile compliant codestream.\n");
fprintf(stdout," Need to specify the frames per second for a 2K resolution.\n");
fprintf(stdout," Only 24 or 48 fps are currently allowed.\n");
fprintf(stdout,"-cinema4K\n");
fprintf(stdout," Digital Cinema 4K profile compliant codestream.\n");
fprintf(stdout," Frames per second not required. Default value is 24fps.\n");
fprintf(stdout,"-jpip\n");
fprintf(stdout," Write jpip codestream index box in JP2 output file.\n");
fprintf(stdout," Currently supports only RPCL order.\n");
fprintf(stdout,"-C <comment>\n");
fprintf(stdout," Add <comment> in the comment marker segment.\n");
/* UniPG>> */
#ifdef USE_JPWL
fprintf(stdout,"-W : adoption of JPWL (Part 11) capabilities (-W params)\n");
fprintf(stdout," The parameters can be written and repeated in any order:\n");
fprintf(stdout," [h<tilepart><=type>,s<tilepart><=method>,a=<addr>,...\n");
fprintf(stdout," ...,z=<size>,g=<range>,p<tilepart:pack><=type>]\n");
fprintf(stdout,"\n");
fprintf(stdout," h selects the header error protection (EPB): 'type' can be\n");
fprintf(stdout," [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]\n");
fprintf(stdout," if 'tilepart' is absent, it is for main and tile headers\n");
fprintf(stdout," if 'tilepart' is present, it applies from that tile\n");
fprintf(stdout," onwards, up to the next h<> spec, or to the last tilepart\n");
fprintf(stdout," in the codestream (max. %d specs)\n", JPWL_MAX_NO_TILESPECS);
fprintf(stdout,"\n");
fprintf(stdout," p selects the packet error protection (EEP/UEP with EPBs)\n");
fprintf(stdout," to be applied to raw data: 'type' can be\n");
fprintf(stdout," [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]\n");
fprintf(stdout," if 'tilepart:pack' is absent, it is from tile 0, packet 0\n");
fprintf(stdout," if 'tilepart:pack' is present, it applies from that tile\n");
fprintf(stdout," and that packet onwards, up to the next packet spec\n");
fprintf(stdout," or to the last packet in the last tilepart in the stream\n");
fprintf(stdout," (max. %d specs)\n", JPWL_MAX_NO_PACKSPECS);
fprintf(stdout,"\n");
fprintf(stdout," s enables sensitivity data insertion (ESD): 'method' can be\n");
fprintf(stdout," [-1=NO ESD 0=RELATIVE ERROR 1=MSE 2=MSE REDUCTION 3=PSNR\n");
fprintf(stdout," 4=PSNR INCREMENT 5=MAXERR 6=TSE 7=RESERVED]\n");
fprintf(stdout," if 'tilepart' is absent, it is for main header only\n");
fprintf(stdout," if 'tilepart' is present, it applies from that tile\n");
fprintf(stdout," onwards, up to the next s<> spec, or to the last tilepart\n");
fprintf(stdout," in the codestream (max. %d specs)\n", JPWL_MAX_NO_TILESPECS);
fprintf(stdout,"\n");
fprintf(stdout," g determines the addressing mode: <range> can be\n");
fprintf(stdout," [0=PACKET 1=BYTE RANGE 2=PACKET RANGE]\n");
fprintf(stdout,"\n");
fprintf(stdout," a determines the size of data addressing: <addr> can be\n");
fprintf(stdout," 2/4 bytes (small/large codestreams). If not set, auto-mode\n");
fprintf(stdout,"\n");
fprintf(stdout," z determines the size of sensitivity values: <size> can be\n");
fprintf(stdout," 1/2 bytes, for the transformed pseudo-floating point value\n");
fprintf(stdout,"\n");
fprintf(stdout," ex.:\n");
fprintf(stdout," h,h0=64,h3=16,h5=32,p0=78,p0:24=56,p1,p3:0=0,p3:20=32,s=0,\n");
fprintf(stdout," s0=6,s3=-1,a=0,g=1,z=1\n");
fprintf(stdout," means\n");
fprintf(stdout," predefined EPB in MH, rs(64,32) from TPH 0 to TPH 2,\n");
fprintf(stdout," CRC-16 in TPH 3 and TPH 4, CRC-32 in remaining TPHs,\n");
fprintf(stdout," UEP rs(78,32) for packets 0 to 23 of tile 0,\n");
fprintf(stdout," UEP rs(56,32) for packs. 24 to the last of tilepart 0,\n");
fprintf(stdout," UEP rs default for packets of tilepart 1,\n");
fprintf(stdout," no UEP for packets 0 to 19 of tilepart 3,\n");
fprintf(stdout," UEP CRC-32 for packs. 20 of tilepart 3 to last tilepart,\n");
fprintf(stdout," relative sensitivity ESD for MH,\n");
fprintf(stdout," TSE ESD from TPH 0 to TPH 2, byte range with automatic\n");
fprintf(stdout," size of addresses and 1 byte for each sensitivity value\n");
fprintf(stdout,"\n");
fprintf(stdout," ex.:\n");
fprintf(stdout," h,s,p\n");
fprintf(stdout," means\n");
fprintf(stdout," default protection to headers (MH and TPHs) as well as\n");
fprintf(stdout," data packets, one ESD in MH\n");
fprintf(stdout,"\n");
fprintf(stdout," N.B.: use the following recommendations when specifying\n");
fprintf(stdout," the JPWL parameters list\n");
fprintf(stdout," - when you use UEP, always pair the 'p' option with 'h'\n");
fprintf(stdout," \n");
fprintf(stdout,"-W <params>\n");
fprintf(stdout," Adoption of JPWL (Part 11) capabilities (-W params)\n");
fprintf(stdout," The <params> field can be written and repeated in any order:\n");
fprintf(stdout," [h<tilepart><=type>,s<tilepart><=method>,a=<addr>,...\n");
fprintf(stdout," ...,z=<size>,g=<range>,p<tilepart:pack><=type>]\n");
fprintf(stdout," h selects the header error protection (EPB): 'type' can be\n");
fprintf(stdout," [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]\n");
fprintf(stdout," if 'tilepart' is absent, it is for main and tile headers\n");
fprintf(stdout," if 'tilepart' is present, it applies from that tile\n");
fprintf(stdout," onwards, up to the next h<> spec, or to the last tilepart\n");
fprintf(stdout," in the codestream (max. %d specs)\n", JPWL_MAX_NO_TILESPECS);
fprintf(stdout," p selects the packet error protection (EEP/UEP with EPBs)\n");
fprintf(stdout," to be applied to raw data: 'type' can be\n");
fprintf(stdout," [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]\n");
fprintf(stdout," if 'tilepart:pack' is absent, it is from tile 0, packet 0\n");
fprintf(stdout," if 'tilepart:pack' is present, it applies from that tile\n");
fprintf(stdout," and that packet onwards, up to the next packet spec\n");
fprintf(stdout," or to the last packet in the last tilepart in the stream\n");
fprintf(stdout," (max. %d specs)\n", JPWL_MAX_NO_PACKSPECS);
fprintf(stdout," s enables sensitivity data insertion (ESD): 'method' can be\n");
fprintf(stdout," [-1=NO ESD 0=RELATIVE ERROR 1=MSE 2=MSE REDUCTION 3=PSNR\n");
fprintf(stdout," 4=PSNR INCREMENT 5=MAXERR 6=TSE 7=RESERVED]\n");
fprintf(stdout," if 'tilepart' is absent, it is for main header only\n");
fprintf(stdout," if 'tilepart' is present, it applies from that tile\n");
fprintf(stdout," onwards, up to the next s<> spec, or to the last tilepart\n");
fprintf(stdout," in the codestream (max. %d specs)\n", JPWL_MAX_NO_TILESPECS);
fprintf(stdout," g determines the addressing mode: <range> can be\n");
fprintf(stdout," [0=PACKET 1=BYTE RANGE 2=PACKET RANGE]\n");
fprintf(stdout," a determines the size of data addressing: <addr> can be\n");
fprintf(stdout," 2/4 bytes (small/large codestreams). If not set, auto-mode\n");
fprintf(stdout," z determines the size of sensitivity values: <size> can be\n");
fprintf(stdout," 1/2 bytes, for the transformed pseudo-floating point value\n");
fprintf(stdout," ex.:\n");
fprintf(stdout," h,h0=64,h3=16,h5=32,p0=78,p0:24=56,p1,p3:0=0,p3:20=32,s=0,\n");
fprintf(stdout," s0=6,s3=-1,a=0,g=1,z=1\n");
fprintf(stdout," means\n");
fprintf(stdout," predefined EPB in MH, rs(64,32) from TPH 0 to TPH 2,\n");
fprintf(stdout," CRC-16 in TPH 3 and TPH 4, CRC-32 in remaining TPHs,\n");
fprintf(stdout," UEP rs(78,32) for packets 0 to 23 of tile 0,\n");
fprintf(stdout," UEP rs(56,32) for packs. 24 to the last of tilepart 0,\n");
fprintf(stdout," UEP rs default for packets of tilepart 1,\n");
fprintf(stdout," no UEP for packets 0 to 19 of tilepart 3,\n");
fprintf(stdout," UEP CRC-32 for packs. 20 of tilepart 3 to last tilepart,\n");
fprintf(stdout," relative sensitivity ESD for MH,\n");
fprintf(stdout," TSE ESD from TPH 0 to TPH 2, byte range with automatic\n");
fprintf(stdout," size of addresses and 1 byte for each sensitivity value\n");
fprintf(stdout," ex.:\n");
fprintf(stdout," h,s,p\n");
fprintf(stdout," means\n");
fprintf(stdout," default protection to headers (MH and TPHs) as well as\n");
fprintf(stdout," data packets, one ESD in MH\n");
fprintf(stdout," N.B.: use the following recommendations when specifying\n");
fprintf(stdout," the JPWL parameters list\n");
fprintf(stdout," - when you use UEP, always pair the 'p' option with 'h'\n");
#endif /* USE_JPWL */
/* <<UniPG */
fprintf(stdout,"IMPORTANT:\n");
fprintf(stdout,"-----------\n");
fprintf(stdout,"\n");
fprintf(stdout,"The index file has the structure below:\n");
fprintf(stdout,"---------------------------------------\n");
#ifdef FIXME_INDEX
fprintf(stdout,"Index structure:\n");
fprintf(stdout,"----------------\n");
fprintf(stdout,"\n");
fprintf(stdout,"Image_height Image_width\n");
fprintf(stdout,"progression order\n");
@@ -327,10 +344,9 @@ static void encode_help_display(void) {
fprintf(stdout,"Tpacket_0 Tile layer res. comp. prec. start_pos end_pos disto\n");
fprintf(stdout,"...\n");
fprintf(stdout,"Tpacket_Np '' '' '' '' '' '' '' ''\n");
fprintf(stdout,"MaxDisto\n");
fprintf(stdout,"TotalDisto\n\n");
#endif /*FIXME_INDEX*/
}
static OPJ_PROG_ORDER give_progression(const char progression[4]) {
@@ -502,8 +518,8 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
break;
default:
fprintf(stderr,
"!! Unrecognized format for infile : %s "
"[accept only *.pnm, *.pgm, *.ppm, *.pgx, *png, *.bmp, *.tif, *.raw or *.tga] !!\n\n",
"[ERROR] Unknown input file format: %s \n"
" Known file formats are *.pnm, *.pgm, *.ppm, *.pgx, *png, *.bmp, *.tif, *.raw or *.tga\n",
infile);
return 1;
}
@@ -790,6 +806,11 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
{
char *index = opj_optarg;
strncpy(indexfilename, index, OPJ_PATH_LEN);
/* FIXME ADE INDEX >> */
fprintf(stderr,
"[WARNING] Index file generation is currently broken.\n"
" '-x' option ignored.\n");
/* << FIXME ADE INDEX */
}
break;
@@ -968,9 +989,13 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
int fps=0;
sscanf(opj_optarg,"%d",&fps);
if(fps == 24){
parameters->cp_cinema = OPJ_CINEMA2K_24;
parameters->rsiz = OPJ_PROFILE_CINEMA_2K;
parameters->max_comp_size = OPJ_CINEMA_24_COMP;
parameters->max_cs_size = OPJ_CINEMA_24_CS;
}else if(fps == 48 ){
parameters->cp_cinema = OPJ_CINEMA2K_48;
parameters->rsiz = OPJ_PROFILE_CINEMA_2K;
parameters->max_comp_size = OPJ_CINEMA_48_COMP;
parameters->max_cs_size = OPJ_CINEMA_48_CS;
}else {
fprintf(stderr,"Incorrect value!! must be 24 or 48\n");
return 1;
@@ -985,7 +1010,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
case 'y': /* Digital Cinema 4K profile compliance*/
{
parameters->cp_cinema = OPJ_CINEMA4K_24;
parameters->rsiz = OPJ_PROFILE_CINEMA_4K;
fprintf(stdout,"CINEMA 4K profile activated\n"
"Other options specified could be overriden\n");
}
@@ -1408,37 +1433,38 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
default:
fprintf(stderr, "ERROR -> Command line not valid\n");
return 1;
fprintf(stderr, "[WARNING] An invalid option has been ignored\n");
break;
}
}while(c != -1);
if(img_fol->set_imgdir == 1){
if(!(parameters->infile[0] == 0)){
fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
fprintf(stderr, "[ERROR] options -ImgDir and -i cannot be used together !!\n");
return 1;
}
if(img_fol->set_out_format == 0){
fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
fprintf(stderr, "[ERROR] When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
fprintf(stderr, "Only one format allowed! Valid formats are j2k and jp2!!\n");
return 1;
}
if(!((parameters->outfile[0] == 0))){
fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
fprintf(stderr, "[ERROR] options -ImgDir and -o cannot be used together !!\n");
fprintf(stderr, "Specify OutputFormat using -OutFor<FORMAT> !!\n");
return 1;
}
}else{
if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
fprintf(stderr, "Example: %s -i image.ppm -o image.j2k\n",argv[0]);
fprintf(stderr, " Try: %s -h\n",argv[0]);
fprintf(stderr, "[ERROR] Required parameters are missing\n"
"Example: %s -i image.j2k -o image.pgm\n",argv[0]);
fprintf(stderr, " Help: %s -h\n",argv[0]);
return 1;
}
}
if ( (parameters->decod_format == RAW_DFMT && raw_cp->rawWidth == 0)
|| (parameters->decod_format == RAWL_DFMT && raw_cp->rawWidth == 0)) {
fprintf(stderr,"\nError: invalid raw image parameters\n");
fprintf(stderr,"[ERROR] invalid raw image parameters\n");
fprintf(stderr,"Please use the Format option -F:\n");
fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
fprintf(stderr,"Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
@@ -1448,7 +1474,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
if ((parameters->cp_disto_alloc || parameters->cp_fixed_alloc || parameters->cp_fixed_quality)
&& (!(parameters->cp_disto_alloc ^ parameters->cp_fixed_alloc ^ parameters->cp_fixed_quality))) {
fprintf(stderr, "Error: options -r -q and -f cannot be used together !!\n");
fprintf(stderr, "[ERROR] options -r -q and -f cannot be used together !!\n");
return 1;
} /* mod fixed_quality */
@@ -1461,7 +1487,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
if((parameters->cp_tx0 > parameters->image_offset_x0) || (parameters->cp_ty0 > parameters->image_offset_y0)) {
fprintf(stderr,
"Error: Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) \n",
"[ERROR] Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) \n",
parameters->cp_tx0, parameters->image_offset_x0, parameters->cp_ty0, parameters->image_offset_y0);
return 1;
}
@@ -1507,7 +1533,6 @@ static void info_callback(const char *msg, void *client_data) {
*/
/* -------------------------------------------------------------------------- */
int main(int argc, char **argv) {
FILE *fout = NULL;
opj_cparameters_t parameters; /* compression parameters */
@@ -1753,16 +1778,8 @@ int main(int argc, char **argv) {
}
opj_setup_encoder(l_codec, &parameters, image);
/* Open the output file*/
fout = fopen(parameters.outfile, "wb");
if (! fout) {
fprintf(stderr, "Not enable to create output file!\n");
opj_stream_destroy(l_stream);
return 1;
}
/* open a byte stream for writing and allocate memory for all tiles */
l_stream = opj_stream_create_default_file_stream(fout,OPJ_FALSE);
l_stream = opj_stream_create_default_file_stream(parameters.outfile,OPJ_FALSE);
if (! l_stream){
return 1;
}
@@ -1772,7 +1789,7 @@ int main(int argc, char **argv) {
if (!bSuccess) {
fprintf(stderr, "failed to encode image: opj_start_compress\n");
}
if( bUseTiles ) {
if( bSuccess && bUseTiles ) {
OPJ_BYTE *l_data;
OPJ_UINT32 l_data_size = 512*512*3;
l_data = (OPJ_BYTE*) malloc( l_data_size * sizeof(OPJ_BYTE));
@@ -1782,7 +1799,6 @@ int main(int argc, char **argv) {
if (! opj_write_tile(l_codec,i,l_data,l_data_size,l_stream)) {
fprintf(stderr, "ERROR -> test_tile_encoder: failed to write the tile %d!\n",i);
opj_stream_destroy(l_stream);
fclose(fout);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
return 1;
@@ -1803,17 +1819,16 @@ int main(int argc, char **argv) {
if (!bSuccess) {
opj_stream_destroy(l_stream);
fclose(fout);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
fprintf(stderr, "failed to encode image\n");
remove(parameters.outfile);
return 1;
}
fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
fprintf(stdout,"[INFO] Generated outfile %s\n",parameters.outfile);
/* close and free the byte stream */
opj_stream_destroy(l_stream);
fclose(fout);
/* free remaining compression structures */
opj_destroy_codec(l_codec);

View File

@@ -106,31 +106,25 @@ int parse_DA_values( char* inArg, unsigned int *DA_x0, unsigned int *DA_y0, unsi
/* -------------------------------------------------------------------------- */
static void decode_help_display(void) {
fprintf(stdout,"HELP for opj_decompress\n----\n\n");
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
fprintf(stdout,"\nThis is the opj_decompress utility from the OpenJPEG project.\n"
"It decompresses JPEG 2000 codestreams to various image formats.\n"
"It has been compiled against openjp2 library v%s.\n\n",opj_version());
/* UniPG>> */
fprintf(stdout,"List of parameters for the JPEG 2000 "
#ifdef USE_JPWL
"+ JPWL "
#endif /* USE_JPWL */
"decoder:\n");
/* <<UniPG */
fprintf(stdout,"Parameters:\n");
fprintf(stdout,"-----------\n");
fprintf(stdout,"\n");
fprintf(stdout,"\n");
fprintf(stdout," -ImgDir \n");
fprintf(stdout," -ImgDir <directory> \n");
fprintf(stdout," Image file Directory path \n");
fprintf(stdout," -OutFor \n");
fprintf(stdout," -OutFor <PBM|PGM|PPM|PNM|PAM|PGX|PNG|BMP|TIF|RAW|RAWL|TGA>\n");
fprintf(stdout," REQUIRED only if -ImgDir is used\n");
fprintf(stdout," Need to specify only format without filename <BMP> \n");
fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, PNG, BMP, TIF, RAW and TGA formats\n");
fprintf(stdout," Output format for decompressed images.\n");
fprintf(stdout," -i <compressed file>\n");
fprintf(stdout," REQUIRED only if an Input image directory not specified\n");
fprintf(stdout," REQUIRED only if an Input image directory is not specified\n");
fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
fprintf(stdout," is identified based on its suffix.\n");
fprintf(stdout," -o <decompressed file>\n");
fprintf(stdout," REQUIRED\n");
fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, PNG, BMP, TIF, RAW and TGA files\n");
fprintf(stdout," Currently accepts formats specified above (see OutFor option)\n");
fprintf(stdout," Binary data is written to the file (not ascii). If a PGX\n");
fprintf(stdout," filename is given, there will be as many output files as there are\n");
fprintf(stdout," components: an indice starting from 0 will then be appended to the\n");
@@ -331,7 +325,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
int totlen, c;
opj_option_t long_option[]={
{"ImgDir",REQ_ARG, NULL ,'y'},
{"OutFor",REQ_ARG, NULL ,'O'},
{"OutFor",REQ_ARG, NULL ,'O'}
};
const char optlist[] = "i:o:r:l:x:d:t:"
@@ -341,7 +335,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
"W:"
#endif /* USE_JPWL */
/* <<UniPG */
"h" ;
"h" ;
totlen=sizeof(long_option);
img_fol->set_out_format = 0;
do {
@@ -367,7 +361,8 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
return 1;
default:
fprintf(stderr,
"!! Unrecognized format for infile: %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
"[ERROR] Unknown input file format: %s \n"
" Known file formats are *.j2k, *.jp2, *.jpc or *.jpt\n",
infile);
return 1;
}
@@ -472,10 +467,10 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
decode_help_display();
return 1;
/* ------------------------------------------------------ */
/* ----------------------------------------------------- */
case 'y': /* Image Directory path */
{
{
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
strcpy(img_fol->imgdirpath,opj_optarg);
img_fol->set_imgdir=1;
@@ -589,31 +584,33 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
/* ----------------------------------------------------- */
default:
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
break;
default:
fprintf(stderr, "[WARNING] An invalid option has been ignored.\n");
break;
}
}while(c != -1);
/* check for possible errors */
if(img_fol->set_imgdir==1){
if(!(parameters->infile[0]==0)){
fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
fprintf(stderr, "[ERROR] options -ImgDir and -i cannot be used together.\n");
return 1;
}
if(img_fol->set_out_format == 0){
fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
fprintf(stderr, "[ERROR] When -ImgDir is used, -OutFor <FORMAT> must be used.\n");
fprintf(stderr, "Only one format allowed.\n"
"Valid format are PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA.\n");
return 1;
}
if(!((parameters->outfile[0] == 0))){
fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
fprintf(stderr, "[ERROR] options -ImgDir and -o cannot be used together.\n");
return 1;
}
}else{
if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
fprintf(stderr, "Example: %s -i image.j2k -o image.pgm\n",argv[0]);
fprintf(stderr, " Try: %s -h\n",argv[0]);
fprintf(stderr, "[ERROR] Required parameters are missing\n"
"Example: %s -i image.j2k -o image.pgm\n",argv[0]);
fprintf(stderr, " Help: %s -h\n",argv[0]);
return 1;
}
}
@@ -682,8 +679,6 @@ static void info_callback(const char *msg, void *client_data) {
/* -------------------------------------------------------------------------- */
int main(int argc, char **argv)
{
FILE *fsrc = NULL;
opj_dparameters_t parameters; /* decompression parameters */
opj_image_t* image = NULL;
opj_stream_t *l_stream = NULL; /* Stream */
@@ -753,16 +748,10 @@ int main(int argc, char **argv)
/* read the input file and put it in memory */
/* ---------------------------------------- */
fsrc = fopen(parameters.infile, "rb");
if (!fsrc) {
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
return EXIT_FAILURE;
}
l_stream = opj_stream_create_default_file_stream(fsrc,1);
l_stream = opj_stream_create_default_file_stream(parameters.infile,1);
if (!l_stream){
fclose(fsrc);
fprintf(stderr, "ERROR -> failed to create the stream from the file\n");
fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n", parameters.infile);
return EXIT_FAILURE;
}
@@ -803,7 +792,6 @@ int main(int argc, char **argv)
if ( !opj_setup_decoder(l_codec, &parameters) ){
fprintf(stderr, "ERROR -> opj_compress: failed to setup the decoder\n");
opj_stream_destroy(l_stream);
fclose(fsrc);
opj_destroy_codec(l_codec);
return EXIT_FAILURE;
}
@@ -813,7 +801,6 @@ int main(int argc, char **argv)
if(! opj_read_header(l_stream, l_codec, &image)){
fprintf(stderr, "ERROR -> opj_decompress: failed to read the header\n");
opj_stream_destroy(l_stream);
fclose(fsrc);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
return EXIT_FAILURE;
@@ -827,7 +814,6 @@ int main(int argc, char **argv)
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
fclose(fsrc);
return EXIT_FAILURE;
}
@@ -837,7 +823,6 @@ int main(int argc, char **argv)
opj_destroy_codec(l_codec);
opj_stream_destroy(l_stream);
opj_image_destroy(image);
fclose(fsrc);
return EXIT_FAILURE;
}
}
@@ -849,7 +834,6 @@ int main(int argc, char **argv)
opj_destroy_codec(l_codec);
opj_stream_destroy(l_stream);
opj_image_destroy(image);
fclose(fsrc);
return EXIT_FAILURE;
}*/
@@ -858,7 +842,6 @@ int main(int argc, char **argv)
opj_destroy_codec(l_codec);
opj_stream_destroy(l_stream);
opj_image_destroy(image);
fclose(fsrc);
return EXIT_FAILURE;
}
fprintf(stdout, "tile %d is decoded!\n\n", parameters.tile_index);
@@ -866,7 +849,6 @@ int main(int argc, char **argv)
/* Close the byte stream */
opj_stream_destroy(l_stream);
fclose(fsrc);
if(image->color_space == OPJ_CLRSPC_SYCC){
color_sycc_to_rgb(image); /* FIXME */
@@ -892,81 +874,81 @@ int main(int argc, char **argv)
switch (parameters.cod_format) {
case PXM_DFMT: /* PNM PGM PPM */
if (imagetopnm(image, parameters.outfile)) {
fprintf(stderr,"Outfile %s not generated\n",parameters.outfile);
fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
case PGX_DFMT: /* PGX */
if(imagetopgx(image, parameters.outfile)){
fprintf(stderr,"Outfile %s not generated\n",parameters.outfile);
fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
case BMP_DFMT: /* BMP */
if(imagetobmp(image, parameters.outfile)){
fprintf(stderr,"Outfile %s not generated\n",parameters.outfile);
fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
#ifdef OPJ_HAVE_LIBTIFF
case TIF_DFMT: /* TIFF */
if(imagetotif(image, parameters.outfile)){
fprintf(stderr,"Outfile %s not generated\n",parameters.outfile);
fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
#endif /* OPJ_HAVE_LIBTIFF */
case RAW_DFMT: /* RAW */
if(imagetoraw(image, parameters.outfile)){
fprintf(stderr,"Error generating raw file. Outfile %s not generated\n",parameters.outfile);
fprintf(stderr,"[ERROR] Error generating raw file. Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
case RAWL_DFMT: /* RAWL */
if(imagetorawl(image, parameters.outfile)){
fprintf(stderr,"Error generating rawl file. Outfile %s not generated\n",parameters.outfile);
fprintf(stderr,"[ERROR] Error generating rawl file. Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
case TGA_DFMT: /* TGA */
if(imagetotga(image, parameters.outfile)){
fprintf(stderr,"Error generating tga file. Outfile %s not generated\n",parameters.outfile);
fprintf(stderr,"[ERROR] Error generating tga file. Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
#ifdef OPJ_HAVE_LIBPNG
case PNG_DFMT: /* PNG */
if(imagetopng(image, parameters.outfile)){
fprintf(stderr,"Error generating png file. Outfile %s not generated\n",parameters.outfile);
fprintf(stderr,"[ERROR] Error generating png file. Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
#endif /* OPJ_HAVE_LIBPNG */
@@ -974,7 +956,7 @@ int main(int argc, char **argv)
* and OPJ_HAVE_LIBTIF or OPJ_HAVE_LIBPNG is undefined
*/
default:
fprintf(stderr,"Outfile %s not generated\n",parameters.outfile);
fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
@@ -990,6 +972,7 @@ int main(int argc, char **argv)
/* destroy the codestream index */
opj_destroy_cstr_index(&cstr_index);
if(failed) remove(parameters.outfile);
}
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
}

View File

@@ -91,19 +91,14 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param
/* -------------------------------------------------------------------------- */
static void decode_help_display(void) {
fprintf(stdout,"HELP for opj_dump\n----\n\n");
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
fprintf(stdout,"\nThis is the opj_dump utility from the OpenJPEG project.\n"
"It dumps JPEG 2000 codestream info to stdout or a given file.\n"
"It has been compiled against openjp2 library v%s.\n\n",opj_version());
/* UniPG>> */
fprintf(stdout,"List of parameters for the JPEG 2000 "
#ifdef USE_JPWL
"+ JPWL "
#endif /* USE_JPWL */
"decoder:\n");
/* <<UniPG */
fprintf(stdout,"\n");
fprintf(stdout,"\n");
fprintf(stdout," -ImgDir \n");
fprintf(stdout,"Parameters:\n");
fprintf(stdout,"-----------\n");
fprintf(stdout,"\n");
fprintf(stdout," -ImgDir <directory>\n");
fprintf(stdout," Image file Directory path \n");
fprintf(stdout," -i <compressed file>\n");
fprintf(stdout," REQUIRED only if an Input image directory not specified\n");
@@ -113,10 +108,10 @@ static void decode_help_display(void) {
fprintf(stdout," OPTIONAL\n");
fprintf(stdout," Output file where file info will be dump.\n");
fprintf(stdout," By default it will be in the stdout.\n");
fprintf(stdout," -v "); /* FIXME WIP_MSD */
fprintf(stdout," -v "); /* FIXME WIP_MSD */
fprintf(stdout," OPTIONAL\n");
fprintf(stdout," Activate or not the verbose mode (display info and warning message)\n");
fprintf(stdout," By default verbose mode is off.\n");
fprintf(stdout," Enable informative messages\n");
fprintf(stdout," By default verbose mode is off.\n");
fprintf(stdout,"\n");
}
@@ -277,9 +272,9 @@ static int infile_format(const char *fname)
static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
int totlen, c;
opj_option_t long_option[]={
{"ImgDir",REQ_ARG, NULL ,'y'},
{"ImgDir",REQ_ARG, NULL ,'y'}
};
const char optlist[] = "i:o:f:hv";
const char optlist[] = "i:o:f:hv";
totlen=sizeof(long_option);
img_fol->set_out_format = 0;
@@ -298,12 +293,13 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param
case JP2_CFMT:
break;
case JPT_CFMT:
break;
default:
fprintf(stderr,
"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
infile);
return 1;
break;
default:
fprintf(stderr,
"[ERROR] Unknown input file format: %s \n"
" Known file formats are *.j2k, *.jp2, *.jpc or *.jpt\n",
infile);
return 1;
}
strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
}
@@ -340,38 +336,40 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param
/* ----------------------------------------------------- */
case 'v': /* Verbose mode */
case 'v': /* Verbose mode */
{
parameters->m_verbose = 1;
parameters->m_verbose = 1;
}
break;
/* ----------------------------------------------------- */
default:
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
break;
}
default:
fprintf(stderr, "[WARNING] An invalid option has been ignored.\n");
break;
}
}while(c != -1);
/* check for possible errors */
if(img_fol->set_imgdir==1){
if(!(parameters->infile[0]==0)){
fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
fprintf(stderr, "[ERROR] options -ImgDir and -i cannot be used together.\n");
return 1;
}
if(img_fol->set_out_format == 0){
fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
fprintf(stderr, "[ERROR] When -ImgDir is used, -OutFor <FORMAT> must be used.\n");
fprintf(stderr, "Only one format allowed.\n"
"Valid format are PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA.\n");
return 1;
}
if(!(parameters->outfile[0] == 0)){
fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
fprintf(stderr, "[ERROR] options -ImgDir and -o cannot be used together\n");
return 1;
}
}else{
if(parameters->infile[0] == 0) {
fprintf(stderr, "[ERROR] Required parameter is missing\n");
fprintf(stderr, "Example: %s -i image.j2k\n",argv[0]);
fprintf(stderr, " Try: %s -h\n",argv[0]);
fprintf(stderr, " Help: %s -h\n",argv[0]);
return 1;
}
}
@@ -410,7 +408,7 @@ static void info_callback(const char *msg, void *client_data) {
/* -------------------------------------------------------------------------- */
int main(int argc, char *argv[])
{
FILE *fsrc = NULL, *fout = NULL;
FILE *fout = NULL;
opj_dparameters_t parameters; /* Decompression parameters */
opj_image_t* image = NULL; /* Image structure */
@@ -496,16 +494,10 @@ int main(int argc, char *argv[])
/* Read the input file and put it in memory */
/* ---------------------------------------- */
fsrc = fopen(parameters.infile, "rb");
if (!fsrc) {
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
return EXIT_FAILURE;
}
l_stream = opj_stream_create_default_file_stream(fsrc,1);
l_stream = opj_stream_create_default_file_stream(parameters.infile,1);
if (!l_stream){
fclose(fsrc);
fprintf(stderr, "ERROR -> failed to create the stream from the file\n");
fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n",parameters.infile);
return EXIT_FAILURE;
}
@@ -546,7 +538,6 @@ int main(int argc, char *argv[])
if ( !opj_setup_decoder(l_codec, &parameters) ){
fprintf(stderr, "ERROR -> opj_dump: failed to setup the decoder\n");
opj_stream_destroy(l_stream);
fclose(fsrc);
opj_destroy_codec(l_codec);
fclose(fout);
return EXIT_FAILURE;
@@ -556,7 +547,6 @@ int main(int argc, char *argv[])
if(! opj_read_header(l_stream, l_codec, &image)){
fprintf(stderr, "ERROR -> opj_dump: failed to read the header\n");
opj_stream_destroy(l_stream);
fclose(fsrc);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
fclose(fout);
@@ -571,7 +561,6 @@ int main(int argc, char *argv[])
/* close the byte stream */
opj_stream_destroy(l_stream);
fclose(fsrc);
/* free remaining structures */
if (l_codec) {

View File

@@ -68,10 +68,12 @@ install(FILES openjpeg.h opj_stdint.h
DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers
)
if(BUILD_DOC)
# install man page of the library
install(
FILES ${OPENJPEG_SOURCE_DIR}/doc/man/man3/libopenjp2.3
DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man3)
endif()
# internal utilities to generate t1_luts.h (part of the jp2 lib)
# no need to install:

View File

@@ -195,6 +195,9 @@ void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream)
opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
if (l_stream) {
if (l_stream->m_free_user_data_fn) {
l_stream->m_free_user_data_fn(l_stream->m_user_data);
}
opj_free(l_stream->m_stored_data);
l_stream->m_stored_data = 00;
opj_free(l_stream);
@@ -244,12 +247,13 @@ void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream, opj_strea
l_stream->m_skip_fn = p_function;
}
void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t* p_stream, void * p_data)
void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t* p_stream, void * p_data, opj_stream_free_user_data_fn p_function)
{
opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
if (!l_stream)
return;
l_stream->m_user_data = p_data;
l_stream->m_free_user_data_fn = p_function;
}
void OPJ_CALLCONV opj_stream_set_user_data_length(opj_stream_t* p_stream, OPJ_UINT64 data_length)

View File

@@ -49,7 +49,7 @@ The functions in CIO.C have for goal to realize a byte input / output process.
/** @defgroup CIO CIO - byte input-output stream */
/*@{*/
#include "opj_config.h"
#include "opj_config_private.h"
/* ----------------------------------------------------------------------- */
@@ -91,6 +91,13 @@ typedef struct opj_stream_private
*/
void * m_user_data;
/**
* Pointer to function to free m_user_data (NULL at initialization)
* when destroying the stream. If pointer is NULL the function is not
* called and the m_user_data is not freed (even if non-NULL).
*/
opj_stream_free_user_data_fn m_free_user_data_fn;
/**
* User data length
*/

View File

@@ -42,11 +42,6 @@
#include "opj_includes.h"
#define CINEMA_24_CS 1302083 /*Codestream length for 24fps*/
#define CINEMA_48_CS 651041 /*Codestream length for 48fps*/
#define COMP_24_CS 1041666 /*Maximum size per color component for 2K & 4K @ 24fps*/
#define COMP_48_CS 520833 /*Maximum size per color component for 2K @ 48fps*/
/** @defgroup J2K J2K - JPEG-2000 codestream reader/writer */
/*@{*/
@@ -1172,7 +1167,7 @@ static int opj_j2k_initialise_4K_poc(opj_poc_t *POC, int numres);
static void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters, opj_image_t *image, opj_event_mgr_t *p_manager);
static OPJ_BOOL opj_j2k_is_cinema_compliant(opj_image_t *image, OPJ_CINEMA_MODE cinema_mode, opj_event_mgr_t *p_manager);
static OPJ_BOOL opj_j2k_is_cinema_compliant(opj_image_t *image, OPJ_UINT16 rsiz, opj_event_mgr_t *p_manager);
/*@}*/
@@ -1945,7 +1940,7 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
opj_read_bytes(p_header_data,&l_tmp ,2); /* Rsiz (capabilities) */
p_header_data+=2;
l_cp->rsiz = (OPJ_RSIZ_CAPABILITIES) l_tmp;
l_cp->rsiz = (OPJ_UINT16) l_tmp;
opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->x1, 4); /* Xsiz */
p_header_data+=4;
opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->y1, 4); /* Ysiz */
@@ -2066,13 +2061,6 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
i, l_img_comp->dx, l_img_comp->dy);
return OPJ_FALSE;
}
if( l_img_comp->dx < 1 || l_img_comp->dx > 255 ||
l_img_comp->dy < 1 || l_img_comp->dy > 255 ) {
opj_event_msg(p_manager, EVT_ERROR,
"Invalid values for comp = %d : dx=%u dy=%u\n (should be between 1 and 255 according the JPEG2000 norm)",
i, l_img_comp->dx, l_img_comp->dy);
return OPJ_FALSE;
}
#ifdef USE_JPWL
if (l_cp->correct) {
@@ -2110,14 +2098,6 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
l_cp->tw = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(l_image->x1 - l_cp->tx0), (OPJ_INT32)l_cp->tdx);
l_cp->th = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(l_image->y1 - l_cp->ty0), (OPJ_INT32)l_cp->tdy);
/* Check that the number of tiles is valid */
if (l_cp->tw == 0 || l_cp->th == 0 || l_cp->tw > 65535 / l_cp->th) {
opj_event_msg( p_manager, EVT_ERROR,
"Invalid number of tiles : %u x %u (maximum fixed by jpeg2000 norm is 65535 tiles)\n",
l_cp->tw, l_cp->th);
return OPJ_FALSE;
}
/* Check that the number of tiles is valid */
if (l_cp->tw == 0 || l_cp->th == 0 || l_cp->tw > 65535 / l_cp->th) {
opj_event_msg( p_manager, EVT_ERROR,
@@ -3117,7 +3097,7 @@ OPJ_UINT32 opj_j2k_get_specific_header_sizes(opj_j2k_t *p_j2k)
l_nb_comps = p_j2k->m_private_image->numcomps - 1;
l_nb_bytes += opj_j2k_get_max_toc_size(p_j2k);
if (p_j2k->m_cp.m_specific_param.m_enc.m_cinema == 0) {
if (!(OPJ_IS_CINEMA(p_j2k->m_cp.rsiz))) {
l_coc_bytes = opj_j2k_get_max_coc_size(p_j2k);
l_nb_bytes += l_nb_comps * l_coc_bytes;
@@ -4737,7 +4717,7 @@ OPJ_BOOL opj_j2k_update_rates( opj_j2k_t *p_j2k,
return OPJ_FALSE;
}
if (l_cp->m_specific_param.m_enc.m_cinema) {
if (OPJ_IS_CINEMA(l_cp->rsiz)) {
p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer =
(OPJ_BYTE *) opj_malloc(5*p_j2k->m_specific_param.m_encoder.m_total_tile_parts);
if (! p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer) {
@@ -5929,24 +5909,8 @@ int opj_j2k_initialise_4K_poc(opj_poc_t *POC, int numres){
void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters, opj_image_t *image, opj_event_mgr_t *p_manager)
{
/* Configure cinema parameters */
OPJ_FLOAT32 max_rate = 0;
OPJ_FLOAT32 temp_rate = 0;
int i;
/* profile (Rsiz) */
switch (parameters->cp_cinema){
case OPJ_CINEMA2K_24:
case OPJ_CINEMA2K_48:
parameters->cp_rsiz = OPJ_CINEMA2K;
break;
case OPJ_CINEMA4K_24:
parameters->cp_rsiz = OPJ_CINEMA4K;
break;
case OPJ_OFF:
assert(0);
break;
}
/* No tiling */
parameters->tile_size_on = OPJ_FALSE;
parameters->cp_tdx=1;
@@ -5984,15 +5948,16 @@ void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters, opj_image_t *i
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n"
"1 single quality layer"
"-> Number of layers forced to 1 (rather than %d)\n",
parameters->tcp_numlayers);
"-> Number of layers forced to 1 (rather than %d)\n"
"-> Rate of the last layer (%3.1f) will be used",
parameters->tcp_numlayers, parameters->tcp_rates[parameters->tcp_numlayers-1]);
parameters->tcp_rates[0] = parameters->tcp_rates[parameters->tcp_numlayers-1];
parameters->tcp_numlayers = 1;
}
/* Resolution levels */
switch (parameters->cp_cinema){
case OPJ_CINEMA2K_24:
case OPJ_CINEMA2K_48:
switch (parameters->rsiz){
case OPJ_PROFILE_CINEMA_2K:
if(parameters->numresolution > 6){
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Profile-3 (2k dc profile) requires:\n"
@@ -6002,7 +5967,7 @@ void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters, opj_image_t *i
parameters->numresolution = 6;
}
break;
case OPJ_CINEMA4K_24:
case OPJ_PROFILE_CINEMA_4K:
if(parameters->numresolution < 2){
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Profile-4 (4k dc profile) requires:\n"
@@ -6035,7 +6000,7 @@ void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters, opj_image_t *i
parameters->prog_order = OPJ_CPRL;
/* Progression order changes for 4K, disallowed for 2K */
if (parameters->cp_cinema == OPJ_CINEMA4K_24) {
if (parameters->rsiz == OPJ_PROFILE_CINEMA_4K) {
parameters->numpocs = (OPJ_UINT32)opj_j2k_initialise_4K_poc(parameters->POC,parameters->numresolution);
} else {
parameters->numpocs = 0;
@@ -6043,62 +6008,42 @@ void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters, opj_image_t *i
/* Limited bit-rate */
parameters->cp_disto_alloc = 1;
switch (parameters->cp_cinema){
case OPJ_CINEMA2K_24:
case OPJ_CINEMA4K_24:
max_rate = (OPJ_FLOAT32) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec)/
(OPJ_FLOAT32)(CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
if (parameters->tcp_rates[0] == 0){
parameters->tcp_rates[0] = max_rate;
}else{
temp_rate =(OPJ_FLOAT32)(image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec)/
(parameters->tcp_rates[0] * 8 * (OPJ_FLOAT32)image->comps[0].dx * (OPJ_FLOAT32)image->comps[0].dy);
if (temp_rate > CINEMA_24_CS ){
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n"
"Maximum 1302083 compressed bytes @ 24fps\n"
"-> Specified rate (%3.1f) exceeds this limit. Rate will be forced to %3.1f.\n",
parameters->tcp_rates[0], max_rate);
parameters->tcp_rates[0]= max_rate;
}else{
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Profile-3 and 4 (2k/4k dc profile):\n"
"INFO : Specified rate (%3.1f) is below the 2k/4k limit @ 24fps.\n",
parameters->tcp_rates[0]);
}
}
parameters->max_comp_size = COMP_24_CS;
break;
case OPJ_CINEMA2K_48:
max_rate = ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(float)(CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
if (parameters->tcp_rates[0] == 0){
parameters->tcp_rates[0] = max_rate;
}else{
temp_rate =((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(parameters->tcp_rates[0] * 8 * (float)image->comps[0].dx * (float)image->comps[0].dy);
if (temp_rate > CINEMA_48_CS ){
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Profile-3 (2k dc profile) requires:\n"
"Maximum 651041 compressed bytes @ 48fps\n"
"-> Specified rate (%3.1f) exceeds this limit. Rate will be forced to %3.1f.\n",
parameters->tcp_rates[0], max_rate);
parameters->tcp_rates[0]= max_rate;
}else{
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Profile-3 (2k dc profile):\n"
"INFO : Specified rate (%3.1f) is below the 2k limit @ 48 fps.\n",
parameters->tcp_rates[0]);
}
}
parameters->max_comp_size = COMP_48_CS;
break;
default:
break;
if (parameters->max_cs_size <= 0) {
/* No rate has been introduced, 24 fps is assumed */
parameters->max_cs_size = OPJ_CINEMA_24_CS;
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n"
"Maximum 1302083 compressed bytes @ 24fps\n"
"As no rate has been given, this limit will be used.\n");
} else if (parameters->max_cs_size > OPJ_CINEMA_24_CS) {
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n"
"Maximum 1302083 compressed bytes @ 24fps\n"
"-> Specified rate exceeds this limit. Rate will be forced to 1302083 bytes.\n");
parameters->max_cs_size = OPJ_CINEMA_24_CS;
}
if (parameters->max_comp_size <= 0) {
/* No rate has been introduced, 24 fps is assumed */
parameters->max_comp_size = OPJ_CINEMA_24_COMP;
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n"
"Maximum 1041666 compressed bytes @ 24fps\n"
"As no rate has been given, this limit will be used.\n");
} else if (parameters->max_comp_size > OPJ_CINEMA_24_COMP) {
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n"
"Maximum 1041666 compressed bytes @ 24fps\n"
"-> Specified rate exceeds this limit. Rate will be forced to 1041666 bytes.\n");
parameters->max_comp_size = OPJ_CINEMA_24_COMP;
}
parameters->tcp_rates[0] = (OPJ_FLOAT32) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec)/
(OPJ_FLOAT32)(((OPJ_UINT32)parameters->max_cs_size) * 8 * image->comps[0].dx * image->comps[0].dy);
}
OPJ_BOOL opj_j2k_is_cinema_compliant(opj_image_t *image, OPJ_CINEMA_MODE cinema_mode, opj_event_mgr_t *p_manager)
OPJ_BOOL opj_j2k_is_cinema_compliant(opj_image_t *image, OPJ_UINT16 rsiz, opj_event_mgr_t *p_manager)
{
OPJ_UINT32 i;
@@ -6130,9 +6075,8 @@ OPJ_BOOL opj_j2k_is_cinema_compliant(opj_image_t *image, OPJ_CINEMA_MODE cinema_
}
/* Image size */
switch (cinema_mode){
case OPJ_CINEMA2K_24:
case OPJ_CINEMA2K_48:
switch (rsiz){
case OPJ_PROFILE_CINEMA_2K:
if (((image->comps[0].w > 2048) | (image->comps[0].h > 1080))){
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Profile-3 (2k dc profile) requires:\n"
@@ -6143,7 +6087,7 @@ OPJ_BOOL opj_j2k_is_cinema_compliant(opj_image_t *image, OPJ_CINEMA_MODE cinema_
return OPJ_FALSE;
}
break;
case OPJ_CINEMA4K_24:
case OPJ_PROFILE_CINEMA_4K:
if (((image->comps[0].w > 4096) | (image->comps[0].h > 2160))){
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Profile-4 (4k dc profile) requires:\n"
@@ -6180,20 +6124,130 @@ void opj_j2k_setup_encoder( opj_j2k_t *p_j2k,
cp->tw = 1;
cp->th = 1;
/* FIXME ADE: to be removed once deprecated cp_cinema and cp_rsiz have been removed */
if (parameters->rsiz == OPJ_PROFILE_NONE) { /* consider deprecated fields only if RSIZ has not been set */
OPJ_BOOL deprecated_used = OPJ_FALSE;
switch (parameters->cp_cinema){
case OPJ_CINEMA2K_24:
parameters->rsiz = OPJ_PROFILE_CINEMA_2K;
parameters->max_cs_size = OPJ_CINEMA_24_CS;
parameters->max_comp_size = OPJ_CINEMA_24_COMP;
deprecated_used = OPJ_TRUE;
break;
case OPJ_CINEMA2K_48:
parameters->rsiz = OPJ_PROFILE_CINEMA_2K;
parameters->max_cs_size = OPJ_CINEMA_48_CS;
parameters->max_comp_size = OPJ_CINEMA_48_COMP;
deprecated_used = OPJ_TRUE;
break;
case OPJ_CINEMA4K_24:
parameters->rsiz = OPJ_PROFILE_CINEMA_4K;
parameters->max_cs_size = OPJ_CINEMA_24_CS;
parameters->max_comp_size = OPJ_CINEMA_24_COMP;
deprecated_used = OPJ_TRUE;
break;
case OPJ_OFF:
default:
break;
}
switch (parameters->cp_rsiz){
case OPJ_CINEMA2K:
parameters->rsiz = OPJ_PROFILE_CINEMA_2K;
deprecated_used = OPJ_TRUE;
break;
case OPJ_CINEMA4K:
parameters->rsiz = OPJ_PROFILE_CINEMA_4K;
deprecated_used = OPJ_TRUE;
break;
case OPJ_MCT:
parameters->rsiz = OPJ_PROFILE_PART2 | OPJ_EXTENSION_MCT;
deprecated_used = OPJ_TRUE;
case OPJ_STD_RSIZ:
default:
break;
}
if (deprecated_used) {
opj_event_msg(p_manager, EVT_WARNING,
"Deprecated fields cp_cinema or cp_rsiz are used\n"
"Please consider using only the rsiz field\n"
"See openjpeg.h documentation for more details\n");
}
}
/* see if max_codestream_size does limit input rate */
if (parameters->max_cs_size <= 0) {
if (parameters->tcp_rates[parameters->tcp_numlayers-1] > 0) {
OPJ_FLOAT32 temp_size;
temp_size =(OPJ_FLOAT32)(image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec)/
(parameters->tcp_rates[parameters->tcp_numlayers-1] * 8 * (OPJ_FLOAT32)image->comps[0].dx * (OPJ_FLOAT32)image->comps[0].dy);
parameters->max_cs_size = (int) floor(temp_size);
} else {
parameters->max_cs_size = 0;
}
} else {
OPJ_FLOAT32 temp_rate;
OPJ_BOOL cap = OPJ_FALSE;
temp_rate = (OPJ_FLOAT32) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec)/
(OPJ_FLOAT32)(((OPJ_UINT32)parameters->max_cs_size) * 8 * image->comps[0].dx * image->comps[0].dy);
for (i = 0; i < (OPJ_UINT32) parameters->tcp_numlayers; i++) {
if (parameters->tcp_rates[i] < temp_rate) {
parameters->tcp_rates[i] = temp_rate;
cap = OPJ_TRUE;
}
}
if (cap) {
opj_event_msg(p_manager, EVT_WARNING,
"The desired maximum codestream size has limited\n"
"at least one of the desired quality layers\n");
}
}
/* Manage profiles and applications and set RSIZ */
/* set cinema parameters if required */
if (parameters->cp_cinema){
opj_j2k_set_cinema_parameters(parameters,image,p_manager);
if (!opj_j2k_is_cinema_compliant(image,parameters->cp_cinema,p_manager)) {
parameters->cp_rsiz = OPJ_STD_RSIZ;
if (OPJ_IS_CINEMA(parameters->rsiz)){
if ((parameters->rsiz == OPJ_PROFILE_CINEMA_S2K)
|| (parameters->rsiz == OPJ_PROFILE_CINEMA_S4K)){
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Scalable Digital Cinema profiles not yet supported\n");
parameters->rsiz = OPJ_PROFILE_NONE;
} else {
opj_j2k_set_cinema_parameters(parameters,image,p_manager);
if (!opj_j2k_is_cinema_compliant(image,parameters->rsiz,p_manager)) {
parameters->rsiz = OPJ_PROFILE_NONE;
}
}
} else if (OPJ_IS_STORAGE(parameters->rsiz)) {
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Long Term Storage profile not yet supported\n");
parameters->rsiz = OPJ_PROFILE_NONE;
} else if (OPJ_IS_BROADCAST(parameters->rsiz)) {
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Broadcast profiles not yet supported\n");
parameters->rsiz = OPJ_PROFILE_NONE;
} else if (OPJ_IS_IMF(parameters->rsiz)) {
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 IMF profiles not yet supported\n");
parameters->rsiz = OPJ_PROFILE_NONE;
} else if (OPJ_IS_PART2(parameters->rsiz)) {
if (parameters->rsiz == ((OPJ_PROFILE_PART2) | (OPJ_EXTENSION_NONE))) {
opj_event_msg(p_manager, EVT_WARNING,
"JPEG 2000 Part-2 profile defined\n"
"but no Part-2 extension enabled.\n"
"Profile set to NONE.\n");
parameters->rsiz = OPJ_PROFILE_NONE;
} else if (parameters->rsiz != ((OPJ_PROFILE_PART2) | (OPJ_EXTENSION_MCT))) {
opj_event_msg(p_manager, EVT_WARNING,
"Unsupported Part-2 extension enabled\n"
"Profile set to NONE.\n");
parameters->rsiz = OPJ_PROFILE_NONE;
}
}
/*
copy user encoding parameters
*/
cp->m_specific_param.m_enc.m_cinema = parameters->cp_cinema;
cp->m_specific_param.m_enc.m_max_comp_size = (OPJ_UINT32)parameters->max_comp_size;
cp->rsiz = parameters->cp_rsiz;
cp->rsiz = parameters->rsiz;
cp->m_specific_param.m_enc.m_disto_alloc = (OPJ_UINT32)parameters->cp_disto_alloc & 1u;
cp->m_specific_param.m_enc.m_fixed_alloc = (OPJ_UINT32)parameters->cp_fixed_alloc & 1u;
cp->m_specific_param.m_enc.m_fixed_quality = (OPJ_UINT32)parameters->cp_fixed_quality & 1u;
@@ -6308,7 +6362,7 @@ void opj_j2k_setup_encoder( opj_j2k_t *p_j2k,
tcp->numlayers = (OPJ_UINT32)parameters->tcp_numlayers;
for (j = 0; j < tcp->numlayers; j++) {
if(cp->m_specific_param.m_enc.m_cinema){
if(OPJ_IS_CINEMA(cp->rsiz)){
if (cp->m_specific_param.m_enc.m_fixed_quality) {
tcp->distoratio[j] = parameters->tcp_distoratio[j];
}
@@ -9813,7 +9867,7 @@ void opj_j2k_setup_end_compress (opj_j2k_t *p_j2k)
/* DEVELOPER CORNER, insert your custom procedures */
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_eoc );
if (p_j2k->m_cp.m_specific_param.m_enc.m_cinema) {
if (OPJ_IS_CINEMA(p_j2k->m_cp.rsiz)) {
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_updated_tlm);
}
@@ -9845,14 +9899,14 @@ void opj_j2k_setup_header_writing (opj_j2k_t *p_j2k)
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_cod );
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_qcd );
if (p_j2k->m_cp.m_specific_param.m_enc.m_cinema) {
if (OPJ_IS_CINEMA(p_j2k->m_cp.rsiz)) {
/* No need for COC or QCC, QCD and COD are used
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_all_coc );
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_all_qcc );
*/
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_tlm );
if (p_j2k->m_cp.m_specific_param.m_enc.m_cinema == OPJ_CINEMA4K_24) {
if (p_j2k->m_cp.rsiz == OPJ_PROFILE_CINEMA_4K) {
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_poc );
}
}
@@ -9864,7 +9918,7 @@ void opj_j2k_setup_header_writing (opj_j2k_t *p_j2k)
}
/* DEVELOPER CORNER, insert your custom procedures */
if (p_j2k->m_cp.rsiz & OPJ_MCT) {
if (p_j2k->m_cp.rsiz & OPJ_EXTENSION_MCT) {
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_mct_data_group );
}
/* End of Developer Corner */
@@ -9913,7 +9967,7 @@ OPJ_BOOL opj_j2k_write_first_tile_part (opj_j2k_t *p_j2k,
p_data += l_current_nb_bytes_written;
p_total_data_size -= l_current_nb_bytes_written;
if (l_cp->m_specific_param.m_enc.m_cinema == 0) {
if (!OPJ_IS_CINEMA(l_cp->rsiz)) {
#if 0
for (compno = 1; compno < p_j2k->m_private_image->numcomps; compno++) {
l_current_nb_bytes_written = 0;
@@ -9950,7 +10004,7 @@ OPJ_BOOL opj_j2k_write_first_tile_part (opj_j2k_t *p_j2k,
/* Writing Psot in SOT marker */
opj_write_bytes(l_begin_data + 6,l_nb_bytes_written,4); /* PSOT */
if (l_cp->m_specific_param.m_enc.m_cinema){
if (OPJ_IS_CINEMA(l_cp->rsiz)){
opj_j2k_update_tlm(p_j2k,l_nb_bytes_written);
}
@@ -10014,7 +10068,7 @@ OPJ_BOOL opj_j2k_write_all_tile_parts( opj_j2k_t *p_j2k,
/* Writing Psot in SOT marker */
opj_write_bytes(l_begin_data + 6,l_part_tile_size,4); /* PSOT */
if (l_cp->m_specific_param.m_enc.m_cinema) {
if (OPJ_IS_CINEMA(l_cp->rsiz)) {
opj_j2k_update_tlm(p_j2k,l_part_tile_size);
}
@@ -10055,7 +10109,7 @@ OPJ_BOOL opj_j2k_write_all_tile_parts( opj_j2k_t *p_j2k,
/* Writing Psot in SOT marker */
opj_write_bytes(l_begin_data + 6,l_part_tile_size,4); /* PSOT */
if (l_cp->m_specific_param.m_enc.m_cinema) {
if (OPJ_IS_CINEMA(l_cp->rsiz)) {
opj_j2k_update_tlm(p_j2k,l_part_tile_size);
}

View File

@@ -304,8 +304,6 @@ typedef struct opj_tcp
typedef struct opj_encoding_param
{
/** Digital cinema profile*/
OPJ_CINEMA_MODE m_cinema;
/** Maximum rate for each component. If == 0, component size limitation is not considered */
OPJ_UINT32 m_max_comp_size;
/** Position of tile part flag in progression order*/
@@ -343,7 +341,7 @@ typedef struct opj_cp
/** Size of the image in bits*/
/*int img_size;*/
/** Rsiz*/
OPJ_RSIZ_CAPABILITIES rsiz;
OPJ_UINT16 rsiz;
/** XTOsiz */
OPJ_UINT32 tx0; /* MSD see norm */
/** YTOsiz */

View File

@@ -1097,6 +1097,8 @@ void opj_jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color)
asoc = info[i].asoc;
if(asoc == 0 || asoc == 65535)
{
if (i < image->numcomps)
image->comps[i].alpha = info[i].typ;
continue;
}
@@ -1120,6 +1122,7 @@ void opj_jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color)
info[acn].asoc = (OPJ_UINT16)(info[acn].cn + 1);
}
image->comps[cn].alpha = info[i].typ;
}
if(color->jp2_cdef->info) opj_free(color->jp2_cdef->info);
@@ -1305,6 +1308,8 @@ OPJ_BOOL opj_jp2_decode(opj_jp2_t *jp2,
p_image->color_space = OPJ_CLRSPC_GRAY;
else if (jp2->enumcs == 18)
p_image->color_space = OPJ_CLRSPC_SYCC;
else if (jp2->enumcs == 24)
p_image->color_space = OPJ_CLRSPC_EYCC;
else
p_image->color_space = OPJ_CLRSPC_UNKNOWN;

View File

@@ -639,10 +639,11 @@ void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *paramete
if(parameters) {
memset(parameters, 0, sizeof(opj_cparameters_t));
/* default coding parameters */
parameters->cp_cinema = OPJ_OFF;
parameters->cp_cinema = OPJ_OFF; /* DEPRECATED */
parameters->rsiz = OPJ_PROFILE_NONE;
parameters->max_comp_size = 0;
parameters->numresolution = 6;
parameters->cp_rsiz = OPJ_STD_RSIZ;
parameters->cp_rsiz = OPJ_STD_RSIZ; /* DEPRECATED */
parameters->cblockw_init = 64;
parameters->cblockh_init = 64;
parameters->prog_order = OPJ_LRCP;
@@ -793,8 +794,11 @@ OPJ_BOOL OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters,
OPJ_UINT32 l_mct_total_size = l_matrix_size + l_dc_shift_size;
/* add MCT capability */
OPJ_INT32 rsiz = (OPJ_INT32)parameters->cp_rsiz | (OPJ_INT32)OPJ_MCT;
parameters->cp_rsiz = (OPJ_RSIZ_CAPABILITIES)rsiz;
if (OPJ_IS_PART2(parameters->rsiz)) {
parameters->rsiz |= OPJ_EXTENSION_MCT;
} else {
parameters->rsiz = ((OPJ_PROFILE_PART2) | (OPJ_EXTENSION_MCT));
}
parameters->irreversible = 1;
/* use array based MCT */
@@ -917,33 +921,44 @@ void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t **p_cstr_index)
}
}
/* ---------------------------------------------------------------------- */
opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (FILE * p_file, OPJ_BOOL p_is_read_stream)
opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (const char *fname, OPJ_BOOL p_is_read_stream)
{
return opj_stream_create_file_stream(p_file,OPJ_J2K_STREAM_CHUNK_SIZE,p_is_read_stream);
return opj_stream_create_file_stream(fname, OPJ_J2K_STREAM_CHUNK_SIZE, p_is_read_stream);
}
opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream ( FILE * p_file,
OPJ_SIZE_T p_size,
OPJ_BOOL p_is_read_stream)
opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (
const char *fname,
OPJ_SIZE_T p_size,
OPJ_BOOL p_is_read_stream)
{
opj_stream_t* l_stream = 00;
opj_stream_t* l_stream = 00;
FILE *p_file;
const char *mode;
if (! p_file) {
return NULL;
}
if (! fname) {
return NULL;
}
if(p_is_read_stream) mode = "rb"; else mode = "wb";
l_stream = opj_stream_create(p_size,p_is_read_stream);
if (! l_stream) {
return NULL;
}
p_file = fopen(fname, mode);
opj_stream_set_user_data(l_stream, p_file);
opj_stream_set_user_data_length(l_stream, opj_get_data_length_from_file(p_file));
opj_stream_set_read_function(l_stream, (opj_stream_read_fn) opj_read_from_file);
opj_stream_set_write_function(l_stream, (opj_stream_write_fn) opj_write_from_file);
opj_stream_set_skip_function(l_stream, (opj_stream_skip_fn) opj_skip_from_file);
opj_stream_set_seek_function(l_stream, (opj_stream_seek_fn) opj_seek_from_file);
if (! p_file) {
return NULL;
}
return l_stream;
l_stream = opj_stream_create(p_size,p_is_read_stream);
if (! l_stream) {
fclose(p_file);
return NULL;
}
opj_stream_set_user_data(l_stream, p_file, (opj_stream_free_user_data_fn) fclose);
opj_stream_set_user_data_length(l_stream, opj_get_data_length_from_file(p_file));
opj_stream_set_read_function(l_stream, (opj_stream_read_fn) opj_read_from_file);
opj_stream_set_write_function(l_stream, (opj_stream_write_fn) opj_write_from_file);
opj_stream_set_skip_function(l_stream, (opj_stream_skip_fn) opj_skip_from_file);
opj_stream_set_seek_function(l_stream, (opj_stream_seek_fn) opj_seek_from_file);
return l_stream;
}

View File

@@ -173,30 +173,88 @@ typedef size_t OPJ_SIZE_T;
#define OPJ_JP2_INFO 128 /**< JP2 file information */
#define OPJ_JP2_IND 256 /**< JP2 file index */
/**
* JPEG 2000 Profiles, see Table A.10 from 15444-1 (updated in various AMD)
* These values help chosing the RSIZ value for the J2K codestream.
* The RSIZ value triggers various encoding options, as detailed in Table A.10.
* If OPJ_PROFILE_PART2 is chosen, it has to be combined with one or more extensions
* described hereunder.
* Example: rsiz = OPJ_PROFILE_PART2 | OPJ_EXTENSION_MCT;
* For broadcast profiles, the OPJ_PROFILE value has to be combined with the targeted
* mainlevel (3-0 LSB, value between 0 and 11):
* Example: rsiz = OPJ_PROFILE_BC_MULTI | 0x0005; (here mainlevel 5)
* For IMF profiles, the OPJ_PROFILE value has to be combined with the targeted mainlevel
* (3-0 LSB, value between 0 and 11) and sublevel (7-4 LSB, value between 0 and 9):
* Example: rsiz = OPJ_PROFILE_IMF_2K | 0x0040 | 0x0005; (here main 5 and sublevel 4)
* */
#define OPJ_PROFILE_NONE 0x0000 /** no profile, conform to 15444-1 */
#define OPJ_PROFILE_0 0x0001 /** Profile 0 as described in 15444-1,Table A.45 */
#define OPJ_PROFILE_1 0x0002 /** Profile 1 as described in 15444-1,Table A.45 */
#define OPJ_PROFILE_PART2 0x8000 /** At least 1 extension defined in 15444-2 (Part-2) */
#define OPJ_PROFILE_CINEMA_2K 0x0003 /** 2K cinema profile defined in 15444-1 AMD1 */
#define OPJ_PROFILE_CINEMA_4K 0x0004 /** 4K cinema profile defined in 15444-1 AMD1 */
#define OPJ_PROFILE_CINEMA_S2K 0x0005 /** Scalable 2K cinema profile defined in 15444-1 AMD2 */
#define OPJ_PROFILE_CINEMA_S4K 0x0006 /** Scalable 4K cinema profile defined in 15444-1 AMD2 */
#define OPJ_PROFILE_CINEMA_LTS 0x0007 /** Long term storage cinema profile defined in 15444-1 AMD2 */
#define OPJ_PROFILE_BC_SINGLE 0x0100 /** Single Tile Broadcast profile defined in 15444-1 AMD3 */
#define OPJ_PROFILE_BC_MULTI 0x0200 /** Multi Tile Broadcast profile defined in 15444-1 AMD3 */
#define OPJ_PROFILE_BC_MULTI_R 0x0300 /** Multi Tile Reversible Broadcast profile defined in 15444-1 AMD3 */
#define OPJ_PROFILE_IMF_2K 0x0400 /** 2K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */
#define OPJ_PROFILE_IMF_4K 0x0401 /** 4K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */
#define OPJ_PROFILE_IMF_8K 0x0402 /** 8K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */
#define OPJ_PROFILE_IMF_2K_R 0x0403 /** 2K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */
#define OPJ_PROFILE_IMF_4K_R 0x0800 /** 4K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */
#define OPJ_PROFILE_IMF_8K_R 0x0801 /** 8K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */
/**
* JPEG 2000 Part-2 extensions
* */
#define OPJ_EXTENSION_NONE 0x0000 /** No Part-2 extension */
#define OPJ_EXTENSION_MCT 0x0100 /** Custom MCT support */
/**
* JPEG 2000 profile macros
* */
#define OPJ_IS_CINEMA(v) (((v) >= OPJ_PROFILE_CINEMA_2K)&&((v) <= OPJ_PROFILE_CINEMA_S4K))
#define OPJ_IS_STORAGE(v) ((v) == OPJ_PROFILE_CINEMA_LTS)
#define OPJ_IS_BROADCAST(v) (((v) >= OPJ_PROFILE_BC_SINGLE)&&((v) <= ((OPJ_PROFILE_BC_MULTI_R) | (0x000b))))
#define OPJ_IS_IMF(v) (((v) >= OPJ_PROFILE_IMF_2K)&&((v) <= ((OPJ_PROFILE_IMF_8K_R) | (0x009b))))
#define OPJ_IS_PART2(v) ((v) & OPJ_PROFILE_PART2)
/**
* JPEG 2000 codestream and component size limits in cinema profiles
* */
#define OPJ_CINEMA_24_CS 1302083 /** Maximum codestream length for 24fps */
#define OPJ_CINEMA_48_CS 651041 /** Maximum codestream length for 48fps */
#define OPJ_CINEMA_24_COMP 1041666 /** Maximum size per color component for 2K & 4K @ 24fps */
#define OPJ_CINEMA_48_COMP 520833 /** Maximum size per color component for 2K @ 48fps */
/*
==========================================================
enum definitions
==========================================================
*/
/**
/**
* DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead
* Rsiz Capabilities
* */
typedef enum RSIZ_CAPABILITIES {
OPJ_STD_RSIZ = 0, /** Standard JPEG2000 profile*/
OPJ_CINEMA2K = 3, /** Profile name for a 2K image*/
OPJ_CINEMA4K = 4, /** Profile name for a 4K image*/
OPJ_MCT = 0x8100
OPJ_STD_RSIZ = 0, /** Standard JPEG2000 profile*/
OPJ_CINEMA2K = 3, /** Profile name for a 2K image*/
OPJ_CINEMA4K = 4, /** Profile name for a 4K image*/
OPJ_MCT = 0x8100
} OPJ_RSIZ_CAPABILITIES;
/**
/**
* DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead
* Digital cinema operation mode
* */
typedef enum CINEMA_MODE {
OPJ_OFF = 0, /** Not Digital Cinema*/
OPJ_CINEMA2K_24 = 1, /** 2K Digital Cinema at 24 fps*/
OPJ_CINEMA2K_48 = 2, /** 2K Digital Cinema at 48 fps*/
OPJ_CINEMA4K_24 = 3 /** 4K Digital Cinema at 24 fps*/
OPJ_OFF = 0, /** Not Digital Cinema*/
OPJ_CINEMA2K_24 = 1, /** 2K Digital Cinema at 24 fps*/
OPJ_CINEMA2K_48 = 2, /** 2K Digital Cinema at 48 fps*/
OPJ_CINEMA4K_24 = 3 /** 4K Digital Cinema at 24 fps*/
}OPJ_CINEMA_MODE;
/**
@@ -215,11 +273,13 @@ typedef enum PROG_ORDER {
* Supported image color spaces
*/
typedef enum COLOR_SPACE {
OPJ_CLRSPC_UNKNOWN = -1, /**< not supported by the library */
OPJ_CLRSPC_UNSPECIFIED = 0, /**< not specified in the codestream */
OPJ_CLRSPC_SRGB = 1, /**< sRGB */
OPJ_CLRSPC_GRAY = 2, /**< grayscale */
OPJ_CLRSPC_SYCC = 3 /**< YUV */
OPJ_CLRSPC_UNKNOWN = -1, /**< not supported by the library */
OPJ_CLRSPC_UNSPECIFIED = 0, /**< not specified in the codestream */
OPJ_CLRSPC_SRGB = 1, /**< sRGB */
OPJ_CLRSPC_GRAY = 2, /**< grayscale */
OPJ_CLRSPC_SYCC = 3, /**< YUV */
OPJ_CLRSPC_EYCC = 4, /**< e-YCC */
OPJ_CLRSPC_CMYK = 5 /**< CMYK */
} OPJ_COLOR_SPACE;
/**
@@ -229,7 +289,9 @@ typedef enum CODEC_FORMAT {
OPJ_CODEC_UNKNOWN = -1, /**< place-holder */
OPJ_CODEC_J2K = 0, /**< JPEG-2000 codestream : read/write */
OPJ_CODEC_JPT = 1, /**< JPT-stream (JPEG 2000, JPIP) : read only */
OPJ_CODEC_JP2 = 2 /**< JPEG-2000 file format : read/write */
OPJ_CODEC_JP2 = 2, /**< JP2 file format : read/write */
OPJ_CODEC_JPP = 3, /**< JPP-stream (JPEG 2000, JPIP) : to be coded */
OPJ_CODEC_JPX = 4 /**< JPX file format (JPEG 2000 Part-2) : to be coded */
} OPJ_CODEC_FORMAT;
@@ -315,7 +377,7 @@ typedef struct opj_cparameters {
OPJ_UINT32 numpocs;
/** number of layers */
int tcp_numlayers;
/** rates of layers */
/** rates of layers - might be subsequently limited by the max_cs_size field */
float tcp_rates[100];
/** different psnr for successive layers */
float tcp_distoratio[100];
@@ -396,12 +458,21 @@ typedef struct opj_cparameters {
/*@}*/
/* <<UniPG */
/** Digital Cinema compliance 0-not compliant, 1-compliant*/
OPJ_CINEMA_MODE cp_cinema;
/** Maximum rate for each component. If == 0, component size limitation is not considered */
/**
* DEPRECATED: use RSIZ, OPJ_PROFILE_* and MAX_COMP_SIZE instead
* Digital Cinema compliance 0-not compliant, 1-compliant
* */
OPJ_CINEMA_MODE cp_cinema;
/**
* Maximum size (in bytes) for each component.
* If == 0, component size limitation is not considered
* */
int max_comp_size;
/** Profile name*/
OPJ_RSIZ_CAPABILITIES cp_rsiz;
/**
* DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead
* Profile name
* */
OPJ_RSIZ_CAPABILITIES cp_rsiz;
/** Tile part generation*/
char tp_on;
/** Flag for Tile part generation*/
@@ -413,6 +484,16 @@ typedef struct opj_cparameters {
/** Naive implementation of MCT restricted to a single reversible array based
encoding without offset concerning all the components. */
void * mct_data;
/**
* Maximum size (in bytes) for the whole codestream.
* If == 0, codestream size limitation is not considered
* If it does not comply with tcp_rates, max_cs_size prevails
* and a warning is issued.
* */
int max_cs_size;
/** RSIZ value
To be used to combine OPJ_PROFILE_*, OPJ_EXTENSION_* and (sub)levels values. */
OPJ_UINT16 rsiz;
} opj_cparameters_t;
#define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001
@@ -522,6 +603,11 @@ typedef OPJ_OFF_T (* opj_stream_skip_fn) (OPJ_OFF_T p_nb_bytes, void * p_user_da
*/
typedef OPJ_BOOL (* opj_stream_seek_fn) (OPJ_OFF_T p_nb_bytes, void * p_user_data) ;
/*
* Callback function prototype for free user data function
*/
typedef void (* opj_stream_free_user_data_fn) (void * p_user_data) ;
/*
* JPEG2000 Stream.
*/
@@ -561,6 +647,8 @@ typedef struct opj_image_comp {
OPJ_UINT32 factor;
/** image component data */
OPJ_INT32 *data;
/** alpha channel */
OPJ_UINT16 alpha;
} opj_image_comp_t;
/**
@@ -1028,7 +1116,7 @@ OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size, O
* @param p_stream the stream to destroy.
*/
OPJ_API void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream);
/**
* Sets the given function to be used as a read function.
* @param p_stream the stream to modify
@@ -1061,8 +1149,9 @@ OPJ_API void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream, o
* Sets the given data to be used as a user data for the stream.
* @param p_stream the stream to modify
* @param p_data the data to set.
* @param p_function the function to free p_data when opj_stream_destroy() is called.
*/
OPJ_API void OPJ_CALLCONV opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data);
OPJ_API void OPJ_CALLCONV opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data, opj_stream_free_user_data_fn p_function);
/**
* Sets the length of the user data for the stream.
@@ -1073,21 +1162,21 @@ OPJ_API void OPJ_CALLCONV opj_stream_set_user_data (opj_stream_t* p_stream, void
OPJ_API void OPJ_CALLCONV opj_stream_set_user_data_length(opj_stream_t* p_stream, OPJ_UINT64 data_length);
/**
* Helper function.
* Sets the stream to be a file stream. The FILE must have been open previously.
* @param p_file the file stream to operate on
* Create a stream from a file identified with its filename with default parameters (helper function)
* @param fname the filename of the file to stream
* @param p_is_read_stream whether the stream is a read stream (true) or not (false)
*/
OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (FILE * p_file, OPJ_BOOL p_is_read_stream);
/**
* FIXME DOC
* @param p_file the file stream to operate on
OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (const char *fname, OPJ_BOOL p_is_read_stream);
/** Create a stream from a file identified with its filename with a specific buffer size
* @param fname the filename of the file to stream
* @param p_buffer_size size of the chunk used to stream
* @param p_is_read_stream whether the stream is a read stream (true) or not (false)
*/
OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (FILE * p_file, OPJ_SIZE_T p_buffer_size, OPJ_BOOL p_is_read_stream);
OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (const char *fname,
OPJ_SIZE_T p_buffer_size,
OPJ_BOOL p_is_read_stream);
/*
==========================================================
event manager functions definitions

View File

@@ -1,2 +1,10 @@
/* create opj_config.h for CMake */
#cmakedefine OPJ_HAVE_STDINT_H @OPJ_HAVE_STDINT_H@
/*--------------------------------------------------------------------------*/
/* OpenJPEG Versioning */
/* Version number. */
#define OPJ_VERSION_MAJOR @OPENJPEG_VERSION_MAJOR@
#define OPJ_VERSION_MINOR @OPENJPEG_VERSION_MINOR@
#define OPJ_VERSION_BUILD @OPENJPEG_VERSION_BUILD@

View File

@@ -1525,7 +1525,7 @@ opj_pi_iterator_t *opj_pi_initialise_encode(const opj_image_t *p_image,
opj_free(l_tmp_ptr);
l_tmp_ptr = 00;
if (l_tcp->POC && ( p_cp->m_specific_param.m_enc.m_cinema || p_t2_mode == FINAL_PASS)) {
if (l_tcp->POC && (OPJ_IS_CINEMA(p_cp->rsiz) || p_t2_mode == FINAL_PASS)) {
opj_pi_update_encode_poc_and_final(p_cp,p_tile_no,l_tx0,l_tx1,l_ty0,l_ty1,l_max_prec,l_max_res,l_dx_min,l_dy_min);
}
else {
@@ -1554,7 +1554,7 @@ void opj_pi_create_encode( opj_pi_iterator_t *pi,
pi[pino].first = 1;
pi[pino].poc.prg = tcp->prg;
if(!(cp->m_specific_param.m_enc.m_tp_on && ((!cp->m_specific_param.m_enc.m_cinema && (t2_mode == FINAL_PASS)) || cp->m_specific_param.m_enc.m_cinema))){
if(!(cp->m_specific_param.m_enc.m_tp_on && ((!OPJ_IS_CINEMA(cp->rsiz) && (t2_mode == FINAL_PASS)) || OPJ_IS_CINEMA(cp->rsiz)))){
pi[pino].poc.resno0 = tcp->resS;
pi[pino].poc.resno1 = tcp->resE;
pi[pino].poc.compno0 = tcp->compS;

View File

@@ -218,7 +218,7 @@ OPJ_BOOL opj_t2_encode_packets( opj_t2_t* p_t2,
opj_image_t *l_image = p_t2->image;
opj_cp_t *l_cp = p_t2->cp;
opj_tcp_t *l_tcp = &l_cp->tcps[p_tile_no];
OPJ_UINT32 pocno = l_cp->m_specific_param.m_enc.m_cinema == OPJ_CINEMA4K_24? 2: 1;
OPJ_UINT32 pocno = (l_cp->rsiz == OPJ_PROFILE_CINEMA_4K)? 2: 1;
OPJ_UINT32 l_max_comp = l_cp->m_specific_param.m_enc.m_max_comp_size > 0 ? l_image->numcomps : 1;
OPJ_UINT32 l_nb_pocs = l_tcp->numpocs + 1;

View File

@@ -502,7 +502,7 @@ OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd,
opj_tcd_makelayer(tcd, layno, thresh, 0);
if (cp->m_specific_param.m_enc.m_fixed_quality) { /* fixed_quality */
if(cp->m_specific_param.m_enc.m_cinema){
if(OPJ_IS_CINEMA(cp->rsiz)){
if (! opj_t2_encode_packets(t2,tcd->tcd_tileno, tcd_tile, layno + 1, dest, p_data_written, maxlen, cstr_info,tcd->cur_tp_num,tcd->tp_pos,tcd->cur_pino,THRESH_CALC)) {
lo = thresh;

View File

@@ -43,7 +43,7 @@ static void info_callback(const char *msg, void *client_data);
static Byte_t * imagetopnm(opj_image_t *image, ihdrbox_param_t **ihdrbox);
Byte_t * j2k_to_pnm( FILE *fp, ihdrbox_param_t **ihdrbox)
Byte_t * j2k_to_pnm( const char *fn, ihdrbox_param_t **ihdrbox)
{
Byte_t *pnmstream = NULL;
opj_dparameters_t parameters; /* decompression parameters */
@@ -55,7 +55,7 @@ Byte_t * j2k_to_pnm( FILE *fp, ihdrbox_param_t **ihdrbox)
opj_set_default_decoder_parameters(&parameters);
/* set a byte stream */
l_stream = opj_stream_create_default_file_stream( fp, 1);
l_stream = opj_stream_create_default_file_stream( fn, OPJ_TRUE);
if (!l_stream){
fprintf(stderr, "ERROR -> failed to create the stream from the file\n");
return NULL;

View File

@@ -34,6 +34,6 @@
#include "byte_manager.h"
#include "ihdrbox_manager.h"
Byte_t * j2k_to_pnm( FILE *fp, ihdrbox_param_t **ihdrbox);
Byte_t * j2k_to_pnm( const char *fn, ihdrbox_param_t **ihdrbox);
#endif /* !JP2K_DECODER_H_ */

View File

@@ -76,19 +76,34 @@ Byte_t * jpipstream_to_pnm( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte
Byte_t *pnmstream;
Byte_t *j2kstream; /* j2k or jp2 codestream */
Byte8_t j2klen;
size_t retlen;
FILE *fp;
const char j2kfname[] = "tmp.j2k";
j2kstream = recons_j2k( msgqueue, jpipstream, csn, fw, fh, &j2klen);
fp = fopen( j2kfname, "w+b");
fwrite( j2kstream, j2klen, 1, fp);
if( !fp )
{
return NULL;
}
j2kstream = recons_j2k( msgqueue, jpipstream, csn, fw, fh, &j2klen);
if( !j2kstream )
{
fclose(fp);
remove( j2kfname);
return NULL;
}
retlen = fwrite( j2kstream, 1, j2klen, fp);
opj_free( j2kstream);
fseek( fp, 0, SEEK_SET);
fclose(fp);
if( retlen != j2klen )
{
remove( j2kfname);
return NULL;
}
pnmstream = j2k_to_pnm( fp, ihdrbox);
pnmstream = j2k_to_pnm( j2kfname, ihdrbox);
fclose( fp);
remove( j2kfname);
return pnmstream;

View File

@@ -30,6 +30,7 @@
#ifdef _WIN32
#include <windows.h>
typedef SSIZE_T ssize_t;
#else
#include <sys/types.h>
#include <sys/socket.h>

View File

@@ -150,9 +150,7 @@ static int infile_format(const char *fname)
/* -------------------------------------------------------------------------- */
int main(int argc, char **argv)
{
FILE *fsrc = NULL;
OPJ_UINT32 index;
OPJ_UINT32 index;
opj_dparameters_t parameters; /* decompression parameters */
opj_image_t* image = NULL;
opj_stream_t *l_stream = NULL; /* Stream */
@@ -175,13 +173,6 @@ int main(int argc, char **argv)
strncpy(parameters.infile, argv[1], OPJ_PATH_LEN - 1);
/* read the input file */
/* ------------------- */
fsrc = fopen(parameters.infile, "rb");
if (!fsrc) {
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
return EXIT_FAILURE;
}
/* decode the JPEG2000 stream */
/* -------------------------- */
@@ -218,10 +209,9 @@ int main(int argc, char **argv)
opj_set_warning_handler(l_codec, warning_callback,00);
opj_set_error_handler(l_codec, error_callback,00);
l_stream = opj_stream_create_default_file_stream(fsrc,1);
l_stream = opj_stream_create_default_file_stream(parameters.infile,1);
if (!l_stream){
fclose(fsrc);
fprintf(stderr, "ERROR -> failed to create the stream from the file\n");
fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n", parameters.infile);
return EXIT_FAILURE;
}
@@ -229,7 +219,6 @@ int main(int argc, char **argv)
if ( !opj_setup_decoder(l_codec, &parameters) ){
fprintf(stderr, "ERROR -> j2k_dump: failed to setup the decoder\n");
opj_stream_destroy(l_stream);
fclose(fsrc);
opj_destroy_codec(l_codec);
return EXIT_FAILURE;
}
@@ -238,7 +227,6 @@ int main(int argc, char **argv)
if(! opj_read_header(l_stream, l_codec, &image)){
fprintf(stderr, "ERROR -> j2k_to_image: failed to read the header\n");
opj_stream_destroy(l_stream);
fclose(fsrc);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
return EXIT_FAILURE;
@@ -262,7 +250,6 @@ int main(int argc, char **argv)
opj_destroy_cstr_info(&cstr_info); \
opj_destroy_codec(l_codec); \
opj_image_destroy(image); \
fclose(fsrc); \
return EXIT_FAILURE; \
} \
for(index = 0; index < image->numcomps; ++index) { \
@@ -272,7 +259,6 @@ int main(int argc, char **argv)
opj_destroy_cstr_info(&cstr_info); \
opj_destroy_codec(l_codec); \
opj_image_destroy(image); \
fclose(fsrc); \
return EXIT_FAILURE; \
} \
} \
@@ -297,9 +283,6 @@ int main(int argc, char **argv)
/* Free image data structure */
opj_image_destroy(image);
/* Close the input file */
fclose(fsrc);
return EXIT_SUCCESS;
}
/*end main*/

View File

@@ -165,7 +165,6 @@ int main (int argc, char *argv[])
opj_dparameters_t l_param;
opj_codec_t * l_codec;
opj_image_t * l_image;
FILE * l_file;
opj_stream_t * l_stream;
OPJ_UINT32 l_data_size;
OPJ_UINT32 l_max_data_size = 1000;
@@ -204,17 +203,8 @@ int main (int argc, char *argv[])
return EXIT_FAILURE;
}
l_file = fopen(input_file,"rb");
if (! l_file)
{
fprintf(stdout, "ERROR while opening input file\n");
free(l_data);
return EXIT_FAILURE;
}
l_stream = opj_stream_create_default_file_stream(l_file,OPJ_TRUE);
l_stream = opj_stream_create_default_file_stream(input_file,OPJ_TRUE);
if (!l_stream){
fclose(l_file);
free(l_data);
fprintf(stderr, "ERROR -> failed to create the stream from the file\n");
return EXIT_FAILURE;
@@ -253,7 +243,6 @@ int main (int argc, char *argv[])
default:
{
fprintf(stderr, "ERROR -> Not a valid JPEG2000 file!\n");
fclose(l_file);
free(l_data);
opj_stream_destroy(l_stream);
return EXIT_FAILURE;
@@ -269,7 +258,6 @@ int main (int argc, char *argv[])
if (! opj_setup_decoder(l_codec, &l_param))
{
fprintf(stderr, "ERROR -> j2k_dump: failed to setup the decoder\n");
fclose(l_file);
free(l_data);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
@@ -280,7 +268,6 @@ int main (int argc, char *argv[])
if (! opj_read_header(l_stream, l_codec, &l_image))
{
fprintf(stderr, "ERROR -> j2k_to_image: failed to read the header\n");
fclose(l_file);
free(l_data);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
@@ -289,7 +276,6 @@ int main (int argc, char *argv[])
if (!opj_set_decode_area(l_codec, l_image, da_x0, da_y0,da_x1, da_y1)){
fprintf(stderr, "ERROR -> j2k_to_image: failed to set the decoded area\n");
fclose(l_file);
free(l_data);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
@@ -311,7 +297,6 @@ int main (int argc, char *argv[])
&l_nb_comps,
&l_go_on))
{
fclose(l_file);
free(l_data);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
@@ -326,7 +311,6 @@ int main (int argc, char *argv[])
OPJ_BYTE *l_new_data = (OPJ_BYTE *) realloc(l_data, l_data_size);
if (! l_new_data)
{
fclose(l_file);
free(l_new_data);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
@@ -339,7 +323,6 @@ int main (int argc, char *argv[])
if (! opj_decode_tile_data(l_codec,l_tile_index,l_data,l_data_size,l_stream))
{
fclose(l_file);
free(l_data);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
@@ -352,7 +335,6 @@ int main (int argc, char *argv[])
if (! opj_end_decompress(l_codec,l_stream))
{
fclose(l_file);
free(l_data);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
@@ -361,7 +343,6 @@ int main (int argc, char *argv[])
}
/* Free memory */
fclose(l_file);
free(l_data);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);

View File

@@ -66,7 +66,6 @@ int main (int argc, char *argv[])
opj_codec_t * l_codec;
opj_image_t * l_image;
opj_image_cmptparm_t l_params [NUM_COMPS_MAX];
FILE * l_file;
opj_stream_t * l_stream;
OPJ_UINT32 l_nb_tiles;
OPJ_UINT32 l_data_size;
@@ -264,18 +263,9 @@ int main (int argc, char *argv[])
return 1;
}
l_file = fopen(output_file,"wb");
if (! l_file) {
fprintf(stderr, "ERROR -> test_tile_encoder: failed to create the output file!\n");
opj_destroy_codec(l_codec);
opj_image_destroy(l_image);
return 1;
}
l_stream = opj_stream_create_default_file_stream(l_file, OPJ_FALSE);
l_stream = opj_stream_create_default_file_stream(output_file, OPJ_FALSE);
if (! l_stream) {
fprintf(stderr, "ERROR -> test_tile_encoder: failed to create the stream from the output file %s !\n",output_file );
fclose(l_file);
opj_destroy_codec(l_codec);
opj_image_destroy(l_image);
return 1;
@@ -283,8 +273,7 @@ int main (int argc, char *argv[])
if (! opj_start_compress(l_codec,l_image,l_stream)) {
fprintf(stderr, "ERROR -> test_tile_encoder: failed to start compress!\n");
opj_stream_destroy(l_stream);
fclose(l_file);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
opj_image_destroy(l_image);
return 1;
@@ -293,8 +282,7 @@ int main (int argc, char *argv[])
for (i=0;i<l_nb_tiles;++i) {
if (! opj_write_tile(l_codec,i,l_data,l_data_size,l_stream)) {
fprintf(stderr, "ERROR -> test_tile_encoder: failed to write the tile %d!\n",i);
opj_stream_destroy(l_stream);
fclose(l_file);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
opj_image_destroy(l_image);
return 1;
@@ -303,15 +291,13 @@ int main (int argc, char *argv[])
if (! opj_end_compress(l_codec,l_stream)) {
fprintf(stderr, "ERROR -> test_tile_encoder: failed to end compress!\n");
opj_stream_destroy(l_stream);
fclose(l_file);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
opj_image_destroy(l_image);
return 1;
}
opj_stream_destroy(l_stream);
fclose(l_file);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
opj_image_destroy(l_image);

View File

@@ -71,7 +71,6 @@ int main(int argc, char *argv[])
opj_image_t *image;
opj_codec_t* l_codec = 00;
OPJ_BOOL bSuccess;
FILE *f;
opj_stream_t *l_stream = 00;
(void)argc;
(void)argv;
@@ -111,11 +110,7 @@ int main(int argc, char *argv[])
opj_setup_encoder(l_codec, &parameters, image);
strcpy(parameters.outfile, "testempty1.j2k");
f = fopen(parameters.outfile, "wb");
assert( f );
l_stream = opj_stream_create_default_file_stream(f,OPJ_FALSE);
l_stream = opj_stream_create_default_file_stream("testempty1.j2k",OPJ_FALSE);
assert(l_stream);
bSuccess = opj_start_compress(l_codec,image,l_stream);
if( !bSuccess )
@@ -133,7 +128,6 @@ int main(int argc, char *argv[])
assert( bSuccess );
opj_stream_destroy(l_stream);
fclose(f);
opj_destroy_codec(l_codec);
opj_image_destroy(image);

View File

@@ -73,7 +73,6 @@ int main(int argc, char *argv[])
opj_image_t *image;
opj_codec_t* l_codec = 00;
OPJ_BOOL bSuccess;
FILE *f;
opj_stream_t *l_stream = 00;
(void)argc;
(void)argv;
@@ -90,6 +89,7 @@ int main(int argc, char *argv[])
cmptparm.dy = subsampling_dy;
cmptparm.w = image_width;
cmptparm.h = image_height;
strncpy(parameters.outfile, outputfile, sizeof(parameters.outfile)-1);
image = opj_image_create(numcomps, &cmptparm, color_space);
assert( image );
@@ -115,15 +115,10 @@ int main(int argc, char *argv[])
opj_setup_encoder(l_codec, &parameters, image);
strcpy(parameters.outfile, outputfile);
f = fopen(parameters.outfile, "wb");
assert( f );
l_stream = opj_stream_create_default_file_stream(f,OPJ_FALSE);
l_stream = opj_stream_create_default_file_stream(parameters.outfile,OPJ_FALSE);
if( !l_stream )
{
fprintf( stderr, "Something went wrong during creation of stream\n" );
fclose(f);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
opj_stream_destroy(l_stream);
@@ -133,7 +128,6 @@ int main(int argc, char *argv[])
bSuccess = opj_start_compress(l_codec,image,l_stream);
if( !bSuccess )
{
fclose(f);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
@@ -147,7 +141,6 @@ int main(int argc, char *argv[])
assert( bSuccess );
opj_stream_destroy(l_stream);
fclose(f);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
@@ -155,10 +148,8 @@ int main(int argc, char *argv[])
/* read back the generated file */
{
FILE *fsrc = fopen(outputfile, "rb");
opj_codec_t* d_codec = 00;
opj_dparameters_t dparameters;
assert( fsrc );
d_codec = opj_create_decompress(OPJ_CODEC_J2K);
opj_set_info_handler(d_codec, info_callback,00);
@@ -168,7 +159,7 @@ int main(int argc, char *argv[])
bSuccess = opj_setup_decoder(d_codec, &dparameters);
assert( bSuccess );
l_stream = opj_stream_create_default_file_stream(fsrc,1);
l_stream = opj_stream_create_default_file_stream(outputfile,1);
assert( l_stream );
bSuccess = opj_read_header(l_stream, d_codec, &image);
@@ -181,7 +172,7 @@ int main(int argc, char *argv[])
assert( bSuccess );
opj_stream_destroy(l_stream);
fclose(fsrc);
opj_destroy_codec(d_codec);
opj_image_destroy(image);