Compare commits
93 Commits
version.1.
...
version.1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb230d0b6b | ||
|
|
5be29a0c5a | ||
|
|
b953d10ee9 | ||
|
|
20f9f96719 | ||
|
|
4776f48477 | ||
|
|
c2f32bb485 | ||
|
|
bba708462d | ||
|
|
4935eaf773 | ||
|
|
bad9a71e77 | ||
|
|
a74a41b932 | ||
|
|
6b5bbc2645 | ||
|
|
8b5f815925 | ||
|
|
abce31e706 | ||
|
|
8062f74deb | ||
|
|
b8fecbbc99 | ||
|
|
cd8896968d | ||
|
|
b94bc0dbe2 | ||
|
|
083d4c2361 | ||
|
|
6c5a066b20 | ||
|
|
835bf5357f | ||
|
|
8a279881d4 | ||
|
|
6da56bb11a | ||
|
|
8cd13f3a55 | ||
|
|
eeca4a220c | ||
|
|
e17dcf58c9 | ||
|
|
39ac7c479f | ||
|
|
401e9cbb5c | ||
|
|
5dbf771bb9 | ||
|
|
ce9d5083ef | ||
|
|
baa7e32f9c | ||
|
|
097496a9f0 | ||
|
|
6b649f3bf6 | ||
|
|
65f8ae765e | ||
|
|
3aba3e203b | ||
|
|
95cf10e979 | ||
|
|
3a643798bd | ||
|
|
875591f664 | ||
|
|
4e8aea6b5a | ||
|
|
5379ec5715 | ||
|
|
b431cb0a41 | ||
|
|
dfbab28b4d | ||
|
|
3819c1b5f4 | ||
|
|
b09cd38b08 | ||
|
|
da453218a4 | ||
|
|
e0795464c1 | ||
|
|
fab8de59d3 | ||
|
|
dcf78f14f6 | ||
|
|
d1a1653f2a | ||
|
|
5a817eba3d | ||
|
|
ce5bbefff0 | ||
|
|
a5d96e54b9 | ||
|
|
2dddf54f8b | ||
|
|
992409c00c | ||
|
|
ee9c46d350 | ||
|
|
87a1081f7c | ||
|
|
83332e13ad | ||
|
|
675f34fabd | ||
|
|
0c7b21c46f | ||
|
|
590ba6d460 | ||
|
|
6f314ae48e | ||
|
|
24ab49a363 | ||
|
|
ecb36f02c8 | ||
|
|
8c9fd1b351 | ||
|
|
dd999a2840 | ||
|
|
b3b2ee0925 | ||
|
|
58cfcaff9f | ||
|
|
c1c2d24b16 | ||
|
|
cefa643823 | ||
|
|
64e37e2a66 | ||
|
|
545680cdb4 | ||
|
|
23cab09e07 | ||
|
|
8336ace29a | ||
|
|
a794ee233d | ||
|
|
a39e4a2a82 | ||
|
|
b267239603 | ||
|
|
54e4e8f809 | ||
|
|
8fc06de0c5 | ||
|
|
9a5ab44e35 | ||
|
|
4d76145884 | ||
|
|
bdf1343f62 | ||
|
|
52f5452d4d | ||
|
|
a9b7c7b0b4 | ||
|
|
07521a5dc2 | ||
|
|
d1bb3ed1f2 | ||
|
|
6c6cd79820 | ||
|
|
7b6ae8810d | ||
|
|
699f172e6c | ||
|
|
5fbf79e730 | ||
|
|
aa28216f9b | ||
|
|
e449cb706f | ||
|
|
a85c5151ce | ||
|
|
ed58a22d2e | ||
|
|
3408787101 |
425
CHANGES
Normal file
425
CHANGES
Normal file
@@ -0,0 +1,425 @@
|
|||||||
|
2012-09-10 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1920] NEWS: [1.5] update NEWS file
|
||||||
|
* [r1919] libopenjpeg/j2k.c: [1.5] Fix Heap-based buffer-overflow
|
||||||
|
when decoding openjpeg image
|
||||||
|
|
||||||
|
Thanks to Huzaifa Sidhpurwala of Red Hat Security Response Team
|
||||||
|
for dataset to reproduce the issue.
|
||||||
|
Fixes issue 170
|
||||||
|
* [r1917] libopenjpeg/event.c: [1.5] Fix issue with str_length not
|
||||||
|
being used. Rewrite code to prefer use of vsnprintf to prevent
|
||||||
|
potential buffer overflow.
|
||||||
|
* [r1914] libopenjpeg/jpwl/crc.c, libopenjpeg/jpwl/jpwl_lib.c:
|
||||||
|
[1.5] remove extra trailing semicolon
|
||||||
|
|
||||||
|
2012-08-24 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1899] applications/codec/j2k_dump.c,
|
||||||
|
applications/jpip/libopenjpip/byte_manager.c,
|
||||||
|
libopenjpeg/jpwl/jpwl_lib.c, libopenjpeg/tcd.c: [1.5] COMP: Fix
|
||||||
|
warnings identified by clang31
|
||||||
|
|
||||||
|
openjpeg/libopenjpeg/tcd.c:1884 col 48: warning: comparison of
|
||||||
|
unsigned expressi
|
||||||
|
on < 0 is always false
|
||||||
|
|
||||||
|
openjpeg/applications/codec/j2k_dump.c:362 col 29: warning:
|
||||||
|
equality comparison
|
||||||
|
with extraneous parentheses
|
||||||
|
|
||||||
|
openjpeg/libopenjpeg/jpwl/jpwl_lib.c:680:19: warning: format
|
||||||
|
specifies type 'int
|
||||||
|
' but the argument has type 'long long' [-Wformat]
|
||||||
|
printf("Marker@%d: %X\n", cio_tell(cio) - 2, id);
|
||||||
|
~^ ~~~~~~~~~~~~~~~~~
|
||||||
|
%lld
|
||||||
|
|
||||||
|
openjpeg/applications/jpip/libopenjpip/byte_manager.c:58:63:
|
||||||
|
warning: format spe
|
||||||
|
cifies type 'long' but the argument has type 'OPJ_OFF_T' (aka
|
||||||
|
'long long') [-Wfo
|
||||||
|
rmat]
|
||||||
|
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld,
|
||||||
|
%lu)\n", fd, offset
|
||||||
|
, size);
|
||||||
|
|
||||||
|
Author: Hans Johnson <hans-johnson@uiowa.edu>
|
||||||
|
|
||||||
|
2012-07-29 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1736] applications/jpip/libopenjpip/sock_manager.c: [1.5]
|
||||||
|
Import portion of patch from Alex Zimnitsky to fix compilation on
|
||||||
|
FreeBSD
|
||||||
|
|
||||||
|
2012-07-11 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1733] libopenjpeg/cio.c, libopenjpeg/cio.h: [1.5] Fix
|
||||||
|
compilation issue with Compiler Borland C++ v. 5.5
|
||||||
|
|
||||||
|
Fixes issue 154
|
||||||
|
* [r1732] libopenjpeg/j2k.c: [1.5] Fix r1727 (Issue 156) to compile
|
||||||
|
on compilers where false is not defined.
|
||||||
|
* [r1729] libopenjpeg/j2k.c, libopenjpeg/tcd.c: [1.5] This fixes
|
||||||
|
issues seen on PDF files
|
||||||
|
|
||||||
|
Fixes issue 156
|
||||||
|
|
||||||
|
2012-07-10 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1727] libopenjpeg/j2k.c: [1.5] Fix heap buffer overflow
|
||||||
|
|
||||||
|
Enforce sanity checks on tile number and tile length, even when
|
||||||
|
the (rather
|
||||||
|
broken) USE_JPWL code isn't enabled.
|
||||||
|
|
||||||
|
2012-05-29 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1705] libopenjpeg/jp2.c: [1.5] jp2_read_boxhdr() call ignores
|
||||||
|
return value
|
||||||
|
Fixes issue 91
|
||||||
|
* [r1704] applications/mj2/frames_to_mj2.c, applications/mj2/mj2.c,
|
||||||
|
applications/mj2/mj2_convert.c: [1.5] Make sure openjpeg/mj2 can
|
||||||
|
be compiled with gcc -std=c89
|
||||||
|
* [r1703] libopenjpeg/tcd.c: [1.5] This commit hides symptoms of
|
||||||
|
CVE-2009-5030
|
||||||
|
|
||||||
|
As explained in issue 5, comment 1. This is an easy fix to avoid
|
||||||
|
memory overrun.
|
||||||
|
Update issue 5
|
||||||
|
Update issue 62
|
||||||
|
* [r1702] libopenjpeg/j2k.c,
|
||||||
|
tests/nonregression/test_suite.ctest.in: [1.5] Applying old patch
|
||||||
|
from r1642, with further modification from winfried. Also enable
|
||||||
|
failing test. Everything seems to be working well now.
|
||||||
|
Fixes issue 150
|
||||||
|
* [r1701] libopenjpeg/tcd.c: [1.5] Import r1669 from trunk over to
|
||||||
|
1.5 branch
|
||||||
|
* [r1700] libopenjpeg/j2k.c, libopenjpeg/t1.c, libopenjpeg/t2.c,
|
||||||
|
libopenjpeg/tcd.c: [1.5] Apply private patch from Alex Macfarlane
|
||||||
|
Smith
|
||||||
|
This gets rids of a lot memory leaks when used on device with low
|
||||||
|
memory
|
||||||
|
* [r1696] applications/codec/convert.c, libopenjpeg/jp2.c: [1.5]
|
||||||
|
The two files in Issue145 have a precision < 8-bit:
|
||||||
|
therefore 'jp2_read_pclr' must be changed.
|
||||||
|
|
||||||
|
j2k_to_image fails to create RGB/RGBA images with a
|
||||||
|
precision < 8-bit: therefore 'imagetopng' must be
|
||||||
|
changed.
|
||||||
|
Update issue 145
|
||||||
|
* [r1694] libopenjpeg-jpwl.pc.in, libopenjpeg/Makefile.am: [1.5]
|
||||||
|
Fix autotools installation. Thanks to winfried for patch.
|
||||||
|
Update issue 149
|
||||||
|
* [r1693] libopenjpeg/opj_malloc.h: [1.5] Fix compilation on
|
||||||
|
FreeBSD. Thanks to rafael carre (funman@videolan.org) for patch.
|
||||||
|
|
||||||
|
Fixes issue 111
|
||||||
|
|
||||||
|
2012-05-21 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1686] libopenjpeg/opj_malloc.h: [1.5] Build fails on AIX
|
||||||
|
|
||||||
|
Fixes issue 139
|
||||||
|
* [r1683] doc/man/man1/image_to_j2k.1, doc/man/man1/j2k_to_image.1,
|
||||||
|
doc/man/man3/libopenjpeg.3: [1.5] Man page syntax fixes. Thanks
|
||||||
|
to vskytta for patch.
|
||||||
|
|
||||||
|
Fixes issue 147
|
||||||
|
* [r1682] libopenjpeg/tcd.c: [1.5] fix compilation warning about
|
||||||
|
lrintf being implicit.
|
||||||
|
|
||||||
|
Fixes issue 144
|
||||||
|
|
||||||
|
2012-04-23 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1649] libopenjpeg/j2k.c: [1.5] Revert r1642, as explained on
|
||||||
|
https://groups.google.com/group/openjpeg/msg/77a67fef94a0309b
|
||||||
|
* [r1648] tests/nonregression/test_suite.ctest.in: [1.5] Adding
|
||||||
|
test suite for file409752.jp2
|
||||||
|
* [r1647] CMakeLists.txt: [1.5] Make it easier to find /data from
|
||||||
|
within 1.5 sub-branch
|
||||||
|
* [r1643] applications/JavaOpenJPEG/JavaOpenJPEG.c,
|
||||||
|
applications/JavaOpenJPEG/JavaOpenJPEGDecoder.c,
|
||||||
|
applications/codec/convert.c: [1.5] Integrate patch from winfried
|
||||||
|
posted on the mailing list. See here for more info:
|
||||||
|
https://groups.google.com/group/openjpeg/msg/6488859a0dce77
|
||||||
|
* [r1642] libopenjpeg/j2k.c: [1.5] Integrate patch from winfried
|
||||||
|
posted on the mailing list. See here for more info:
|
||||||
|
https://groups.google.com/group/openjpeg/msg/1bbf7ae7ddee3a51
|
||||||
|
* [r1640] applications/mj2/extract_j2k_from_mj2.c,
|
||||||
|
applications/mj2/frames_to_mj2.c, applications/mj2/mj2.h,
|
||||||
|
applications/mj2/mj2_to_frames.c,
|
||||||
|
applications/mj2/wrap_j2k_in_mj2.c, libopenjpeg/openjpeg.h: [1.5]
|
||||||
|
Integrate patch from winfried posted on the mailing list. See
|
||||||
|
here for more info:
|
||||||
|
https://groups.google.com/group/openjpeg/msg/7e30b6e288ad5908
|
||||||
|
|
||||||
|
2012-04-20 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1637] applications/jpip/util/CMakeLists.txt,
|
||||||
|
applications/jpip/util/addXMLinJP2.c: [1.5] Need to
|
||||||
|
compile/install tool to embed XML file in JP2 for jpip server
|
||||||
|
|
||||||
|
2012-04-19 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1636] applications/JavaOpenJPEG/CMakeLists.txt,
|
||||||
|
applications/jpip/util/CMakeLists.txt: [1.5] jar files are arch
|
||||||
|
independant. We can install them safely in share
|
||||||
|
* [r1635] applications/jpip/util/CMakeLists.txt: [1.5] Add install
|
||||||
|
rules for openjpip client
|
||||||
|
* [r1634] applications/JavaOpenJPEG/CMakeLists.txt: [1.5] Add
|
||||||
|
missing symbols from getopt into the java glue lib
|
||||||
|
* [r1633] applications/JavaOpenJPEG/CMakeLists.txt: [1.5] resolve
|
||||||
|
missing symbols from convert.c/index.c
|
||||||
|
* [r1632] applications/JavaOpenJPEG/CMakeLists.txt: [1.5] Add
|
||||||
|
explicit linking from glue java lib to real openjpeg lib
|
||||||
|
* [r1631] applications/JavaOpenJPEG/CMakeLists.txt: [1.5] install
|
||||||
|
java module
|
||||||
|
* [r1630] CMake/OpenJPEGConfig.cmake.in, CMakeLists.txt: [1.5] Fix
|
||||||
|
computation of relative path from include/ to lib/
|
||||||
|
|
||||||
|
2012-04-18 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1629] CMakeLists.txt, libopenjpeg/jpwl/CMakeLists.txt,
|
||||||
|
tests/unit/testempty1.c, tests/unit/testempty2.c: [1.5] fix
|
||||||
|
compilation warnings on windows box
|
||||||
|
|
||||||
|
2012-04-16 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1628] libopenjpeg/jpwl/CMakeLists.txt: [1.5] debian tools
|
||||||
|
detected a missing link to math lib
|
||||||
|
|
||||||
|
2012-04-06 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1626] tests/CMakeLists.txt, tests/unit,
|
||||||
|
tests/unit/CMakeLists.txt, tests/unit/testempty1.c,
|
||||||
|
tests/unit/testempty2.c: [1.5] Adding some simple unit tests
|
||||||
|
|
||||||
|
2012-04-05 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1625] CMakeLists.txt: [1.5] introduce fix for the SOVERSION
|
||||||
|
regression introduced in 1.5.0
|
||||||
|
|
||||||
|
2012-03-16 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1571] applications/jpip/libopenjpip/j2kheader_manager.c,
|
||||||
|
applications/jpip/libopenjpip/query_parser.c: [1.5] Remove a
|
||||||
|
simple warning report
|
||||||
|
* [r1570] applications/jpip/libopenjpip/query_parser.c: [1.5] I
|
||||||
|
think == was meant here.
|
||||||
|
|
||||||
|
2012-03-02 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1534] applications/jpip/libopenjpip/channel_manager.c: [1.5]
|
||||||
|
Remove a warning about undefined snprintf on windows compiler.
|
||||||
|
* [r1533] applications/jpip/libopenjpip/auxtrans_manager.c,
|
||||||
|
applications/jpip/libopenjpip/byte_manager.h,
|
||||||
|
applications/jpip/libopenjpip/channel_manager.c,
|
||||||
|
applications/jpip/libopenjpip/channel_manager.h,
|
||||||
|
applications/jpip/libopenjpip/codestream_manager.c,
|
||||||
|
applications/jpip/libopenjpip/j2kheader_manager.c,
|
||||||
|
applications/jpip/libopenjpip/jp2k_decoder.c,
|
||||||
|
applications/jpip/libopenjpip/manfbox_manager.c,
|
||||||
|
applications/jpip/libopenjpip/marker_manager.c,
|
||||||
|
applications/jpip/libopenjpip/mhixbox_manager.c,
|
||||||
|
applications/jpip/libopenjpip/session_manager.c,
|
||||||
|
applications/jpip/libopenjpip/session_manager.h: [1.5] Change the
|
||||||
|
logic in byte_manager.h. Prefer the use of stdint.h when
|
||||||
|
available. Default to compiler specific mecanism otherwise.
|
||||||
|
Remove some c++ comments. Fix signed vs unsigned comparison
|
||||||
|
* [r1527] doc/CMakeLists.txt, doc/Doxyfile.dox.cmake.in: [1.5]
|
||||||
|
Finish import of r963
|
||||||
|
* [r1526] ., doc/Doxyfile.dox, doc/Doxyfile.dox.cmake.in,
|
||||||
|
doc/mainpage.dox.cmake[CPY]: [1.5] merge r963 from trunk over to
|
||||||
|
branch 1.5
|
||||||
|
* [r1524] tests/nonregression/test_suite.ctest.in: [1.5] Convert
|
||||||
|
from DOS eol to UNIX eol
|
||||||
|
* [r1517] libopenjpeg/jpwl/README.txt, libopenjpeg/jpwl/crc.c,
|
||||||
|
libopenjpeg/jpwl/jpwl.c: [1.5] Set from DOS eol to UNIX eol
|
||||||
|
* [r1510] libopenjpeg/cidx_manager.c: [1.5] Sync with trunk and
|
||||||
|
remove uneeded include headers
|
||||||
|
* [r1506] applications/mj2/extract_j2k_from_mj2.c,
|
||||||
|
applications/mj2/frames_to_mj2.c, applications/mj2/mj2.c: [1.5]
|
||||||
|
Import rev 1053 from trunk over to 1.5
|
||||||
|
* [r1504] applications/codec/j2k_dump.c: [1.5] Fix typo in date.
|
||||||
|
* [r1496] applications/jpip/libopenjpip/comMakefile.mk[DEL]: [1.5]
|
||||||
|
Sync with trunk. Remove remainings bits of old Makefile based
|
||||||
|
build system
|
||||||
|
* [r1492] applications/codec/index.c, applications/codec/index.h,
|
||||||
|
applications/codec/windirent.h: [1.5] Convert from DOS eol to
|
||||||
|
UNIX eol
|
||||||
|
* [r1488] applications/OPJViewer/CMakeLists.txt,
|
||||||
|
applications/OPJViewer/OPJViewer.iss,
|
||||||
|
applications/OPJViewer/Readme.txt,
|
||||||
|
applications/OPJViewer/about/about.htm,
|
||||||
|
applications/OPJViewer/source/OPJAbout.cpp,
|
||||||
|
applications/OPJViewer/source/OPJChild16.xpm,
|
||||||
|
applications/OPJViewer/source/OPJDialogs.cpp,
|
||||||
|
applications/OPJViewer/source/OPJThreads.cpp,
|
||||||
|
applications/OPJViewer/source/OPJViewer.cpp,
|
||||||
|
applications/OPJViewer/source/OPJViewer.h,
|
||||||
|
applications/OPJViewer/source/OPJViewer.rc,
|
||||||
|
applications/OPJViewer/source/OPJViewer16.xpm,
|
||||||
|
applications/OPJViewer/source/about_htm.h,
|
||||||
|
applications/OPJViewer/source/build.h,
|
||||||
|
applications/OPJViewer/source/imagjpeg2000.cpp,
|
||||||
|
applications/OPJViewer/source/imagjpeg2000.h,
|
||||||
|
applications/OPJViewer/source/imagmxf.cpp,
|
||||||
|
applications/OPJViewer/source/imagmxf.h,
|
||||||
|
applications/OPJViewer/source/license.txt,
|
||||||
|
applications/OPJViewer/source/readmeafter.txt,
|
||||||
|
applications/OPJViewer/source/readmebefore.txt,
|
||||||
|
applications/OPJViewer/source/wxj2kparser.cpp,
|
||||||
|
applications/OPJViewer/source/wxjp2parser.cpp: [1.5] Use UNIX eol
|
||||||
|
for source code
|
||||||
|
* [r1486] INSTALL: [1.5] Sync with trunk.
|
||||||
|
* [r1482] CMakeLists.txt: [1.5] As discussed on the mailing list.
|
||||||
|
OpenJPEG should be compatible with Multi-Arch distros. Thanks to
|
||||||
|
Rex for report
|
||||||
|
* [r1481] applications/jpip/libopenjpip/box_manager.c,
|
||||||
|
applications/jpip/libopenjpip/box_manager.h,
|
||||||
|
applications/jpip/libopenjpip/boxheader_manager.c,
|
||||||
|
applications/jpip/libopenjpip/byte_manager.h,
|
||||||
|
applications/jpip/libopenjpip/cachemodel_manager.c,
|
||||||
|
applications/jpip/libopenjpip/cachemodel_manager.h,
|
||||||
|
applications/jpip/libopenjpip/imgreg_manager.c,
|
||||||
|
applications/jpip/libopenjpip/imgreg_manager.h,
|
||||||
|
applications/jpip/libopenjpip/jp2k_encoder.c,
|
||||||
|
applications/jpip/libopenjpip/jpip_parser.c,
|
||||||
|
applications/jpip/libopenjpip/manfbox_manager.c,
|
||||||
|
applications/jpip/libopenjpip/manfbox_manager.h,
|
||||||
|
applications/jpip/libopenjpip/metadata_manager.c,
|
||||||
|
applications/jpip/libopenjpip/metadata_manager.h,
|
||||||
|
applications/jpip/libopenjpip/placeholder_manager.c,
|
||||||
|
applications/jpip/libopenjpip/placeholder_manager.h,
|
||||||
|
applications/jpip/libopenjpip/target_manager.c,
|
||||||
|
applications/jpip/libopenjpip/target_manager.h,
|
||||||
|
applications/jpip/util/jpip_to_j2k.c,
|
||||||
|
applications/jpip/util/opj_server.c: [1.5] Fix a bunch of
|
||||||
|
comparison between signed and unsigned integer expressions. Some
|
||||||
|
are still left to decide.
|
||||||
|
|
||||||
|
2012-03-01 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1480] applications/jpip/libopenjpip/openjpip.c: [1.5] Fix rev
|
||||||
|
1474, typo in the spelling.
|
||||||
|
* [r1479] libopenjpeg/jpwl/jpwl.c: [1.5] Fix a warning about
|
||||||
|
comparison of ulong >= 0. Thanks to winfried for report.
|
||||||
|
* [r1475] applications/codec/convert.c: [1.5] Apply big-endian
|
||||||
|
patch from winfried: libopenjpeg and WORDS_BIGENDIAN, 2012/02/14
|
||||||
|
* [r1474] applications/jpip/libopenjpip/openjpip.c: Fix a warning
|
||||||
|
reported on the continuous dashboard for linux.
|
||||||
|
* [r1473] applications/codec/convert.c: [1.5] j2k_to_image does not
|
||||||
|
support writing image with precision less than 8bits. Simply give
|
||||||
|
up for now. Thanks to winfried for report. Also add static
|
||||||
|
keyword for undeclared function in convert.h
|
||||||
|
* [r1472] applications/jpip/libopenjpip/jpipstream_manager.c,
|
||||||
|
applications/jpip/libopenjpip/jpipstream_manager.h: [1.5] Fix a
|
||||||
|
warning about conversion from const char* to char*
|
||||||
|
* [r1471] CMakeLists.txt: [1.5] cmake recommends the use of
|
||||||
|
fullpath. Thanks to winfried for report.
|
||||||
|
* [r1468] libopenjpeg/jpwl/CMakeLists.txt: [1.5] Fix JPWL's DLL
|
||||||
|
installation. Thanks to winfried for report.
|
||||||
|
|
||||||
|
2012-02-29 Kaori Hagihara
|
||||||
|
|
||||||
|
* [r1467] applications/jpip/README: [1.5][JPIP] README modification
|
||||||
|
regarding the JP2 encoding
|
||||||
|
|
||||||
|
2012-02-28 Rex Dieter
|
||||||
|
|
||||||
|
* [r1464] CMakeLists.txt, libopenjpeg/CMakeLists.txt,
|
||||||
|
libopenjpeg1.pc.cmake: allow finer-grain control of header
|
||||||
|
location via OPENJPEG_INSTALL_INCLUDE_DIR
|
||||||
|
* [r1463] CMakeLists.txt, libopenjpeg1.pc.cmake: fix assumptions
|
||||||
|
that OPENJPEG_INSTALL_*_DIR aren't relative paths
|
||||||
|
|
||||||
|
2012-02-28 Kaori Hagihara
|
||||||
|
|
||||||
|
* [r1462] applications/jpip/CHANGES,
|
||||||
|
applications/jpip/libopenjpip/comMakefile.mk,
|
||||||
|
applications/jpip/libopenjpip/jpip_parser.c,
|
||||||
|
applications/jpip/libopenjpip/metadata_manager.c,
|
||||||
|
applications/jpip/libopenjpip/openjpip.c,
|
||||||
|
applications/jpip/libopenjpip/query_parser.c,
|
||||||
|
applications/jpip/util/opj_server.c: [1.5][JPIP] enabled the
|
||||||
|
opj_server to reply the first query consisting with len request
|
||||||
|
from kakadu client
|
||||||
|
|
||||||
|
2012-02-23 Rex Dieter
|
||||||
|
|
||||||
|
* [r1460] libopenjpeg1.pc.cmake, libopenjpeg1.pc.in: fix pkgconfig
|
||||||
|
to include -I/usr/include/openjpeg-1.5 in cflags (issue #118)
|
||||||
|
|
||||||
|
2012-02-17 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1444] applications/jpip/util/CMakeLists.txt: [1.5] allow
|
||||||
|
mecanism to provide JFLAGS
|
||||||
|
|
||||||
|
2012-02-16 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1437] CMakeLists.txt: only install CHANGES when present
|
||||||
|
* [r1436] applications/jpip/util/opj_dec_server.c: remove a warning
|
||||||
|
about unused variable
|
||||||
|
|
||||||
|
2012-02-14 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1435] CMake/CTestCustom.cmake.in: Hide some warnings generated
|
||||||
|
by 3rd party libs
|
||||||
|
* [r1434] applications/jpip/util/opj_dec_server.c: Make the code
|
||||||
|
C90 compliant for VS2010
|
||||||
|
* [r1433] applications/jpip/util/CMakeLists.txt: Work around issue
|
||||||
|
with FindJava module
|
||||||
|
|
||||||
|
2012-02-13 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r1429] applications/jpip/libopenjpip/sock_manager.c: Use C style
|
||||||
|
comment.
|
||||||
|
* [r1424] applications/jpip/libopenjpip/sock_manager.c: [1.5] Need
|
||||||
|
to include unistd for close() declaration
|
||||||
|
* [r1423] applications/jpip/util/CMakeLists.txt: By default,
|
||||||
|
openjpip client can still built even without java compiler. Print
|
||||||
|
a message to the user as warning.
|
||||||
|
* [r1422] applications/jpip/CMakeLists.txt: [1.5] Fix typo in
|
||||||
|
CMAKE_USE_PTHREADS vs CMAKE_USE_PTHREADS_INIT
|
||||||
|
* [r1420] CMake/FindFCGI.cmake: [1.5] Backport diff from trunk
|
||||||
|
* [r1419] CMake/FindPTHREAD.cmake[DEL],
|
||||||
|
applications/jpip/CMakeLists.txt,
|
||||||
|
applications/jpip/libopenjpip/CMakeLists.txt: [1.5] Remove use of
|
||||||
|
custom PTHREAD module. Prefer cmake's one.
|
||||||
|
|
||||||
|
2012-02-10 Kaori Hagihara
|
||||||
|
|
||||||
|
* [r1405] applications/jpip/CHANGES, applications/jpip/README,
|
||||||
|
applications/jpip/util/opj_dec_server.c,
|
||||||
|
applications/jpip/util/opj_viewer/src/ImageManager.java,
|
||||||
|
applications/jpip/util/opj_viewer/src/ImageWindow.java,
|
||||||
|
applications/jpip/util/opj_viewer/src/ImgdecClient.java,
|
||||||
|
applications/jpip/util/opj_viewer_xerces/src/ImageWindow.java:
|
||||||
|
[1.5][JPIP] added execution argument to set port number for
|
||||||
|
opj_dec_server, opj_viewer*
|
||||||
|
* [r1404] applications/jpip/CHANGES,
|
||||||
|
applications/jpip/doc/Doxyfile: [1.5][JPIP] fixed Doxygen
|
||||||
|
configuration file to document the utilities
|
||||||
|
|
||||||
|
2012-02-10 Antonin Descampe
|
||||||
|
|
||||||
|
* [r1403] CMakeLists.txt, libopenjpeg/CMakeLists.txt: [1.5] revert
|
||||||
|
r1399 and r1400
|
||||||
|
* [r1402] doc/Makefile.am: [1.5] fixed an error in autotools that
|
||||||
|
prevented the build because no CHANGES file anymore
|
||||||
|
|
||||||
|
2012-02-10 Rex Dieter
|
||||||
|
|
||||||
|
* [r1401] CMake/OpenJPEGConfig.cmake.in: make OpenJPEGConfig.cmake
|
||||||
|
provide useful (non-empty) values
|
||||||
|
* [r1400] libopenjpeg/CMakeLists.txt: make openjpeg.h header
|
||||||
|
symlink to match autotools
|
||||||
|
* [r1399] CMakeLists.txt: install cmake/pkgconfig bits in LIB_DIR
|
||||||
|
|
||||||
|
2012-02-07 Antonin Descampe
|
||||||
|
|
||||||
|
* [r1391] CMake/OpenJPEGCPack.cmake: update OpenJPEGCPack.cmake
|
||||||
|
with correct package names
|
||||||
|
|
||||||
@@ -29,4 +29,6 @@ SET(CTEST_CUSTOM_WARNING_EXCEPTION
|
|||||||
".*warning,.* is deprecated"
|
".*warning,.* is deprecated"
|
||||||
# supress warnings caused by 3rd party libs:
|
# supress warnings caused by 3rd party libs:
|
||||||
".*/thirdparty/.*"
|
".*/thirdparty/.*"
|
||||||
|
"libtiff.*has no symbols"
|
||||||
|
"libpng.*has no symbols"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -17,4 +17,4 @@ ELSE(FCGI_FOUND)
|
|||||||
SET(FCGI_INCLUDE_DIRS)
|
SET(FCGI_INCLUDE_DIRS)
|
||||||
ENDIF(FCGI_FOUND)
|
ENDIF(FCGI_FOUND)
|
||||||
|
|
||||||
MARK_AS_ADVANCED(FCGI_INCLUDE_DIRS FCGI_LIBRARIES)
|
MARK_AS_ADVANCED(FCGI_INCLUDE_DIR FCGI_LIBRARY)
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
# Look for the header file.
|
|
||||||
FIND_PATH(PTHREAD_INCLUDE_DIR NAMES pthread.h)
|
|
||||||
|
|
||||||
# Look for the library.
|
|
||||||
FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthread)
|
|
||||||
|
|
||||||
# Handle the QUIETLY and REQUIRED arguments and set PTHREAD_FOUND to TRUE if all listed variables are TRUE.
|
|
||||||
INCLUDE(FindPackageHandleStandardArgs)
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PTHREAD DEFAULT_MSG PTHREAD_LIBRARY PTHREAD_INCLUDE_DIR)
|
|
||||||
|
|
||||||
# Copy the results to the output variables.
|
|
||||||
IF(PTHREAD_FOUND)
|
|
||||||
SET(PTHREAD_LIBRARIES ${PTHREAD_LIBRARY})
|
|
||||||
SET(PTHREAD_INCLUDE_DIRS ${PTHREAD_INCLUDE_DIR})
|
|
||||||
ELSE(PTHREAD_FOUND)
|
|
||||||
SET(PTHREAD_LIBRARIES)
|
|
||||||
SET(PTHREAD_INCLUDE_DIRS)
|
|
||||||
ENDIF(PTHREAD_FOUND)
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(PTHREAD_INCLUDE_DIRS PTHREAD_LIBRARIES)
|
|
||||||
@@ -14,11 +14,11 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
|||||||
|
|
||||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${OPJ_PACKAGE_DESCRIPTION_SUMMARY})
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${OPJ_PACKAGE_DESCRIPTION_SUMMARY})
|
||||||
set(CPACK_PACKAGE_VENDOR "OpenJPEG Team")
|
set(CPACK_PACKAGE_VENDOR "OpenJPEG Team")
|
||||||
#set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" COPYONLY
|
"${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" COPYONLY
|
||||||
)
|
)
|
||||||
# For PackageMaker on MacOSX it is important to have a file extension:
|
# For PackageMaker on MacOSX it is important to have a file extension:
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
|
||||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
|
||||||
set(CPACK_PACKAGE_VERSION_MAJOR "${OPENJPEG_VERSION_MAJOR}")
|
set(CPACK_PACKAGE_VERSION_MAJOR "${OPENJPEG_VERSION_MAJOR}")
|
||||||
set(CPACK_PACKAGE_VERSION_MINOR "${OPENJPEG_VERSION_MINOR}")
|
set(CPACK_PACKAGE_VERSION_MINOR "${OPENJPEG_VERSION_MINOR}")
|
||||||
@@ -26,6 +26,39 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
|||||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
||||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "openjpeg-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
set(CPACK_SOURCE_PACKAGE_FILE_NAME "openjpeg-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||||
|
|
||||||
|
# Make this explicit here, rather than accepting the CPack default value,
|
||||||
|
# so we can refer to it:
|
||||||
|
SET(CPACK_PACKAGE_NAME "${OPENJPEG_LIBRARY_NAME}")
|
||||||
|
|
||||||
|
IF(NOT DEFINED CPACK_SYSTEM_NAME)
|
||||||
|
# make sure package is not Cygwin-unknown, for Cygwin just
|
||||||
|
# cygwin is good for the system name
|
||||||
|
IF("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||||
|
SET(CPACK_SYSTEM_NAME Cygwin)
|
||||||
|
ELSE("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||||
|
SET(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
|
||||||
|
ENDIF("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||||
|
ENDIF(NOT DEFINED CPACK_SYSTEM_NAME)
|
||||||
|
IF(${CPACK_SYSTEM_NAME} MATCHES Windows)
|
||||||
|
IF(CMAKE_CL_64)
|
||||||
|
SET(CPACK_SYSTEM_NAME win64-x64)
|
||||||
|
ELSE(CMAKE_CL_64)
|
||||||
|
SET(CPACK_SYSTEM_NAME win32-x86)
|
||||||
|
ENDIF(CMAKE_CL_64)
|
||||||
|
ENDIF(${CPACK_SYSTEM_NAME} MATCHES Windows)
|
||||||
|
|
||||||
|
IF(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
|
||||||
|
# if the CPACK_PACKAGE_FILE_NAME is not defined by the cache
|
||||||
|
# default to source package - system, on cygwin system is not
|
||||||
|
# needed
|
||||||
|
IF(CYGWIN)
|
||||||
|
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
|
||||||
|
ELSE(CYGWIN)
|
||||||
|
SET(CPACK_PACKAGE_FILE_NAME
|
||||||
|
"${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
|
||||||
|
ENDIF(CYGWIN)
|
||||||
|
ENDIF(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
|
||||||
|
|
||||||
set(CPACK_BUNDLE_NAME "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
set(CPACK_BUNDLE_NAME "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
||||||
configure_file(${CMAKE_ROOT}/Templates/AppleInfo.plist
|
configure_file(${CMAKE_ROOT}/Templates/AppleInfo.plist
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
||||||
|
|||||||
@@ -11,22 +11,28 @@ SET(OPENJPEG_MINOR_VERSION "@OPENJPEG_VERSION_MINOR@")
|
|||||||
SET(OPENJPEG_BUILD_VERSION "@OPENJPEG_VERSION_BUILD@")
|
SET(OPENJPEG_BUILD_VERSION "@OPENJPEG_VERSION_BUILD@")
|
||||||
|
|
||||||
# The libraries.
|
# The libraries.
|
||||||
SET(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARIES@")
|
SET(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARY_NAME@")
|
||||||
|
|
||||||
# The CMake macros dir.
|
# The CMake macros dir.
|
||||||
SET(OPENJPEG_CMAKE_DIR "@OPENJPEG_CMAKE_DIR_CONFIG@")
|
SET(OPENJPEG_CMAKE_DIR "@OPENJPEG_INSTALL_PACKAGE_DIR@")
|
||||||
|
|
||||||
# The configuration options.
|
# The configuration options.
|
||||||
SET(OPENJPEG_BUILD_SHARED_LIBS "@OPENJPEG_BUILD_SHARED_LIBS@")
|
SET(OPENJPEG_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
|
||||||
|
|
||||||
# The "use" file.
|
# The "use" file.
|
||||||
SET(OPENJPEG_USE_FILE "@OPENJPEG_USE_FILE_CONFIG@")
|
SET(OPENJPEG_USE_FILE "@OPENJPEG_USE_FILE_CONFIG@")
|
||||||
|
|
||||||
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
# The following is inspired from:
|
||||||
|
# http://www.cmake.org/Wiki/CMake/Tutorials/Packaging#Packaging_and_Exporting
|
||||||
|
# However the following is difficult to handle:
|
||||||
|
# get_filename_component(myproj_INCLUDE_DIRS "${SELF_DIR}/../../include/myproj" ABSOLUTE)
|
||||||
|
# it asssumes a non multi-arch system, where 'include' is located '../include' from lib
|
||||||
|
# therefore we need to take into account the number of subdirs in OPENJPEG_INSTALL_LIB_DIR
|
||||||
if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
# This is an install tree
|
# This is an install tree
|
||||||
include(${SELF_DIR}/OpenJPEGTargets.cmake)
|
include(${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/../../@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
|
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/@relative_parent@/@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
|
||||||
set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_ROOT})
|
set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_ROOT})
|
||||||
|
|
||||||
else(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
else(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
|
|||||||
@@ -29,14 +29,32 @@ INCLUDE_REGULAR_EXPRESSION("^.*$")
|
|||||||
# OPENJPEG version number, useful for packaging and doxygen doc:
|
# OPENJPEG version number, useful for packaging and doxygen doc:
|
||||||
SET(OPENJPEG_VERSION_MAJOR 1)
|
SET(OPENJPEG_VERSION_MAJOR 1)
|
||||||
SET(OPENJPEG_VERSION_MINOR 5)
|
SET(OPENJPEG_VERSION_MINOR 5)
|
||||||
SET(OPENJPEG_VERSION_BUILD 0)
|
SET(OPENJPEG_VERSION_BUILD 1)
|
||||||
SET(OPENJPEG_VERSION
|
SET(OPENJPEG_VERSION
|
||||||
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||||
SET(PACKAGE_VERSION
|
SET(PACKAGE_VERSION
|
||||||
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||||
|
|
||||||
|
# Because autotools does not support X.Y notation for SOVERSION, we have to use
|
||||||
|
# two numerorations, one for the openjpeg version and one for openjpeg soversion
|
||||||
|
# version | soversion
|
||||||
|
# 1.0 | 0
|
||||||
|
# 1.1 | 1
|
||||||
|
# 1.2 | 2
|
||||||
|
# 1.3 | 3
|
||||||
|
# 1.4 | 4
|
||||||
|
# 1.5 | 5
|
||||||
|
# 1.5.1 | 5
|
||||||
|
# 2.0 | 6
|
||||||
|
# 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
|
||||||
|
if(NOT OPENJPEG_SOVERSION)
|
||||||
|
SET(OPENJPEG_SOVERSION 5)
|
||||||
|
endif(NOT OPENJPEG_SOVERSION)
|
||||||
SET(OPENJPEG_LIBRARY_PROPERTIES
|
SET(OPENJPEG_LIBRARY_PROPERTIES
|
||||||
VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
|
VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
|
||||||
SOVERSION "${OPENJPEG_VERSION_MAJOR}"
|
SOVERSION "${OPENJPEG_SOVERSION}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
@@ -86,6 +104,18 @@ IF(NOT OPENJPEG_INSTALL_LIB_DIR)
|
|||||||
SET(OPENJPEG_INSTALL_LIB_DIR "lib")
|
SET(OPENJPEG_INSTALL_LIB_DIR "lib")
|
||||||
ENDIF(NOT OPENJPEG_INSTALL_LIB_DIR)
|
ENDIF(NOT OPENJPEG_INSTALL_LIB_DIR)
|
||||||
|
|
||||||
|
# The following will compute the amount of parent dir to go
|
||||||
|
# from include to lib. it works nicely with
|
||||||
|
# OPENJPEG_INSTALL_LIB_DIR=lib
|
||||||
|
# OPENJPEG_INSTALL_LIB_DIR=lib/
|
||||||
|
# OPENJPEG_INSTALL_LIB_DIR=/lib
|
||||||
|
# OPENJPEG_INSTALL_LIB_DIR=lib/gnu-linux-x64
|
||||||
|
STRING(REPLACE "/" ";" relative_to_lib ${OPENJPEG_INSTALL_LIB_DIR})
|
||||||
|
set(relative_parent "..")
|
||||||
|
foreach( elem ${relative_to_lib})
|
||||||
|
set( relative_parent "${relative_parent}/.." )
|
||||||
|
endforeach()
|
||||||
|
|
||||||
IF(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
IF(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
||||||
SET(OPENJPEG_INSTALL_SHARE_DIR "share")
|
SET(OPENJPEG_INSTALL_SHARE_DIR "share")
|
||||||
ENDIF(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
ENDIF(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
||||||
@@ -95,7 +125,7 @@ IF(NOT OPENJPEG_INSTALL_DATA_DIR)
|
|||||||
ENDIF(NOT OPENJPEG_INSTALL_DATA_DIR)
|
ENDIF(NOT OPENJPEG_INSTALL_DATA_DIR)
|
||||||
|
|
||||||
IF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
IF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||||
SET(OPENJPEG_INSTALL_INCLUDE_DIR "include/")
|
SET(OPENJPEG_INSTALL_INCLUDE_DIR "include/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
ENDIF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
ENDIF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||||
|
|
||||||
IF(NOT OPENJPEG_INSTALL_MAN_DIR)
|
IF(NOT OPENJPEG_INSTALL_MAN_DIR)
|
||||||
@@ -107,7 +137,10 @@ IF(NOT OPENJPEG_INSTALL_DOC_DIR)
|
|||||||
ENDIF(NOT OPENJPEG_INSTALL_DOC_DIR)
|
ENDIF(NOT OPENJPEG_INSTALL_DOC_DIR)
|
||||||
|
|
||||||
IF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
IF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||||
SET(OPENJPEG_INSTALL_PACKAGE_DIR "${OPENJPEG_INSTALL_SHARE_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
# We could install *.cmake files in share/ however those files contains
|
||||||
|
# hardcoded path to libraries on a multi-arch system (fedora/debian) those
|
||||||
|
# path will be different (lib/i386-linux-gnu vs lib/x86_64-linux-gnu)
|
||||||
|
SET(OPENJPEG_INSTALL_PACKAGE_DIR "${OPENJPEG_INSTALL_LIB_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
@@ -143,13 +176,14 @@ ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
|||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# pkgconfig support
|
# pkgconfig support
|
||||||
IF(UNIX)
|
IF(UNIX)
|
||||||
|
# install in lib and not share (see multi-arch note above)
|
||||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libopenjpeg1.pc.cmake
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libopenjpeg1.pc.cmake
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc @ONLY)
|
${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc @ONLY)
|
||||||
INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc DESTINATION
|
INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc DESTINATION
|
||||||
${OPENJPEG_INSTALL_SHARE_DIR}/pkgconfig )
|
${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||||
INSTALL( CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink
|
INSTALL( CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||||
\"libopenjpeg1.pc\"
|
\"libopenjpeg1.pc\"
|
||||||
\"\$ENV{DESTDIR}${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig/libopenjpeg.pc\")")
|
\"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_SHARE_DIR}/pkgconfig/libopenjpeg.pc\")")
|
||||||
ENDIF(UNIX)
|
ENDIF(UNIX)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
@@ -231,6 +265,7 @@ IF(BUILD_TESTING)
|
|||||||
PATHS
|
PATHS
|
||||||
$ENV{OPJ_DATA_ROOT}
|
$ENV{OPJ_DATA_ROOT}
|
||||||
${CMAKE_SOURCE_DIR}/../data
|
${CMAKE_SOURCE_DIR}/../data
|
||||||
|
${CMAKE_SOURCE_DIR}/../../data
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add repository where to find tests
|
# Add repository where to find tests
|
||||||
@@ -254,9 +289,9 @@ INSTALL( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
|||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# install CHANGES and LICENSE
|
# install CHANGES and LICENSE
|
||||||
INSTALL(
|
IF(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
|
||||||
FILES CHANGES
|
INSTALL(FILES CHANGES DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||||
LICENSE
|
ENDIF(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
|
||||||
DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
INSTALL(FILES LICENSE DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||||
|
|
||||||
INCLUDE (CMake/OpenJPEGCPack.cmake)
|
INCLUDE (CMake/OpenJPEGCPack.cmake)
|
||||||
|
|||||||
9
INSTALL
9
INSTALL
@@ -66,11 +66,12 @@ Type:
|
|||||||
|
|
||||||
If you are root:
|
If you are root:
|
||||||
make install
|
make install
|
||||||
make clean
|
|
||||||
|
|
||||||
else:
|
else if you have sudo power:
|
||||||
sudo make install
|
sudo make install
|
||||||
make clean
|
|
||||||
|
else
|
||||||
|
DESTDIR=$HOME/local make install
|
||||||
|
|
||||||
To build the Doxygen documentation (Doxygen needs to be found on the system):
|
To build the Doxygen documentation (Doxygen needs to be found on the system):
|
||||||
(A 'html' directory is generated in the 'doc' directory)
|
(A 'html' directory is generated in the 'doc' directory)
|
||||||
@@ -79,7 +80,7 @@ To build the Doxygen documentation (Doxygen needs to be found on the system):
|
|||||||
Binaries are located in the 'bin' directory.
|
Binaries are located in the 'bin' directory.
|
||||||
|
|
||||||
Main available cmake flags:
|
Main available cmake flags:
|
||||||
* To specify the install path: '-DCMAKE_INSTALL_PREFIX=/path'
|
* To specify the install path: '-DCMAKE_INSTALL_PREFIX=/path', or use DESTDIR env variable (see above)
|
||||||
* To build the shared libraries and links the executables against it: '-DBUILD_SHARED_LIBS:bool=on' (default: 'ON')
|
* To build the shared libraries and links the executables against it: '-DBUILD_SHARED_LIBS:bool=on' (default: 'ON')
|
||||||
Note: when using this option, static libraries are not built and executables are dynamically linked.
|
Note: when using this option, static libraries are not built and executables are dynamically linked.
|
||||||
* To build the CODEC executables: '-DBUILD_CODEC:bool=on' (default: 'ON')
|
* To build the CODEC executables: '-DBUILD_CODEC:bool=on' (default: 'ON')
|
||||||
|
|||||||
34
NEWS
34
NEWS
@@ -2,33 +2,23 @@
|
|||||||
OpenJPEG NEWS - user visible changes
|
OpenJPEG NEWS - user visible changes
|
||||||
====================================
|
====================================
|
||||||
|
|
||||||
Changes from OpenJPEG 1.4.0 to OpenJPEG 1.5.0
|
Changes from OpenJPEG 1.5.1 to OpenJPEG 1.5.0
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
|
|
||||||
|
Security:
|
||||||
|
|
||||||
|
* Fixes: CVE-2012-3535
|
||||||
|
* Fixes: CVE-2012-3358
|
||||||
|
|
||||||
New Features:
|
New Features:
|
||||||
|
|
||||||
* openjpip:
|
* Use a new API scheme and solve the SOVERSIONing in OpenJPEG
|
||||||
- complete client-server architecture for remote browsing of jpeg 2000 images.
|
* Allow better integration with multi-arch system
|
||||||
- located in 'applications/jpip'.
|
* Compile & Install Java bindings (CMake)
|
||||||
- see corresponding README for more details.
|
* Install required addXMLinJP2 (JPIP)
|
||||||
|
|
||||||
API modifications:
|
|
||||||
|
|
||||||
* 'bool' type has been replaced by 'opj_bool' type. 'stdbool.h' is no more required.
|
|
||||||
|
|
||||||
Misc:
|
Misc:
|
||||||
|
|
||||||
* added this NEWS file.
|
* fix linker error by resolving all symbols (eg. missing -lm)
|
||||||
* improved cmake and autotools build methods.
|
* fix some man page typos
|
||||||
* removed manual makefiles, VS project files and XCode project files.
|
|
||||||
* added a 'thirdparty' directory to contain all dependencies.
|
|
||||||
- These libraries will be build only if there are not found on the system.
|
|
||||||
- Note that libopenjpeg itself does not have any dependency.
|
|
||||||
* changed the directory hierarchy of the whole project. See README files for details.
|
|
||||||
* tests : a complete test suite has been setup.
|
|
||||||
- both JPEG 2000 conformance tests and non-regressions tests are configured.
|
|
||||||
- results are submitted to the OpenJPEG dashboard (http://my.cdash.org/index.php?project=OPENJPEG)
|
|
||||||
- images are located in 'http://openjpeg.googlecode.com/svn/data' folder.
|
|
||||||
- configuration files and utilities are located in 'tests' folder.
|
|
||||||
* OPJViewer re-activated (need wxWidgets)
|
|
||||||
* Huge amount of bug fixes. See CHANGES for details.
|
* Huge amount of bug fixes. See CHANGES for details.
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
SET(openjpegjni_SRCS
|
SET(openjpegjni_SRCS
|
||||||
JavaOpenJPEGDecoder.c
|
JavaOpenJPEGDecoder.c
|
||||||
JavaOpenJPEG.c
|
JavaOpenJPEG.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/codec/index.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/codec/convert.c
|
||||||
|
#${OPENJPEG_SOURCE_DIR}/applications/common/color.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c
|
||||||
)
|
)
|
||||||
|
|
||||||
# JNI binding:
|
# JNI binding:
|
||||||
@@ -20,6 +24,18 @@ include_directories(
|
|||||||
add_library(openjpegjni MODULE
|
add_library(openjpegjni MODULE
|
||||||
${openjpegjni_SRCS}
|
${openjpegjni_SRCS}
|
||||||
)
|
)
|
||||||
|
TARGET_LINK_LIBRARIES(openjpegjni ${OPENJPEG_LIBRARY_NAME})
|
||||||
|
|
||||||
|
IF(WIN32)
|
||||||
|
SET(OPENJPEG_INSTALL_JNI_DIR ${OPENJPEG_INSTALL_BIN_DIR})
|
||||||
|
ELSE()
|
||||||
|
SET(OPENJPEG_INSTALL_JNI_DIR ${OPENJPEG_INSTALL_LIB_DIR})
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
INSTALL(TARGETS openjpegjni
|
||||||
|
EXPORT OpenJPEGTargets
|
||||||
|
LIBRARY DESTINATION ${OPENJPEG_INSTALL_JNI_DIR} COMPONENT Libraries
|
||||||
|
)
|
||||||
|
|
||||||
# build jar:
|
# build jar:
|
||||||
FIND_PACKAGE(Java 1.5 REQUIRED) # javac, jar
|
FIND_PACKAGE(Java 1.5 REQUIRED) # javac, jar
|
||||||
@@ -45,3 +61,7 @@ ADD_CUSTOM_TARGET(OpenJPEGJavaJar ALL
|
|||||||
DEPENDS ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
DEPENDS ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
||||||
COMMENT "building openjpeg.jar"
|
COMMENT "building openjpeg.jar"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_SHARE_DIR} COMPONENT JavaModule
|
||||||
|
)
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
extern int get_file_format(char *filename);
|
extern int get_file_format(char *filename);
|
||||||
extern void error_callback(const char *msg, void *client_data);
|
extern void error_callback(const char *msg, void *client_data);
|
||||||
extern warning_callback(const char *msg, void *client_data);
|
extern void warning_callback(const char *msg, void *client_data);
|
||||||
extern void info_callback(const char *msg, void *client_data);
|
extern void info_callback(const char *msg, void *client_data);
|
||||||
|
|
||||||
typedef struct callback_variables {
|
typedef struct callback_variables {
|
||||||
@@ -349,10 +349,11 @@ OPJ_PROG_ORDER give_progression(char progression[4]) {
|
|||||||
return PROG_UNKNOWN;
|
return PROG_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
/// <summary>
|
* <summary>
|
||||||
/// Get logarithm of an integer and round downwards.
|
* Get logarithm of an integer and round downwards.
|
||||||
/// </summary>
|
* </summary>
|
||||||
|
*/
|
||||||
int int_floorlog2(int a) {
|
int int_floorlog2(int a) {
|
||||||
int l;
|
int l;
|
||||||
for (l=0; a>1; l++) {
|
for (l=0; a>1; l++) {
|
||||||
@@ -494,7 +495,7 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_
|
|||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------------------ */
|
||||||
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
int parse_cmdline_encoder(int argc, char * const argv[], opj_cparameters_t *parameters,
|
||||||
img_fol_t *img_fol, char *indexfilename) {
|
img_fol_t *img_fol, char *indexfilename) {
|
||||||
int i, j,totlen;
|
int i, j,totlen;
|
||||||
opj_option_t long_option[]={
|
opj_option_t long_option[]={
|
||||||
@@ -628,6 +629,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
|||||||
numresolution = parameters->numresolution;
|
numresolution = parameters->numresolution;
|
||||||
matrix_width = numresolution * 3;
|
matrix_width = numresolution * 3;
|
||||||
parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int));
|
parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int));
|
||||||
|
if(parameters->cp_matrice == NULL) return 1;
|
||||||
|
|
||||||
s = s + 2;
|
s = s + 2;
|
||||||
|
|
||||||
for (i = 0; i < numlayers; i++) {
|
for (i = 0; i < numlayers; i++) {
|
||||||
@@ -856,6 +859,9 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
|||||||
case 'C': /* add a comment */
|
case 'C': /* add a comment */
|
||||||
{
|
{
|
||||||
parameters->cp_comment = (char*)malloc(strlen(opj_optarg) + 1);
|
parameters->cp_comment = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
|
|
||||||
|
if(parameters->cp_comment == NULL) return 1;
|
||||||
|
|
||||||
if(parameters->cp_comment) {
|
if(parameters->cp_comment) {
|
||||||
strcpy(parameters->cp_comment, opj_optarg);
|
strcpy(parameters->cp_comment, opj_optarg);
|
||||||
}
|
}
|
||||||
@@ -885,6 +891,9 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
|||||||
case 'z': /* Image Directory path */
|
case 'z': /* Image Directory path */
|
||||||
{
|
{
|
||||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
|
|
||||||
|
if(img_fol->imgdirpath == NULL) return 1;
|
||||||
|
|
||||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||||
img_fol->set_imgdir=1;
|
img_fol->set_imgdir=1;
|
||||||
}
|
}
|
||||||
@@ -1352,7 +1361,7 @@ char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int* buffer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the size of the index buffer, in number of bytes*/
|
/* Compute the size of the index buffer, in number of bytes*/
|
||||||
*buffer_size =
|
*buffer_size =
|
||||||
1 /* version */
|
1 /* version */
|
||||||
+ (10 /* image_w until decomposition */
|
+ (10 /* image_w until decomposition */
|
||||||
@@ -1361,18 +1370,18 @@ char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int* buffer
|
|||||||
+ cstr_info->tw * cstr_info->th * 4 /* tile info, without distorsion info */
|
+ cstr_info->tw * cstr_info->th * 4 /* tile info, without distorsion info */
|
||||||
+ cstr_info->tw*cstr_info->th * cstr_info->numlayers * (cstr_info->numdecompos[0] + 1) * cstr_info->numcomps * prec_max *8
|
+ cstr_info->tw*cstr_info->th * cstr_info->numlayers * (cstr_info->numdecompos[0] + 1) * cstr_info->numcomps * prec_max *8
|
||||||
) * sizeof(int);
|
) * sizeof(int);
|
||||||
//printf("C: index buffer size = %d bytes\n", *buffer_size);
|
/*printf("C: index buffer size = %d bytes\n", *buffer_size); */
|
||||||
buffer = (char*) malloc(*buffer_size);
|
buffer = (char*) malloc(*buffer_size);
|
||||||
|
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
//opj_event_msg(j2k->cinfo, EVT_ERROR, "failed to allocate index buffer for writing %d int\n", *buffer_size);
|
/* opj_event_msg(j2k->cinfo, EVT_ERROR, "failed to allocate index buffer for writing %d int\n", *buffer_size); */
|
||||||
fprintf(stderr, "failed to allocate index buffer for writing %d int\n", *buffer_size);
|
fprintf(stderr, "failed to allocate index buffer for writing %d int\n", *buffer_size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[0] = 1; // Version stored on a byte
|
buffer[0] = 1; /* Version stored on a byte */
|
||||||
buffer++;
|
buffer++;
|
||||||
// Remaining informations are stored on a int.
|
/* Remaining informations are stored on a int. */
|
||||||
((int*)buffer)[buffer_pos++] = cstr_info->image_w;
|
((int*)buffer)[buffer_pos++] = cstr_info->image_w;
|
||||||
((int*)buffer)[buffer_pos++] = cstr_info->image_h;
|
((int*)buffer)[buffer_pos++] = cstr_info->image_h;
|
||||||
((int*)buffer)[buffer_pos++] = cstr_info->prog;
|
((int*)buffer)[buffer_pos++] = cstr_info->prog;
|
||||||
@@ -1597,7 +1606,7 @@ char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int* buffer
|
|||||||
} /* tileno */
|
} /* tileno */
|
||||||
|
|
||||||
if (buffer_pos > *buffer_size) {
|
if (buffer_pos > *buffer_size) {
|
||||||
//opj_event_msg(j2k->cinfo, EVT_ERROR, "index creation: buffer_pos (%d) > buffer_size (%d)!\n", buffer_pos, *buffer_size);
|
/* opj_event_msg(j2k->cinfo, EVT_ERROR, "index creation: buffer_pos (%d) > buffer_size (%d)!\n", buffer_pos, *buffer_size); */
|
||||||
fprintf(stderr, "index creation: buffer_pos (%d) > buffer_size (%d)!\n", buffer_pos, *buffer_size);
|
fprintf(stderr, "index creation: buffer_pos (%d) > buffer_size (%d)!\n", buffer_pos, *buffer_size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1630,7 +1639,7 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
|
|||||||
jint *jiBody;
|
jint *jiBody;
|
||||||
jboolean isCopy;
|
jboolean isCopy;
|
||||||
|
|
||||||
// Image width, height and depth
|
/* Image width, height and depth */
|
||||||
fid = (*env)->GetFieldID(env, cls,"width", "I");
|
fid = (*env)->GetFieldID(env, cls,"width", "I");
|
||||||
ji = (*env)->GetIntField(env, obj, fid);
|
ji = (*env)->GetIntField(env, obj, fid);
|
||||||
w = ji;
|
w = ji;
|
||||||
@@ -1643,7 +1652,7 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
|
|||||||
ji = (*env)->GetIntField(env, obj, fid);
|
ji = (*env)->GetIntField(env, obj, fid);
|
||||||
depth = ji;
|
depth = ji;
|
||||||
|
|
||||||
// Read the image
|
/* Read the image */
|
||||||
if (depth <=16) {
|
if (depth <=16) {
|
||||||
numcomps = 1;
|
numcomps = 1;
|
||||||
color_space = CLRSPC_GRAY;
|
color_space = CLRSPC_GRAY;
|
||||||
@@ -1658,8 +1667,10 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
|
|||||||
cmptparm[0].y0 = parameters->image_offset_y0;
|
cmptparm[0].y0 = parameters->image_offset_y0;
|
||||||
cmptparm[0].w = !cmptparm[0].x0 ? (w - 1) * parameters->subsampling_dx + 1 : cmptparm[0].x0 + (w - 1) * parameters->subsampling_dx + 1;
|
cmptparm[0].w = !cmptparm[0].x0 ? (w - 1) * parameters->subsampling_dx + 1 : cmptparm[0].x0 + (w - 1) * parameters->subsampling_dx + 1;
|
||||||
cmptparm[0].h = !cmptparm[0].y0 ? (h - 1) * parameters->subsampling_dy + 1 : cmptparm[0].y0 + (h - 1) * parameters->subsampling_dy + 1;
|
cmptparm[0].h = !cmptparm[0].y0 ? (h - 1) * parameters->subsampling_dy + 1 : cmptparm[0].y0 + (h - 1) * parameters->subsampling_dy + 1;
|
||||||
// Java types are always signed but we use them as unsigned types (shift of the negative part of
|
/* Java types are always signed but we use them as unsigned types
|
||||||
// the pixels of the images in Telemis before entering the encoder).
|
* (shift of the negative part of the pixels of the images in
|
||||||
|
* Telemis before entering the encoder).
|
||||||
|
*/
|
||||||
cmptparm[0].sgnd = 0;
|
cmptparm[0].sgnd = 0;
|
||||||
if (depth<=16)
|
if (depth<=16)
|
||||||
cmptparm[0].prec=depth;
|
cmptparm[0].prec=depth;
|
||||||
@@ -1705,12 +1716,12 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
|
|||||||
comp = &image->comps[compno];
|
comp = &image->comps[compno];
|
||||||
max = -100000;
|
max = -100000;
|
||||||
if (depth == 8) {
|
if (depth == 8) {
|
||||||
fid = (*env)->GetFieldID(env, cls,"image8", "[B"); // byteArray []
|
fid = (*env)->GetFieldID(env, cls,"image8", "[B");/* byteArray []*/
|
||||||
jba = (*env)->GetObjectField(env, obj, fid);
|
jba = (*env)->GetObjectField(env, obj, fid);
|
||||||
len = (*env)->GetArrayLength(env, jba);
|
len = (*env)->GetArrayLength(env, jba);
|
||||||
|
|
||||||
jbBody = (*env)->GetPrimitiveArrayCritical(env, jba, &isCopy);
|
jbBody = (*env)->GetPrimitiveArrayCritical(env, jba, &isCopy);
|
||||||
//printf("C: before transfering 8 bpp image\n");
|
/* printf("C: before transfering 8 bpp image\n"); */
|
||||||
if (comp->sgnd) {
|
if (comp->sgnd) {
|
||||||
for(i=0; i< len;i++) {
|
for(i=0; i< len;i++) {
|
||||||
comp->data[i] = (char) jbBody[i];
|
comp->data[i] = (char) jbBody[i];
|
||||||
@@ -1724,13 +1735,14 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
|
|||||||
}
|
}
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jba, jbBody, 0);
|
(*env)->ReleasePrimitiveArrayCritical(env, jba, jbBody, 0);
|
||||||
} else if(depth == 16) {
|
} else if(depth == 16) {
|
||||||
fid = (*env)->GetFieldID(env, cls,"image16", "[S"); // shortArray []
|
fid = (*env)->GetFieldID(env, cls,"image16", "[S");/*shortArray []*/
|
||||||
jsa = (*env)->GetObjectField(env, obj, fid);
|
jsa = (*env)->GetObjectField(env, obj, fid);
|
||||||
len = (*env)->GetArrayLength(env, jsa);
|
len = (*env)->GetArrayLength(env, jsa);
|
||||||
|
|
||||||
jsBody = (*env)->GetPrimitiveArrayCritical(env, jsa, &isCopy);
|
jsBody = (*env)->GetPrimitiveArrayCritical(env, jsa, &isCopy);
|
||||||
//printf("C: before transfering 16 bpp image\n");
|
/*printf("C: before transfering 16 bpp image\n"); */
|
||||||
if (comp->sgnd) { // Special behaviour to deal with signed elements ??
|
if (comp->sgnd) {
|
||||||
|
/* Special behaviour to deal with signed elements ?? */
|
||||||
comp->data[i] = (short) jsBody[i];
|
comp->data[i] = (short) jsBody[i];
|
||||||
for(i=0; i< len;i++) {
|
for(i=0; i< len;i++) {
|
||||||
if (comp->data[i] > max) max = comp->data[i];
|
if (comp->data[i] > max) max = comp->data[i];
|
||||||
@@ -1743,14 +1755,15 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
|
|||||||
}
|
}
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jsa, jsBody, 0);
|
(*env)->ReleasePrimitiveArrayCritical(env, jsa, jsBody, 0);
|
||||||
} else if (depth == 24) {
|
} else if (depth == 24) {
|
||||||
fid = (*env)->GetFieldID(env, cls,"image24", "[I"); // intArray []
|
fid = (*env)->GetFieldID(env, cls,"image24", "[I");/* intArray []*/
|
||||||
jia = (*env)->GetObjectField(env, obj, fid);
|
jia = (*env)->GetObjectField(env, obj, fid);
|
||||||
len = (*env)->GetArrayLength(env, jia);
|
len = (*env)->GetArrayLength(env, jia);
|
||||||
shift = compno*8;
|
shift = compno*8;
|
||||||
|
|
||||||
jiBody = (*env)->GetPrimitiveArrayCritical(env, jia, &isCopy);
|
jiBody = (*env)->GetPrimitiveArrayCritical(env, jia, &isCopy);
|
||||||
//printf("C: before transfering 24 bpp image (component %d, signed = %d)\n", compno, comp->sgnd);
|
/*printf("C: before transfering 24 bpp image (component %d, signed = %d)\n", compno, comp->sgnd);*/
|
||||||
if (comp->sgnd) { // Special behaviour to deal with signed elements ?? XXXXX
|
if (comp->sgnd) {
|
||||||
|
/* Special behaviour to deal with signed elements ?? XXXXX */
|
||||||
for(i=0; i< len;i++) {
|
for(i=0; i< len;i++) {
|
||||||
comp->data[i] = ( ((int) jiBody[i]) & (0xFF << shift) ) >> shift;
|
comp->data[i] = ( ((int) jiBody[i]) & (0xFF << shift) ) >> shift;
|
||||||
if (comp->data[i] > max) max = comp->data[i];
|
if (comp->data[i] > max) max = comp->data[i];
|
||||||
@@ -1765,7 +1778,7 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
|
|||||||
}
|
}
|
||||||
comp->bpp = int_floorlog2(max)+1;
|
comp->bpp = int_floorlog2(max)+1;
|
||||||
comp->prec = comp->bpp;
|
comp->prec = comp->bpp;
|
||||||
//printf("C: component %d: max %d, real bpp = %d\n", compno, max, comp->bpp);
|
/*printf("C: component %d: max %d, real bpp = %d\n", compno, max, comp->bpp);*/
|
||||||
}
|
}
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
@@ -1775,7 +1788,7 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
|
|||||||
-------------------- MAIN METHOD, CALLED BY JAVA -----------------------*/
|
-------------------- MAIN METHOD, CALLED BY JAVA -----------------------*/
|
||||||
JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImageToJ2K(JNIEnv *env, jobject obj, jobjectArray javaParameters) {
|
JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImageToJ2K(JNIEnv *env, jobject obj, jobjectArray javaParameters) {
|
||||||
int argc; /* To simulate the command line parameters (taken from the javaParameters variable) and be able to re-use the */
|
int argc; /* To simulate the command line parameters (taken from the javaParameters variable) and be able to re-use the */
|
||||||
char **argv; /* 'parse_cmdline_decoder' method taken from the j2k_to_image project */
|
const char **argv; /* 'parse_cmdline_decoder' method taken from the j2k_to_image project */
|
||||||
opj_bool bSuccess;
|
opj_bool bSuccess;
|
||||||
opj_cparameters_t parameters; /* compression parameters */
|
opj_cparameters_t parameters; /* compression parameters */
|
||||||
img_fol_t img_fol;
|
img_fol_t img_fol;
|
||||||
@@ -1783,12 +1796,12 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
opj_image_t *image = NULL;
|
opj_image_t *image = NULL;
|
||||||
int i,j,num_images;
|
int i,j,num_images;
|
||||||
int imageno;
|
int imageno;
|
||||||
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
||||||
char indexfilename[OPJ_PATH_LEN]; /* index file name */
|
char indexfilename[OPJ_PATH_LEN]; /* index file name */
|
||||||
|
|
||||||
int* compressed_index = NULL;
|
int* compressed_index = NULL;
|
||||||
int compressed_index_size=-1;
|
int compressed_index_size=-1;
|
||||||
// ==> Access variables to the Java member variables
|
/* ==> Access variables to the Java member variables */
|
||||||
jsize arraySize;
|
jsize arraySize;
|
||||||
jclass cls;
|
jclass cls;
|
||||||
jobject object;
|
jobject object;
|
||||||
@@ -1797,18 +1810,20 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
jbyteArray jba;
|
jbyteArray jba;
|
||||||
jbyte *jbBody;
|
jbyte *jbBody;
|
||||||
callback_variables_t msgErrorCallback_vars;
|
callback_variables_t msgErrorCallback_vars;
|
||||||
// <== access variable to the Java member variables.
|
/* <== access variable to the Java member variables. */
|
||||||
|
jlong retval = -1;
|
||||||
// For the encoding and storage into the file
|
/* For the encoding and storage into the file */
|
||||||
opj_cinfo_t* cinfo;
|
opj_cinfo_t* cinfo;
|
||||||
int codestream_length;
|
int codestream_length = -1;
|
||||||
opj_cio_t *cio = NULL;
|
opj_cio_t *cio = NULL;
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
|
|
||||||
// JNI reference to the calling class
|
/* JNI reference to the calling class */
|
||||||
cls = (*env)->GetObjectClass(env, obj);
|
cls = (*env)->GetObjectClass(env, obj);
|
||||||
|
|
||||||
// Pointers to be able to call a Java method for all the info and error messages
|
/* Pointers to be able to call a Java method
|
||||||
|
* for all the info and error messages
|
||||||
|
*/
|
||||||
msgErrorCallback_vars.env = env;
|
msgErrorCallback_vars.env = env;
|
||||||
msgErrorCallback_vars.jobj = &obj;
|
msgErrorCallback_vars.jobj = &obj;
|
||||||
msgErrorCallback_vars.message_mid = (*env)->GetMethodID(env, cls, "logMessage", "(Ljava/lang/String;)V");
|
msgErrorCallback_vars.message_mid = (*env)->GetMethodID(env, cls, "logMessage", "(Ljava/lang/String;)V");
|
||||||
@@ -1816,8 +1831,11 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
|
|
||||||
arraySize = (*env)->GetArrayLength(env, javaParameters);
|
arraySize = (*env)->GetArrayLength(env, javaParameters);
|
||||||
argc = (int) arraySize +1;
|
argc = (int) arraySize +1;
|
||||||
argv = malloc(argc*sizeof(char*));
|
argv = (const char **)malloc(argc*sizeof(char*));
|
||||||
argv[0] = "ProgramName.exe"; // The program name: useless
|
|
||||||
|
if(argv == NULL) return -1;
|
||||||
|
|
||||||
|
argv[0] = "ProgramName.exe";/* The program name: useless */
|
||||||
j=0;
|
j=0;
|
||||||
for (i=1; i<argc; i++) {
|
for (i=1; i<argc; i++) {
|
||||||
object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
|
object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
|
||||||
@@ -1841,23 +1859,21 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
/* set encoding parameters to default values */
|
/* set encoding parameters to default values */
|
||||||
opj_set_default_encoder_parameters(¶meters);
|
opj_set_default_encoder_parameters(¶meters);
|
||||||
parameters.cod_format = J2K_CFMT;
|
parameters.cod_format = J2K_CFMT;
|
||||||
//parameters.index_on = 1;
|
/* parameters.index_on = 1; */
|
||||||
|
|
||||||
/* Initialize indexfilename and img_fol */
|
/* Initialize indexfilename and img_fol */
|
||||||
*indexfilename = 0;
|
*indexfilename = 0;
|
||||||
memset(&img_fol,0,sizeof(img_fol_t));
|
memset(&img_fol,0,sizeof(img_fol_t));
|
||||||
|
|
||||||
/* parse input and get user encoding parameters */
|
/* parse input and get user encoding parameters */
|
||||||
if (parse_cmdline_encoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
|
j = parse_cmdline_encoder(argc, (char *const*)argv, ¶meters,&img_fol, indexfilename);
|
||||||
// Release the Java arguments array
|
|
||||||
for (i=1; i<argc; i++)
|
|
||||||
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Release the Java arguments array
|
/* Release the Java arguments array */
|
||||||
for (i=1; i<argc; i++)
|
for (i=1; i<argc; i++)
|
||||||
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
(*env)->ReleaseStringUTFChars(env,
|
||||||
|
(*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
||||||
|
|
||||||
|
if(j == 1) goto fin; /* failure */
|
||||||
|
|
||||||
if (parameters.cp_cinema){
|
if (parameters.cp_cinema){
|
||||||
cinema_parameters(¶meters);
|
cinema_parameters(¶meters);
|
||||||
@@ -1872,9 +1888,15 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
/* UniPG>> */
|
/* UniPG>> */
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
parameters.cp_comment = (char*)malloc(clen+strlen(version)+11);
|
parameters.cp_comment = (char*)malloc(clen+strlen(version)+11);
|
||||||
|
|
||||||
|
if(parameters.cp_comment == NULL) goto fin;
|
||||||
|
|
||||||
sprintf(parameters.cp_comment,"%s%s with JPWL", comment, version);
|
sprintf(parameters.cp_comment,"%s%s with JPWL", comment, version);
|
||||||
#else
|
#else
|
||||||
parameters.cp_comment = (char*)malloc(clen+strlen(version)+1);
|
parameters.cp_comment = (char*)malloc(clen+strlen(version)+1);
|
||||||
|
|
||||||
|
if(parameters.cp_comment == NULL) goto fin;
|
||||||
|
|
||||||
sprintf(parameters.cp_comment,"%s%s", comment, version);
|
sprintf(parameters.cp_comment,"%s%s", comment, version);
|
||||||
#endif
|
#endif
|
||||||
/* <<UniPG */
|
/* <<UniPG */
|
||||||
@@ -1891,10 +1913,10 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
fprintf(stderr,"\n");
|
fprintf(stderr,"\n");
|
||||||
|
|
||||||
image = loadImage(¶meters, env, obj, cls);
|
image = loadImage(¶meters, env, obj, cls);
|
||||||
//printf("C: after load image: image = %d\n", image);
|
/* printf("C: after load image: image = %d\n", image); */
|
||||||
if (!image) {
|
if (!image) {
|
||||||
fprintf(stderr, "Unable to load image\n");
|
fprintf(stderr, "Unable to load image\n");
|
||||||
return -1;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decide if MCT should be used */
|
/* Decide if MCT should be used */
|
||||||
@@ -1928,7 +1950,7 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
if (!bSuccess) {
|
if (!bSuccess) {
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
fprintf(stderr, "failed to encode image\n");
|
fprintf(stderr, "failed to encode image\n");
|
||||||
return -1;
|
goto fin;
|
||||||
}
|
}
|
||||||
codestream_length = cio_tell(cio);
|
codestream_length = cio_tell(cio);
|
||||||
|
|
||||||
@@ -1940,7 +1962,8 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compressed_index = create_index_into_byte_array(&cstr_info, &compressed_index_size);
|
compressed_index = (int*)
|
||||||
|
create_index_into_byte_array(&cstr_info, &compressed_index_size);
|
||||||
/* Allocates the Java compressedIndex byte[] and sends this index into the Java object */
|
/* Allocates the Java compressedIndex byte[] and sends this index into the Java object */
|
||||||
fid = (*env)->GetFieldID(env, cls,"compressedIndex", "[B");
|
fid = (*env)->GetFieldID(env, cls,"compressedIndex", "[B");
|
||||||
jba = (*env)->NewByteArray(env, compressed_index_size+1);
|
jba = (*env)->NewByteArray(env, compressed_index_size+1);
|
||||||
@@ -1955,14 +1978,14 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
f = fopen(parameters.outfile, "wb");
|
f = fopen(parameters.outfile, "wb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
fprintf(stderr, "failed to open [%s] for writing\n", parameters.outfile);
|
fprintf(stderr, "failed to open [%s] for writing\n", parameters.outfile);
|
||||||
return -1;
|
goto fin;
|
||||||
}
|
}
|
||||||
fwrite(cio->buffer, 1, codestream_length, f);
|
fwrite(cio->buffer, 1, codestream_length, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
fprintf(stdout,"Generated outfile [%s]\n",parameters.outfile);
|
fprintf(stdout,"Generated outfile [%s]\n",parameters.outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the generated codestream to the Java pre-allocated compressedStream byte[] */
|
/* Write the generated codestream to the Java pre-allocated compressedStream byte[] */
|
||||||
fid = (*env)->GetFieldID(env, cls,"compressedStream", "[B");
|
fid = (*env)->GetFieldID(env, cls,"compressedStream", "[B");
|
||||||
jba = (*env)->GetObjectField(env, obj, fid);
|
jba = (*env)->GetObjectField(env, obj, fid);
|
||||||
jbBody = (*env)->GetPrimitiveArrayCritical(env, jba, 0);
|
jbBody = (*env)->GetPrimitiveArrayCritical(env, jba, 0);
|
||||||
@@ -1984,5 +2007,10 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
if(parameters.cp_comment) free(parameters.cp_comment);
|
if(parameters.cp_comment) free(parameters.cp_comment);
|
||||||
if(parameters.cp_matrice) free(parameters.cp_matrice);
|
if(parameters.cp_matrice) free(parameters.cp_matrice);
|
||||||
|
|
||||||
return codestream_length;
|
retval = codestream_length;
|
||||||
|
|
||||||
|
fin:
|
||||||
|
free(argv);
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ int get_file_format(char *filename) {
|
|||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
|
int parse_cmdline_decoder(int argc, char * const argv[], opj_dparameters_t *parameters,img_fol_t *img_fol) {
|
||||||
/* parse the command line */
|
/* parse the command line */
|
||||||
int totlen;
|
int totlen;
|
||||||
opj_option_t long_option[]={
|
opj_option_t long_option[]={
|
||||||
@@ -339,6 +339,9 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
case 'y': /* Image Directory path */
|
case 'y': /* Image Directory path */
|
||||||
{
|
{
|
||||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
|
|
||||||
|
if(img_fol->imgdirpath == NULL) return 1;
|
||||||
|
|
||||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||||
img_fol->set_imgdir=1;
|
img_fol->set_imgdir=1;
|
||||||
}
|
}
|
||||||
@@ -426,7 +429,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
/* No check for possible errors before the -i and -o options are of course not mandatory*/
|
/* No check for possible errors before the -i and -o options are of course not mandatory*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}/* parse_cmdline_decoder() */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
@@ -488,12 +491,13 @@ void info_callback(const char *msg, void *client_data) {
|
|||||||
(*env)->DeleteLocalRef(env, jbuffer);
|
(*env)->DeleteLocalRef(env, jbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define FAILS -1
|
||||||
|
#define OK 0
|
||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
-------------------- MAIN METHOD, CALLED BY JAVA -----------------------*/
|
-------------------- MAIN METHOD, CALLED BY JAVA -----------------------*/
|
||||||
JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2KtoImage(JNIEnv *env, jobject obj, jobjectArray javaParameters) {
|
JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2KtoImage(JNIEnv *env, jobject obj, jobjectArray javaParameters) {
|
||||||
int argc; /* To simulate the command line parameters (taken from the javaParameters variable) and be able to re-use the */
|
int argc; /* To simulate the command line parameters (taken from the javaParameters variable) and be able to re-use the */
|
||||||
char **argv; /* 'parse_cmdline_decoder' method taken from the j2k_to_image project */
|
const char **argv; /* 'parse_cmdline_decoder' method taken from the j2k_to_image project */
|
||||||
opj_dparameters_t parameters; /* decompression parameters */
|
opj_dparameters_t parameters; /* decompression parameters */
|
||||||
img_fol_t img_fol;
|
img_fol_t img_fol;
|
||||||
opj_event_mgr_t event_mgr; /* event manager */
|
opj_event_mgr_t event_mgr; /* event manager */
|
||||||
@@ -508,7 +512,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
int w,h;
|
int w,h;
|
||||||
long min_value, max_value;
|
long min_value, max_value;
|
||||||
short tempS; unsigned char tempUC, tempUC1, tempUC2;
|
short tempS; unsigned char tempUC, tempUC1, tempUC2;
|
||||||
// ==> Access variables to the Java member variables
|
/* ==> Access variables to the Java member variables */
|
||||||
jsize arraySize;
|
jsize arraySize;
|
||||||
jclass cls;
|
jclass cls;
|
||||||
jobject object;
|
jobject object;
|
||||||
@@ -521,8 +525,9 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
jshort *jsBody, *ptrSBody;
|
jshort *jsBody, *ptrSBody;
|
||||||
jint *jiBody, *ptrIBody;
|
jint *jiBody, *ptrIBody;
|
||||||
callback_variables_t msgErrorCallback_vars;
|
callback_variables_t msgErrorCallback_vars;
|
||||||
// <=== access variable to Java member variables */
|
/* <=== access variable to Java member variables */
|
||||||
int *ptr, *ptr1, *ptr2; // <== To transfer the decoded image to Java
|
int *ptr, *ptr1, *ptr2;/* <== To transfer the decoded image to Java */
|
||||||
|
jint retval = FAILS;
|
||||||
|
|
||||||
/* configure the event callbacks */
|
/* configure the event callbacks */
|
||||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||||
@@ -530,20 +535,26 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
event_mgr.warning_handler = warning_callback;
|
event_mgr.warning_handler = warning_callback;
|
||||||
event_mgr.info_handler = info_callback;
|
event_mgr.info_handler = info_callback;
|
||||||
|
|
||||||
// JNI reference to the calling class
|
/* JNI reference to the calling class */
|
||||||
cls = (*env)->GetObjectClass(env, obj);
|
cls = (*env)->GetObjectClass(env, obj);
|
||||||
|
|
||||||
// Pointers to be able to call a Java method for all the info and error messages
|
/* Pointers to be able to call a Java method
|
||||||
|
* for all the info and error messages
|
||||||
|
*/
|
||||||
msgErrorCallback_vars.env = env;
|
msgErrorCallback_vars.env = env;
|
||||||
msgErrorCallback_vars.jobj = &obj;
|
msgErrorCallback_vars.jobj = &obj;
|
||||||
msgErrorCallback_vars.message_mid = (*env)->GetMethodID(env, cls, "logMessage", "(Ljava/lang/String;)V");
|
msgErrorCallback_vars.message_mid = (*env)->GetMethodID(env, cls, "logMessage", "(Ljava/lang/String;)V");
|
||||||
msgErrorCallback_vars.error_mid = (*env)->GetMethodID(env, cls, "logError", "(Ljava/lang/String;)V");
|
msgErrorCallback_vars.error_mid = (*env)->GetMethodID(env, cls, "logError", "(Ljava/lang/String;)V");
|
||||||
|
|
||||||
// Get the String[] containing the parameters, and converts it into a char** to simulate command line arguments.
|
/* Get the String[] containing the parameters */
|
||||||
|
|
||||||
arraySize = (*env)->GetArrayLength(env, javaParameters);
|
arraySize = (*env)->GetArrayLength(env, javaParameters);
|
||||||
argc = (int) arraySize +1;
|
argc = (int) arraySize +1;
|
||||||
argv = malloc(argc*sizeof(char*));
|
argv = (const char **)malloc(argc*sizeof(char*));
|
||||||
argv[0] = "ProgramName.exe"; // The program name: useless
|
|
||||||
|
if(argv == NULL) return FAILS;
|
||||||
|
|
||||||
|
argv[0] = "ProgramName.exe";/* The program name: useless */
|
||||||
j=0;
|
j=0;
|
||||||
for (i=1; i<argc; i++) {
|
for (i=1; i<argc; i++) {
|
||||||
object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
|
object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
|
||||||
@@ -561,19 +572,18 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
parameters.decod_format = J2K_CFMT;
|
parameters.decod_format = J2K_CFMT;
|
||||||
|
|
||||||
/* parse input and get user encoding parameters */
|
/* parse input and get user encoding parameters */
|
||||||
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol) == 1) {
|
j = parse_cmdline_decoder(argc, (char * const*)argv, ¶meters,&img_fol);
|
||||||
// Release the Java arguments array
|
|
||||||
for (i=1; i<argc; i++)
|
/* Release the Java arguments array */
|
||||||
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
// Release the Java arguments array
|
|
||||||
for (i=1; i<argc; i++)
|
for (i=1; i<argc; i++)
|
||||||
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
(*env)->ReleaseStringUTFChars(env,
|
||||||
|
(*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
||||||
|
|
||||||
|
if(j == 1) goto fin; /* failure */
|
||||||
|
|
||||||
num_images=1;
|
num_images=1;
|
||||||
|
|
||||||
// Get additional information from the Java object variables
|
/* Get additional information from the Java object variables */
|
||||||
fid = (*env)->GetFieldID(env, cls,"skippedResolutions", "I");
|
fid = (*env)->GetFieldID(env, cls,"skippedResolutions", "I");
|
||||||
parameters.cp_reduce = (short) (*env)->GetIntField(env, obj, fid);
|
parameters.cp_reduce = (short) (*env)->GetIntField(env, obj, fid);
|
||||||
|
|
||||||
@@ -587,22 +597,25 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
Implemented for debug purpose. */
|
Implemented for debug purpose. */
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
if (parameters.infile && parameters.infile[0]!='\0') {
|
if (parameters.infile && parameters.infile[0]!='\0') {
|
||||||
//printf("C: opening [%s]\n", parameters.infile);
|
/* printf("C: opening [%s]\n", parameters.infile); */
|
||||||
fsrc = fopen(parameters.infile, "rb");
|
fsrc = fopen(parameters.infile, "rb");
|
||||||
if (!fsrc) {
|
if (!fsrc) {
|
||||||
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
||||||
return 1;
|
goto fin;
|
||||||
}
|
}
|
||||||
fseek(fsrc, 0, SEEK_END);
|
fseek(fsrc, 0, SEEK_END);
|
||||||
file_length = ftell(fsrc);
|
file_length = ftell(fsrc);
|
||||||
fseek(fsrc, 0, SEEK_SET);
|
fseek(fsrc, 0, SEEK_SET);
|
||||||
src = (unsigned char *) malloc(file_length);
|
src = (unsigned char *) malloc(file_length);
|
||||||
|
|
||||||
|
if(src == NULL) goto fin;
|
||||||
|
|
||||||
fread(src, 1, file_length, fsrc);
|
fread(src, 1, file_length, fsrc);
|
||||||
fclose(fsrc);
|
fclose(fsrc);
|
||||||
//printf("C: %d bytes read from file\n",file_length);
|
/* printf("C: %d bytes read from file\n",file_length); */
|
||||||
} else {
|
} else {
|
||||||
// Preparing the transfer of the codestream from Java to C
|
/* Preparing the transfer of the codestream from Java to C */
|
||||||
//printf("C: before transfering codestream\n");
|
/* printf("C: before transfering codestream\n"); */
|
||||||
fid = (*env)->GetFieldID(env, cls,"compressedStream", "[B");
|
fid = (*env)->GetFieldID(env, cls,"compressedStream", "[B");
|
||||||
jba = (*env)->GetObjectField(env, obj, fid);
|
jba = (*env)->GetObjectField(env, obj, fid);
|
||||||
file_length = (*env)->GetArrayLength(env, jba);
|
file_length = (*env)->GetArrayLength(env, jba);
|
||||||
@@ -636,7 +649,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
opj_destroy_decompress(dinfo);
|
opj_destroy_decompress(dinfo);
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
return 1;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close the byte stream */
|
/* close the byte stream */
|
||||||
@@ -666,7 +679,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
opj_destroy_decompress(dinfo);
|
opj_destroy_decompress(dinfo);
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
return 1;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close the byte stream */
|
/* close the byte stream */
|
||||||
@@ -697,7 +710,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
opj_destroy_decompress(dinfo);
|
opj_destroy_decompress(dinfo);
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
return 1;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close the byte stream */
|
/* close the byte stream */
|
||||||
@@ -752,17 +765,21 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========= Return the image to the Java structure ===============
|
/* ========= Return the image to the Java structure =============== */
|
||||||
#ifdef CHECK_THRESHOLDS
|
#ifdef CHECK_THRESHOLDS
|
||||||
printf("C: checking thresholds\n");
|
printf("C: checking thresholds\n");
|
||||||
#endif
|
#endif
|
||||||
// First compute the real with and height, in function of the resolutions decoded.
|
/* First compute the real with and height,
|
||||||
//wr = (image->comps[0].w + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;
|
* in function of the resolutions decoded.
|
||||||
//hr = (image->comps[0].h + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;
|
*/
|
||||||
|
/*---
|
||||||
|
wr = (image->comps[0].w + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;
|
||||||
|
hr = (image->comps[0].h + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;
|
||||||
|
---*/
|
||||||
w = image->comps[0].w;
|
w = image->comps[0].w;
|
||||||
h = image->comps[0].h;
|
h = image->comps[0].h;
|
||||||
|
|
||||||
if (image->numcomps==3) { // 3 components color image
|
if (image->numcomps==3) { /* 3 components color image */
|
||||||
ptr = image->comps[0].data;
|
ptr = image->comps[0].data;
|
||||||
ptr1 = image->comps[1].data;
|
ptr1 = image->comps[1].data;
|
||||||
ptr2 = image->comps[2].data;
|
ptr2 = image->comps[2].data;
|
||||||
@@ -775,7 +792,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
max_value = 255;
|
max_value = 255;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// Get the pointer to the Java structure where the data must be copied
|
/* Get the pointer to the Java structure where the data must be copied */
|
||||||
fid = (*env)->GetFieldID(env, cls,"image24", "[I");
|
fid = (*env)->GetFieldID(env, cls,"image24", "[I");
|
||||||
jia = (*env)->GetObjectField(env, obj, fid);
|
jia = (*env)->GetObjectField(env, obj, fid);
|
||||||
jiBody = (*env)->GetIntArrayElements(env, jia, 0);
|
jiBody = (*env)->GetIntArrayElements(env, jia, 0);
|
||||||
@@ -804,7 +821,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
}
|
}
|
||||||
(*env)->ReleaseIntArrayElements(env, jia, jiBody, 0);
|
(*env)->ReleaseIntArrayElements(env, jia, jiBody, 0);
|
||||||
|
|
||||||
} else { // 1 component 8 or 16 bpp image
|
} else { /* 1 component 8 or 16 bpp image */
|
||||||
ptr = image->comps[0].data;
|
ptr = image->comps[0].data;
|
||||||
printf("C: before transfering a %d bpp image to java (length = %d)\n",image->comps[0].prec ,w*h);
|
printf("C: before transfering a %d bpp image to java (length = %d)\n",image->comps[0].prec ,w*h);
|
||||||
if (image->comps[0].prec<=8) {
|
if (image->comps[0].prec<=8) {
|
||||||
@@ -821,7 +838,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
max_value = 255;
|
max_value = 255;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//printf("C: transfering %d shorts to Java image8 pointer = %d\n", wr*hr,ptrSBody);
|
/* printf("C: transfering %d shorts to Java image8 pointer = %d\n", wr*hr,ptrSBody); */
|
||||||
for (i=0; i<w*h; i++) {
|
for (i=0; i<w*h; i++) {
|
||||||
tempUC = (unsigned char) (ptr[i]);
|
tempUC = (unsigned char) (ptr[i]);
|
||||||
#ifdef CHECK_THRESHOLDS
|
#ifdef CHECK_THRESHOLDS
|
||||||
@@ -877,7 +894,12 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
|
|
||||||
}
|
}
|
||||||
return 1; /* OK */
|
retval = OK;
|
||||||
}
|
|
||||||
//end main
|
fin:
|
||||||
|
free(argv);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
/* end main MAIN */
|
||||||
|
|
||||||
|
|||||||
@@ -94,8 +94,8 @@ struct tga_header
|
|||||||
|
|
||||||
static unsigned short get_ushort(unsigned short val) {
|
static unsigned short get_ushort(unsigned short val) {
|
||||||
|
|
||||||
#ifdef ORDER_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
return( ((val & 0xff) << 8) + (val >> 8) );
|
return( ((val & 0xff) << 8) + (val >> 8) );
|
||||||
#else
|
#else
|
||||||
return( val );
|
return( val );
|
||||||
#endif
|
#endif
|
||||||
@@ -104,7 +104,7 @@ static unsigned short get_ushort(unsigned short val) {
|
|||||||
|
|
||||||
#define TGA_HEADER_SIZE 18
|
#define TGA_HEADER_SIZE 18
|
||||||
|
|
||||||
int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
|
static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
|
||||||
unsigned int *width, unsigned int *height, int *flip_image)
|
unsigned int *width, unsigned int *height, int *flip_image)
|
||||||
{
|
{
|
||||||
int palette_size;
|
int palette_size;
|
||||||
@@ -179,7 +179,17 @@ int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height,
|
#if WORDS_BIGENDIAN == 1
|
||||||
|
|
||||||
|
static inline int16_t swap16(int16_t x)
|
||||||
|
{
|
||||||
|
return((((u_int16_t)x & 0x00ffU) << 8) |
|
||||||
|
(((u_int16_t)x & 0xff00U) >> 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height,
|
||||||
opj_bool flip_image)
|
opj_bool flip_image)
|
||||||
{
|
{
|
||||||
unsigned short image_w, image_h, us0;
|
unsigned short image_w, image_h, us0;
|
||||||
@@ -216,8 +226,15 @@ int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height,
|
|||||||
image_w = (unsigned short)width;
|
image_w = (unsigned short)width;
|
||||||
image_h = (unsigned short) height;
|
image_h = (unsigned short) height;
|
||||||
|
|
||||||
|
#if WORDS_BIGENDIAN == 0
|
||||||
if(fwrite(&image_w, 2, 1, fp) != 1) goto fails;
|
if(fwrite(&image_w, 2, 1, fp) != 1) goto fails;
|
||||||
if(fwrite(&image_h, 2, 1, fp) != 1) goto fails;
|
if(fwrite(&image_h, 2, 1, fp) != 1) goto fails;
|
||||||
|
#else
|
||||||
|
image_w = swap16(image_w);
|
||||||
|
image_h = swap16(image_h);
|
||||||
|
if(fwrite(&image_w, 2, 1, fp) != 1) goto fails;
|
||||||
|
if(fwrite(&image_h, 2, 1, fp) != 1) goto fails;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(fwrite(&pixel_depth, 1, 1, fp) != 1) goto fails;
|
if(fwrite(&pixel_depth, 1, 1, fp) != 1) goto fails;
|
||||||
|
|
||||||
@@ -493,7 +510,7 @@ int imagetotga(opj_image_t * image, const char *outfile) {
|
|||||||
typedef unsigned short int WORD;
|
typedef unsigned short int WORD;
|
||||||
|
|
||||||
/* DWORD defines a four byte word */
|
/* DWORD defines a four byte word */
|
||||||
typedef unsigned long int DWORD;
|
typedef unsigned int DWORD;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
WORD bfType; /* 'BM' for Bitmap (19776) */
|
WORD bfType; /* 'BM' for Bitmap (19776) */
|
||||||
@@ -583,7 +600,7 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
|
|||||||
|
|
||||||
if(Info_h.biSize != 40)
|
if(Info_h.biSize != 40)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Error, unknown BMP header size %ld\n", Info_h.biSize);
|
fprintf(stderr,"Error, unknown BMP header size %d\n", Info_h.biSize);
|
||||||
fclose(IN);
|
fclose(IN);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -993,7 +1010,11 @@ int imagetobmp(opj_image_t * image, const char *outfile) {
|
|||||||
FILE *fdest = NULL;
|
FILE *fdest = NULL;
|
||||||
int adjustR, adjustG, adjustB;
|
int adjustR, adjustG, adjustB;
|
||||||
|
|
||||||
if (image->numcomps == 3 && image->comps[0].dx == image->comps[1].dx
|
if (image->comps[0].prec < 8) {
|
||||||
|
fprintf(stderr, "Unsupported precision: %d\n", image->comps[0].prec);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (image->numcomps >= 3 && image->comps[0].dx == image->comps[1].dx
|
||||||
&& image->comps[1].dx == image->comps[2].dx
|
&& image->comps[1].dx == image->comps[2].dx
|
||||||
&& image->comps[0].dy == image->comps[1].dy
|
&& image->comps[0].dy == image->comps[1].dy
|
||||||
&& image->comps[1].dy == image->comps[2].dy
|
&& image->comps[1].dy == image->comps[2].dy
|
||||||
@@ -1181,7 +1202,7 @@ PGX IMAGE FORMAT
|
|||||||
<<-- <<-- <<-- <<-- */
|
<<-- <<-- <<-- <<-- */
|
||||||
|
|
||||||
|
|
||||||
unsigned char readuchar(FILE * f)
|
static unsigned char readuchar(FILE * f)
|
||||||
{
|
{
|
||||||
unsigned char c1;
|
unsigned char c1;
|
||||||
if ( !fread(&c1, 1, 1, f) )
|
if ( !fread(&c1, 1, 1, f) )
|
||||||
@@ -1192,7 +1213,7 @@ unsigned char readuchar(FILE * f)
|
|||||||
return c1;
|
return c1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short readushort(FILE * f, int bigendian)
|
static unsigned short readushort(FILE * f, int bigendian)
|
||||||
{
|
{
|
||||||
unsigned char c1, c2;
|
unsigned char c1, c2;
|
||||||
if ( !fread(&c1, 1, 1, f) )
|
if ( !fread(&c1, 1, 1, f) )
|
||||||
@@ -1211,7 +1232,7 @@ unsigned short readushort(FILE * f, int bigendian)
|
|||||||
return (c2 << 8) + c1;
|
return (c2 << 8) + c1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int readuint(FILE * f, int bigendian)
|
static unsigned int readuint(FILE * f, int bigendian)
|
||||||
{
|
{
|
||||||
unsigned char c1, c2, c3, c4;
|
unsigned char c1, c2, c3, c4;
|
||||||
if ( !fread(&c1, 1, 1, f) )
|
if ( !fread(&c1, 1, 1, f) )
|
||||||
@@ -1247,6 +1268,7 @@ opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters) {
|
|||||||
OPJ_COLOR_SPACE color_space;
|
OPJ_COLOR_SPACE color_space;
|
||||||
opj_image_cmptparm_t cmptparm; /* maximum of 1 component */
|
opj_image_cmptparm_t cmptparm; /* maximum of 1 component */
|
||||||
opj_image_t * image = NULL;
|
opj_image_t * image = NULL;
|
||||||
|
int adjustS, ushift, dshift, force8;
|
||||||
|
|
||||||
char endian1,endian2,sign;
|
char endian1,endian2,sign;
|
||||||
char signtmp[32];
|
char signtmp[32];
|
||||||
@@ -1303,6 +1325,16 @@ opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters) {
|
|||||||
} else {
|
} else {
|
||||||
cmptparm.sgnd = 0;
|
cmptparm.sgnd = 0;
|
||||||
}
|
}
|
||||||
|
if(prec < 8)
|
||||||
|
{
|
||||||
|
force8 = 1;
|
||||||
|
ushift = 8 - prec; dshift = prec - ushift;
|
||||||
|
if(cmptparm.sgnd) adjustS = (1<<(prec - 1)); else adjustS = 0;
|
||||||
|
cmptparm.sgnd = 0;
|
||||||
|
prec = 8;
|
||||||
|
}
|
||||||
|
else ushift = dshift = force8 = adjustS = 0;
|
||||||
|
|
||||||
cmptparm.prec = prec;
|
cmptparm.prec = prec;
|
||||||
cmptparm.bpp = prec;
|
cmptparm.bpp = prec;
|
||||||
cmptparm.dx = parameters->subsampling_dx;
|
cmptparm.dx = parameters->subsampling_dx;
|
||||||
@@ -1326,7 +1358,17 @@ opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters) {
|
|||||||
|
|
||||||
for (i = 0; i < w * h; i++) {
|
for (i = 0; i < w * h; i++) {
|
||||||
int v;
|
int v;
|
||||||
if (comp->prec <= 8) {
|
if(force8)
|
||||||
|
{
|
||||||
|
v = readuchar(f) + adjustS;
|
||||||
|
v = (v<<ushift) + (v>>dshift);
|
||||||
|
comp->data[i] = (unsigned char)v;
|
||||||
|
|
||||||
|
if(v > max) max = v;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (comp->prec == 8) {
|
||||||
if (!comp->sgnd) {
|
if (!comp->sgnd) {
|
||||||
v = readuchar(f);
|
v = readuchar(f);
|
||||||
} else {
|
} else {
|
||||||
@@ -2039,16 +2081,6 @@ int imagetopnm(opj_image_t * image, const char *outfile)
|
|||||||
|
|
||||||
<<-- <<-- <<-- <<-- */
|
<<-- <<-- <<-- <<-- */
|
||||||
|
|
||||||
typedef struct tiff_infoheader{
|
|
||||||
DWORD tiWidth; /* Width of Image in pixel*/
|
|
||||||
DWORD tiHeight; /* Height of Image in pixel */
|
|
||||||
DWORD tiPhoto; /* Photometric */
|
|
||||||
WORD tiBps; /* Bits per sample */
|
|
||||||
WORD tiSf; /* Sample Format */
|
|
||||||
WORD tiSpp; /* Sample per pixel 1-bilevel,gray scale , 2- RGB */
|
|
||||||
WORD tiPC; /* Planar config (1-Interleaved, 2-Planarcomp) */
|
|
||||||
}tiff_infoheader_t;
|
|
||||||
|
|
||||||
int imagetotif(opj_image_t * image, const char *outfile)
|
int imagetotif(opj_image_t * image, const char *outfile)
|
||||||
{
|
{
|
||||||
int width, height, imgsize;
|
int width, height, imgsize;
|
||||||
@@ -2420,7 +2452,6 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||||||
int subsampling_dx = parameters->subsampling_dx;
|
int subsampling_dx = parameters->subsampling_dx;
|
||||||
int subsampling_dy = parameters->subsampling_dy;
|
int subsampling_dy = parameters->subsampling_dy;
|
||||||
TIFF *tif;
|
TIFF *tif;
|
||||||
tiff_infoheader_t Info;
|
|
||||||
tdata_t buf;
|
tdata_t buf;
|
||||||
tstrip_t strip;
|
tstrip_t strip;
|
||||||
tsize_t strip_size;
|
tsize_t strip_size;
|
||||||
@@ -2430,6 +2461,8 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||||||
opj_image_t *image = NULL;
|
opj_image_t *image = NULL;
|
||||||
int imgsize = 0;
|
int imgsize = 0;
|
||||||
int has_alpha = 0;
|
int has_alpha = 0;
|
||||||
|
unsigned short tiBps, tiPhoto, tiSf, tiSpp, tiPC;
|
||||||
|
unsigned int tiWidth, tiHeight;
|
||||||
|
|
||||||
tif = TIFFOpen(filename, "r");
|
tif = TIFFOpen(filename, "r");
|
||||||
|
|
||||||
@@ -2438,32 +2471,34 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||||||
fprintf(stderr, "tiftoimage:Failed to open %s for reading\n", filename);
|
fprintf(stderr, "tiftoimage:Failed to open %s for reading\n", filename);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &Info.tiWidth);
|
tiBps = tiPhoto = tiSf = tiSpp = tiPC = 0;
|
||||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &Info.tiHeight);
|
tiWidth = tiHeight = 0;
|
||||||
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &Info.tiBps);
|
|
||||||
TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &Info.tiSf);
|
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &tiWidth);
|
||||||
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &Info.tiSpp);
|
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &tiHeight);
|
||||||
Info.tiPhoto = 0;
|
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &tiBps);
|
||||||
TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &Info.tiPhoto);
|
TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &tiSf);
|
||||||
TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &Info.tiPC);
|
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &tiSpp);
|
||||||
w= Info.tiWidth;
|
TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &tiPhoto);
|
||||||
h= Info.tiHeight;
|
TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &tiPC);
|
||||||
|
w= tiWidth;
|
||||||
|
h= tiHeight;
|
||||||
|
|
||||||
{
|
{
|
||||||
int b, p;
|
unsigned short b = tiBps, p = tiPhoto;
|
||||||
|
|
||||||
if((b = Info.tiBps) != 8 && b != 16 && b != 12) b = 0;
|
if(tiBps != 8 && tiBps != 16 && tiBps != 12) b = 0;
|
||||||
if((p = Info.tiPhoto) != 1 && p != 2) p = 0;
|
if(tiPhoto != 1 && tiPhoto != 2) p = 0;
|
||||||
|
|
||||||
if( !b || !p)
|
if( !b || !p)
|
||||||
{
|
{
|
||||||
if( !b)
|
if( !b)
|
||||||
fprintf(stderr,"imagetotif: Bits=%d, Only 8 and 16 bits"
|
fprintf(stderr,"imagetotif: Bits=%d, Only 8 and 16 bits"
|
||||||
" implemented\n",Info.tiBps);
|
" implemented\n",tiBps);
|
||||||
else
|
else
|
||||||
if( !p)
|
if( !p)
|
||||||
fprintf(stderr,"tiftoimage: Bad color format %d.\n\tOnly RGB(A)"
|
fprintf(stderr,"tiftoimage: Bad color format %d.\n\tOnly RGB(A)"
|
||||||
" and GRAY(A) has been implemented\n",(int) Info.tiPhoto);
|
" and GRAY(A) has been implemented\n",(int) tiPhoto);
|
||||||
|
|
||||||
fprintf(stderr,"\tAborting\n");
|
fprintf(stderr,"\tAborting\n");
|
||||||
TIFFClose(tif);
|
TIFFClose(tif);
|
||||||
@@ -2471,7 +2506,6 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{/* From: tiff-4.0.x/libtiff/tif_getimage.c : */
|
{/* From: tiff-4.0.x/libtiff/tif_getimage.c : */
|
||||||
uint16* sampleinfo;
|
uint16* sampleinfo;
|
||||||
uint16 extrasamples;
|
uint16 extrasamples;
|
||||||
@@ -2486,7 +2520,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||||||
case EXTRASAMPLE_UNSPECIFIED:
|
case EXTRASAMPLE_UNSPECIFIED:
|
||||||
/* Workaround for some images without correct info about alpha channel
|
/* Workaround for some images without correct info about alpha channel
|
||||||
*/
|
*/
|
||||||
if(Info.tiSpp > 3)
|
if(tiSpp > 3)
|
||||||
has_alpha = 1;
|
has_alpha = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -2496,12 +2530,15 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else /* extrasamples == 0 */
|
||||||
|
if(tiSpp == 4 || tiSpp == 2) has_alpha = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize image components
|
/* initialize image components
|
||||||
*/
|
*/
|
||||||
memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t));
|
memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t));
|
||||||
|
|
||||||
if(Info.tiPhoto == PHOTOMETRIC_RGB) /* RGB(A) */
|
if(tiPhoto == PHOTOMETRIC_RGB) /* RGB(A) */
|
||||||
{
|
{
|
||||||
numcomps = 3 + has_alpha;
|
numcomps = 3 + has_alpha;
|
||||||
color_space = CLRSPC_SRGB;
|
color_space = CLRSPC_SRGB;
|
||||||
@@ -2515,8 +2552,8 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmptparm[j].prec = Info.tiBps;
|
cmptparm[j].prec = tiBps;
|
||||||
cmptparm[j].bpp = Info.tiBps;
|
cmptparm[j].bpp = tiBps;
|
||||||
}
|
}
|
||||||
cmptparm[j].dx = subsampling_dx;
|
cmptparm[j].dx = subsampling_dx;
|
||||||
cmptparm[j].dy = subsampling_dy;
|
cmptparm[j].dy = subsampling_dy;
|
||||||
@@ -2555,7 +2592,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||||||
ssize = TIFFReadEncodedStrip(tif, strip, buf, strip_size);
|
ssize = TIFFReadEncodedStrip(tif, strip, buf, strip_size);
|
||||||
dat8 = (unsigned char*)buf;
|
dat8 = (unsigned char*)buf;
|
||||||
|
|
||||||
if(Info.tiBps == 16)
|
if(tiBps == 16)
|
||||||
{
|
{
|
||||||
step = 6 + has_alpha + has_alpha;
|
step = 6 + has_alpha + has_alpha;
|
||||||
|
|
||||||
@@ -2588,9 +2625,9 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}/*for(i = 0)*/
|
}/*for(i = 0)*/
|
||||||
}/*if(Info.tiBps == 16)*/
|
}/*if(tiBps == 16)*/
|
||||||
else
|
else
|
||||||
if(Info.tiBps == 8)
|
if(tiBps == 8)
|
||||||
{
|
{
|
||||||
step = 3 + has_alpha;
|
step = 3 + has_alpha;
|
||||||
|
|
||||||
@@ -2619,9 +2656,9 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}/*for(i )*/
|
}/*for(i )*/
|
||||||
}/*if( Info.tiBps == 8)*/
|
}/*if( tiBps == 8)*/
|
||||||
else
|
else
|
||||||
if(Info.tiBps == 12)/* CINEMA file */
|
if(tiBps == 12)/* CINEMA file */
|
||||||
{
|
{
|
||||||
step = 9;
|
step = 9;
|
||||||
|
|
||||||
@@ -2652,15 +2689,15 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||||||
return image;
|
return image;
|
||||||
}/*RGB(A)*/
|
}/*RGB(A)*/
|
||||||
|
|
||||||
if(Info.tiPhoto == PHOTOMETRIC_MINISBLACK) /* GRAY(A) */
|
if(tiPhoto == PHOTOMETRIC_MINISBLACK) /* GRAY(A) */
|
||||||
{
|
{
|
||||||
numcomps = 1 + has_alpha;
|
numcomps = 1 + has_alpha;
|
||||||
color_space = CLRSPC_GRAY;
|
color_space = CLRSPC_GRAY;
|
||||||
|
|
||||||
for(j = 0; j < numcomps; ++j)
|
for(j = 0; j < numcomps; ++j)
|
||||||
{
|
{
|
||||||
cmptparm[j].prec = Info.tiBps;
|
cmptparm[j].prec = tiBps;
|
||||||
cmptparm[j].bpp = Info.tiBps;
|
cmptparm[j].bpp = tiBps;
|
||||||
cmptparm[j].dx = subsampling_dx;
|
cmptparm[j].dx = subsampling_dx;
|
||||||
cmptparm[j].dy = subsampling_dy;
|
cmptparm[j].dy = subsampling_dy;
|
||||||
cmptparm[j].w = w;
|
cmptparm[j].w = w;
|
||||||
@@ -2698,7 +2735,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||||||
ssize = TIFFReadEncodedStrip(tif, strip, buf, strip_size);
|
ssize = TIFFReadEncodedStrip(tif, strip, buf, strip_size);
|
||||||
dat8 = (unsigned char*)buf;
|
dat8 = (unsigned char*)buf;
|
||||||
|
|
||||||
if(Info.tiBps == 16)
|
if(tiBps == 16)
|
||||||
{
|
{
|
||||||
step = 2 + has_alpha + has_alpha;
|
step = 2 + has_alpha + has_alpha;
|
||||||
|
|
||||||
@@ -2716,7 +2753,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||||||
}/*for(i )*/
|
}/*for(i )*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if(Info.tiBps == 8)
|
if(tiBps == 8)
|
||||||
{
|
{
|
||||||
step = 1 + has_alpha;
|
step = 1 + has_alpha;
|
||||||
|
|
||||||
@@ -3182,18 +3219,27 @@ int imagetopng(opj_image_t * image, const char *write_idf)
|
|||||||
int *red, *green, *blue, *alpha;
|
int *red, *green, *blue, *alpha;
|
||||||
unsigned char *row_buf, *d;
|
unsigned char *row_buf, *d;
|
||||||
int has_alpha, width, height, nr_comp, color_type;
|
int has_alpha, width, height, nr_comp, color_type;
|
||||||
int adjustR, adjustG, adjustB, x, y, fails, is16, force16;
|
int adjustR, adjustG, adjustB, adjustA, x, y, fails;
|
||||||
int opj_prec, prec, ushift, dshift;
|
int prec, ushift, dshift, is16, force16, force8;
|
||||||
unsigned short mask = 0xffff;
|
unsigned short mask = 0xffff;
|
||||||
png_color_8 sig_bit;
|
png_color_8 sig_bit;
|
||||||
|
|
||||||
is16 = force16 = ushift = dshift = 0; fails = 1;
|
is16 = force16 = force8 = ushift = dshift = 0; fails = 1;
|
||||||
prec = opj_prec = image->comps[0].prec;
|
prec = image->comps[0].prec;
|
||||||
|
nr_comp = image->numcomps;
|
||||||
|
|
||||||
if(prec > 8 && prec < 16)
|
if(prec > 8 && prec < 16)
|
||||||
{
|
{
|
||||||
prec = 16; force16 = 1;
|
ushift = 16 - prec; dshift = prec - ushift;
|
||||||
|
prec = 16; force16 = 1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
if(prec < 8 && nr_comp > 1)/* GRAY_ALPHA, RGB, RGB_ALPHA */
|
||||||
|
{
|
||||||
|
ushift = 8 - prec; dshift = 8 - ushift;
|
||||||
|
prec = 8; force8 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if(prec != 1 && prec != 2 && prec != 4 && prec != 8 && prec != 16)
|
if(prec != 1 && prec != 2 && prec != 4 && prec != 8 && prec != 16)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"imagetopng: can not create %s"
|
fprintf(stderr,"imagetopng: can not create %s"
|
||||||
@@ -3241,6 +3287,14 @@ int imagetopng(opj_image_t * image, const char *write_idf)
|
|||||||
* PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
|
* PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
|
||||||
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE.
|
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE.
|
||||||
* REQUIRED
|
* REQUIRED
|
||||||
|
*
|
||||||
|
* ERRORS:
|
||||||
|
*
|
||||||
|
* color_type == PNG_COLOR_TYPE_PALETTE && bit_depth > 8
|
||||||
|
* color_type == PNG_COLOR_TYPE_RGB && bit_depth < 8
|
||||||
|
* color_type == PNG_COLOR_TYPE_GRAY_ALPHA && bit_depth < 8
|
||||||
|
* color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
png_set_compression_level(png, Z_BEST_COMPRESSION);
|
png_set_compression_level(png, Z_BEST_COMPRESSION);
|
||||||
|
|
||||||
@@ -3254,8 +3308,6 @@ int imagetopng(opj_image_t * image, const char *write_idf)
|
|||||||
else
|
else
|
||||||
if(prec == 1) mask = 0x0001;
|
if(prec == 1) mask = 0x0001;
|
||||||
|
|
||||||
nr_comp = image->numcomps;
|
|
||||||
|
|
||||||
if(nr_comp >= 3
|
if(nr_comp >= 3
|
||||||
&& image->comps[0].dx == image->comps[1].dx
|
&& image->comps[0].dx == image->comps[1].dx
|
||||||
&& image->comps[1].dx == image->comps[2].dx
|
&& image->comps[1].dx == image->comps[2].dx
|
||||||
@@ -3284,11 +3336,13 @@ int imagetopng(opj_image_t * image, const char *write_idf)
|
|||||||
sig_bit.alpha = prec;
|
sig_bit.alpha = prec;
|
||||||
alpha = image->comps[3].data;
|
alpha = image->comps[3].data;
|
||||||
color_type = PNG_COLOR_TYPE_RGB_ALPHA;
|
color_type = PNG_COLOR_TYPE_RGB_ALPHA;
|
||||||
|
adjustA = (image->comps[3].sgnd ? 1 << (image->comps[3].prec - 1) : 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sig_bit.alpha = 0; alpha = NULL;
|
sig_bit.alpha = 0; alpha = NULL;
|
||||||
color_type = PNG_COLOR_TYPE_RGB;
|
color_type = PNG_COLOR_TYPE_RGB;
|
||||||
|
adjustA = 0;
|
||||||
}
|
}
|
||||||
png_set_sBIT(png, info, &sig_bit);
|
png_set_sBIT(png, info, &sig_bit);
|
||||||
|
|
||||||
@@ -3296,17 +3350,12 @@ int imagetopng(opj_image_t * image, const char *write_idf)
|
|||||||
color_type,
|
color_type,
|
||||||
PNG_INTERLACE_NONE,
|
PNG_INTERLACE_NONE,
|
||||||
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||||
|
|
||||||
/*=============================*/
|
/*=============================*/
|
||||||
png_write_info(png, info);
|
png_write_info(png, info);
|
||||||
/*=============================*/
|
/*=============================*/
|
||||||
if(opj_prec < 8)
|
if(prec < 8)
|
||||||
{
|
{
|
||||||
png_set_packing(png);
|
png_set_packing(png);
|
||||||
}
|
|
||||||
if(force16)
|
|
||||||
{
|
|
||||||
ushift = 16 - opj_prec; dshift = opj_prec - ushift;
|
|
||||||
}
|
}
|
||||||
adjustR = (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
adjustR = (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
||||||
adjustG = (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
|
adjustG = (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
|
||||||
@@ -3342,21 +3391,40 @@ int imagetopng(opj_image_t * image, const char *write_idf)
|
|||||||
|
|
||||||
if(has_alpha)
|
if(has_alpha)
|
||||||
{
|
{
|
||||||
v = *alpha++;
|
v = *alpha + adjustA; ++alpha;
|
||||||
|
|
||||||
if(force16) { v = (v<<ushift) + (v>>dshift); }
|
if(force16) { v = (v<<ushift) + (v>>dshift); }
|
||||||
|
|
||||||
*d++ = (unsigned char)(v>>8); *d++ = (unsigned char)v;
|
*d++ = (unsigned char)(v>>8); *d++ = (unsigned char)v;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}/* if(is16) */
|
||||||
*d++ = (unsigned char)((*red + adjustR) & mask); ++red;
|
|
||||||
*d++ = (unsigned char)((*green + adjustG) & mask); ++green;
|
v = *red + adjustR; ++red;
|
||||||
*d++ = (unsigned char)((*blue + adjustB) & mask); ++blue;
|
|
||||||
|
if(force8) { v = (v<<ushift) + (v>>dshift); }
|
||||||
|
|
||||||
|
*d++ = (unsigned char)(v & mask);
|
||||||
|
|
||||||
|
v = *green + adjustG; ++green;
|
||||||
|
|
||||||
|
if(force8) { v = (v<<ushift) + (v>>dshift); }
|
||||||
|
|
||||||
|
*d++ = (unsigned char)(v & mask);
|
||||||
|
|
||||||
|
v = *blue + adjustB; ++blue;
|
||||||
|
|
||||||
|
if(force8) { v = (v<<ushift) + (v>>dshift); }
|
||||||
|
|
||||||
|
*d++ = (unsigned char)(v & mask);
|
||||||
|
|
||||||
if(has_alpha)
|
if(has_alpha)
|
||||||
{
|
{
|
||||||
*d++ = (unsigned char)(*alpha & mask); ++alpha;
|
v = *alpha + adjustA; ++alpha;
|
||||||
|
|
||||||
|
if(force8) { v = (v<<ushift) + (v>>dshift); }
|
||||||
|
|
||||||
|
*d++ = (unsigned char)(v & mask);
|
||||||
}
|
}
|
||||||
} /* for(x) */
|
} /* for(x) */
|
||||||
|
|
||||||
@@ -3377,13 +3445,9 @@ int imagetopng(opj_image_t * image, const char *write_idf)
|
|||||||
|
|
||||||
red = image->comps[0].data;
|
red = image->comps[0].data;
|
||||||
|
|
||||||
if(force16)
|
|
||||||
{
|
|
||||||
ushift = 16 - opj_prec; dshift = opj_prec - ushift;
|
|
||||||
}
|
|
||||||
sig_bit.gray = prec;
|
sig_bit.gray = prec;
|
||||||
sig_bit.red = sig_bit.green = sig_bit.blue = sig_bit.alpha = 0;
|
sig_bit.red = sig_bit.green = sig_bit.blue = sig_bit.alpha = 0;
|
||||||
alpha = NULL;
|
alpha = NULL; adjustA = 0;
|
||||||
color_type = PNG_COLOR_TYPE_GRAY;
|
color_type = PNG_COLOR_TYPE_GRAY;
|
||||||
|
|
||||||
if(nr_comp == 2)
|
if(nr_comp == 2)
|
||||||
@@ -3391,6 +3455,7 @@ int imagetopng(opj_image_t * image, const char *write_idf)
|
|||||||
has_alpha = 1; sig_bit.alpha = prec;
|
has_alpha = 1; sig_bit.alpha = prec;
|
||||||
alpha = image->comps[1].data;
|
alpha = image->comps[1].data;
|
||||||
color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
|
color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
|
||||||
|
adjustA = (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
|
||||||
}
|
}
|
||||||
width = image->comps[0].w;
|
width = image->comps[0].w;
|
||||||
height = image->comps[0].h;
|
height = image->comps[0].h;
|
||||||
@@ -3406,7 +3471,7 @@ int imagetopng(opj_image_t * image, const char *write_idf)
|
|||||||
/*=============================*/
|
/*=============================*/
|
||||||
adjustR = (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
adjustR = (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
||||||
|
|
||||||
if(opj_prec < 8)
|
if(prec < 8)
|
||||||
{
|
{
|
||||||
png_set_packing(png);
|
png_set_packing(png);
|
||||||
}
|
}
|
||||||
@@ -3452,11 +3517,19 @@ int imagetopng(opj_image_t * image, const char *write_idf)
|
|||||||
|
|
||||||
for(x = 0; x < width; ++x)
|
for(x = 0; x < width; ++x)
|
||||||
{
|
{
|
||||||
*d++ = (unsigned char)((*red + adjustR) & mask); ++red;
|
v = *red + adjustR; ++red;
|
||||||
|
|
||||||
|
if(force8) { v = (v<<ushift) + (v>>dshift); }
|
||||||
|
|
||||||
|
*d++ = (unsigned char)(v & mask);
|
||||||
|
|
||||||
if(has_alpha)
|
if(has_alpha)
|
||||||
{
|
{
|
||||||
*d++ = (unsigned char)(*alpha & mask); ++alpha;
|
v = *alpha + adjustA; ++alpha;
|
||||||
|
|
||||||
|
if(force8) { v = (v<<ushift) + (v>>dshift); }
|
||||||
|
|
||||||
|
*d++ = (unsigned char)(v & mask);
|
||||||
}
|
}
|
||||||
}/* for(x) */
|
}/* for(x) */
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 20010, Mathieu Malaterre, GDCM
|
* Copyright (c) 2010, Mathieu Malaterre, GDCM
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -274,12 +274,12 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
|
fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(!((parameters->outfile[0] == 0))){
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if((parameters->infile[0] == 0) ) {
|
if( parameters->infile[0] == 0 ) {
|
||||||
fprintf(stderr, "Example: %s -i image.j2k\n",argv[0]);
|
fprintf(stderr, "Example: %s -i image.j2k\n",argv[0]);
|
||||||
fprintf(stderr, " Try: %s -h\n",argv[0]);
|
fprintf(stderr, " Try: %s -h\n",argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -5,7 +5,14 @@ What's New for OpenJPIP
|
|||||||
! : changed
|
! : changed
|
||||||
+ : added
|
+ : added
|
||||||
|
|
||||||
January 26, 2011
|
Feburary 28, 2012
|
||||||
|
+ [kaori] enabled the opj_server to reply the first query consisting with len request from kakadu client
|
||||||
|
|
||||||
|
February 9, 2012
|
||||||
|
* [kaori] fixed Doxygen configuration file to document the utilities
|
||||||
|
+ [kaori] added execution argument to set port number for opj_dec_server, opj_viewer*
|
||||||
|
|
||||||
|
January 26, 2012
|
||||||
! [kaori] unapplied auxtrans_manager to the local mode
|
! [kaori] unapplied auxtrans_manager to the local mode
|
||||||
|
|
||||||
December 24, 2011
|
December 24, 2011
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
IF(BUILD_JPIP_SERVER)
|
IF(BUILD_JPIP_SERVER)
|
||||||
FIND_PACKAGE(CURL REQUIRED)
|
FIND_PACKAGE(CURL REQUIRED)
|
||||||
FIND_PACKAGE(FCGI REQUIRED)
|
FIND_PACKAGE(FCGI REQUIRED)
|
||||||
FIND_PACKAGE(PTHREAD REQUIRED)
|
FIND_PACKAGE(Threads REQUIRED)
|
||||||
|
IF(NOT CMAKE_USE_PTHREADS_INIT)
|
||||||
|
MESSAGE(FATAL_ERROR "Only pthread are supported")
|
||||||
|
ENDIF(NOT CMAKE_USE_PTHREADS_INIT)
|
||||||
ENDIF(BUILD_JPIP_SERVER)
|
ENDIF(BUILD_JPIP_SERVER)
|
||||||
|
|
||||||
# JPIP library:
|
# JPIP library:
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ Server:
|
|||||||
|
|
||||||
Client:
|
Client:
|
||||||
1. Launch image decoding server, and keep it alive as long as image viewers are open
|
1. Launch image decoding server, and keep it alive as long as image viewers are open
|
||||||
% ./opj_dec_server
|
% ./opj_dec_server [portnumber (50000 by default)]
|
||||||
|
|
||||||
You might prefer to implement this program from another directory since cache files are saved in the working directory.
|
You might prefer to implement this program from another directory since cache files are saved in the working directory.
|
||||||
% mkdir cache
|
% mkdir cache
|
||||||
@@ -104,10 +104,12 @@ Client:
|
|||||||
% ../opj_dec_server
|
% ../opj_dec_server
|
||||||
|
|
||||||
2. Open image viewers (as many as needed)
|
2. Open image viewers (as many as needed)
|
||||||
% java -jar opj_viewer.jar http://hostname/myFCGI path/filename.jp2 [stateless/session] [jptstream/jppstream] [tcp/udp]
|
% java -jar opj_viewer.jar http://hostname/myFCGI path/filename.jp2 [hostname] [portnumber] [stateless/session] [jptstream/jppstream] [tcp/udp]
|
||||||
( The arguments
|
( The arguments
|
||||||
- http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
|
- http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
|
||||||
- path/filename.jp2 is the server local path or URL of a JP2 file
|
- path/filename.jp2 is the server local path or URL of a JP2 file
|
||||||
|
- host name of opj_dec_server, localhost by default
|
||||||
|
- portnumber of opj_dec_server, 50000 by default
|
||||||
- request type stateless for no caching, session (default) for caching
|
- request type stateless for no caching, session (default) for caching
|
||||||
- return media type, JPT-stream tile based stream, or JPP-stream (default) precinct based stream
|
- return media type, JPT-stream tile based stream, or JPP-stream (default) precinct based stream
|
||||||
- auxiliary return protocol, tcp or udp (udp is not implemented yet), if not given, return data is filled in http chunk
|
- auxiliary return protocol, tcp or udp (udp is not implemented yet), if not given, return data is filled in http chunk
|
||||||
@@ -131,7 +133,7 @@ An example to encode a TIF image "copenhague1.tif" at resolution 4780x4050, 8bit
|
|||||||
% ./image_to_j2k -i copenhague1.tif -o copenhague1.jp2 -p RPCL -c [64,64] -t 640,480 -jpip -TP R
|
% ./image_to_j2k -i copenhague1.tif -o copenhague1.jp2 -p RPCL -c [64,64] -t 640,480 -jpip -TP R
|
||||||
|
|
||||||
options
|
options
|
||||||
-jpip : embed index table box into the output JP2 file (obligation for JPIP)
|
-jpip : embed index table 'cidx' box into the output JP2 file (obligation for JPIP)
|
||||||
-TP R : partition a tile into tile parts of different resolution levels (obligation for JPT-stream)
|
-TP R : partition a tile into tile parts of different resolution levels (obligation for JPT-stream)
|
||||||
|
|
||||||
<Option>
|
<Option>
|
||||||
|
|||||||
@@ -568,7 +568,7 @@ WARN_LOGFILE =
|
|||||||
# directories like "/usr/src/myproject". Separate the files or directories
|
# directories like "/usr/src/myproject". Separate the files or directories
|
||||||
# with spaces.
|
# with spaces.
|
||||||
|
|
||||||
INPUT = .. ../libopenjpip ../opj_server ../opj_client/opj_dec_server ../tools ../tools/indexer
|
INPUT = .. ../libopenjpip ../util
|
||||||
|
|
||||||
# This tag can be used to specify the character encoding of the source files
|
# This tag can be used to specify the character encoding of the source files
|
||||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
|
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ INCLUDE_DIRECTORIES(
|
|||||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||||
${FCGI_INCLUDE_DIRS}
|
${FCGI_INCLUDE_DIRS}
|
||||||
${CURL_INCLUDE_DIRS}
|
${CURL_INCLUDE_DIRS}
|
||||||
${PTHREAD_INCLUDE_DIRS}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Defines the source code for the library
|
# Defines the source code for the library
|
||||||
@@ -63,7 +62,7 @@ INSTALL(TARGETS openjpip_local
|
|||||||
|
|
||||||
IF(BUILD_JPIP_SERVER)
|
IF(BUILD_JPIP_SERVER)
|
||||||
ADD_LIBRARY(openjpip_server STATIC ${OPENJPIP_SRCS} ${SERVER_SRCS})
|
ADD_LIBRARY(openjpip_server STATIC ${OPENJPIP_SRCS} ${SERVER_SRCS})
|
||||||
TARGET_LINK_LIBRARIES(openjpip_server ${FCGI_LIBRARIES} ${CURL_LIBRARIES} ${PTHREAD_LIBRARIES})
|
TARGET_LINK_LIBRARIES(openjpip_server ${FCGI_LIBRARIES} ${CURL_LIBRARIES} ${CMAKE_THREAD_LIBS})
|
||||||
SET_TARGET_PROPERTIES(openjpip_server
|
SET_TARGET_PROPERTIES(openjpip_server
|
||||||
PROPERTIES COMPILE_FLAGS "-DSERVER")
|
PROPERTIES COMPILE_FLAGS "-DSERVER")
|
||||||
INSTALL(TARGETS openjpip_server
|
INSTALL(TARGETS openjpip_server
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif //SERVER
|
#endif /*SERVER */
|
||||||
|
|
||||||
auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport)
|
auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport)
|
||||||
{
|
{
|
||||||
@@ -61,7 +61,7 @@ auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport)
|
|||||||
auxtrans.tcplistensock = -1;
|
auxtrans.tcplistensock = -1;
|
||||||
|
|
||||||
auxtrans.udplistensock = -1;
|
auxtrans.udplistensock = -1;
|
||||||
// open listening socket for udp later
|
/* open listening socket for udp later */
|
||||||
|
|
||||||
return auxtrans;
|
return auxtrans;
|
||||||
}
|
}
|
||||||
@@ -78,15 +78,15 @@ void close_aux_transport( auxtrans_param_t auxtrans)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//!< auxiliary response parameters
|
/*!< auxiliary response parameters */
|
||||||
typedef struct aux_response_param{
|
typedef struct aux_response_param{
|
||||||
char *cid; //!< channel ID
|
char *cid; /*!< channel ID */
|
||||||
unsigned char *data; //!< sending data
|
unsigned char *data; /*!< sending data */
|
||||||
int datalen; //!< length of data
|
int datalen; /*!< length of data */
|
||||||
int maxlenPerFrame; //!< maximum data length to send per frame
|
int maxlenPerFrame; /*!< maximum data length to send per frame */
|
||||||
SOCKET listensock; //!< listeing socket
|
SOCKET listensock; /*!< listeing socket */
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HANDLE hTh; //!< thread handle
|
HANDLE hTh; /*!< thread handle */
|
||||||
#endif
|
#endif
|
||||||
} aux_response_param_t;
|
} aux_response_param_t;
|
||||||
|
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ box_param_t * gene_boxbyOffinStream( Byte_t *stream, Byte8_t offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, char TBox[])
|
box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, const char TBox[])
|
||||||
{
|
{
|
||||||
Byte8_t pos;
|
Byte8_t pos;
|
||||||
Byte_t *data;
|
Byte_t *data;
|
||||||
@@ -221,7 +221,7 @@ box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, char TBox[
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t length, char TBox[])
|
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t length, const char TBox[])
|
||||||
{
|
{
|
||||||
Byte8_t pos;
|
Byte8_t pos;
|
||||||
Byte_t *data;
|
Byte_t *data;
|
||||||
@@ -272,7 +272,7 @@ box_param_t * gene_childboxbyOffset( box_param_t *superbox, Byte8_t offset)
|
|||||||
return gene_boxbyOffset( superbox->fd, get_DBoxoff( superbox)+offset);
|
return gene_boxbyOffset( superbox->fd, get_DBoxoff( superbox)+offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, char TBox[])
|
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, const char TBox[])
|
||||||
{
|
{
|
||||||
return gene_boxbyType( superbox->fd, get_DBoxoff( superbox)+offset, get_DBoxlen( superbox)-offset, TBox);
|
return gene_boxbyType( superbox->fd, get_DBoxoff( superbox)+offset, get_DBoxlen( superbox)-offset, TBox);
|
||||||
}
|
}
|
||||||
@@ -317,7 +317,7 @@ Byte8_t fetch_DBox8bytebigendian( box_param_t *box, long offset)
|
|||||||
return fetch_8bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
return fetch_8bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
box_param_t * search_box( char type[], boxlist_param_t *boxlist)
|
box_param_t * search_box( const char type[], boxlist_param_t *boxlist)
|
||||||
{
|
{
|
||||||
box_param_t *foundbox;
|
box_param_t *foundbox;
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ box_param_t * gene_boxbyOffinStream( Byte_t *stream, Byte8_t offset);
|
|||||||
* @param[in] TBox Box Type
|
* @param[in] TBox Box Type
|
||||||
* @return pointer to the structure of generate/found box parameters
|
* @return pointer to the structure of generate/found box parameters
|
||||||
*/
|
*/
|
||||||
box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, char TBox[]);
|
box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, const char TBox[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate(search) box from code stream
|
* generate(search) box from code stream
|
||||||
@@ -108,7 +108,7 @@ box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, char TBox[
|
|||||||
* @param[in] TBox Box Type
|
* @param[in] TBox Box Type
|
||||||
* @return pointer to the structure of generate/found box parameters
|
* @return pointer to the structure of generate/found box parameters
|
||||||
*/
|
*/
|
||||||
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t length, char TBox[]);
|
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t length, const char TBox[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate child box from JP2 file at the given offset
|
* generate child box from JP2 file at the given offset
|
||||||
@@ -127,7 +127,7 @@ box_param_t * gene_childboxbyOffset( box_param_t *superbox, Byte8_t offset);
|
|||||||
* @param[in] TBox Box Type
|
* @param[in] TBox Box Type
|
||||||
* @return pointer to the structure of generate/found box parameters
|
* @return pointer to the structure of generate/found box parameters
|
||||||
*/
|
*/
|
||||||
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, char TBox[]);
|
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, const char TBox[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get DBox offset
|
* get DBox offset
|
||||||
@@ -210,7 +210,7 @@ Byte8_t fetch_DBox8bytebigendian( box_param_t *box, long offset);
|
|||||||
* @param[in] boxlist box list pointer
|
* @param[in] boxlist box list pointer
|
||||||
* @return found box pointer
|
* @return found box pointer
|
||||||
*/
|
*/
|
||||||
box_param_t * search_box( char type[], boxlist_param_t *boxlist);
|
box_param_t * search_box( const char type[], boxlist_param_t *boxlist);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* print box parameters
|
* print box parameters
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif //SERVER
|
#endif /*SERVER*/
|
||||||
|
|
||||||
|
|
||||||
boxheader_param_t * gene_boxheader( int fd, Byte8_t offset)
|
boxheader_param_t * gene_boxheader( int fd, Byte8_t offset)
|
||||||
@@ -55,7 +55,7 @@ boxheader_param_t * gene_boxheader( int fd, Byte8_t offset)
|
|||||||
boxtype = (char *)fetch_bytes( fd, offset+4, 4);
|
boxtype = (char *)fetch_bytes( fd, offset+4, 4);
|
||||||
headlen = 8;
|
headlen = 8;
|
||||||
|
|
||||||
if( boxlen == 1){ // read XLBox
|
if( boxlen == 1){ /* read XLBox */
|
||||||
boxlen = fetch_8bytebigendian( fd, offset+8);
|
boxlen = fetch_8bytebigendian( fd, offset+8);
|
||||||
headlen = 16;
|
headlen = 16;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,13 +76,13 @@ Byte_t fetch_1byte( int fd, long offset)
|
|||||||
|
|
||||||
if( lseek( fd, offset, SEEK_SET)==-1){
|
if( lseek( fd, offset, SEEK_SET)==-1){
|
||||||
fprintf( FCGI_stdout, "Reason: Target broken (seek error)\r\n");
|
fprintf( FCGI_stdout, "Reason: Target broken (seek error)\r\n");
|
||||||
fprintf( FCGI_stderr, "Error: error in fetch_1byte( %d, %ld)\n", fd, offset);
|
fprintf( FCGI_stderr, "Error: error in fetch_1byte( %d, %lld)\n", fd, offset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( read( fd, &code, 1) != 1){
|
if( read( fd, &code, 1) != 1){
|
||||||
fprintf( FCGI_stdout, "Reason: Target broken (read error)\r\n");
|
fprintf( FCGI_stdout, "Reason: Target broken (read error)\r\n");
|
||||||
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld)\n", fd, offset);
|
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %lld)\n", fd, offset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
@@ -94,7 +94,7 @@ Byte2_t fetch_2bytebigendian( int fd, long offset)
|
|||||||
Byte2_t code;
|
Byte2_t code;
|
||||||
|
|
||||||
if(!(data = fetch_bytes( fd, offset, 2))){
|
if(!(data = fetch_bytes( fd, offset, 2))){
|
||||||
fprintf( FCGI_stderr, "Error: error in fetch_2bytebigendian( %d, %ld)\n", fd, offset);
|
fprintf( FCGI_stderr, "Error: error in fetch_2bytebigendian( %d, %lld)\n", fd, offset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
code = big2(data);
|
code = big2(data);
|
||||||
@@ -109,7 +109,7 @@ Byte4_t fetch_4bytebigendian( int fd, long offset)
|
|||||||
Byte4_t code;
|
Byte4_t code;
|
||||||
|
|
||||||
if(!(data = fetch_bytes( fd, offset, 4))){
|
if(!(data = fetch_bytes( fd, offset, 4))){
|
||||||
fprintf( FCGI_stderr, "Error: error in fetch_4bytebigendian( %d, %ld)\n", fd, offset);
|
fprintf( FCGI_stderr, "Error: error in fetch_4bytebigendian( %d, %lld)\n", fd, offset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
code = big4(data);
|
code = big4(data);
|
||||||
@@ -124,7 +124,7 @@ Byte8_t fetch_8bytebigendian( int fd, long offset)
|
|||||||
Byte8_t code;
|
Byte8_t code;
|
||||||
|
|
||||||
if(!(data = fetch_bytes( fd, offset, 8))){
|
if(!(data = fetch_bytes( fd, offset, 8))){
|
||||||
fprintf( FCGI_stderr, "Error: error in fetch_8bytebigendian( %d, %ld)\n", fd, offset);
|
fprintf( FCGI_stderr, "Error: error in fetch_8bytebigendian( %d, %lld)\n", fd, offset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
code = big8(data);
|
code = big8(data);
|
||||||
|
|||||||
@@ -29,19 +29,29 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BYTE_MANAGER_H_
|
#ifndef BYTE_MANAGER_H_
|
||||||
# define BYTE_MANAGER_H_
|
#define BYTE_MANAGER_H_
|
||||||
|
|
||||||
|
#include "opj_config.h"
|
||||||
|
#ifdef HAVE_STDINT_H
|
||||||
|
#include <stdint.h>
|
||||||
|
typedef uint8_t Byte_t;
|
||||||
|
typedef uint16_t Byte2_t;
|
||||||
|
typedef uint32_t Byte4_t;
|
||||||
|
typedef uint64_t Byte8_t;
|
||||||
|
#else
|
||||||
|
#if defined(_WIN32)
|
||||||
/** 1Byte parameter type*/
|
/** 1Byte parameter type*/
|
||||||
typedef unsigned char Byte_t;
|
typedef unsigned __int8 Byte_t;
|
||||||
|
|
||||||
/** 2Byte parameter type*/
|
/** 2Byte parameter type*/
|
||||||
typedef unsigned short int Byte2_t;
|
typedef unsigned __int16 Byte2_t;
|
||||||
|
|
||||||
/** 4Byte parameter type*/
|
/** 4Byte parameter type*/
|
||||||
typedef unsigned int Byte4_t;
|
typedef unsigned __int32 Byte4_t;
|
||||||
|
|
||||||
/** 8Byte parameter type*/
|
/** 8Byte parameter type*/
|
||||||
typedef unsigned long long int Byte8_t;
|
typedef unsigned __int64 Byte8_t;
|
||||||
|
#else
|
||||||
|
#error unsupported platform
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -40,10 +40,10 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif //SERVER
|
#endif /*SERVER*/
|
||||||
|
|
||||||
|
|
||||||
cachemodellist_param_t * gene_cachemodellist()
|
cachemodellist_param_t * gene_cachemodellist(void)
|
||||||
{
|
{
|
||||||
cachemodellist_param_t *cachemodellist;
|
cachemodellist_param_t *cachemodellist;
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, ta
|
|||||||
cachemodel->jppstream = true;
|
cachemodel->jppstream = true;
|
||||||
else
|
else
|
||||||
cachemodel->jppstream = false;
|
cachemodel->jppstream = false;
|
||||||
} else{ // reqJPT
|
} else{ /* reqJPT */
|
||||||
if( target->jptstream)
|
if( target->jptstream)
|
||||||
cachemodel->jppstream = false;
|
cachemodel->jppstream = false;
|
||||||
else
|
else
|
||||||
@@ -95,9 +95,9 @@ cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, ta
|
|||||||
cachemodel->next = NULL;
|
cachemodel->next = NULL;
|
||||||
|
|
||||||
if( cachemodellist){
|
if( cachemodellist){
|
||||||
if( cachemodellist->first) // there are one or more entries
|
if( cachemodellist->first) /* there are one or more entries */
|
||||||
cachemodellist->last->next = cachemodel;
|
cachemodellist->last->next = cachemodel;
|
||||||
else // first entry
|
else /* first entry */
|
||||||
cachemodellist->first = cachemodel;
|
cachemodellist->first = cachemodel;
|
||||||
cachemodellist->last = cachemodel;
|
cachemodellist->last = cachemodel;
|
||||||
}
|
}
|
||||||
@@ -112,9 +112,10 @@ cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, ta
|
|||||||
void print_cachemodel( cachemodel_param_t cachemodel)
|
void print_cachemodel( cachemodel_param_t cachemodel)
|
||||||
{
|
{
|
||||||
target_param_t *target;
|
target_param_t *target;
|
||||||
Byte8_t TPnum; // num of tile parts in each tile
|
Byte8_t TPnum; /* num of tile parts in each tile */
|
||||||
Byte8_t Pmax; // max num of packets per tile
|
Byte8_t Pmax; /* max num of packets per tile */
|
||||||
int i, j, k, n;
|
Byte8_t i, j, k;
|
||||||
|
int n; /* FIXME: Is this large enough ? */
|
||||||
|
|
||||||
target = cachemodel.target;
|
target = cachemodel.target;
|
||||||
|
|
||||||
@@ -135,9 +136,9 @@ void print_cachemodel( cachemodel_param_t cachemodel)
|
|||||||
|
|
||||||
fprintf( logstream, "\t tile header and precinct packet model:\n");
|
fprintf( logstream, "\t tile header and precinct packet model:\n");
|
||||||
for( i=0; i<target->codeidx->SIZ.XTnum*target->codeidx->SIZ.YTnum; i++){
|
for( i=0; i<target->codeidx->SIZ.XTnum*target->codeidx->SIZ.YTnum; i++){
|
||||||
fprintf( logstream, "\t tile.%d %d\n", i, cachemodel.th_model[i]);
|
fprintf( logstream, "\t tile.%llud %d\n", i, cachemodel.th_model[i]);
|
||||||
for( j=0; j<target->codeidx->SIZ.Csiz; j++){
|
for( j=0; j<target->codeidx->SIZ.Csiz; j++){
|
||||||
fprintf( logstream, "\t compo.%d: ", j);
|
fprintf( logstream, "\t compo.%llud: ", j);
|
||||||
Pmax = get_nmax( target->codeidx->precpacket[j]);
|
Pmax = get_nmax( target->codeidx->precpacket[j]);
|
||||||
for( k=0; k<Pmax; k++)
|
for( k=0; k<Pmax; k++)
|
||||||
fprintf( logstream, "%d", cachemodel.pp_model[j][i*Pmax+k]);
|
fprintf( logstream, "%d", cachemodel.pp_model[j][i*Pmax+k]);
|
||||||
@@ -197,9 +198,10 @@ void delete_cachemodel( cachemodel_param_t **cachemodel)
|
|||||||
bool is_allsent( cachemodel_param_t cachemodel)
|
bool is_allsent( cachemodel_param_t cachemodel)
|
||||||
{
|
{
|
||||||
target_param_t *target;
|
target_param_t *target;
|
||||||
Byte8_t TPnum; // num of tile parts in each tile
|
Byte8_t TPnum; /* num of tile parts in each tile */
|
||||||
Byte8_t Pmax; // max num of packets per tile
|
Byte8_t Pmax; /* max num of packets per tile */
|
||||||
int i, j, k, n;
|
Byte8_t i, j, k;
|
||||||
|
int n; /* FIXME: is this large enough ? */
|
||||||
|
|
||||||
target = cachemodel.target;
|
target = cachemodel.target;
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ typedef struct cachemodellist_param{
|
|||||||
*
|
*
|
||||||
* @return pointer to the generated cache model list
|
* @return pointer to the generated cache model list
|
||||||
*/
|
*/
|
||||||
cachemodellist_param_t * gene_cachemodellist();
|
cachemodellist_param_t * gene_cachemodellist(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate a cache model under a list
|
* generate a cache model under a list
|
||||||
|
|||||||
@@ -32,6 +32,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "channel_manager.h"
|
#include "channel_manager.h"
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define snprintf _snprintf /* Visual Studio */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef SERVER
|
#ifdef SERVER
|
||||||
#include "fcgi_stdio.h"
|
#include "fcgi_stdio.h"
|
||||||
@@ -40,9 +43,9 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif //SERVER
|
#endif /*SERVER */
|
||||||
|
|
||||||
channellist_param_t * gene_channellist()
|
channellist_param_t * gene_channellist(void)
|
||||||
{
|
{
|
||||||
channellist_param_t *channellist;
|
channellist_param_t *channellist;
|
||||||
|
|
||||||
@@ -68,12 +71,12 @@ channel_param_t * gene_channel( query_param_t query_param, auxtrans_param_t auxt
|
|||||||
channel = (channel_param_t *)malloc( sizeof(channel_param_t));
|
channel = (channel_param_t *)malloc( sizeof(channel_param_t));
|
||||||
channel->cachemodel = cachemodel;
|
channel->cachemodel = cachemodel;
|
||||||
|
|
||||||
// set channel ID and get present time
|
/* set channel ID and get present time */
|
||||||
snprintf( channel->cid, MAX_LENOFCID, "%x%x", (unsigned int)time( &channel->start_tm), (unsigned int)rand());
|
snprintf( channel->cid, MAX_LENOFCID, "%x%x", (unsigned int)time( &channel->start_tm), (unsigned int)rand());
|
||||||
|
|
||||||
channel->aux = query_param.cnew;
|
channel->aux = query_param.cnew;
|
||||||
|
|
||||||
// only tcp implemented for now
|
/* only tcp implemented for now */
|
||||||
if( channel->aux == udp)
|
if( channel->aux == udp)
|
||||||
channel->aux = tcp;
|
channel->aux = tcp;
|
||||||
|
|
||||||
@@ -101,7 +104,9 @@ channel_param_t * gene_channel( query_param_t query_param, auxtrans_param_t auxt
|
|||||||
|
|
||||||
void set_channel_variable_param( query_param_t query_param, channel_param_t *channel)
|
void set_channel_variable_param( query_param_t query_param, channel_param_t *channel)
|
||||||
{
|
{
|
||||||
// set roi information
|
/* set roi information */
|
||||||
|
(void)query_param;
|
||||||
|
(void)channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ typedef struct channellist_param{
|
|||||||
*
|
*
|
||||||
* @return pointer to the generated channel list
|
* @return pointer to the generated channel list
|
||||||
*/
|
*/
|
||||||
channellist_param_t * gene_channellist();
|
channellist_param_t * gene_channellist(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif //SERVER
|
#endif /*SERVER */
|
||||||
|
|
||||||
codestream_param_t set_codestream( int fd, Byte8_t offset, Byte8_t length)
|
codestream_param_t set_codestream( int fd, Byte8_t offset, Byte8_t length)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
ifdef jpipserver
|
|
||||||
CFLAGS = -O3 -Wall -m32 -DSERVER
|
|
||||||
LIBNAME = libopenjpip_server.a
|
|
||||||
else
|
|
||||||
J2KINCDIR = ../../../libopenjpeg
|
|
||||||
CFLAGS = -O3 -Wall -I$(J2KINCDIR)
|
|
||||||
LIBNAME = libopenjpip_local.a
|
|
||||||
endif
|
|
||||||
|
|
||||||
all: $(LIBNAME)
|
|
||||||
|
|
||||||
ifdef jpipserver
|
|
||||||
$(LIBNAME): openjpip.o target_manager.o byte_manager.o box_manager.o boxheader_manager.o manfbox_manager.o \
|
|
||||||
mhixbox_manager.o marker_manager.o codestream_manager.o faixbox_manager.o index_manager.o \
|
|
||||||
msgqueue_manager.o metadata_manager.o placeholder_manager.o ihdrbox_manager.o imgreg_manager.o \
|
|
||||||
cachemodel_manager.o j2kheader_manager.o jp2k_encoder.o query_parser.o channel_manager.o \
|
|
||||||
session_manager.o jpip_parser.o sock_manager.o auxtrans_manager.o
|
|
||||||
ar r $@ $^
|
|
||||||
else
|
|
||||||
$(LIBNAME): openjpip.o target_manager.o byte_manager.o box_manager.o boxheader_manager.o manfbox_manager.o \
|
|
||||||
mhixbox_manager.o marker_manager.o codestream_manager.o faixbox_manager.o index_manager.o \
|
|
||||||
msgqueue_manager.o metadata_manager.o placeholder_manager.o ihdrbox_manager.o imgreg_manager.o \
|
|
||||||
cachemodel_manager.o j2kheader_manager.o jp2k_encoder.o query_parser.o channel_manager.o \
|
|
||||||
session_manager.o jpip_parser.o jp2k_decoder.o imgsock_manager.o jpipstream_manager.o cache_manager.o \
|
|
||||||
dec_clientmsg_handler.o sock_manager.o
|
|
||||||
ar r $@ $^
|
|
||||||
endif
|
|
||||||
clean:
|
|
||||||
rm -f $(LIBNAME) *.o *~
|
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif //SERVER
|
#endif /*SERVER*/
|
||||||
|
|
||||||
imgreg_param_t map_viewin2imgreg( const int fx, const int fy,
|
imgreg_param_t map_viewin2imgreg( const int fx, const int fy,
|
||||||
const int rx, const int ry,
|
const int rx, const int ry,
|
||||||
@@ -106,13 +106,13 @@ void find_level( int maxlev, int *lev, int *fx, int *fy, int *xmin, int *ymin, i
|
|||||||
int xwidth = *xmax - *xmin;
|
int xwidth = *xmax - *xmin;
|
||||||
int ywidth = *ymax - *ymin;
|
int ywidth = *ymax - *ymin;
|
||||||
|
|
||||||
/// Find smaller frame size for now (i.e. assume "round-down").
|
/* Find smaller frame size for now (i.e. assume "round-down"). */
|
||||||
if ((*fx < 1 && xwidth != 0) || (*fy < 1 && ywidth != 0)){
|
if ((*fx < 1 && xwidth != 0) || (*fy < 1 && ywidth != 0)){
|
||||||
fprintf( FCGI_stderr, "Frame size must be strictly positive");
|
fprintf( FCGI_stderr, "Frame size must be strictly positive");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
else if( *lev < maxlev-1 && ( *fx < xwidth || *fy < ywidth)) {
|
else if( *lev < maxlev-1 && ( *fx < xwidth || *fy < ywidth)) {
|
||||||
// Simulate the ceil function.
|
/* Simulate the ceil function. */
|
||||||
*xmin = ceil((double)*xmin/(double)2.0);
|
*xmin = ceil((double)*xmin/(double)2.0);
|
||||||
*ymin = ceil((double)*ymin/(double)2.0);
|
*ymin = ceil((double)*ymin/(double)2.0);
|
||||||
*xmax = ceil((double)*xmax/(double)2.0);
|
*xmax = ceil((double)*xmax/(double)2.0);
|
||||||
@@ -149,5 +149,7 @@ void print_imgreg( imgreg_param_t imgreg)
|
|||||||
fprintf( logstream, "\t roff: %d, %d\n", imgreg.ox, imgreg.oy);
|
fprintf( logstream, "\t roff: %d, %d\n", imgreg.ox, imgreg.oy);
|
||||||
fprintf( logstream, "\t rsiz: %d, %d\n", imgreg.sx, imgreg.sy);
|
fprintf( logstream, "\t rsiz: %d, %d\n", imgreg.sx, imgreg.sy);
|
||||||
fprintf( logstream, "\t level: %d\n", imgreg.level);
|
fprintf( logstream, "\t level: %d\n", imgreg.level);
|
||||||
|
#else
|
||||||
|
(void)imgreg;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,14 +31,14 @@
|
|||||||
#ifndef IMGREG_MANAGER_H_
|
#ifndef IMGREG_MANAGER_H_
|
||||||
# define IMGREG_MANAGER_H_
|
# define IMGREG_MANAGER_H_
|
||||||
|
|
||||||
//! image region parameters
|
/** image region parameters */
|
||||||
typedef struct imgreg_param{
|
typedef struct imgreg_param{
|
||||||
int xosiz, yosiz; //!< offset from the origin of the reference grid
|
int xosiz, yosiz; /** offset from the origin of the reference grid
|
||||||
//!at the decomposition level
|
at the decomposition level */
|
||||||
int fx, fy; //!< frame size (fsiz)
|
int fx, fy; /** frame size (fsiz) */
|
||||||
int ox, oy; //!< offset (roff)
|
int ox, oy; /** offset (roff) */
|
||||||
int sx, sy; //!< region size (rsiz)
|
int sx, sy; /** region size (rsiz) */
|
||||||
int level; //!< decomposition level
|
int level; /** decomposition level */
|
||||||
} imgreg_param_t;
|
} imgreg_param_t;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif //SERVER
|
#endif /*SERVER */
|
||||||
|
|
||||||
|
|
||||||
SIZmarker_param_t get_SIZmkrdata_from_j2kstream( Byte_t *SIZstream);
|
SIZmarker_param_t get_SIZmkrdata_from_j2kstream( Byte_t *SIZstream);
|
||||||
@@ -76,7 +76,7 @@ bool get_mainheader_from_j2kstream( Byte_t *j2kstream, SIZmarker_param_t *SIZ, C
|
|||||||
|
|
||||||
SIZmarker_param_t get_SIZmkrdata_from_j2kstream( Byte_t *SIZstream)
|
SIZmarker_param_t get_SIZmkrdata_from_j2kstream( Byte_t *SIZstream)
|
||||||
{
|
{
|
||||||
SIZmarker_param_t SIZ ={0};
|
SIZmarker_param_t SIZ = {0};
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if( *SIZstream++ != 0xff || *SIZstream++ != 0x51){
|
if( *SIZstream++ != 0xff || *SIZstream++ != 0x51){
|
||||||
@@ -115,6 +115,13 @@ CODmarker_param_t get_CODmkrdata_from_j2kstream( Byte_t *CODstream)
|
|||||||
|
|
||||||
if( *CODstream++ != 0xff || *CODstream++ != 0x52){
|
if( *CODstream++ != 0xff || *CODstream++ != 0x52){
|
||||||
fprintf( FCGI_stderr, "Error, COD marker not found in the reconstructed j2kstream\n");
|
fprintf( FCGI_stderr, "Error, COD marker not found in the reconstructed j2kstream\n");
|
||||||
|
COD.Lcod = 0;
|
||||||
|
COD.Scod = 0;
|
||||||
|
COD.prog_order = 0;
|
||||||
|
COD.numOflayers = 0;
|
||||||
|
COD.numOfdecomp = 0;
|
||||||
|
COD.XPsiz = 0;
|
||||||
|
COD.YPsiz = 0;
|
||||||
return COD;
|
return COD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +136,7 @@ CODmarker_param_t get_CODmkrdata_from_j2kstream( Byte_t *CODstream)
|
|||||||
COD.YPsiz = (Byte4_t *)malloc( (COD.numOfdecomp+1)*sizeof(Byte4_t));
|
COD.YPsiz = (Byte4_t *)malloc( (COD.numOfdecomp+1)*sizeof(Byte4_t));
|
||||||
|
|
||||||
for( i=0; i<=COD.numOfdecomp; i++){
|
for( i=0; i<=COD.numOfdecomp; i++){
|
||||||
//precinct size
|
/*precinct size */
|
||||||
COD.XPsiz[i] = pow( 2, *( CODstream+12+i) & 0x0F);
|
COD.XPsiz[i] = pow( 2, *( CODstream+12+i) & 0x0F);
|
||||||
COD.YPsiz[i] = pow( 2, (*( CODstream+12+i) & 0xF0) >> 4);
|
COD.YPsiz[i] = pow( 2, (*( CODstream+12+i) & 0xF0) >> 4);
|
||||||
}
|
}
|
||||||
@@ -188,7 +195,7 @@ bool modify_SIZmkrstream( SIZmarker_param_t SIZ, int difOfdecomplev, Byte_t *SIZ
|
|||||||
SIZ.YTOsiz = ceil( (double)SIZ.YTOsiz/2.0);
|
SIZ.YTOsiz = ceil( (double)SIZ.YTOsiz/2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SIZstream += 4; // skip Lsiz + Rsiz
|
SIZstream += 4; /* skip Lsiz + Rsiz */
|
||||||
|
|
||||||
modify_4Bytecode( SIZ.Xsiz, SIZstream);
|
modify_4Bytecode( SIZ.Xsiz, SIZstream);
|
||||||
modify_4Bytecode( SIZ.Ysiz, SIZstream+4);
|
modify_4Bytecode( SIZ.Ysiz, SIZstream+4);
|
||||||
@@ -222,9 +229,9 @@ Byte2_t modify_CODmkrstream( CODmarker_param_t COD, int numOfdecomp, Byte_t *COD
|
|||||||
CODstream += 2;
|
CODstream += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
CODstream += 5; // skip Scod & SGcod
|
CODstream += 5; /* skip Scod & SGcod */
|
||||||
|
|
||||||
// SPcod
|
/* SPcod */
|
||||||
*CODstream++ = (Byte_t) numOfdecomp;
|
*CODstream++ = (Byte_t) numOfdecomp;
|
||||||
|
|
||||||
return newLcod;
|
return newLcod;
|
||||||
@@ -234,7 +241,7 @@ bool modify_COCmkrstream( int numOfdecomp, Byte_t *COCstream, Byte2_t Csiz, Byte
|
|||||||
|
|
||||||
bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, Byte2_t Csiz, Byte8_t *j2klen)
|
bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, Byte2_t Csiz, Byte8_t *j2klen)
|
||||||
{
|
{
|
||||||
Byte4_t Psot; // tile part length ref A.4.2 Start of tile-part SOT
|
Byte4_t Psot; /* tile part length ref A.4.2 Start of tile-part SOT */
|
||||||
Byte_t *thstream, *SOTstream, *Psot_stream;
|
Byte_t *thstream, *SOTstream, *Psot_stream;
|
||||||
Byte2_t oldLcoc, newLcoc;
|
Byte2_t oldLcoc, newLcoc;
|
||||||
|
|
||||||
@@ -245,14 +252,14 @@ bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, B
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOTstream += 4; // skip Lsot & Isot
|
SOTstream += 4; /* skip Lsot & Isot */
|
||||||
Psot = (SOTstream[0]<<24)+(SOTstream[1]<<16)+(SOTstream[2]<<8)+(SOTstream[3]);
|
Psot = (SOTstream[0]<<24)+(SOTstream[1]<<16)+(SOTstream[2]<<8)+(SOTstream[3]);
|
||||||
Psot_stream = SOTstream;
|
Psot_stream = SOTstream;
|
||||||
|
|
||||||
thstream += 12; // move to next marker (SOT always 12bytes)
|
thstream += 12; /* move to next marker (SOT always 12bytes) */
|
||||||
|
|
||||||
while( !( *thstream == 0xff && *(thstream+1) == 0x93)){ // search SOD
|
while( !( *thstream == 0xff && *(thstream+1) == 0x93)){ /* search SOD */
|
||||||
if( numOfdecomp != -1 && *thstream == 0xff && *(thstream+1) == 0x53){ // COC
|
if( numOfdecomp != -1 && *thstream == 0xff && *(thstream+1) == 0x53){ /* COC */
|
||||||
if( !modify_COCmkrstream( numOfdecomp, thstream, Csiz, &oldLcoc, &newLcoc))
|
if( !modify_COCmkrstream( numOfdecomp, thstream, Csiz, &oldLcoc, &newLcoc))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -260,7 +267,7 @@ bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, B
|
|||||||
*j2klen -= ( oldLcoc - newLcoc);
|
*j2klen -= ( oldLcoc - newLcoc);
|
||||||
}
|
}
|
||||||
thstream += 2;
|
thstream += 2;
|
||||||
thstream += ((thstream[0]<<8)+(thstream[1])); // marker length
|
thstream += ((thstream[0]<<8)+(thstream[1])); /* marker length */
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (*j2klen)-SOToffset != Psot){
|
if( (*j2klen)-SOToffset != Psot){
|
||||||
@@ -282,7 +289,7 @@ bool modify_COCmkrstream( int numOfdecomp, Byte_t *COCstream, Byte2_t Csiz, Byte
|
|||||||
*COCstream++ = (Byte_t)((Byte2_t)((*newLcoc) & 0xff00) >> 8);
|
*COCstream++ = (Byte_t)((Byte2_t)((*newLcoc) & 0xff00) >> 8);
|
||||||
*COCstream++ = (Byte_t)((*newLcoc) & 0x00ff);
|
*COCstream++ = (Byte_t)((*newLcoc) & 0x00ff);
|
||||||
|
|
||||||
if( Csiz < 257) COCstream +=2; // skip Ccoc & Scoc
|
if( Csiz < 257) COCstream +=2; /* skip Ccoc & Scoc */
|
||||||
else COCstream += 3;
|
else COCstream += 3;
|
||||||
|
|
||||||
*COCstream = numOfdecomp;
|
*COCstream = numOfdecomp;
|
||||||
|
|||||||
@@ -125,7 +125,8 @@ void warning_callback(const char *msg, void *client_data) {
|
|||||||
*/
|
*/
|
||||||
void info_callback(const char *msg, void *client_data) {
|
void info_callback(const char *msg, void *client_data) {
|
||||||
(void)client_data;
|
(void)client_data;
|
||||||
// fprintf(stdout, "[INFO] %s", msg);
|
(void)msg;
|
||||||
|
/* fprintf(stdout, "[INFO] %s", msg); */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -190,7 +191,7 @@ Byte_t * imagetopnm(opj_image_t *image, ihdrbox_param_t **ihdrbox)
|
|||||||
r = image->comps[0].data[i];
|
r = image->comps[0].data[i];
|
||||||
r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
||||||
|
|
||||||
// if( adjustR > 0)
|
/* if( adjustR > 0) */
|
||||||
*(ptr++) = (Byte_t) ((r >> adjustR)+((r >> (adjustR-1))%2));
|
*(ptr++) = (Byte_t) ((r >> adjustR)+((r >> (adjustR-1))%2));
|
||||||
|
|
||||||
if( image->numcomps == 3){
|
if( image->numcomps == 3){
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif //SERVER
|
#endif /*SERVER*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,11 +105,11 @@ Byte_t * recons_jp2( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn
|
|||||||
if( ptr->phld){
|
if( ptr->phld){
|
||||||
if( strncmp( (char *)ptr->phld->OrigBH+4, "jp2c", 4) == 0){
|
if( strncmp( (char *)ptr->phld->OrigBH+4, "jp2c", 4) == 0){
|
||||||
jp2cDBoxOffset = *jp2len + ptr->phld->OrigBHlen;
|
jp2cDBoxOffset = *jp2len + ptr->phld->OrigBHlen;
|
||||||
jp2stream = add_emptyboxstream( ptr->phld, jp2stream, jp2len); // header only
|
jp2stream = add_emptyboxstream( ptr->phld, jp2stream, jp2len); /* header only */
|
||||||
jp2cDBoxlen = *jp2len - jp2cDBoxOffset;
|
jp2cDBoxlen = *jp2len - jp2cDBoxOffset;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
jp2stream = add_emptyboxstream( ptr->phld, jp2stream, jp2len); // header only
|
jp2stream = add_emptyboxstream( ptr->phld, jp2stream, jp2len); /* header only */
|
||||||
}
|
}
|
||||||
jp2stream = add_msgstream( ptr, jpipstream, jp2stream, jp2len);
|
jp2stream = add_msgstream( ptr, jpipstream, jp2stream, jp2len);
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
@@ -203,7 +203,7 @@ Byte_t * recons_codestream_from_JPTstream( msgqueue_param_t *msgqueue, Byte_t *j
|
|||||||
}
|
}
|
||||||
ptr = msgqueue->first;
|
ptr = msgqueue->first;
|
||||||
while(( ptr = search_message( EXT_TILE_MSG, tileID, csn, ptr))!=NULL){
|
while(( ptr = search_message( EXT_TILE_MSG, tileID, csn, ptr))!=NULL){
|
||||||
if( ptr->aux > mindeclev){
|
if( ptr->aux > mindeclev){ /* FIXME: pointer comparison ? */
|
||||||
if( ptr->bin_offset == binOffset){
|
if( ptr->bin_offset == binOffset){
|
||||||
found = true;
|
found = true;
|
||||||
j2kstream = add_msgstream( ptr, jpipstream, j2kstream, j2klen);
|
j2kstream = add_msgstream( ptr, jpipstream, j2kstream, j2klen);
|
||||||
@@ -625,7 +625,7 @@ Byte8_t get_last_tileID( msgqueue_param_t *msgqueue, Byte8_t csn, bool isJPPstre
|
|||||||
message_param_t * search_message( Byte8_t class_id, Byte8_t in_class_id, Byte8_t csn, message_param_t *msg)
|
message_param_t * search_message( Byte8_t class_id, Byte8_t in_class_id, Byte8_t csn, message_param_t *msg)
|
||||||
{
|
{
|
||||||
while( msg != NULL){
|
while( msg != NULL){
|
||||||
if( in_class_id == -1){
|
if( in_class_id == (Byte8_t)-1){
|
||||||
if( msg->class_id == class_id && msg->csn == csn)
|
if( msg->class_id == class_id && msg->csn == csn)
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif //SERVER
|
#endif /*SERVER*/
|
||||||
|
|
||||||
|
|
||||||
bool identify_target( query_param_t query_param, targetlist_param_t *targetlist, target_param_t **target)
|
bool identify_target( query_param_t query_param, targetlist_param_t *targetlist, target_param_t **target)
|
||||||
@@ -132,35 +132,35 @@ bool close_channel( query_param_t query_param,
|
|||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
fprintf( logstream, "local log: close all\n");
|
fprintf( logstream, "local log: close all\n");
|
||||||
#endif
|
#endif
|
||||||
// all channels associatd with the session will be closed
|
/* all channels associatd with the session will be closed */
|
||||||
if( !delete_session( cursession, sessionlist))
|
if( !delete_session( cursession, sessionlist))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// check if all entry belonging to the same session
|
/* check if all entry belonging to the same session */
|
||||||
|
|
||||||
for( i=0, cclose=query_param.cclose; i<query_param.numOfcclose; i++, cclose += (strlen(cclose)+1)){
|
for( i=0, cclose=query_param.cclose; i<query_param.numOfcclose; i++, cclose += (strlen(cclose)+1)){
|
||||||
|
|
||||||
// In case of the first entry of close cid
|
/* In case of the first entry of close cid */
|
||||||
if( *cursession == NULL){
|
if( *cursession == NULL){
|
||||||
if( !search_session_and_channel( cclose, sessionlist, cursession, curchannel))
|
if( !search_session_and_channel( cclose, sessionlist, cursession, curchannel))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else // second or more entry of close cid
|
else /* second or more entry of close cid */
|
||||||
if( !(*curchannel=search_channel( cclose, (*cursession)->channellist))){
|
if( !(*curchannel=search_channel( cclose, (*cursession)->channellist))){
|
||||||
fprintf( FCGI_stdout, "Reason: Cclose id %s is from another session\r\n", cclose);
|
fprintf( FCGI_stdout, "Reason: Cclose id %s is from another session\r\n", cclose);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete channels
|
/* delete channels */
|
||||||
for( i=0, cclose=query_param.cclose; i<query_param.numOfcclose; i++, cclose += (strlen(cclose)+1)){
|
for( i=0, cclose=query_param.cclose; i<query_param.numOfcclose; i++, cclose += (strlen(cclose)+1)){
|
||||||
*curchannel = search_channel( cclose, (*cursession)->channellist);
|
*curchannel = search_channel( cclose, (*cursession)->channellist);
|
||||||
delete_channel( curchannel, (*cursession)->channellist);
|
delete_channel( curchannel, (*cursession)->channellist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (*cursession)->channellist->first == NULL || (*cursession)->channellist->last == NULL)
|
if( (*cursession)->channellist->first == NULL || (*cursession)->channellist->last == NULL)
|
||||||
// In case of empty session
|
/* In case of empty session */
|
||||||
delete_session( cursession, sessionlist);
|
delete_session( cursession, sessionlist);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -181,8 +181,9 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue);
|
|||||||
* @param[in] query_param structured query
|
* @param[in] query_param structured query
|
||||||
* @param[in] metadatalist pointer to metadata bin list
|
* @param[in] metadatalist pointer to metadata bin list
|
||||||
* @param[in,out] msgqueue message queue pointer
|
* @param[in,out] msgqueue message queue pointer
|
||||||
|
* @return if succeeded (true) or failed (false)
|
||||||
*/
|
*/
|
||||||
void enqueue_metabins( query_param_t query_param, metadatalist_param_t *metadatalist, msgqueue_param_t *msgqueue);
|
bool enqueue_metabins( query_param_t query_param, metadatalist_param_t *metadatalist, msgqueue_param_t *msgqueue);
|
||||||
|
|
||||||
|
|
||||||
bool gene_JPIPstream( query_param_t query_param,
|
bool gene_JPIPstream( query_param_t query_param,
|
||||||
@@ -194,14 +195,14 @@ bool gene_JPIPstream( query_param_t query_param,
|
|||||||
index_param_t *codeidx;
|
index_param_t *codeidx;
|
||||||
cachemodel_param_t *cachemodel;
|
cachemodel_param_t *cachemodel;
|
||||||
|
|
||||||
if( !cursession || !curchannel){ // stateless
|
if( !cursession || !curchannel){ /* stateless */
|
||||||
if( !target)
|
if( !target)
|
||||||
return false;
|
return false;
|
||||||
if( !(cachemodel = gene_cachemodel( NULL, target, query_param.return_type==JPPstream)))
|
if( !(cachemodel = gene_cachemodel( NULL, target, query_param.return_type==JPPstream)))
|
||||||
return false;
|
return false;
|
||||||
*msgqueue = gene_msgqueue( true, cachemodel);
|
*msgqueue = gene_msgqueue( true, cachemodel);
|
||||||
}
|
}
|
||||||
else{ // session
|
else{ /* session */
|
||||||
cachemodel = curchannel->cachemodel;
|
cachemodel = curchannel->cachemodel;
|
||||||
target = cachemodel->target;
|
target = cachemodel->target;
|
||||||
*msgqueue = gene_msgqueue( false, cachemodel);
|
*msgqueue = gene_msgqueue( false, cachemodel);
|
||||||
@@ -221,16 +222,22 @@ bool gene_JPIPstream( query_param_t query_param,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//meta
|
/*meta*/
|
||||||
if( query_param.box_type[0][0] != 0 && query_param.len != 0)
|
if( query_param.box_type[0][0] != 0 && query_param.len != 0)
|
||||||
enqueue_metabins( query_param, codeidx->metadatalist, *msgqueue);
|
if( !enqueue_metabins( query_param, codeidx->metadatalist, *msgqueue))
|
||||||
|
return false;
|
||||||
|
|
||||||
// image codestream
|
if( query_param.metadata_only)
|
||||||
if( query_param.fx > 0 && query_param.fy > 0){
|
return true;
|
||||||
if( !cachemodel->mhead_model && query_param.len != 0)
|
|
||||||
|
/* main header */
|
||||||
|
if( !cachemodel->mhead_model && query_param.len != 0)
|
||||||
enqueue_mainheader( *msgqueue);
|
enqueue_mainheader( *msgqueue);
|
||||||
|
|
||||||
|
/* image codestream */
|
||||||
|
if( (query_param.fx > 0 && query_param.fy > 0))
|
||||||
enqueue_imagedata( query_param, *msgqueue);
|
enqueue_imagedata( query_param, *msgqueue);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,13 +277,13 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue)
|
|||||||
index_param_t *codeidx;
|
index_param_t *codeidx;
|
||||||
imgreg_param_t imgreg;
|
imgreg_param_t imgreg;
|
||||||
range_param_t tile_Xrange, tile_Yrange;
|
range_param_t tile_Xrange, tile_Yrange;
|
||||||
int u, v, tile_id;
|
Byte4_t u, v, tile_id;
|
||||||
int xmin, xmax, ymin, ymax;
|
int xmin, xmax, ymin, ymax;
|
||||||
int numOfreslev;
|
int numOfreslev;
|
||||||
|
|
||||||
codeidx = msgqueue->cachemodel->target->codeidx;
|
codeidx = msgqueue->cachemodel->target->codeidx;
|
||||||
|
|
||||||
if( !(msgqueue->cachemodel->jppstream) && get_nmax( codeidx->tilepart) == 1) // normally not the case
|
if( !(msgqueue->cachemodel->jppstream) && get_nmax( codeidx->tilepart) == 1) /* normally not the case */
|
||||||
numOfreslev = 1;
|
numOfreslev = 1;
|
||||||
else
|
else
|
||||||
numOfreslev = codeidx->COD.numOfdecomp+1;
|
numOfreslev = codeidx->COD.numOfdecomp+1;
|
||||||
@@ -296,20 +303,20 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue)
|
|||||||
tile_Xrange = get_tile_Xrange( codeidx->SIZ, tile_id, imgreg.level);
|
tile_Xrange = get_tile_Xrange( codeidx->SIZ, tile_id, imgreg.level);
|
||||||
|
|
||||||
if( tile_Xrange.minvalue < tile_Xrange.maxvalue && tile_Yrange.minvalue < tile_Yrange.maxvalue){
|
if( tile_Xrange.minvalue < tile_Xrange.maxvalue && tile_Yrange.minvalue < tile_Yrange.maxvalue){
|
||||||
if( tile_Xrange.maxvalue <= imgreg.xosiz + imgreg.ox ||
|
if( tile_Xrange.maxvalue <= (Byte4_t)(imgreg.xosiz + imgreg.ox) ||
|
||||||
tile_Xrange.minvalue >= imgreg.xosiz + imgreg.ox + imgreg.sx ||
|
tile_Xrange.minvalue >= (Byte4_t)(imgreg.xosiz + imgreg.ox + imgreg.sx) ||
|
||||||
tile_Yrange.maxvalue <= imgreg.yosiz + imgreg.oy ||
|
tile_Yrange.maxvalue <= (Byte4_t)(imgreg.yosiz + imgreg.oy) ||
|
||||||
tile_Yrange.minvalue >= imgreg.yosiz + imgreg.oy + imgreg.sy) {
|
tile_Yrange.minvalue >= (Byte4_t)(imgreg.yosiz + imgreg.oy + imgreg.sy)) {
|
||||||
//printf("Tile completely excluded from view-window %d\n", tile_id);
|
/*printf("Tile completely excluded from view-window %d\n", tile_id);*/
|
||||||
// Tile completely excluded from view-window
|
/* Tile completely excluded from view-window */
|
||||||
}
|
}
|
||||||
else if( tile_Xrange.minvalue >= imgreg.xosiz + imgreg.ox &&
|
else if( tile_Xrange.minvalue >= (Byte4_t)(imgreg.xosiz + imgreg.ox) &&
|
||||||
tile_Xrange.maxvalue <= imgreg.xosiz + imgreg.ox + imgreg.sx &&
|
tile_Xrange.maxvalue <= (Byte4_t)(imgreg.xosiz + imgreg.ox + imgreg.sx) &&
|
||||||
tile_Yrange.minvalue >= imgreg.yosiz + imgreg.oy &&
|
tile_Yrange.minvalue >= (Byte4_t)(imgreg.yosiz + imgreg.oy) &&
|
||||||
tile_Yrange.maxvalue <= imgreg.yosiz + imgreg.oy + imgreg.sy) {
|
tile_Yrange.maxvalue <= (Byte4_t)(imgreg.yosiz + imgreg.oy + imgreg.sy)) {
|
||||||
// Tile completely contained within view-window
|
/* Tile completely contained within view-window */
|
||||||
// high priority
|
/* high priority */
|
||||||
//printf("Tile completely contained within view-window %d\n", tile_id);
|
/*printf("Tile completely contained within view-window %d\n", tile_id);*/
|
||||||
if( msgqueue->cachemodel->jppstream){
|
if( msgqueue->cachemodel->jppstream){
|
||||||
enqueue_tileheader( tile_id, msgqueue);
|
enqueue_tileheader( tile_id, msgqueue);
|
||||||
enqueue_allprecincts( tile_id, imgreg.level, query_param.lastcomp, query_param.comps, query_param.layers, msgqueue);
|
enqueue_allprecincts( tile_id, imgreg.level, query_param.lastcomp, query_param.comps, query_param.layers, msgqueue);
|
||||||
@@ -318,16 +325,17 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue)
|
|||||||
enqueue_tile( tile_id, imgreg.level, msgqueue);
|
enqueue_tile( tile_id, imgreg.level, msgqueue);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// Tile partially overlaps view-window
|
/* Tile partially overlaps view-window */
|
||||||
// low priority
|
/* low priority */
|
||||||
//printf("Tile partially overlaps view-window %d\n", tile_id);
|
/*printf("Tile partially overlaps view-window %d\n", tile_id);*/
|
||||||
if( msgqueue->cachemodel->jppstream){
|
if( msgqueue->cachemodel->jppstream){
|
||||||
enqueue_tileheader( tile_id, msgqueue);
|
enqueue_tileheader( tile_id, msgqueue);
|
||||||
|
|
||||||
xmin = tile_Xrange.minvalue >= imgreg.xosiz + imgreg.ox ? 0 : imgreg.xosiz + imgreg.ox - tile_Xrange.minvalue;
|
/* FIXME: The following code is suspicious it implicitely cast an unsigned int to int, which truncates values */
|
||||||
xmax = tile_Xrange.maxvalue <= imgreg.xosiz + imgreg.ox + imgreg.sx ? tile_Xrange.maxvalue - tile_Xrange.minvalue -1 : imgreg.xosiz + imgreg.ox + imgreg.sx - tile_Xrange.minvalue -1;
|
xmin = tile_Xrange.minvalue >= (Byte4_t)(imgreg.xosiz + imgreg.ox) ? 0 : imgreg.xosiz + imgreg.ox - tile_Xrange.minvalue;
|
||||||
ymin = tile_Yrange.minvalue >= imgreg.yosiz + imgreg.oy ? 0 : imgreg.yosiz + imgreg.oy - tile_Yrange.minvalue;
|
xmax = tile_Xrange.maxvalue <= (Byte4_t)(imgreg.xosiz + imgreg.ox + imgreg.sx) ? tile_Xrange.maxvalue - tile_Xrange.minvalue -1 : imgreg.xosiz + imgreg.ox + imgreg.sx - tile_Xrange.minvalue -1;
|
||||||
ymax = tile_Yrange.maxvalue <= imgreg.yosiz + imgreg.oy + imgreg.sy ? tile_Yrange.maxvalue - tile_Yrange.minvalue -1 : imgreg.yosiz + imgreg.oy + imgreg.sy - tile_Yrange.minvalue -1;
|
ymin = tile_Yrange.minvalue >= (Byte4_t)(imgreg.yosiz + imgreg.oy) ? 0 : imgreg.yosiz + imgreg.oy - tile_Yrange.minvalue;
|
||||||
|
ymax = tile_Yrange.maxvalue <= (Byte4_t)(imgreg.yosiz + imgreg.oy + imgreg.sy) ? tile_Yrange.maxvalue - tile_Yrange.minvalue -1 : imgreg.yosiz + imgreg.oy + imgreg.sy - tile_Yrange.minvalue -1;
|
||||||
enqueue_precincts( xmin, xmax, ymin, ymax, tile_id, imgreg.level, query_param.lastcomp, query_param.comps, query_param.layers, msgqueue);
|
enqueue_precincts( xmin, xmax, ymin, ymax, tile_id, imgreg.level, query_param.lastcomp, query_param.comps, query_param.layers, msgqueue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -339,6 +347,7 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* MM: shouldnt xmin/xmax be Byte4_t instead ? */
|
||||||
void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int level, int lastcomp, bool *comps, int layers, msgqueue_param_t *msgqueue)
|
void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int level, int lastcomp, bool *comps, int layers, msgqueue_param_t *msgqueue)
|
||||||
{
|
{
|
||||||
index_param_t *codeidx;
|
index_param_t *codeidx;
|
||||||
@@ -374,16 +383,16 @@ void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int
|
|||||||
xmaxP = XTsiz-1;
|
xmaxP = XTsiz-1;
|
||||||
|
|
||||||
if( xmaxP < xmin || xminP > xmax || ymaxP < ymin || yminP > ymax){
|
if( xmaxP < xmin || xminP > xmax || ymaxP < ymin || yminP > ymax){
|
||||||
// Precinct completely excluded from view-window
|
/* Precinct completely excluded from view-window */
|
||||||
}
|
}
|
||||||
else if( xminP >= xmin && xmaxP <= xmax && yminP >= ymin && ymaxP <= ymax){
|
else if( xminP >= xmin && xmaxP <= xmax && yminP >= ymin && ymaxP <= ymax){
|
||||||
// Precinct completely contained within view-window
|
/* Precinct completely contained within view-window
|
||||||
// high priority
|
high priority */
|
||||||
enqueue_precinct( seq_id, tile_id, c, (dec_lev>level)?-1:layers, msgqueue);
|
enqueue_precinct( seq_id, tile_id, c, (dec_lev>level)?-1:layers, msgqueue);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// Precinct partially overlaps view-window
|
/* Precinct partially overlaps view-window
|
||||||
// low priority
|
low priority */
|
||||||
enqueue_precinct( seq_id, tile_id, c, (dec_lev>level)?-1:layers, msgqueue);
|
enqueue_precinct( seq_id, tile_id, c, (dec_lev>level)?-1:layers, msgqueue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -419,18 +428,26 @@ void enqueue_allprecincts( int tile_id, int level, int lastcomp, bool *comps, in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enqueue_metabins( query_param_t query_param, metadatalist_param_t *metadatalist, msgqueue_param_t *msgqueue)
|
bool enqueue_metabins( query_param_t query_param, metadatalist_param_t *metadatalist, msgqueue_param_t *msgqueue)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for( i=0; query_param.box_type[i][0]!=0 && i<MAX_NUMOFBOX; i++){
|
for( i=0; query_param.box_type[i][0]!=0 && i<MAX_NUMOFBOX; i++){
|
||||||
if( query_param.box_type[i][0] == '*'){
|
if( query_param.box_type[i][0] == '*'){
|
||||||
// not implemented
|
fprintf( FCGI_stdout, "Status: 501\r\n");
|
||||||
|
fprintf( FCGI_stdout, "Reason: metareq with all box-property * not implemented\r\n");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
int idx = search_metadataidx( query_param.box_type[i], metadatalist);
|
int idx = search_metadataidx( query_param.box_type[i], metadatalist);
|
||||||
|
|
||||||
if( idx != -1)
|
if( idx != -1)
|
||||||
enqueue_metadata( idx, msgqueue);
|
enqueue_metadata( idx, msgqueue);
|
||||||
|
else{
|
||||||
|
fprintf( FCGI_stdout, "Status: 400\r\n");
|
||||||
|
fprintf( FCGI_stdout, "Reason: box-type %.4s not found\r\n", query_param.box_type[i]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ Byte_t * update_JPIPstream( Byte_t *newstream, int newstreamlen, Byte_t *cache_s
|
|||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_codestream( Byte_t *codestream, Byte8_t streamlen, char *fmt)
|
void save_codestream( Byte_t *codestream, Byte8_t streamlen, const char *fmt)
|
||||||
{
|
{
|
||||||
time_t timer;
|
time_t timer;
|
||||||
struct tm *t_st;
|
struct tm *t_st;
|
||||||
@@ -74,7 +74,7 @@ void save_codestream( Byte_t *codestream, Byte8_t streamlen, char *fmt)
|
|||||||
Byte_t * jpipstream_to_pnm( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte8_t csn, int fw, int fh, ihdrbox_param_t **ihdrbox)
|
Byte_t * jpipstream_to_pnm( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte8_t csn, int fw, int fh, ihdrbox_param_t **ihdrbox)
|
||||||
{
|
{
|
||||||
Byte_t *pnmstream;
|
Byte_t *pnmstream;
|
||||||
Byte_t *j2kstream; // j2k or jp2 codestream
|
Byte_t *j2kstream; /* j2k or jp2 codestream */
|
||||||
Byte8_t j2klen;
|
Byte8_t j2klen;
|
||||||
|
|
||||||
j2kstream = recons_j2k( msgqueue, jpipstream, csn, fw, fh, &j2klen);
|
j2kstream = recons_j2k( msgqueue, jpipstream, csn, fw, fh, &j2klen);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
Byte_t * update_JPIPstream( Byte_t *newstream, int newstreamlen, Byte_t *cache_stream, int *streamlen);
|
Byte_t * update_JPIPstream( Byte_t *newstream, int newstreamlen, Byte_t *cache_stream, int *streamlen);
|
||||||
|
|
||||||
void save_codestream( Byte_t *codestream, Byte8_t streamlen, char *fmt);
|
void save_codestream( Byte_t *codestream, Byte8_t streamlen, const char *fmt);
|
||||||
|
|
||||||
Byte_t * jpipstream_to_pnm( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte8_t csn, int fw, int fh, ihdrbox_param_t **ihdrbox);
|
Byte_t * jpipstream_to_pnm( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte8_t csn, int fw, int fh, ihdrbox_param_t **ihdrbox);
|
||||||
|
|
||||||
|
|||||||
@@ -40,14 +40,14 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif //SERVER
|
#endif /*SERVER */
|
||||||
|
|
||||||
manfbox_param_t * gene_manfbox( box_param_t *box)
|
manfbox_param_t * gene_manfbox( box_param_t *box)
|
||||||
{
|
{
|
||||||
manfbox_param_t *manf; // manifest parameters
|
manfbox_param_t *manf; /* manifest parameters */
|
||||||
boxheader_param_t *bh; // current box pointer
|
boxheader_param_t *bh; /* current box pointer */
|
||||||
boxheader_param_t *last; // last boxheader pointer of the list
|
boxheader_param_t *last; /* last boxheader pointer of the list */
|
||||||
int pos; // current position in manf_box contents;
|
Byte8_t pos; /* current position in manf_box contents; */
|
||||||
|
|
||||||
manf = ( manfbox_param_t *)malloc( sizeof( manfbox_param_t));
|
manf = ( manfbox_param_t *)malloc( sizeof( manfbox_param_t));
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ manfbox_param_t * gene_manfbox( box_param_t *box)
|
|||||||
bh = gene_childboxheader( box, pos);
|
bh = gene_childboxheader( box, pos);
|
||||||
pos += bh->headlen;
|
pos += bh->headlen;
|
||||||
|
|
||||||
// insert into the list
|
/* insert into the list */
|
||||||
if( manf->first)
|
if( manf->first)
|
||||||
last->next = bh;
|
last->next = bh;
|
||||||
else
|
else
|
||||||
@@ -77,7 +77,7 @@ void delete_manfbox( manfbox_param_t **manf)
|
|||||||
while( bhPtr != NULL){
|
while( bhPtr != NULL){
|
||||||
bhNext = bhPtr->next;
|
bhNext = bhPtr->next;
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
// fprintf( logstream, "local log: boxheader %.4s deleted!\n", bhPtr->type);
|
/* fprintf( logstream, "local log: boxheader %.4s deleted!\n", bhPtr->type); */
|
||||||
#endif
|
#endif
|
||||||
free(bhPtr);
|
free(bhPtr);
|
||||||
bhPtr = bhNext;
|
bhPtr = bhNext;
|
||||||
@@ -96,7 +96,7 @@ void print_manfbox( manfbox_param_t *manf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boxheader_param_t * search_boxheader( char type[], manfbox_param_t *manf)
|
boxheader_param_t * search_boxheader( const char type[], manfbox_param_t *manf)
|
||||||
{
|
{
|
||||||
boxheader_param_t *found;
|
boxheader_param_t *found;
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ void print_manfbox( manfbox_param_t *manf);
|
|||||||
* @param[in] manf manf box pointer
|
* @param[in] manf manf box pointer
|
||||||
* @return found box pointer
|
* @return found box pointer
|
||||||
*/
|
*/
|
||||||
boxheader_param_t * search_boxheader( char type[], manfbox_param_t *manf);
|
boxheader_param_t * search_boxheader( const char type[], manfbox_param_t *manf);
|
||||||
|
|
||||||
|
|
||||||
#endif /* !MANFBOX_MANAGER_H_ */
|
#endif /* !MANFBOX_MANAGER_H_ */
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif //SERVER
|
#endif /*SERVER */
|
||||||
|
|
||||||
marker_param_t set_marker( codestream_param_t cs, Byte2_t code, Byte8_t offset, Byte2_t length)
|
marker_param_t set_marker( codestream_param_t cs, Byte2_t code, Byte8_t offset, Byte2_t length)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
#endif /*SERVER*/
|
#endif /*SERVER*/
|
||||||
|
|
||||||
|
|
||||||
metadatalist_param_t * gene_metadatalist()
|
metadatalist_param_t * gene_metadatalist(void)
|
||||||
{
|
{
|
||||||
metadatalist_param_t *list;
|
metadatalist_param_t *list;
|
||||||
|
|
||||||
@@ -77,10 +77,6 @@ metadatalist_param_t * const_metadatalist( int fd)
|
|||||||
phldlist = gene_placeholderlist();
|
phldlist = gene_placeholderlist();
|
||||||
metadatalist = gene_metadatalist();
|
metadatalist = gene_metadatalist();
|
||||||
|
|
||||||
delete_box_in_list_by_type( "iptr", toplev_boxlist);
|
|
||||||
delete_box_in_list_by_type( "cidx", toplev_boxlist);
|
|
||||||
delete_box_in_list_by_type( "fidx", toplev_boxlist);
|
|
||||||
|
|
||||||
box = toplev_boxlist->first;
|
box = toplev_boxlist->first;
|
||||||
idx = 0;
|
idx = 0;
|
||||||
while( box){
|
while( box){
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ typedef struct metadatalist_param{
|
|||||||
*
|
*
|
||||||
* @return pointer to the generated metadata list
|
* @return pointer to the generated metadata list
|
||||||
*/
|
*/
|
||||||
metadatalist_param_t * gene_metadatalist();
|
metadatalist_param_t * gene_metadatalist(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -40,14 +40,14 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif //SERVER
|
#endif /*SERVER */
|
||||||
|
|
||||||
|
|
||||||
mhixbox_param_t * gene_mhixbox( box_param_t *box)
|
mhixbox_param_t * gene_mhixbox( box_param_t *box)
|
||||||
{
|
{
|
||||||
mhixbox_param_t *mhix;
|
mhixbox_param_t *mhix;
|
||||||
markeridx_param_t *mkridx, *lastmkidx;
|
markeridx_param_t *mkridx, *lastmkidx;
|
||||||
long pos = 0;
|
Byte8_t pos = 0;
|
||||||
|
|
||||||
mhix = ( mhixbox_param_t *)malloc( sizeof( mhixbox_param_t));
|
mhix = ( mhixbox_param_t *)malloc( sizeof( mhixbox_param_t));
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ void delete_mhixbox( mhixbox_param_t **mhix)
|
|||||||
while( mkPtr != NULL){
|
while( mkPtr != NULL){
|
||||||
mkNext=mkPtr->next;
|
mkNext=mkPtr->next;
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
// fprintf( logstream, "local log: marker index %#x deleted!\n", mkPtr->code);
|
/* fprintf( logstream, "local log: marker index %#x deleted!\n", mkPtr->code); */
|
||||||
#endif
|
#endif
|
||||||
free(mkPtr);
|
free(mkPtr);
|
||||||
mkPtr=mkNext;
|
mkPtr=mkNext;
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ bool process_JPIPrequest( server_record_t *rec, QR_t *qr)
|
|||||||
if( !close_channel( *(qr->query), rec->sessionlist, &cursession, &curchannel))
|
if( !close_channel( *(qr->query), rec->sessionlist, &cursession, &curchannel))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( (qr->query->fx > 0 && qr->query->fy > 0) || qr->query->box_type[0][0] != 0)
|
if( (qr->query->fx > 0 && qr->query->fy > 0) || qr->query->box_type[0][0] != 0 || qr->query->len > 0)
|
||||||
if( !gene_JPIPstream( *(qr->query), target, cursession, curchannel, &qr->msgqueue))
|
if( !gene_JPIPstream( *(qr->query), target, cursession, curchannel, &qr->msgqueue))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -150,16 +150,20 @@ void send_responsedata( server_record_t *rec, QR_t *qr)
|
|||||||
|
|
||||||
fprintf( FCGI_stdout, "\r\n");
|
fprintf( FCGI_stdout, "\r\n");
|
||||||
|
|
||||||
if( qr->channel)
|
if( len_of_jpipstream){
|
||||||
if( qr->channel->aux == tcp || qr->channel->aux == udp){
|
|
||||||
send_responsedata_on_aux( qr->channel->aux==tcp, rec->auxtrans, qr->channel->cid, jpipstream, len_of_jpipstream, 1000); /* 1KB per frame*/
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( fwrite( jpipstream, len_of_jpipstream, 1, FCGI_stdout) != 1)
|
if( qr->channel)
|
||||||
fprintf( FCGI_stderr, "Error: failed to write jpipstream\n");
|
if( qr->channel->aux == tcp || qr->channel->aux == udp){
|
||||||
|
send_responsedata_on_aux( qr->channel->aux==tcp, rec->auxtrans, qr->channel->cid, jpipstream, len_of_jpipstream, 1000); /* 1KB per frame*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( fwrite( jpipstream, len_of_jpipstream, 1, FCGI_stdout) != 1)
|
||||||
|
fprintf( FCGI_stderr, "Error: failed to write jpipstream\n");
|
||||||
|
}
|
||||||
|
|
||||||
free( jpipstream);
|
free( jpipstream);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +183,7 @@ void add_EORmsg( int fd, QR_t *qr)
|
|||||||
void end_QRprocess( server_record_t *rec, QR_t **qr)
|
void end_QRprocess( server_record_t *rec, QR_t **qr)
|
||||||
{
|
{
|
||||||
/* TODO: record client preferences if necessary*/
|
/* TODO: record client preferences if necessary*/
|
||||||
|
(void)rec; /* unused */
|
||||||
delete_query( &((*qr)->query));
|
delete_query( &((*qr)->query));
|
||||||
delete_msgqueue( &((*qr)->msgqueue));
|
delete_msgqueue( &((*qr)->msgqueue));
|
||||||
free( *qr);
|
free( *qr);
|
||||||
|
|||||||
@@ -41,11 +41,11 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif //SERVER
|
#endif /*SERVER*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
placeholderlist_param_t * gene_placeholderlist()
|
placeholderlist_param_t * gene_placeholderlist(void)
|
||||||
{
|
{
|
||||||
placeholderlist_param_t *list;
|
placeholderlist_param_t *list;
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ placeholder_param_t * gene_placeholder( box_param_t *box, int origID)
|
|||||||
placeholder = (placeholder_param_t *)malloc( sizeof(placeholder_param_t));
|
placeholder = (placeholder_param_t *)malloc( sizeof(placeholder_param_t));
|
||||||
|
|
||||||
strncpy( placeholder->TBox, "phld", 4);
|
strncpy( placeholder->TBox, "phld", 4);
|
||||||
placeholder->Flags = 1; // only the access to the original contents of this box, for now
|
placeholder->Flags = 1; /* only the access to the original contents of this box, for now */
|
||||||
placeholder->OrigID = origID;
|
placeholder->OrigID = origID;
|
||||||
placeholder->OrigBH = fetch_headbytes( box);
|
placeholder->OrigBH = fetch_headbytes( box);
|
||||||
placeholder->OrigBHlen = box->headlen;
|
placeholder->OrigBHlen = box->headlen;
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ typedef struct placeholderlist_param{
|
|||||||
*
|
*
|
||||||
* @return pointer to the generated placeholder list
|
* @return pointer to the generated placeholder list
|
||||||
*/
|
*/
|
||||||
placeholderlist_param_t * gene_placeholderlist();
|
placeholderlist_param_t * gene_placeholderlist(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
*
|
*
|
||||||
* @return initial query parameters
|
* @return initial query parameters
|
||||||
*/
|
*/
|
||||||
query_param_t * get_initquery();
|
query_param_t * get_initquery(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get a pair of field name and value from the string starting fieldname=fieldval&... format
|
* get a pair of field name and value from the string starting fieldname=fieldval&... format
|
||||||
@@ -141,14 +141,17 @@ query_param_t * parse_query( char *query_string)
|
|||||||
query_param->return_type = JPTstream;
|
query_param->return_type = JPTstream;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( strcasecmp( fieldname, "len") == 0)
|
else if( strcasecmp( fieldname, "len") == 0){
|
||||||
sscanf( fieldval, "%d", &query_param->len);
|
sscanf( fieldval, "%d", &query_param->len);
|
||||||
|
if( query_param->len == 2000) /* for kakadu client*/
|
||||||
|
strncpy( query_param->box_type[0], "ftyp", 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return query_param;
|
return query_param;
|
||||||
}
|
}
|
||||||
|
|
||||||
query_param_t * get_initquery()
|
query_param_t * get_initquery(void)
|
||||||
{
|
{
|
||||||
query_param_t *query;
|
query_param_t *query;
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -41,10 +41,10 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif //SERVER
|
#endif /*SERVER */
|
||||||
|
|
||||||
|
|
||||||
sessionlist_param_t * gene_sessionlist()
|
sessionlist_param_t * gene_sessionlist(void)
|
||||||
{
|
{
|
||||||
sessionlist_param_t *sessionlist;
|
sessionlist_param_t *sessionlist;
|
||||||
|
|
||||||
@@ -67,9 +67,9 @@ session_param_t * gene_session( sessionlist_param_t *sessionlist)
|
|||||||
|
|
||||||
session->next = NULL;
|
session->next = NULL;
|
||||||
|
|
||||||
if( sessionlist->first) // there are one or more entries
|
if( sessionlist->first) /* there are one or more entries */
|
||||||
sessionlist->last->next = session;
|
sessionlist->last->next = session;
|
||||||
else // first entry
|
else /* first entry */
|
||||||
sessionlist->first = session;
|
sessionlist->first = session;
|
||||||
sessionlist->last = session;
|
sessionlist->last = session;
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ typedef struct sessionlist_param{
|
|||||||
*
|
*
|
||||||
* @return pointer to the generated session list
|
* @return pointer to the generated session list
|
||||||
*/
|
*/
|
||||||
sessionlist_param_t * gene_sessionlist();
|
sessionlist_param_t * gene_sessionlist(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -34,6 +34,10 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#endif
|
||||||
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -48,7 +52,7 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif //SERVER
|
#endif /*SERVER*/
|
||||||
|
|
||||||
SOCKET open_listeningsocket( int port)
|
SOCKET open_listeningsocket( int port)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif /*SERVER*/
|
#endif /*SERVER*/
|
||||||
|
|
||||||
targetlist_param_t * gene_targetlist()
|
targetlist_param_t * gene_targetlist(void)
|
||||||
{
|
{
|
||||||
targetlist_param_t *targetlist;
|
targetlist_param_t *targetlist;
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ typedef struct targetlist_param{
|
|||||||
*
|
*
|
||||||
* @return pointer to the generated target list
|
* @return pointer to the generated target list
|
||||||
*/
|
*/
|
||||||
targetlist_param_t * gene_targetlist();
|
targetlist_param_t * gene_targetlist(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,6 +4,14 @@ INCLUDE_DIRECTORIES(
|
|||||||
${FCGI_INCLUDE_DIRS}
|
${FCGI_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Tool to embed metadata into JP2 file
|
||||||
|
ADD_EXECUTABLE(addXMLinJP2 addXMLinJP2.c)
|
||||||
|
# Install exe
|
||||||
|
INSTALL(TARGETS addXMLinJP2
|
||||||
|
EXPORT OpenJPEGTargets
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||||
|
)
|
||||||
|
|
||||||
IF(BUILD_JPIP_SERVER)
|
IF(BUILD_JPIP_SERVER)
|
||||||
|
|
||||||
SET(OPJ_SERVER_SRCS
|
SET(OPJ_SERVER_SRCS
|
||||||
@@ -47,81 +55,95 @@ FOREACH(exe ${EXES})
|
|||||||
ENDFOREACH(exe)
|
ENDFOREACH(exe)
|
||||||
|
|
||||||
# Build the two java clients:
|
# Build the two java clients:
|
||||||
FIND_PACKAGE(Java 1.5 REQUIRED) # javac, jar
|
FIND_PACKAGE(Java 1.5 COMPONENTS Development) # javac, jar
|
||||||
|
|
||||||
# 1. opj_viewer
|
# Only build the java viewer if dev is found:
|
||||||
# build dep list:
|
if(Java_Development_FOUND AND Java_JAVAC_EXECUTABLE)
|
||||||
file(GLOB java1_srcs "opj_viewer/src/*.java")
|
set(jflags $ENV{JFLAGS})
|
||||||
|
# 1. opj_viewer
|
||||||
# make sure target javac dir exists:
|
|
||||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes1)
|
|
||||||
# Build java
|
|
||||||
ADD_CUSTOM_COMMAND(
|
|
||||||
OUTPUT ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
|
||||||
COMMAND ${Java_JAVAC_EXECUTABLE}
|
|
||||||
${java1_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes1
|
|
||||||
COMMAND ${Java_JAR_EXECUTABLE} cfm ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/dist/manifest.txt -C
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/classes1 .
|
|
||||||
DEPENDS ${java1_srcs}
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/dist/manifest.txt
|
|
||||||
COMMENT "javac *.java; jar cvf -> opj_viewer.jar"
|
|
||||||
)
|
|
||||||
|
|
||||||
# name the target
|
|
||||||
ADD_CUSTOM_TARGET(OPJViewerJar ALL
|
|
||||||
DEPENDS ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
|
||||||
COMMENT "building opj_viewer.jar"
|
|
||||||
)
|
|
||||||
|
|
||||||
# 2. opj_viewer_xerces
|
|
||||||
# search for package org.apache.xerces.parsers
|
|
||||||
find_file(APACHE_XERCES_JAR
|
|
||||||
NAMES xerces-j2.jar xercesImpl.jar
|
|
||||||
PATHS /usr/share/java/
|
|
||||||
NO_DEFAULT_PATH
|
|
||||||
)
|
|
||||||
mark_as_advanced(APACHE_XERCES_JAR)
|
|
||||||
|
|
||||||
if(EXISTS ${APACHE_XERCES_JAR})
|
|
||||||
configure_file(
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer_xerces/dist/manifest.txt.in
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/opj_viewer_xerces/dist/manifest.txt
|
|
||||||
@ONLY
|
|
||||||
)
|
|
||||||
# build dep list:
|
# build dep list:
|
||||||
file(GLOB java2_srcs "opj_viewer_xerces/src/*.java")
|
file(GLOB java1_srcs "opj_viewer/src/*.java")
|
||||||
|
|
||||||
# Need some common files:
|
|
||||||
list(APPEND java2_srcs
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ImageManager.java
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ImgdecClient.java
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/JPIPHttpClient.java
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/MML.java
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/PnmImage.java
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/RegimViewer.java
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ResizeListener.java
|
|
||||||
)
|
|
||||||
|
|
||||||
# make sure target javac dir exists:
|
# make sure target javac dir exists:
|
||||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes2)
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes1)
|
||||||
# Build java
|
# Build java
|
||||||
ADD_CUSTOM_COMMAND(
|
ADD_CUSTOM_COMMAND(
|
||||||
OUTPUT ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
OUTPUT ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
||||||
COMMAND ${Java_JAVAC_EXECUTABLE}
|
COMMAND ${Java_JAVAC_EXECUTABLE} ${jflags}
|
||||||
-classpath ${APACHE_XERCES_JAR}
|
${java1_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes1
|
||||||
${java2_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes2
|
COMMAND ${Java_JAR_EXECUTABLE} cfm ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
||||||
COMMAND ${Java_JAR_EXECUTABLE} cfm ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/dist/manifest.txt -C
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/opj_viewer_xerces/dist/manifest.txt
|
${CMAKE_CURRENT_BINARY_DIR}/classes1 .
|
||||||
-C ${CMAKE_CURRENT_BINARY_DIR}/classes2 .
|
DEPENDS ${java1_srcs}
|
||||||
DEPENDS ${java2_srcs}
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/dist/manifest.txt
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer_xerces/dist/manifest.txt.in
|
COMMENT "javac *.java; jar cvf -> opj_viewer.jar"
|
||||||
COMMENT "javac *.java; jar cvf -> opj_viewer_xerces.jar"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# name the target
|
# name the target
|
||||||
ADD_CUSTOM_TARGET(OPJViewerXercesJar ALL
|
ADD_CUSTOM_TARGET(OPJViewerJar ALL
|
||||||
DEPENDS ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
DEPENDS ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
||||||
COMMENT "building opj_viewer_xerces.jar"
|
COMMENT "building opj_viewer.jar"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_SHARE_DIR} COMPONENT JavaModule
|
||||||
|
)
|
||||||
|
|
||||||
|
# 2. opj_viewer_xerces
|
||||||
|
# search for package org.apache.xerces.parsers
|
||||||
|
find_file(APACHE_XERCES_JAR
|
||||||
|
NAMES xerces-j2.jar xercesImpl.jar
|
||||||
|
PATHS /usr/share/java/
|
||||||
|
NO_DEFAULT_PATH
|
||||||
|
)
|
||||||
|
mark_as_advanced(APACHE_XERCES_JAR)
|
||||||
|
|
||||||
|
if(EXISTS ${APACHE_XERCES_JAR})
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer_xerces/dist/manifest.txt.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/opj_viewer_xerces/dist/manifest.txt
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
# build dep list:
|
||||||
|
file(GLOB java2_srcs "opj_viewer_xerces/src/*.java")
|
||||||
|
|
||||||
|
# Need some common files:
|
||||||
|
list(APPEND java2_srcs
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ImageManager.java
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ImgdecClient.java
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/JPIPHttpClient.java
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/MML.java
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/PnmImage.java
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/RegimViewer.java
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ResizeListener.java
|
||||||
|
)
|
||||||
|
|
||||||
|
# make sure target javac dir exists:
|
||||||
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes2)
|
||||||
|
# Build java
|
||||||
|
ADD_CUSTOM_COMMAND(
|
||||||
|
OUTPUT ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
||||||
|
COMMAND ${Java_JAVAC_EXECUTABLE} ${jflags}
|
||||||
|
-classpath ${APACHE_XERCES_JAR}
|
||||||
|
${java2_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes2
|
||||||
|
COMMAND ${Java_JAR_EXECUTABLE} cfm ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/opj_viewer_xerces/dist/manifest.txt
|
||||||
|
-C ${CMAKE_CURRENT_BINARY_DIR}/classes2 .
|
||||||
|
DEPENDS ${java2_srcs}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer_xerces/dist/manifest.txt.in
|
||||||
|
COMMENT "javac *.java; jar cvf -> opj_viewer_xerces.jar"
|
||||||
|
)
|
||||||
|
|
||||||
|
# name the target
|
||||||
|
ADD_CUSTOM_TARGET(OPJViewerXercesJar ALL
|
||||||
|
DEPENDS ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
||||||
|
COMMENT "building opj_viewer_xerces.jar"
|
||||||
|
)
|
||||||
|
|
||||||
|
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_SHARE_DIR} COMPONENT JavaModule
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
else(Java_Development_FOUND)
|
||||||
|
message(WARNING "No java compiler found. Wont be able to build java viewer")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -73,15 +73,15 @@ char * read_xmlfile( char filename[], long *fsize);
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
FILE *fp;
|
||||||
|
char *xmldata, type[]="xml ";
|
||||||
|
long fsize, boxsize;
|
||||||
|
|
||||||
if( argc<3){
|
if( argc<3){
|
||||||
fprintf( stderr, "USAGE: ./addXMLinJP2 modifing.jp2 adding.xml\n");
|
fprintf( stderr, "USAGE: ./addXMLinJP2 modifing.jp2 adding.xml\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *fp;
|
|
||||||
char *xmldata, type[]="xml ";
|
|
||||||
long fsize, boxsize;
|
|
||||||
|
|
||||||
fp = open_jp2file( argv[1]);
|
fp = open_jp2file( argv[1]);
|
||||||
if( !fp)
|
if( !fp)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
|
|||||||
fputc( (boxsize>>8)&0xff, fp);
|
fputc( (boxsize>>8)&0xff, fp);
|
||||||
fputc( boxsize&0xff, fp);
|
fputc( boxsize&0xff, fp);
|
||||||
fwrite( type, 4, 1, fp);
|
fwrite( type, 4, 1, fp);
|
||||||
fwrite( xmldata, fsize, 1, fp);
|
fwrite( xmldata, (size_t)fsize, 1, fp);
|
||||||
|
|
||||||
free( xmldata);
|
free( xmldata);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
@@ -111,14 +111,14 @@ FILE * open_jp2file( char filename[])
|
|||||||
fprintf( stderr, "Original JP2 %s not found\n", filename);
|
fprintf( stderr, "Original JP2 %s not found\n", filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
// Check resource is a JP family file.
|
/* Check resource is a JP family file. */
|
||||||
if( fseek( fp, 0, SEEK_SET)==-1){
|
if( fseek( fp, 0, SEEK_SET)==-1){
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
fprintf( stderr, "Original JP2 %s broken (fseek error)\n", filename);
|
fprintf( stderr, "Original JP2 %s broken (fseek error)\n", filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = (char *)malloc( 12); // size of header
|
data = (char *)malloc( 12); /* size of header */
|
||||||
if( fread( data, 12, 1, fp) != 1){
|
if( fread( data, 12, 1, fp) != 1){
|
||||||
free( data);
|
free( data);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
@@ -142,7 +142,7 @@ char * read_xmlfile( char filename[], long *fsize)
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *data;
|
char *data;
|
||||||
|
|
||||||
// fprintf( stderr, "open %s\n", filename);
|
/* fprintf( stderr, "open %s\n", filename); */
|
||||||
if(!(fp = fopen( filename, "r"))){
|
if(!(fp = fopen( filename, "r"))){
|
||||||
fprintf( stderr, "XML file %s not found\n", filename);
|
fprintf( stderr, "XML file %s not found\n", filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -166,9 +166,9 @@ char * read_xmlfile( char filename[], long *fsize)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = (char *)malloc( *fsize);
|
data = (char *)malloc( (size_t)*fsize);
|
||||||
|
|
||||||
if( fread( data, *fsize, 1, fp) != 1){
|
if( fread( data, (size_t)*fsize, 1, fp) != 1){
|
||||||
fprintf( stderr, "XML file %s broken (read error)\n", filename);
|
fprintf( stderr, "XML file %s broken (read error)\n", filename);
|
||||||
free( data);
|
free( data);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ int main(int argc,char *argv[])
|
|||||||
if(!( fwrite_jp2k( argv[2], dec)))
|
if(!( fwrite_jp2k( argv[2], dec)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// output_log( true, false, false, dec);
|
/* output_log( true, false, false, dec); */
|
||||||
|
|
||||||
destroy_jpipdecoder( &dec);
|
destroy_jpipdecoder( &dec);
|
||||||
|
|
||||||
|
|||||||
@@ -33,11 +33,12 @@
|
|||||||
*
|
*
|
||||||
* \section impinst Implementing instructions
|
* \section impinst Implementing instructions
|
||||||
* Launch opj_dec_server from a terminal in the same machine as JPIP client image viewers. \n
|
* Launch opj_dec_server from a terminal in the same machine as JPIP client image viewers. \n
|
||||||
* % ./opj_dec_server \n
|
* % ./opj_dec_server [portnumber]\n
|
||||||
|
* ( portnumber=50000 by default)\n
|
||||||
* Keep it alive as long as image viewers are open.\n
|
* Keep it alive as long as image viewers are open.\n
|
||||||
*
|
*
|
||||||
* To quite the opj_dec_server, send a message "quit" through the telnet.\n
|
* To quite the opj_dec_server, send a message "quit" through the telnet.\n
|
||||||
* % telnet localhost 5000\n
|
* % telnet localhost 50000\n
|
||||||
* quit\n
|
* quit\n
|
||||||
* Be sure all image viewers are closed.\n
|
* Be sure all image viewers are closed.\n
|
||||||
* Cache file in JPT format is stored in the working directly before it quites.
|
* Cache file in JPT format is stored in the working directly before it quites.
|
||||||
@@ -45,6 +46,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "openjpip.h"
|
#include "openjpip.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -55,16 +57,22 @@ int main(int argc, char *argv[]){
|
|||||||
|
|
||||||
dec_server_record_t *server_record;
|
dec_server_record_t *server_record;
|
||||||
client_t client;
|
client_t client;
|
||||||
|
int port = 50000;
|
||||||
|
int erreur;
|
||||||
|
(void)erreur;
|
||||||
|
|
||||||
|
if( argc > 1)
|
||||||
|
port = atoi( argv[1]);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32);
|
erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32);
|
||||||
if( erreur!=0)
|
if( erreur!=0)
|
||||||
fprintf( stderr, "Erreur initialisation Winsock error : %d %d\n",erreur,WSAGetLastError());
|
fprintf( stderr, "Erreur initialisation Winsock error : %d %d\n",erreur,WSAGetLastError());
|
||||||
else
|
else
|
||||||
printf( "Initialisation Winsock\n");
|
printf( "Initialisation Winsock\n");
|
||||||
#endif //_WIN32
|
#endif /*_WIN32*/
|
||||||
|
|
||||||
server_record = init_dec_server( 50000);
|
server_record = init_dec_server( port);
|
||||||
|
|
||||||
while(( client = accept_connection( server_record)) != -1 )
|
while(( client = accept_connection( server_record)) != -1 )
|
||||||
if(!handle_clientreq( client, server_record))
|
if(!handle_clientreq( client, server_record))
|
||||||
|
|||||||
@@ -56,11 +56,14 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WSADATA initialisation_win32;
|
WSADATA initialisation_win32;
|
||||||
#endif //_WIN32
|
#endif /*_WIN32*/
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
server_record_t *server_record;
|
server_record_t *server_record;
|
||||||
|
#ifdef SERVER
|
||||||
|
char *query_string;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32);
|
int erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32);
|
||||||
@@ -68,13 +71,11 @@ int main(void)
|
|||||||
fprintf( stderr, "Erreur initialisation Winsock error : %d %d\n",erreur,WSAGetLastError());
|
fprintf( stderr, "Erreur initialisation Winsock error : %d %d\n",erreur,WSAGetLastError());
|
||||||
else
|
else
|
||||||
fprintf( stderr, "Initialisation Winsock\n");
|
fprintf( stderr, "Initialisation Winsock\n");
|
||||||
#endif //_WIN32
|
#endif /*_WIN32*/
|
||||||
|
|
||||||
server_record = init_JPIPserver( 60000, 0);
|
server_record = init_JPIPserver( 60000, 0);
|
||||||
|
|
||||||
#ifdef SERVER
|
#ifdef SERVER
|
||||||
|
|
||||||
char *query_string;
|
|
||||||
while(FCGI_Accept() >= 0)
|
while(FCGI_Accept() >= 0)
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -82,17 +83,16 @@ int main(void)
|
|||||||
while( fgets( query_string, 128, stdin) && query_string[0]!='\n')
|
while( fgets( query_string, 128, stdin) && query_string[0]!='\n')
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
QR_t *qr;
|
||||||
|
bool parse_status;
|
||||||
|
|
||||||
#ifdef SERVER
|
#ifdef SERVER
|
||||||
query_string = getenv("QUERY_STRING");
|
query_string = getenv("QUERY_STRING");
|
||||||
#endif //SERVER
|
#endif /*SERVER*/
|
||||||
|
|
||||||
if( strcmp( query_string, QUIT_SIGNAL) == 0)
|
if( strcmp( query_string, QUIT_SIGNAL) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
QR_t *qr;
|
|
||||||
bool parse_status;
|
|
||||||
|
|
||||||
qr = parse_querystring( query_string);
|
qr = parse_querystring( query_string);
|
||||||
|
|
||||||
parse_status = process_JPIPrequest( server_record, qr);
|
parse_status = process_JPIPrequest( server_record, qr);
|
||||||
@@ -103,8 +103,10 @@ int main(void)
|
|||||||
|
|
||||||
if( parse_status)
|
if( parse_status)
|
||||||
send_responsedata( server_record, qr);
|
send_responsedata( server_record, qr);
|
||||||
else
|
else{
|
||||||
fprintf( FCGI_stderr, "Error: JPIP request failed\n");
|
fprintf( FCGI_stderr, "Error: JPIP request failed\n");
|
||||||
|
fprintf( FCGI_stdout, "\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
end_QRprocess( server_record, &qr);
|
end_QRprocess( server_record, &qr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,10 +35,12 @@ public class ImageManager extends JPIPHttpClient
|
|||||||
private PnmImage pnmimage;
|
private PnmImage pnmimage;
|
||||||
private int origwidth;
|
private int origwidth;
|
||||||
private int origheight;
|
private int origheight;
|
||||||
|
private ImgdecClient imgdecoder;
|
||||||
|
|
||||||
public ImageManager( String uri)
|
public ImageManager( String uri, String host, int port)
|
||||||
{
|
{
|
||||||
super( uri);
|
super( uri);
|
||||||
|
imgdecoder = new ImgdecClient( host, port);
|
||||||
pnmimage = null;
|
pnmimage = null;
|
||||||
origwidth = 0;
|
origwidth = 0;
|
||||||
origheight = 0;
|
origheight = 0;
|
||||||
@@ -47,7 +49,7 @@ public class ImageManager extends JPIPHttpClient
|
|||||||
public int getOrigWidth(){
|
public int getOrigWidth(){
|
||||||
if( origwidth == 0){
|
if( origwidth == 0){
|
||||||
if( cid != null || tid != null){
|
if( cid != null || tid != null){
|
||||||
java.awt.Dimension dim = ImgdecClient.query_imagesize( cid, tid);
|
java.awt.Dimension dim = imgdecoder.query_imagesize( cid, tid);
|
||||||
if( dim != null){
|
if( dim != null){
|
||||||
origwidth = dim.width;
|
origwidth = dim.width;
|
||||||
origheight = dim.height;
|
origheight = dim.height;
|
||||||
@@ -69,10 +71,10 @@ public class ImageManager extends JPIPHttpClient
|
|||||||
|
|
||||||
// Todo: check if the cid is for the same stream type
|
// Todo: check if the cid is for the same stream type
|
||||||
if( reqcnew)
|
if( reqcnew)
|
||||||
refcid = ImgdecClient.query_cid( j2kfilename);
|
refcid = imgdecoder.query_cid( j2kfilename);
|
||||||
|
|
||||||
if( refcid == null){
|
if( refcid == null){
|
||||||
String reftid = ImgdecClient.query_tid( j2kfilename);
|
String reftid = imgdecoder.query_tid( j2kfilename);
|
||||||
if( reftid == null)
|
if( reftid == null)
|
||||||
jpipstream = super.requestViewWindow( j2kfilename, reqfw, reqfh, reqcnew, reqaux, reqJPP, reqJPT);
|
jpipstream = super.requestViewWindow( j2kfilename, reqfw, reqfh, reqcnew, reqaux, reqJPP, reqJPT);
|
||||||
else
|
else
|
||||||
@@ -82,7 +84,7 @@ public class ImageManager extends JPIPHttpClient
|
|||||||
jpipstream = super.requestViewWindow( reqfw, reqfh, refcid, reqcnew, reqaux, reqJPP, reqJPT);
|
jpipstream = super.requestViewWindow( reqfw, reqfh, refcid, reqcnew, reqaux, reqJPP, reqJPT);
|
||||||
|
|
||||||
System.err.println( "decoding to PNM image");
|
System.err.println( "decoding to PNM image");
|
||||||
if((pnmimage = ImgdecClient.decode_jpipstream( jpipstream, j2kfilename, tid, cid, fw, fh))!=null){
|
if((pnmimage = imgdecoder.decode_jpipstream( jpipstream, j2kfilename, tid, cid, fw, fh))!=null){
|
||||||
System.err.println( " done");
|
System.err.println( " done");
|
||||||
return pnmimage.createROIImage( rx, ry, rw, rh);
|
return pnmimage.createROIImage( rx, ry, rw, rh);
|
||||||
}
|
}
|
||||||
@@ -99,7 +101,7 @@ public class ImageManager extends JPIPHttpClient
|
|||||||
byte[] jpipstream = super.requestViewWindow( reqfw, reqfh, reqrx, reqry, reqrw, reqrh);
|
byte[] jpipstream = super.requestViewWindow( reqfw, reqfh, reqrx, reqry, reqrw, reqrh);
|
||||||
|
|
||||||
System.err.println( "decoding to PNM image");
|
System.err.println( "decoding to PNM image");
|
||||||
if((pnmimage = ImgdecClient.decode_jpipstream( jpipstream, tid, cid, fw, fh)) != null){
|
if((pnmimage = imgdecoder.decode_jpipstream( jpipstream, tid, cid, fw, fh)) != null){
|
||||||
System.err.println( " done");
|
System.err.println( " done");
|
||||||
return pnmimage.createROIImage( rx, ry, rw, rh);
|
return pnmimage.createROIImage( rx, ry, rw, rh);
|
||||||
}
|
}
|
||||||
@@ -117,9 +119,9 @@ public class ImageManager extends JPIPHttpClient
|
|||||||
byte[] jpipstream = super.requestXML();
|
byte[] jpipstream = super.requestXML();
|
||||||
|
|
||||||
if( jpipstream != null){
|
if( jpipstream != null){
|
||||||
ImgdecClient.send_JPIPstream( jpipstream);
|
imgdecoder.send_JPIPstream( jpipstream);
|
||||||
|
|
||||||
xmldata = ImgdecClient.get_XMLstream( cid);
|
xmldata = imgdecoder.get_XMLstream( cid);
|
||||||
}
|
}
|
||||||
return xmldata;
|
return xmldata;
|
||||||
}
|
}
|
||||||
@@ -127,7 +129,7 @@ public class ImageManager extends JPIPHttpClient
|
|||||||
public void closeChannel()
|
public void closeChannel()
|
||||||
{
|
{
|
||||||
if( cid != null){
|
if( cid != null){
|
||||||
ImgdecClient.destroy_cid( cid);
|
imgdecoder.destroy_cid( cid);
|
||||||
super.closeChannel();
|
super.closeChannel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ public class ImageWindow extends JFrame
|
|||||||
private ImageViewer imgviewer;
|
private ImageViewer imgviewer;
|
||||||
private ImageManager imgmanager;
|
private ImageManager imgmanager;
|
||||||
|
|
||||||
public ImageWindow( String uri, String j2kfilename, boolean session, boolean jppstream, int aux)
|
public ImageWindow( String uri, String j2kfilename, String host, int port, boolean session, boolean jppstream, int aux)
|
||||||
{
|
{
|
||||||
super( j2kfilename);
|
super( j2kfilename);
|
||||||
|
|
||||||
imgmanager = new ImageManager( uri);
|
imgmanager = new ImageManager( uri, host, port);
|
||||||
|
|
||||||
imgviewer = new ImageViewer( j2kfilename, imgmanager, session, jppstream, aux);
|
imgviewer = new ImageViewer( j2kfilename, imgmanager, session, jppstream, aux);
|
||||||
imgviewer.setOpaque(true); //content panes must be opaque
|
imgviewer.setOpaque(true); //content panes must be opaque
|
||||||
@@ -66,25 +66,36 @@ public class ImageWindow extends JFrame
|
|||||||
|
|
||||||
public static void main(String s[])
|
public static void main(String s[])
|
||||||
{
|
{
|
||||||
String j2kfilename, uri;
|
String j2kfilename, uri, host;
|
||||||
boolean session, jppstream;
|
boolean session, jppstream;
|
||||||
int aux; // 0: none, 1: tcp, 2: udp
|
int port, aux; // 0: none, 1: tcp, 2: udp
|
||||||
|
|
||||||
if(s.length >= 2){
|
if(s.length >= 2){
|
||||||
uri = s[0];
|
uri = s[0];
|
||||||
j2kfilename = s[1];
|
j2kfilename = s[1];
|
||||||
|
|
||||||
if( s.length > 2)
|
if( s.length > 2)
|
||||||
session = !s[2].equalsIgnoreCase( "stateless");
|
host = s[2];
|
||||||
|
else
|
||||||
|
host = "localhost";
|
||||||
|
|
||||||
|
if( s.length > 3)
|
||||||
|
port = Integer.valueOf( s[3]).intValue();
|
||||||
|
else
|
||||||
|
port = 50000;
|
||||||
|
|
||||||
|
if( s.length > 4)
|
||||||
|
session = !s[4].equalsIgnoreCase( "stateless");
|
||||||
else
|
else
|
||||||
session = true;
|
session = true;
|
||||||
|
|
||||||
if( s.length > 3)
|
if( s.length > 5)
|
||||||
jppstream = !s[3].equalsIgnoreCase( "JPT");
|
jppstream = !s[5].equalsIgnoreCase( "JPT");
|
||||||
else
|
else
|
||||||
jppstream = true;
|
jppstream = true;
|
||||||
|
|
||||||
if( s.length > 4){
|
if( s.length > 6){
|
||||||
if( s[4].equalsIgnoreCase("udp"))
|
if( s[6].equalsIgnoreCase("udp"))
|
||||||
aux = 2;
|
aux = 2;
|
||||||
else
|
else
|
||||||
aux = 1;
|
aux = 1;
|
||||||
@@ -93,10 +104,10 @@ public class ImageWindow extends JFrame
|
|||||||
aux = 0;
|
aux = 0;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
System.out.println("Usage: java -jar opj_viewer.jar HTTP_server_URI imagefile.jp2 [stateless/session] [JPT/JPP] [tcp/udp]");
|
System.out.println("Usage: java -jar opj_viewer.jar HTTP_server_URI imagefile.jp2 [hostname] [portnumber] [stateless/session] [JPT/JPP] [tcp/udp]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ImageWindow frame = new ImageWindow( uri, j2kfilename, session, jppstream, aux);
|
ImageWindow frame = new ImageWindow( uri, j2kfilename, host, port, session, jppstream, aux);
|
||||||
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
|||||||
@@ -33,23 +33,32 @@ import java.net.*;
|
|||||||
|
|
||||||
public class ImgdecClient{
|
public class ImgdecClient{
|
||||||
|
|
||||||
public static PnmImage decode_jpipstream( byte[] jpipstream, String tid, String cid, int fw, int fh)
|
private String hostname;
|
||||||
|
private int portNo;
|
||||||
|
|
||||||
|
public ImgdecClient( String host, int port)
|
||||||
|
{
|
||||||
|
hostname = host;
|
||||||
|
portNo = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PnmImage decode_jpipstream( byte[] jpipstream, String tid, String cid, int fw, int fh)
|
||||||
{
|
{
|
||||||
if( jpipstream != null)
|
if( jpipstream != null)
|
||||||
send_JPIPstream( jpipstream);
|
send_JPIPstream( jpipstream);
|
||||||
return get_PNMstream( cid, tid, fw, fh);
|
return get_PNMstream( cid, tid, fw, fh);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PnmImage decode_jpipstream( byte[] jpipstream, String j2kfilename, String tid, String cid, int fw, int fh)
|
public PnmImage decode_jpipstream( byte[] jpipstream, String j2kfilename, String tid, String cid, int fw, int fh)
|
||||||
{
|
{
|
||||||
send_JPIPstream( jpipstream, j2kfilename, tid, cid);
|
send_JPIPstream( jpipstream, j2kfilename, tid, cid);
|
||||||
return get_PNMstream( cid, tid, fw, fh);
|
return get_PNMstream( cid, tid, fw, fh);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void send_JPIPstream( byte[] jpipstream)
|
public void send_JPIPstream( byte[] jpipstream)
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
Socket imgdecSocket = new Socket( "localhost", 50000);
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
|
|
||||||
@@ -71,10 +80,10 @@ public class ImgdecClient{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void send_JPIPstream( byte[] jpipstream, String j2kfilename, String tid, String cid)
|
public void send_JPIPstream( byte[] jpipstream, String j2kfilename, String tid, String cid)
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
Socket imgdecSocket = new Socket( "localhost", 50000);
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
int length = 0;
|
int length = 0;
|
||||||
@@ -109,12 +118,12 @@ public class ImgdecClient{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PnmImage get_PNMstream( String cid, String tid, int fw, int fh)
|
public PnmImage get_PNMstream( String cid, String tid, int fw, int fh)
|
||||||
{
|
{
|
||||||
PnmImage pnmstream = null;
|
PnmImage pnmstream = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Socket imgdecSocket = new Socket( "localhost", 50000);
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
byte []header = new byte[7];
|
byte []header = new byte[7];
|
||||||
@@ -166,12 +175,12 @@ public class ImgdecClient{
|
|||||||
return pnmstream;
|
return pnmstream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte [] get_XMLstream( String cid)
|
public byte [] get_XMLstream( String cid)
|
||||||
{
|
{
|
||||||
byte []xmldata = null;
|
byte []xmldata = null;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
Socket imgdecSocket = new Socket( "localhost", 50000);
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
byte []header = new byte[5];
|
byte []header = new byte[5];
|
||||||
@@ -197,7 +206,7 @@ public class ImgdecClient{
|
|||||||
return xmldata;
|
return xmldata;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String query_cid( String j2kfilename)
|
public String query_cid( String j2kfilename)
|
||||||
{
|
{
|
||||||
int []retmsglabel = new int[3];
|
int []retmsglabel = new int[3];
|
||||||
retmsglabel[0] = 67;
|
retmsglabel[0] = 67;
|
||||||
@@ -207,7 +216,7 @@ public class ImgdecClient{
|
|||||||
return query_id( "CID request", j2kfilename, retmsglabel);
|
return query_id( "CID request", j2kfilename, retmsglabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String query_tid( String j2kfilename)
|
public String query_tid( String j2kfilename)
|
||||||
{
|
{
|
||||||
int []retmsglabel = new int[3];
|
int []retmsglabel = new int[3];
|
||||||
retmsglabel[0] = 84;
|
retmsglabel[0] = 84;
|
||||||
@@ -217,12 +226,12 @@ public class ImgdecClient{
|
|||||||
return query_id( "TID request", j2kfilename, retmsglabel);
|
return query_id( "TID request", j2kfilename, retmsglabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String query_id( String reqmsghead, String j2kfilename, int[] retmsglabel)
|
public String query_id( String reqmsghead, String j2kfilename, int[] retmsglabel)
|
||||||
{
|
{
|
||||||
String id = null;
|
String id = null;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
Socket imgdecSocket = new Socket( "localhost", 50000);
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
byte []header = new byte[4];
|
byte []header = new byte[4];
|
||||||
@@ -254,12 +263,12 @@ public class ImgdecClient{
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static java.awt.Dimension query_imagesize( String cid, String tid)
|
public java.awt.Dimension query_imagesize( String cid, String tid)
|
||||||
{
|
{
|
||||||
java.awt.Dimension dim = null;
|
java.awt.Dimension dim = null;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
Socket imgdecSocket = new Socket( "localhost", 50000);
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
byte []header = new byte[3];
|
byte []header = new byte[3];
|
||||||
@@ -297,7 +306,7 @@ public class ImgdecClient{
|
|||||||
return dim;
|
return dim;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void read_stream( DataInputStream is, byte []stream, int length)
|
private static void read_stream( DataInputStream is, byte []stream, int length)
|
||||||
{
|
{
|
||||||
int remlen = length;
|
int remlen = length;
|
||||||
int off = 0;
|
int off = 0;
|
||||||
@@ -318,10 +327,10 @@ public class ImgdecClient{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void destroy_cid( String cid)
|
public void destroy_cid( String cid)
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
Socket imgdecSocket = new Socket( "localhost", 50000);
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
|
|
||||||
|
|||||||
@@ -38,11 +38,11 @@ public class ImageWindow extends JFrame
|
|||||||
private OptionPanel optpanel;
|
private OptionPanel optpanel;
|
||||||
private ImageManager imgmanager;
|
private ImageManager imgmanager;
|
||||||
|
|
||||||
public ImageWindow( String uri, String j2kfilename, boolean session, boolean jppstream, int aux)
|
public ImageWindow( String uri, String j2kfilename, String host, int port, boolean session, boolean jppstream, int aux)
|
||||||
{
|
{
|
||||||
super( j2kfilename);
|
super( j2kfilename);
|
||||||
|
|
||||||
imgmanager = new ImageManager( uri);
|
imgmanager = new ImageManager( uri, host, port);
|
||||||
|
|
||||||
imgviewer = new ImageViewer( j2kfilename, imgmanager, session, jppstream, aux);
|
imgviewer = new ImageViewer( j2kfilename, imgmanager, session, jppstream, aux);
|
||||||
imgviewer.setOpaque(true); //content panes must be opaque
|
imgviewer.setOpaque(true); //content panes must be opaque
|
||||||
@@ -70,25 +70,36 @@ public class ImageWindow extends JFrame
|
|||||||
|
|
||||||
public static void main(String s[])
|
public static void main(String s[])
|
||||||
{
|
{
|
||||||
String j2kfilename, uri;
|
String j2kfilename, uri, host;
|
||||||
boolean session, jppstream;
|
boolean session, jppstream;
|
||||||
int aux; // 0: none, 1: tcp, 2: udp
|
int port, aux; // 0: none, 1: tcp, 2: udp
|
||||||
|
|
||||||
if(s.length >= 2){
|
if(s.length >= 2){
|
||||||
uri = s[0];
|
uri = s[0];
|
||||||
j2kfilename = s[1];
|
j2kfilename = s[1];
|
||||||
|
|
||||||
if( s.length > 2)
|
if( s.length > 2)
|
||||||
session = !s[2].equalsIgnoreCase( "stateless");
|
host = s[2];
|
||||||
|
else
|
||||||
|
host = "localhost";
|
||||||
|
|
||||||
|
if( s.length > 3)
|
||||||
|
port = Integer.valueOf( s[3]).intValue();
|
||||||
|
else
|
||||||
|
port = 50000;
|
||||||
|
|
||||||
|
if( s.length > 4)
|
||||||
|
session = !s[4].equalsIgnoreCase( "stateless");
|
||||||
else
|
else
|
||||||
session = true;
|
session = true;
|
||||||
|
|
||||||
if( s.length > 3)
|
if( s.length > 5)
|
||||||
jppstream = !s[3].equalsIgnoreCase( "JPT");
|
jppstream = !s[5].equalsIgnoreCase( "JPT");
|
||||||
else
|
else
|
||||||
jppstream = true;
|
jppstream = true;
|
||||||
|
|
||||||
if( s.length > 4){
|
if( s.length > 6){
|
||||||
if( s[4].equalsIgnoreCase("udp"))
|
if( s[6].equalsIgnoreCase("udp"))
|
||||||
aux = 2;
|
aux = 2;
|
||||||
else
|
else
|
||||||
aux = 1;
|
aux = 1;
|
||||||
@@ -97,10 +108,10 @@ public class ImageWindow extends JFrame
|
|||||||
aux = 0;
|
aux = 0;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
System.out.println("Usage: java -jar opj_viewer.jar HTTP_server_URI imagefile.jp2 [stateless/session] [JPT/JPP] [tcp/udp]");
|
System.out.println("Usage: java -jar opj_viewer.jar HTTP_server_URI imagefile.jp2 [hostname] [portnumber] [stateless/session] [JPT/JPP] [tcp/udp]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ImageWindow frame = new ImageWindow( uri, j2kfilename, session, jppstream, aux);
|
ImageWindow frame = new ImageWindow( uri, j2kfilename, host, port, session, jppstream, aux);
|
||||||
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "openjpeg.h"
|
#include "openjpeg.h"
|
||||||
|
#include "cio.h"
|
||||||
#include "j2k.h"
|
#include "j2k.h"
|
||||||
#include "jp2.h"
|
#include "jp2.h"
|
||||||
#include "mj2.h"
|
#include "mj2.h"
|
||||||
@@ -60,34 +61,52 @@ void info_callback(const char *msg, void *client_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
#define JP2_RFC3745_MAGIC "\x00\x00\x00\x0c\x6a\x50\x20\x20\x0d\x0a\x87\x0a"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
opj_dinfo_t* dinfo;
|
opj_dinfo_t* dinfo;
|
||||||
opj_event_mgr_t event_mgr; /* event manager */
|
opj_event_mgr_t event_mgr; /* event manager */
|
||||||
int tnum;
|
int tnum, failed;
|
||||||
unsigned int snum;
|
unsigned int snum;
|
||||||
opj_mj2_t *movie;
|
opj_mj2_t *movie;
|
||||||
mj2_tk_t *track;
|
mj2_tk_t *track;
|
||||||
mj2_sample_t *sample;
|
mj2_sample_t *sample;
|
||||||
unsigned char* frame_codestream;
|
unsigned char* frame_codestream;
|
||||||
FILE *file, *outfile;
|
FILE *mj2file, *outfile;
|
||||||
char outfilename[50];
|
char *outfilename;
|
||||||
mj2_dparameters_t parameters;
|
mj2_dparameters_t parameters;
|
||||||
|
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
printf("Usage: %s mj2filename output_location\n",argv[0]);
|
printf("\nUsage: %s mj2filename output_location\n",argv[0]);
|
||||||
printf("Example: %s foreman.mj2 output/foreman\n",argv[0]);
|
printf("Example: %s foreman.mj2 output/foreman\n\n",argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
file = fopen(argv[1], "rb");
|
mj2file = fopen(argv[1], "rb");
|
||||||
|
|
||||||
if (!file) {
|
if (!mj2file) {
|
||||||
fprintf(stderr, "failed to open %s for reading\n", argv[1]);
|
fprintf(stderr, "failed to open %s for reading\n", argv[1]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
unsigned char buf[28];
|
||||||
|
|
||||||
|
memset(buf, 0, 28);
|
||||||
|
fread(buf, 1, 24, mj2file);
|
||||||
|
|
||||||
|
if(memcmp(buf, JP2_RFC3745_MAGIC, 12) == 0
|
||||||
|
&& memcmp(buf+20, "\x6d\x6a\x70\x32", 4) == 0)
|
||||||
|
{
|
||||||
|
rewind(mj2file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fclose(mj2file);
|
||||||
|
fprintf(stderr,"%s:%d: %s\n\tThis file is not an MJ2 file."
|
||||||
|
"Quitting\n",__FILE__,__LINE__, argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
configure the event callbacks (not required)
|
configure the event callbacks (not required)
|
||||||
setting of each callback is optionnal
|
setting of each callback is optionnal
|
||||||
@@ -97,9 +116,15 @@ int main(int argc, char *argv[]) {
|
|||||||
event_mgr.warning_handler = warning_callback;
|
event_mgr.warning_handler = warning_callback;
|
||||||
event_mgr.info_handler = info_callback;
|
event_mgr.info_handler = info_callback;
|
||||||
|
|
||||||
|
failed = 1;
|
||||||
|
outfilename = (char*)malloc(strlen(argv[2]) + 32);
|
||||||
|
if(outfilename == NULL) goto fin;
|
||||||
|
|
||||||
/* get a MJ2 decompressor handle */
|
/* get a MJ2 decompressor handle */
|
||||||
dinfo = mj2_create_decompress();
|
dinfo = mj2_create_decompress();
|
||||||
|
|
||||||
|
if(dinfo == NULL) goto fin;
|
||||||
|
|
||||||
/* catch events using our callbacks and give a local context */
|
/* catch events using our callbacks and give a local context */
|
||||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||||
|
|
||||||
@@ -108,42 +133,62 @@ int main(int argc, char *argv[]) {
|
|||||||
movie = (opj_mj2_t*) dinfo->mj2_handle;
|
movie = (opj_mj2_t*) dinfo->mj2_handle;
|
||||||
mj2_setup_decoder(movie, ¶meters);
|
mj2_setup_decoder(movie, ¶meters);
|
||||||
|
|
||||||
if (mj2_read_struct(file, movie)) // Creating the movie structure
|
/* Create the movie structure: */
|
||||||
return 1;
|
if (mj2_read_struct(mj2file, movie))
|
||||||
|
goto fin;
|
||||||
|
|
||||||
// Decode first video track
|
/* Decode first video track : */
|
||||||
tnum = 0;
|
tnum = 0;
|
||||||
while (movie->tk[tnum].track_type != 0)
|
while (movie->tk[tnum].track_type != 0)
|
||||||
tnum ++;
|
tnum ++;
|
||||||
|
|
||||||
track = &movie->tk[tnum];
|
track = &movie->tk[tnum];
|
||||||
|
|
||||||
|
if(track->jp2_struct.enumcs != ENUMCS_SRGB
|
||||||
|
&& track->jp2_struct.enumcs != ENUMCS_GRAY)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"%s:%d: %s\n"
|
||||||
|
"\tERROR: this MJ2 file does not contain J2K frames.\n"
|
||||||
|
"\tPlease try mj2_to_frames for this file.\n",
|
||||||
|
__FILE__,__LINE__, argv[0]);
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stdout,"Extracting %d frames from file...\n",track->num_samples);
|
fprintf(stdout,"Extracting %d frames from file...\n",track->num_samples);
|
||||||
|
|
||||||
for (snum=0; snum < track->num_samples; snum++)
|
for (snum=0; snum < track->num_samples; snum++)
|
||||||
{
|
{
|
||||||
sample = &track->sample[snum];
|
sample = &track->sample[snum];
|
||||||
frame_codestream = (unsigned char*) malloc (sample->sample_size-8); // Skipping JP2C marker
|
frame_codestream = (unsigned char*)
|
||||||
fseek(file,sample->offset+8,SEEK_SET);
|
malloc (sample->sample_size-8); /* Skipping JP2C marker */
|
||||||
fread(frame_codestream,sample->sample_size-8,1, file); // Assuming that jp and ftyp markers size do
|
fseek(mj2file,sample->offset+8,SEEK_SET);
|
||||||
|
/* Assuming that jp and ftyp markers size do: */
|
||||||
|
fread(frame_codestream,sample->sample_size-8,1, mj2file);
|
||||||
|
|
||||||
sprintf(outfilename,"%s_%05d.j2k",argv[2],snum);
|
sprintf(outfilename,"%s_%05d.j2k",argv[2],snum);
|
||||||
outfile = fopen(outfilename, "wb");
|
outfile = fopen(outfilename, "wb");
|
||||||
if (!outfile) {
|
if (!outfile) {
|
||||||
fprintf(stderr, "failed to open %s for writing\n",outfilename);
|
fprintf(stderr, "failed to open %s for writing\n",outfilename);
|
||||||
return 1;
|
goto fin;
|
||||||
}
|
}
|
||||||
fwrite(frame_codestream,sample->sample_size-8,1,outfile);
|
fwrite(frame_codestream,sample->sample_size-8,1,outfile);
|
||||||
fclose(outfile);
|
fclose(outfile);
|
||||||
free(frame_codestream);
|
free(frame_codestream);
|
||||||
}
|
}
|
||||||
fclose(file);
|
|
||||||
fprintf(stdout, "%d frames correctly extracted\n", snum);
|
fprintf(stdout, "%d frames correctly extracted\n", snum);
|
||||||
|
failed = 0;
|
||||||
|
|
||||||
|
fin:
|
||||||
|
fclose(mj2file);
|
||||||
|
|
||||||
|
free(outfilename);
|
||||||
|
|
||||||
/* free remaining structures */
|
/* free remaining structures */
|
||||||
if(dinfo) {
|
if(dinfo)
|
||||||
mj2_destroy_decompress((opj_mj2_t*)dinfo->mj2_handle);
|
{
|
||||||
}
|
mj2_destroy_decompress(movie);
|
||||||
|
free(dinfo);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return failed;
|
||||||
}
|
}/* main() */
|
||||||
|
|||||||
@@ -31,9 +31,9 @@
|
|||||||
|
|
||||||
#include "openjpeg.h"
|
#include "openjpeg.h"
|
||||||
#include "j2k_lib.h"
|
#include "j2k_lib.h"
|
||||||
|
#include "cio.h"
|
||||||
#include "j2k.h"
|
#include "j2k.h"
|
||||||
#include "jp2.h"
|
#include "jp2.h"
|
||||||
#include "cio.h"
|
|
||||||
#include "mj2.h"
|
#include "mj2.h"
|
||||||
#include "mj2_convert.h"
|
#include "mj2_convert.h"
|
||||||
#include "opj_getopt.h"
|
#include "opj_getopt.h"
|
||||||
@@ -43,10 +43,6 @@ Size of memory first allocated for MOOV box
|
|||||||
*/
|
*/
|
||||||
#define TEMP_BUF 10000
|
#define TEMP_BUF 10000
|
||||||
|
|
||||||
#define ENUMCS_GRAY 16
|
|
||||||
#define ENUMCS_SRGB 17
|
|
||||||
#define ENUMCS_SYCC 18
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -238,7 +234,7 @@ int main(int argc, char **argv)
|
|||||||
opj_cparameters_t *j2k_parameters; /* J2K compression parameters */
|
opj_cparameters_t *j2k_parameters; /* J2K compression parameters */
|
||||||
opj_event_mgr_t event_mgr; /* event manager */
|
opj_event_mgr_t event_mgr; /* event manager */
|
||||||
opj_cio_t *cio;
|
opj_cio_t *cio;
|
||||||
int value;
|
int value, failed;
|
||||||
opj_mj2_t *movie;
|
opj_mj2_t *movie;
|
||||||
opj_image_t *img;
|
opj_image_t *img;
|
||||||
int i, j;
|
int i, j;
|
||||||
@@ -257,13 +253,13 @@ int main(int argc, char **argv)
|
|||||||
memset(&mj2_parameters, 0, sizeof(mj2_cparameters_t));
|
memset(&mj2_parameters, 0, sizeof(mj2_cparameters_t));
|
||||||
/* default value */
|
/* default value */
|
||||||
/* ------------- */
|
/* ------------- */
|
||||||
mj2_parameters.w = 352; // CIF default value
|
mj2_parameters.w = 352; /* CIF default value */
|
||||||
mj2_parameters.h = 288; // CIF default value
|
mj2_parameters.h = 288; /* CIF default value */
|
||||||
mj2_parameters.CbCr_subsampling_dx = 2; // CIF default value
|
mj2_parameters.CbCr_subsampling_dx = 2; /* CIF default value */
|
||||||
mj2_parameters.CbCr_subsampling_dy = 2; // CIF default value
|
mj2_parameters.CbCr_subsampling_dy = 2; /* CIF default value */
|
||||||
mj2_parameters.frame_rate = 25;
|
mj2_parameters.frame_rate = 25;
|
||||||
mj2_parameters.prec = 8; /* DEFAULT */
|
mj2_parameters.prec = 8; /* DEFAULT */
|
||||||
mj2_parameters.enumcs = ENUMCS_SYCC; /* FIXME: ENUMCS_YUV420 */
|
mj2_parameters.enumcs = ENUMCS_SYCC;
|
||||||
mj2_parameters.meth = 1; /* enumerated color space */
|
mj2_parameters.meth = 1; /* enumerated color space */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -620,7 +616,7 @@ int main(int argc, char **argv)
|
|||||||
/* -------------- */
|
/* -------------- */
|
||||||
if (!mj2_parameters.cod_format || !mj2_parameters.decod_format) {
|
if (!mj2_parameters.cod_format || !mj2_parameters.decod_format) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Usage: %s -i yuv-file -o mj2-file (+ options)\n",argv[0]);
|
"\nUsage: %s -i yuv-file -o mj2-file (+ options)\n\n",argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(prec < 1 || prec > 16)
|
if(prec < 1 || prec > 16)
|
||||||
@@ -682,9 +678,11 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stderr, "failed to open %s for writing\n", argv[2]);
|
fprintf(stderr, "failed to open %s for writing\n", argv[2]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
failed = 1;
|
||||||
/* get a MJ2 decompressor handle */
|
/* get a MJ2 decompressor handle */
|
||||||
cinfo = mj2_create_compress();
|
cinfo = mj2_create_compress();
|
||||||
|
if(cinfo == NULL) goto fin;
|
||||||
|
|
||||||
movie = (opj_mj2_t*)cinfo->mj2_handle;
|
movie = (opj_mj2_t*)cinfo->mj2_handle;
|
||||||
|
|
||||||
/* catch events using our callbacks and give a local context */
|
/* catch events using our callbacks and give a local context */
|
||||||
@@ -697,27 +695,33 @@ int main(int argc, char **argv)
|
|||||||
yuv_num_frames(&movie->tk[0],mj2_parameters.infile);
|
yuv_num_frames(&movie->tk[0],mj2_parameters.infile);
|
||||||
|
|
||||||
if (movie->tk[0].num_samples == 0) {
|
if (movie->tk[0].num_samples == 0) {
|
||||||
return 1;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// One sample per chunk
|
/* One sample per chunk */
|
||||||
movie->tk[0].chunk = (mj2_chunk_t*)
|
movie->tk[0].chunk = (mj2_chunk_t*)
|
||||||
malloc(movie->tk[0].num_samples * sizeof(mj2_chunk_t));
|
malloc(movie->tk[0].num_samples * sizeof(mj2_chunk_t));
|
||||||
movie->tk[0].sample = (mj2_sample_t*)
|
movie->tk[0].sample = (mj2_sample_t*)
|
||||||
malloc(movie->tk[0].num_samples * sizeof(mj2_sample_t));
|
malloc(movie->tk[0].num_samples * sizeof(mj2_sample_t));
|
||||||
|
|
||||||
|
if(movie->tk[0].chunk == NULL || movie->tk[0].sample == NULL)
|
||||||
|
goto fin;
|
||||||
|
|
||||||
if (mj2_init_stdmovie(movie)) {
|
if (mj2_init_stdmovie(movie)) {
|
||||||
fprintf(stderr, "Error with movie initialization");
|
fprintf(stderr, "Error with movie initialization");
|
||||||
return 1;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writing JP, FTYP and MDAT boxes
|
/* Writing JP, FTYP and MDAT boxes */
|
||||||
// Assuming that the JP and FTYP boxes won't be longer than 300 bytes:
|
/* Assuming that the JP and FTYP boxes won't be longer than 300 bytes:*/
|
||||||
buf = (unsigned char*)
|
buf = (unsigned char*)
|
||||||
malloc (300 * sizeof(unsigned char));
|
malloc (300 * sizeof(unsigned char));
|
||||||
|
if(buf == NULL) goto fin;
|
||||||
|
|
||||||
cio = opj_cio_open((opj_common_ptr)movie->cinfo, buf, 300);
|
cio = opj_cio_open((opj_common_ptr)movie->cinfo, buf, 300);
|
||||||
|
|
||||||
|
if(cio == NULL) goto fin;
|
||||||
|
|
||||||
mj2_write_jp(cio);
|
mj2_write_jp(cio);
|
||||||
mj2_write_ftyp(movie, cio);
|
mj2_write_ftyp(movie, cio);
|
||||||
|
|
||||||
@@ -729,42 +733,52 @@ int main(int argc, char **argv)
|
|||||||
fwrite(buf,cio_tell(cio),1,mj2file);
|
fwrite(buf,cio_tell(cio),1,mj2file);
|
||||||
|
|
||||||
offset = cio_tell(cio);
|
offset = cio_tell(cio);
|
||||||
|
|
||||||
|
/* if(cio->openmode == OPJ_STREAM_READ) */ free(buf);
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
free(buf);
|
buf = NULL; numframes = 0;
|
||||||
|
|
||||||
for(i = 0; i < movie->num_stk + movie->num_htk + movie->num_vtk; i++)
|
for(i = 0; i < movie->num_stk + movie->num_htk + movie->num_vtk; i++)
|
||||||
{
|
{
|
||||||
if(movie->tk[i].track_type != 0)
|
mj2_tk_t *track;
|
||||||
|
|
||||||
|
track = &movie->tk[i];
|
||||||
|
numframes = track->num_samples;
|
||||||
|
|
||||||
|
if(track->track_type != 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Unable to write sound or hint tracks\n");
|
fprintf(stderr, "Unable to write sound or hint tracks\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mj2_tk_t *tk;
|
|
||||||
int buflen = 0;
|
int buflen = 0;
|
||||||
|
|
||||||
tk = &movie->tk[i];
|
track->num_chunks = track->num_samples;
|
||||||
tk->num_chunks = tk->num_samples;
|
track->depth = prec;
|
||||||
numframes = tk->num_samples;
|
|
||||||
tk->depth = prec;
|
|
||||||
|
|
||||||
fprintf(stderr, "Video Track number %d\n", i);
|
fprintf(stderr, "Video Track number %d\n", i);
|
||||||
|
|
||||||
img = mj2_image_create(tk, j2k_parameters);
|
img = mj2_image_create(track, j2k_parameters);
|
||||||
|
if(img == NULL) goto fin;
|
||||||
|
|
||||||
buflen = 2 * (tk->w * tk->h * 8);
|
buflen = 2 * (track->w * track->h * 8);
|
||||||
buf = (unsigned char *) malloc(buflen*sizeof(unsigned char));
|
buf = (unsigned char *) malloc(buflen*sizeof(unsigned char));
|
||||||
|
if(buf == NULL)
|
||||||
|
{
|
||||||
|
opj_image_destroy(img);
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
for(sampleno = 0; sampleno < numframes; sampleno++)
|
for(sampleno = 0; sampleno < numframes; sampleno++)
|
||||||
{
|
{
|
||||||
double init_time = opj_clock();
|
double init_time = opj_clock();
|
||||||
double elapsed_time;
|
double elapsed_time;
|
||||||
|
|
||||||
if(yuvtoimage(tk, img, sampleno, j2k_parameters,
|
if(yuvtoimage(track, img, sampleno, j2k_parameters,
|
||||||
mj2_parameters.infile))
|
mj2_parameters.infile))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error with frame number %d in YUV file\n", sampleno);
|
fprintf(stderr, "Error with frame number %d in YUV file\n", sampleno);
|
||||||
return 1;
|
opj_image_destroy(img);
|
||||||
|
goto fin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setup the encoder parameters using the current image and user parameters */
|
/* setup the encoder parameters using the current image and user parameters */
|
||||||
@@ -772,16 +786,21 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
cio = opj_cio_open((opj_common_ptr)movie->cinfo, buf, buflen);
|
cio = opj_cio_open((opj_common_ptr)movie->cinfo, buf, buflen);
|
||||||
|
|
||||||
|
if(cio == NULL) goto fin;
|
||||||
|
|
||||||
cio_skip(cio, 4);
|
cio_skip(cio, 4);
|
||||||
cio_write(cio, JP2_JP2C, 4); // JP2C
|
cio_write(cio, JP2_JP2C, 4);
|
||||||
|
|
||||||
/* encode the image */
|
/* encode the image */
|
||||||
bSuccess = opj_encode(cinfo, cio, img, NULL);
|
bSuccess = opj_encode(cinfo, cio, img, NULL);
|
||||||
|
|
||||||
if (!bSuccess) {
|
if (!bSuccess) {
|
||||||
|
opj_image_destroy(img);
|
||||||
|
/* if(cio->openmode == OPJ_STREAM_READ) */ free(buf);
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
|
buf = NULL;
|
||||||
fprintf(stderr, "failed to encode image\n");
|
fprintf(stderr, "failed to encode image\n");
|
||||||
return 1;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = cio_tell(cio) - 8;
|
len = cio_tell(cio) - 8;
|
||||||
@@ -789,9 +808,9 @@ int main(int argc, char **argv)
|
|||||||
cio_write(cio, len+8,4);
|
cio_write(cio, len+8,4);
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
|
|
||||||
tk->sample[sampleno].sample_size = len+8;
|
track->sample[sampleno].sample_size = len+8;
|
||||||
tk->sample[sampleno].offset = offset;
|
track->sample[sampleno].offset = offset;
|
||||||
tk->chunk[sampleno].offset = offset; // There is one sample per chunk
|
track->chunk[sampleno].offset = offset; /* There is one sample per chunk */
|
||||||
fwrite(buf, 1, len+8, mj2file);
|
fwrite(buf, 1, len+8, mj2file);
|
||||||
offset += len+8;
|
offset += len+8;
|
||||||
|
|
||||||
@@ -801,43 +820,59 @@ int main(int argc, char **argv)
|
|||||||
total_time += elapsed_time;
|
total_time += elapsed_time;
|
||||||
} /* for(sampleno */
|
} /* for(sampleno */
|
||||||
|
|
||||||
free(buf);
|
free(buf); buf = NULL;
|
||||||
opj_image_destroy(img);
|
opj_image_destroy(img);
|
||||||
}
|
} /* if(track ) */
|
||||||
}/* for(i */
|
}/* for(i */
|
||||||
|
|
||||||
fseek(mj2file, mdat_initpos, SEEK_SET);
|
fseek(mj2file, mdat_initpos, SEEK_SET);
|
||||||
|
|
||||||
buf = (unsigned char*) malloc(4*sizeof(unsigned char));
|
buf = (unsigned char*) malloc(4*sizeof(unsigned char));
|
||||||
|
|
||||||
// Init a cio to write box length variable in a little endian way
|
if(buf == NULL) goto fin;
|
||||||
|
|
||||||
|
/* Init a cio to write box length variable in a little endian way */
|
||||||
cio = opj_cio_open(NULL, buf, 4);
|
cio = opj_cio_open(NULL, buf, 4);
|
||||||
|
|
||||||
|
if(cio == NULL) goto fin;
|
||||||
|
|
||||||
cio_write(cio, offset - mdat_initpos, 4);
|
cio_write(cio, offset - mdat_initpos, 4);
|
||||||
fwrite(buf, 4, 1, mj2file);
|
fwrite(buf, 4, 1, mj2file);
|
||||||
fseek(mj2file,0,SEEK_END);
|
fseek(mj2file,0,SEEK_END);
|
||||||
free(buf);
|
/* if(cio->openmode == OPJ_STREAM_READ) */ free(buf);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
// Writing MOOV box
|
/* Writing MOOV box */
|
||||||
buf = (unsigned char*)
|
buf = (unsigned char*)
|
||||||
malloc ((TEMP_BUF+numframes*20) * sizeof(unsigned char));
|
malloc ((TEMP_BUF+numframes*20) * sizeof(unsigned char));
|
||||||
|
|
||||||
|
if(buf == NULL) goto fin;
|
||||||
|
|
||||||
cio = opj_cio_open(movie->cinfo, buf, (TEMP_BUF+numframes*20));
|
cio = opj_cio_open(movie->cinfo, buf, (TEMP_BUF+numframes*20));
|
||||||
|
|
||||||
|
if(cio == NULL) goto fin;
|
||||||
|
|
||||||
mj2_write_moov(movie, cio);
|
mj2_write_moov(movie, cio);
|
||||||
fwrite(buf,cio_tell(cio),1,mj2file);
|
fwrite(buf,cio_tell(cio),1,mj2file);
|
||||||
free(buf);
|
/* if(cio->openmode == OPJ_STREAM_READ) */ free(buf);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
fprintf(stdout,"Total encoding time: %.2f s for %d frames (%.1f fps)\n",
|
fprintf(stdout,"Total encoding time: %.2f s for %d frames (%.1f fps)\n",
|
||||||
total_time, numframes, (float)numframes/total_time);
|
total_time, numframes, (float)numframes/total_time);
|
||||||
|
failed = 0;
|
||||||
|
|
||||||
// Ending program
|
fin:
|
||||||
|
|
||||||
fclose(mj2file);
|
fclose(mj2file);
|
||||||
/* free remaining compression structures */
|
/* free remaining compression structures */
|
||||||
|
if(cinfo)
|
||||||
|
{
|
||||||
mj2_destroy_compress(movie);
|
mj2_destroy_compress(movie);
|
||||||
free(cinfo);
|
free(cinfo);
|
||||||
|
}
|
||||||
if(j2k_parameters->cp_comment) free(j2k_parameters->cp_comment);
|
if(j2k_parameters->cp_comment) free(j2k_parameters->cp_comment);
|
||||||
if(j2k_parameters->cp_matrice) free(j2k_parameters->cp_matrice);
|
if(j2k_parameters->cp_matrice) free(j2k_parameters->cp_matrice);
|
||||||
opj_cio_close(cio);
|
|
||||||
|
|
||||||
return 0;
|
if(failed) remove(mj2_parameters.outfile);
|
||||||
|
|
||||||
|
return failed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1096,8 +1096,8 @@ int mj2_read_smj2(opj_image_t * img, mj2_tk_t * tk, opj_cio_t *cio)
|
|||||||
{
|
{
|
||||||
mj2_box_t box;
|
mj2_box_t box;
|
||||||
mj2_box_t box2;
|
mj2_box_t box2;
|
||||||
int i;
|
|
||||||
opj_jp2_color_t color;
|
opj_jp2_color_t color;
|
||||||
|
int i;
|
||||||
opj_bool ok;
|
opj_bool ok;
|
||||||
|
|
||||||
mj2_read_boxhdr(&box, cio);
|
mj2_read_boxhdr(&box, cio);
|
||||||
@@ -1236,10 +1236,10 @@ void mj2_write_stsd(mj2_tk_t * tk, opj_cio_t *cio)
|
|||||||
if (tk->track_type == 0) {
|
if (tk->track_type == 0) {
|
||||||
mj2_write_smj2(tk, cio);
|
mj2_write_smj2(tk, cio);
|
||||||
} else if (tk->track_type == 1) {
|
} else if (tk->track_type == 1) {
|
||||||
// Not implemented
|
/* Not implemented */
|
||||||
}
|
}
|
||||||
if (tk->track_type == 2) {
|
if (tk->track_type == 2) {
|
||||||
// Not implemented
|
/* Not implemented */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1287,10 +1287,10 @@ int mj2_read_stsd(mj2_tk_t * tk, opj_image_t * img, opj_cio_t *cio)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if (tk->track_type == 1) {
|
} else if (tk->track_type == 1) {
|
||||||
len_2skip = cio_read(cio, 4); // Not implemented -> skipping box
|
len_2skip = cio_read(cio, 4); /* Not implemented -> skipping box */
|
||||||
cio_skip(cio,len_2skip - 4);
|
cio_skip(cio,len_2skip - 4);
|
||||||
} else if (tk->track_type == 2) {
|
} else if (tk->track_type == 2) {
|
||||||
len_2skip = cio_read(cio, 4); // Not implemented -> skipping box
|
len_2skip = cio_read(cio, 4); /* Not implemented -> skipping box */
|
||||||
cio_skip(cio,len_2skip - 4);
|
cio_skip(cio,len_2skip - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2111,7 +2111,7 @@ int mj2_read_mdhd(mj2_tk_t * tk, opj_cio_t *cio)
|
|||||||
mj2_box_t box;
|
mj2_box_t box;
|
||||||
|
|
||||||
mj2_read_boxhdr(&box, cio);
|
mj2_read_boxhdr(&box, cio);
|
||||||
if (!(MJ2_MHDR == box.type || MJ2_MDHD == box.type)) { // Kakadu writes MHDR instead of MDHD
|
if (!(MJ2_MHDR == box.type || MJ2_MDHD == box.type)) { /* Kakadu writes MHDR instead of MDHD */
|
||||||
opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected MDHD Marker\n");
|
opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected MDHD Marker\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -2765,10 +2765,10 @@ void mj2_destroy_decompress(opj_mj2_t *movie) {
|
|||||||
tk = &movie->tk[i];
|
tk = &movie->tk[i];
|
||||||
if (tk->name_size != 0)
|
if (tk->name_size != 0)
|
||||||
opj_free(tk->name);
|
opj_free(tk->name);
|
||||||
if (tk->track_type == 0) {// Video track
|
if (tk->track_type == 0) {/* Video track */
|
||||||
if (tk->jp2_struct.comps != 0)
|
if (tk->jp2_struct.comps != NULL)
|
||||||
opj_free(tk->jp2_struct.comps);
|
opj_free(tk->jp2_struct.comps);
|
||||||
if (tk->jp2_struct.cl != 0)
|
if (tk->jp2_struct.cl != NULL)
|
||||||
opj_free(tk->jp2_struct.cl);
|
opj_free(tk->jp2_struct.cl);
|
||||||
if (tk->num_jp2x != 0)
|
if (tk->num_jp2x != 0)
|
||||||
opj_free(tk->jp2xdata);
|
opj_free(tk->jp2xdata);
|
||||||
@@ -2821,20 +2821,20 @@ void mj2_setup_encoder(opj_mj2_t *movie, mj2_cparameters_t *parameters) {
|
|||||||
if(movie && parameters) {
|
if(movie && parameters) {
|
||||||
opj_jp2_t *jp2_struct;
|
opj_jp2_t *jp2_struct;
|
||||||
|
|
||||||
movie->num_htk = 0; // No hint tracks
|
movie->num_htk = 0; /* No hint tracks */
|
||||||
movie->num_stk = 0; // No sound tracks
|
movie->num_stk = 0; /* No sound tracks */
|
||||||
movie->num_vtk = 1; // One video track
|
movie->num_vtk = 1; /* One video track */
|
||||||
|
|
||||||
movie->brand = MJ2_MJ2; // One brand: MJ2
|
movie->brand = MJ2_MJ2; /* One brand: MJ2 */
|
||||||
movie->num_cl = 2; // Two compatible brands: MJ2 and MJ2S
|
movie->num_cl = 2; /* Two compatible brands: MJ2 and MJ2S */
|
||||||
movie->cl = (unsigned int*) opj_malloc(movie->num_cl * sizeof(unsigned int));
|
movie->cl = (unsigned int*) opj_malloc(movie->num_cl * sizeof(unsigned int));
|
||||||
movie->cl[0] = MJ2_MJ2;
|
movie->cl[0] = MJ2_MJ2;
|
||||||
movie->cl[1] = MJ2_MJ2S;
|
movie->cl[1] = MJ2_MJ2S;
|
||||||
movie->minversion = 0; // Minimum version: 0
|
movie->minversion = 0; /* Minimum version: 0 */
|
||||||
|
|
||||||
movie->tk = (mj2_tk_t*) opj_malloc(sizeof(mj2_tk_t)); //Memory allocation for the video track
|
movie->tk = (mj2_tk_t*) opj_malloc(sizeof(mj2_tk_t)); /*Memory allocation for the video track*/
|
||||||
movie->tk[0].track_ID = 1; // Track ID = 1
|
movie->tk[0].track_ID = 1; /* Track ID = 1 */
|
||||||
movie->tk[0].track_type = 0; // Video track
|
movie->tk[0].track_type = 0; /* Video track */
|
||||||
movie->tk[0].Dim[0] = parameters->Dim[0];
|
movie->tk[0].Dim[0] = parameters->Dim[0];
|
||||||
movie->tk[0].Dim[1] = parameters->Dim[1];
|
movie->tk[0].Dim[1] = parameters->Dim[1];
|
||||||
movie->tk[0].w = parameters->w;
|
movie->tk[0].w = parameters->w;
|
||||||
@@ -2848,7 +2848,7 @@ void mj2_setup_encoder(opj_mj2_t *movie, mj2_cparameters_t *parameters) {
|
|||||||
movie->tk[0].depth = parameters->prec;
|
movie->tk[0].depth = parameters->prec;
|
||||||
|
|
||||||
jp2_struct = &movie->tk[0].jp2_struct;
|
jp2_struct = &movie->tk[0].jp2_struct;
|
||||||
jp2_struct->numcomps = parameters->numcomps; // NC
|
jp2_struct->numcomps = parameters->numcomps; /* NC */
|
||||||
jp2_struct->comps = (opj_jp2_comps_t*) opj_malloc(jp2_struct->numcomps * sizeof(opj_jp2_comps_t));
|
jp2_struct->comps = (opj_jp2_comps_t*) opj_malloc(jp2_struct->numcomps * sizeof(opj_jp2_comps_t));
|
||||||
jp2_struct->precedence = 0; /* PRECEDENCE*/
|
jp2_struct->precedence = 0; /* PRECEDENCE*/
|
||||||
jp2_struct->approx = 0; /* APPROX*/
|
jp2_struct->approx = 0; /* APPROX*/
|
||||||
@@ -2884,10 +2884,10 @@ void mj2_destroy_compress(opj_mj2_t *movie) {
|
|||||||
tk = &movie->tk[i];
|
tk = &movie->tk[i];
|
||||||
if (tk->name_size != 0)
|
if (tk->name_size != 0)
|
||||||
opj_free(tk->name);
|
opj_free(tk->name);
|
||||||
if (tk->track_type == 0) {// Video track
|
if (tk->track_type == 0) {/* Video track */
|
||||||
if (tk->jp2_struct.comps != 0)
|
if (tk->jp2_struct.comps != NULL)
|
||||||
opj_free(tk->jp2_struct.comps);
|
opj_free(tk->jp2_struct.comps);
|
||||||
if (tk->jp2_struct.cl != 0)
|
if (tk->jp2_struct.cl != NULL)
|
||||||
opj_free(tk->jp2_struct.cl);
|
opj_free(tk->jp2_struct.cl);
|
||||||
if (tk->num_jp2x != 0)
|
if (tk->num_jp2x != 0)
|
||||||
opj_free(tk->jp2xdata);
|
opj_free(tk->jp2xdata);
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ typedef struct mj2_url {
|
|||||||
URN
|
URN
|
||||||
*/
|
*/
|
||||||
typedef struct mj2_urn {
|
typedef struct mj2_urn {
|
||||||
int name[2];
|
int name[4];
|
||||||
int location[4];
|
int location[4];
|
||||||
} mj2_urn_t;
|
} mj2_urn_t;
|
||||||
|
|
||||||
|
|||||||
@@ -67,12 +67,12 @@ unsigned int yuv_num_frames(mj2_tk_t * tk, char *infile)
|
|||||||
return (unsigned int)(end_of_f / frame_size);
|
return (unsigned int)(end_of_f / frame_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------
|
/* -----------------------
|
||||||
//
|
|
||||||
//
|
|
||||||
// YUV to IMAGE
|
YUV to IMAGE
|
||||||
//
|
|
||||||
// -----------------------
|
-----------------------*/
|
||||||
|
|
||||||
opj_image_t *mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters)
|
opj_image_t *mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters)
|
||||||
{
|
{
|
||||||
@@ -169,12 +169,12 @@ char yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------
|
/* -----------------------
|
||||||
//
|
|
||||||
//
|
|
||||||
// IMAGE to YUV
|
IMAGE to YUV
|
||||||
//
|
|
||||||
// -----------------------
|
-----------------------*/
|
||||||
|
|
||||||
|
|
||||||
opj_bool imagetoyuv(opj_image_t * img, char *outfile)
|
opj_bool imagetoyuv(opj_image_t * img, char *outfile)
|
||||||
@@ -263,12 +263,12 @@ opj_bool imagetoyuv(opj_image_t * img, char *outfile)
|
|||||||
return OPJ_TRUE;
|
return OPJ_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------
|
/* -----------------------
|
||||||
//
|
|
||||||
//
|
|
||||||
// IMAGE to BMP
|
IMAGE to BMP
|
||||||
//
|
|
||||||
// -----------------------
|
-----------------------*/
|
||||||
|
|
||||||
int imagetobmp(opj_image_t * img, char *outfile) {
|
int imagetobmp(opj_image_t * img, char *outfile) {
|
||||||
int w,wr,h,hr,i,pad;
|
int w,wr,h,hr,i,pad;
|
||||||
@@ -353,11 +353,11 @@ int imagetobmp(opj_image_t * img, char *outfile) {
|
|||||||
for (i = 0; i < wr * hr; i++) {
|
for (i = 0; i < wr * hr; i++) {
|
||||||
unsigned char R, G, B;
|
unsigned char R, G, B;
|
||||||
/* a modifier */
|
/* a modifier */
|
||||||
// R = img->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
/* R = img->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];*/
|
||||||
R = img->comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
|
R = img->comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
|
||||||
// G = img->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
/* G = img->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];*/
|
||||||
G = img->comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
|
G = img->comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
|
||||||
// B = img->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
/* B = img->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];*/
|
||||||
B = img->comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
|
B = img->comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
|
||||||
fprintf(f, "%c%c%c", B, G, R);
|
fprintf(f, "%c%c%c", B, G, R);
|
||||||
|
|
||||||
|
|||||||
@@ -69,45 +69,67 @@ void info_callback(const char *msg, void *client_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
#define JP2_RFC3745_MAGIC "\x00\x00\x00\x0c\x6a\x50\x20\x20\x0d\x0a\x87\x0a"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
mj2_dparameters_t mj2_parameters; /* decompression parameters */
|
mj2_dparameters_t mj2_parameters; /* decompression parameters */
|
||||||
opj_dinfo_t* dinfo;
|
opj_dinfo_t* dinfo;
|
||||||
opj_event_mgr_t event_mgr; /* event manager */
|
opj_event_mgr_t event_mgr; /* event manager */
|
||||||
opj_cio_t *cio = NULL;
|
opj_cio_t *cio = NULL;
|
||||||
unsigned int tnum, snum;
|
unsigned int tnum, snum, failed;
|
||||||
opj_mj2_t *movie;
|
opj_mj2_t *movie;
|
||||||
mj2_tk_t *track;
|
mj2_tk_t *track;
|
||||||
mj2_sample_t *sample;
|
mj2_sample_t *sample;
|
||||||
unsigned char* frame_codestream;
|
unsigned char* frame_codestream;
|
||||||
FILE *file, *outfile;
|
FILE *infile, *outfile;
|
||||||
char outfilename[50];
|
|
||||||
opj_image_t *img = NULL;
|
opj_image_t *img = NULL;
|
||||||
unsigned int max_codstrm_size = 0;
|
unsigned int max_codstrm_size = 0;
|
||||||
double total_time = 0;
|
double total_time = 0;
|
||||||
unsigned int numframes = 0;
|
unsigned int numframes = 0;
|
||||||
|
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
printf("Usage: %s inputfile.mj2 outputfile.yuv\n",argv[0]);
|
printf("\nUsage: %s inputfile.mj2 outputfile.yuv\n\n",argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
file = fopen(argv[1], "rb");
|
infile = fopen(argv[1], "rb");
|
||||||
|
|
||||||
if (!file) {
|
if (!infile) {
|
||||||
fprintf(stderr, "failed to open %s for reading\n", argv[1]);
|
fprintf(stderr, "failed to open %s for reading\n", argv[1]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
unsigned char buf[28];
|
||||||
|
size_t n;
|
||||||
|
|
||||||
// Checking output file
|
memset(buf, 0, 28);
|
||||||
outfile = fopen(argv[2], "w");
|
n = fread(buf, 1, 24, infile);
|
||||||
if (!file) {
|
|
||||||
fprintf(stderr, "failed to open %s for writing\n", argv[2]);
|
if(memcmp(buf, JP2_RFC3745_MAGIC, 12) == 0
|
||||||
return 1;
|
&& memcmp(buf+20, "\x6d\x6a\x70\x32", 4) == 0)
|
||||||
|
{
|
||||||
|
rewind(infile);
|
||||||
}
|
}
|
||||||
fclose(outfile);
|
else
|
||||||
|
{
|
||||||
|
fclose(infile);
|
||||||
|
fprintf(stderr,"%s:%d: %s\n\tThis file is not an MJ2 file."
|
||||||
|
"Quitting\n",__FILE__,__LINE__,argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Checking output file: */
|
||||||
|
outfile = fopen(argv[2], "w");
|
||||||
|
|
||||||
|
if (!outfile) {
|
||||||
|
fprintf(stderr, "failed to open %s for writing\n", argv[2]);
|
||||||
|
fclose(infile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
fclose(outfile); remove(argv[2]);
|
||||||
|
|
||||||
|
frame_codestream = NULL;
|
||||||
|
failed = 1;
|
||||||
/*
|
/*
|
||||||
configure the event callbacks (not required)
|
configure the event callbacks (not required)
|
||||||
setting of each callback is optionnal
|
setting of each callback is optionnal
|
||||||
@@ -119,6 +141,8 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
/* get a MJ2 decompressor handle */
|
/* get a MJ2 decompressor handle */
|
||||||
dinfo = mj2_create_decompress();
|
dinfo = mj2_create_decompress();
|
||||||
|
if(dinfo == NULL) goto fin;
|
||||||
|
|
||||||
movie = (opj_mj2_t*)dinfo->mj2_handle;
|
movie = (opj_mj2_t*)dinfo->mj2_handle;
|
||||||
|
|
||||||
/* catch events using our callbacks and give a local context */
|
/* catch events using our callbacks and give a local context */
|
||||||
@@ -131,10 +155,11 @@ int main(int argc, char *argv[]) {
|
|||||||
/* setup the decoder decoding parameters using user parameters */
|
/* setup the decoder decoding parameters using user parameters */
|
||||||
mj2_setup_decoder(movie, &mj2_parameters);
|
mj2_setup_decoder(movie, &mj2_parameters);
|
||||||
|
|
||||||
if (mj2_read_struct(file, movie)) // Creating the movie structure
|
/* Create the movie structure: */
|
||||||
return 1;
|
if (mj2_read_struct(infile, movie))
|
||||||
|
goto fin;
|
||||||
|
|
||||||
// Decode first video track
|
/* Decode first video track */
|
||||||
for (tnum=0; tnum < (unsigned int)(movie->num_htk + movie->num_stk + movie->num_vtk); tnum++) {
|
for (tnum=0; tnum < (unsigned int)(movie->num_htk + movie->num_stk + movie->num_vtk); tnum++) {
|
||||||
if (movie->tk[tnum].track_type == 0)
|
if (movie->tk[tnum].track_type == 0)
|
||||||
break;
|
break;
|
||||||
@@ -142,24 +167,34 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
if (movie->tk[tnum].track_type != 0) {
|
if (movie->tk[tnum].track_type != 0) {
|
||||||
printf("Error. Movie does not contain any video track\n");
|
printf("Error. Movie does not contain any video track\n");
|
||||||
return 1;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
|
||||||
track = &movie->tk[tnum];
|
track = &movie->tk[tnum];
|
||||||
|
|
||||||
// Output info on first video tracl
|
if(track->jp2_struct.enumcs != ENUMCS_SYCC)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"%s:%d: %s\n"
|
||||||
|
"\tERROR: this MJ2 file does not contain YUV frames.\n"
|
||||||
|
"\tPlease try extract_j2k_from_mj2 for this file.\n",
|
||||||
|
__FILE__,__LINE__,argv[0]);
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
/* Output info on first video track: */
|
||||||
fprintf(stdout,"The first video track contains %d frames.\nWidth: %d, Height: %d \n\n",
|
fprintf(stdout,"The first video track contains %d frames.\nWidth: %d, Height: %d \n\n",
|
||||||
track->num_samples, track->w, track->h);
|
track->num_samples, track->w, track->h);
|
||||||
|
|
||||||
max_codstrm_size = track->sample[0].sample_size-8;
|
max_codstrm_size = track->sample[0].sample_size-8;
|
||||||
frame_codestream = (unsigned char*) malloc(max_codstrm_size * sizeof(unsigned char));
|
frame_codestream = (unsigned char*)
|
||||||
|
malloc(max_codstrm_size * sizeof(unsigned char));
|
||||||
|
if(frame_codestream == NULL) goto fin;
|
||||||
|
|
||||||
numframes = track->num_samples;
|
numframes = track->num_samples;
|
||||||
|
|
||||||
for (snum=0; snum < numframes; snum++)
|
for (snum=0; snum < numframes; snum++)
|
||||||
{
|
{
|
||||||
double init_time = opj_clock();
|
double init_time = opj_clock();
|
||||||
double elapsed_time;
|
double elapsed_time;
|
||||||
|
|
||||||
sample = &track->sample[snum];
|
sample = &track->sample[snum];
|
||||||
if (sample->sample_size-8 > max_codstrm_size) {
|
if (sample->sample_size-8 > max_codstrm_size) {
|
||||||
@@ -167,85 +202,54 @@ int main(int argc, char *argv[]) {
|
|||||||
if ((frame_codestream = (unsigned char*)
|
if ((frame_codestream = (unsigned char*)
|
||||||
realloc(frame_codestream, max_codstrm_size)) == NULL) {
|
realloc(frame_codestream, max_codstrm_size)) == NULL) {
|
||||||
printf("Error reallocation memory\n");
|
printf("Error reallocation memory\n");
|
||||||
return 1;
|
goto fin;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
fseek(file,sample->offset+8,SEEK_SET);
|
fseek(infile,sample->offset+8,SEEK_SET);
|
||||||
fread(frame_codestream, sample->sample_size-8, 1, file); // Assuming that jp and ftyp markers size do
|
/* Assuming that jp and ftyp markers size do: */
|
||||||
|
fread(frame_codestream, sample->sample_size-8, 1, infile);
|
||||||
|
|
||||||
/* open a byte stream */
|
/* open a byte stream */
|
||||||
cio = opj_cio_open((opj_common_ptr)dinfo, frame_codestream, sample->sample_size-8);
|
cio = opj_cio_open((opj_common_ptr)dinfo, frame_codestream, sample->sample_size-8);
|
||||||
|
|
||||||
img = opj_decode(dinfo, cio); // Decode J2K to image
|
if(cio == NULL) goto fin;
|
||||||
|
|
||||||
#ifdef WANT_SYCC_TO_RGB
|
img = opj_decode(dinfo, cio);
|
||||||
if(img->color_space == CLRSPC_SYCC)
|
|
||||||
{
|
|
||||||
color_sycc_to_rgb(img);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(img->icc_profile_buf)
|
if(img == NULL) goto fin;
|
||||||
{
|
|
||||||
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
|
|
||||||
color_apply_icc_profile(img);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
free(img->icc_profile_buf);
|
/* Convert frame to YUV: */
|
||||||
img->icc_profile_buf = NULL; img->icc_profile_len = 0;
|
if (!imagetoyuv(img, argv[2]))
|
||||||
}
|
goto fin;
|
||||||
|
|
||||||
if (((img->numcomps == 3) && (img->comps[0].dx == img->comps[1].dx / 2)
|
opj_cio_close(cio);
|
||||||
&& (img->comps[0].dx == img->comps[2].dx / 2 ) && (img->comps[0].dx == 1))
|
|
||||||
|| (img->numcomps == 1)) {
|
|
||||||
|
|
||||||
if (!imagetoyuv(img, argv[2])) // Convert image to YUV
|
opj_image_destroy(img);
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if ((img->numcomps == 3) &&
|
|
||||||
(img->comps[0].dx == 1) && (img->comps[1].dx == 1)&&
|
|
||||||
(img->comps[2].dx == 1))// If YUV 4:4:4 input --> to bmp
|
|
||||||
{
|
|
||||||
fprintf(stdout,"The frames will be output in a bmp format (output_1.bmp, ...)\n");
|
|
||||||
sprintf(outfilename,"output_%d.bmp",snum);
|
|
||||||
if (imagetobmp(img, outfilename)) // Convert image to BMP
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
}
|
elapsed_time = opj_clock()-init_time;
|
||||||
else {
|
fprintf(stderr, "Frame number %d/%d decoded in %.2f mseconds\n",
|
||||||
fprintf(stdout,"Image component dimensions are unknown. Unable to output image\n");
|
snum + 1, numframes, elapsed_time*1000);
|
||||||
fprintf(stdout,"The frames will be output in a j2k file (output_1.j2k, ...)\n");
|
total_time += elapsed_time;
|
||||||
|
|
||||||
sprintf(outfilename,"output_%d.j2k",snum);
|
}/* for (snum */
|
||||||
outfile = fopen(outfilename, "wb");
|
|
||||||
if (!outfile) {
|
|
||||||
fprintf(stderr, "failed to open %s for writing\n",outfilename);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
fwrite(frame_codestream,sample->sample_size-8,1,outfile);
|
|
||||||
fclose(outfile);
|
|
||||||
}
|
|
||||||
/* close the byte stream */
|
|
||||||
opj_cio_close(cio);
|
|
||||||
/* free image data structure */
|
|
||||||
opj_image_destroy(img);
|
|
||||||
elapsed_time = opj_clock()-init_time;
|
|
||||||
fprintf(stderr, "Frame number %d/%d decoded in %.2f mseconds\n", snum + 1, numframes, elapsed_time*1000);
|
|
||||||
total_time += elapsed_time;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
free(frame_codestream);
|
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
/* free remaining structures */
|
|
||||||
if(dinfo) {
|
|
||||||
mj2_destroy_decompress((opj_mj2_t*)dinfo->mj2_handle);
|
|
||||||
}
|
|
||||||
free(dinfo);
|
|
||||||
|
|
||||||
fprintf(stdout, "%d frame(s) correctly decompressed\n", snum);
|
fprintf(stdout, "%d frame(s) correctly decompressed\n", snum);
|
||||||
fprintf(stdout,"Total decoding time: %.2f seconds (%.1f fps)\n", total_time, (float)numframes/total_time);
|
fprintf(stdout,"Total decoding time: %.2f seconds (%.1f fps)\n",
|
||||||
|
total_time, (float)numframes/total_time);
|
||||||
|
|
||||||
return 0;
|
failed = 0;
|
||||||
}
|
|
||||||
|
fin:
|
||||||
|
fclose(infile);
|
||||||
|
|
||||||
|
if(frame_codestream) free(frame_codestream);
|
||||||
|
|
||||||
|
/* free remaining structures */
|
||||||
|
if(dinfo)
|
||||||
|
{
|
||||||
|
mj2_destroy_decompress(movie);
|
||||||
|
free(dinfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return failed;
|
||||||
|
}/* main() */
|
||||||
|
|||||||
@@ -45,10 +45,6 @@ Size of memory first allocated for MOOV box
|
|||||||
*/
|
*/
|
||||||
#define TEMP_BUF 10000
|
#define TEMP_BUF 10000
|
||||||
|
|
||||||
#define ENUMCS_GRAY 16
|
|
||||||
#define ENUMCS_SRGB 17
|
|
||||||
#define ENUMCS_SYCC 18
|
|
||||||
|
|
||||||
#define J2K_CODESTREAM_MAGIC "\xff\x4f\xff\x51"
|
#define J2K_CODESTREAM_MAGIC "\xff\x4f\xff\x51"
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
@@ -77,6 +73,8 @@ static int test_image(const char *fname, mj2_cparameters_t *cp)
|
|||||||
|
|
||||||
if(memcmp(src, J2K_CODESTREAM_MAGIC, 4) != 0)
|
if(memcmp(src, J2K_CODESTREAM_MAGIC, 4) != 0)
|
||||||
{
|
{
|
||||||
|
fprintf(stderr,"%s:%d:\n\tONLY J2K files are accepted. Quitting.\n",
|
||||||
|
__FILE__,__LINE__);
|
||||||
free(src); return success;
|
free(src); return success;
|
||||||
}
|
}
|
||||||
memset(&dparameters, 0, sizeof(opj_dparameters_t));
|
memset(&dparameters, 0, sizeof(opj_dparameters_t));
|
||||||
@@ -89,8 +87,12 @@ static int test_image(const char *fname, mj2_cparameters_t *cp)
|
|||||||
|
|
||||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, src_len);
|
cio = opj_cio_open((opj_common_ptr)dinfo, src, src_len);
|
||||||
|
|
||||||
|
if(cio == NULL) goto fin;
|
||||||
|
|
||||||
image = opj_decode(dinfo, cio);
|
image = opj_decode(dinfo, cio);
|
||||||
|
|
||||||
|
if(image == NULL) goto fin;
|
||||||
|
|
||||||
free(src); cio->buffer = NULL;
|
free(src); cio->buffer = NULL;
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
|
|
||||||
@@ -101,68 +103,17 @@ static int test_image(const char *fname, mj2_cparameters_t *cp)
|
|||||||
cp->h = image->comps[0].h;
|
cp->h = image->comps[0].h;
|
||||||
cp->prec = image->comps[0].prec;
|
cp->prec = image->comps[0].prec;
|
||||||
|
|
||||||
if(image->numcomps > 2 )
|
if(image->numcomps > 2)/* RGB or RGBA */
|
||||||
{
|
{
|
||||||
if((image->comps[0].dx == 1)
|
|
||||||
&& (image->comps[1].dx == 2)
|
|
||||||
&& (image->comps[2].dx == 2)
|
|
||||||
&& (image->comps[0].dy == 1)
|
|
||||||
&& (image->comps[1].dy == 2)
|
|
||||||
&& (image->comps[2].dy == 2))// horizontal and vertical
|
|
||||||
{
|
|
||||||
// Y420
|
|
||||||
cp->enumcs = ENUMCS_SYCC;
|
|
||||||
cp->CbCr_subsampling_dx = 2;
|
|
||||||
cp->CbCr_subsampling_dy = 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if((image->comps[0].dx == 1)
|
|
||||||
&& (image->comps[1].dx == 2)
|
|
||||||
&& (image->comps[2].dx == 2)
|
|
||||||
&& (image->comps[0].dy == 1)
|
|
||||||
&& (image->comps[1].dy == 1)
|
|
||||||
&& (image->comps[2].dy == 1))// horizontal only
|
|
||||||
{
|
|
||||||
// Y422
|
|
||||||
cp->enumcs = ENUMCS_SYCC;
|
|
||||||
cp->CbCr_subsampling_dx = 2;
|
|
||||||
cp->CbCr_subsampling_dy = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if((image->comps[0].dx == 1)
|
|
||||||
&& (image->comps[1].dx == 1)
|
|
||||||
&& (image->comps[2].dx == 1)
|
|
||||||
&& (image->comps[0].dy == 1)
|
|
||||||
&& (image->comps[1].dy == 1)
|
|
||||||
&& (image->comps[2].dy == 1))
|
|
||||||
{
|
|
||||||
// Y444 or RGB
|
|
||||||
|
|
||||||
if(image->color_space == CLRSPC_SRGB)
|
|
||||||
{
|
|
||||||
cp->enumcs = ENUMCS_SRGB;
|
cp->enumcs = ENUMCS_SRGB;
|
||||||
|
/* cp->CbCr_subsampling_dx = 0; */
|
||||||
// cp->CbCr_subsampling_dx = 0;
|
/* cp->CbCr_subsampling_dy = 0; */
|
||||||
// cp->CbCr_subsampling_dy = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cp->enumcs = ENUMCS_SYCC;
|
|
||||||
|
|
||||||
cp->CbCr_subsampling_dx = 1;
|
|
||||||
cp->CbCr_subsampling_dy = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
goto fin;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else /* GRAY or GRAYA */
|
||||||
{
|
{
|
||||||
cp->enumcs = ENUMCS_GRAY;
|
cp->enumcs = ENUMCS_GRAY;
|
||||||
// cp->CbCr_subsampling_dx = 0;
|
/* cp->CbCr_subsampling_dx = 0; */
|
||||||
// cp->CbCr_subsampling_dy = 0;
|
/* cp->CbCr_subsampling_dy = 0; */
|
||||||
}
|
}
|
||||||
if(image->icc_profile_buf)
|
if(image->icc_profile_buf)
|
||||||
{
|
{
|
||||||
@@ -228,7 +179,9 @@ static void read_siz_marker(FILE *file, opj_image_t *image)
|
|||||||
|
|
||||||
siz_buffer = (unsigned char*) malloc(len * sizeof(unsigned char));
|
siz_buffer = (unsigned char*) malloc(len * sizeof(unsigned char));
|
||||||
fread(siz_buffer,len, 1, file);
|
fread(siz_buffer,len, 1, file);
|
||||||
cio = opj_cio_open(NULL, siz_buffer, len);
|
cio = opj_cio_open(NULL, siz_buffer, len);
|
||||||
|
|
||||||
|
if(cio == NULL) goto fin;
|
||||||
|
|
||||||
cio_read(cio, 2); /* Rsiz (capabilities) */
|
cio_read(cio, 2); /* Rsiz (capabilities) */
|
||||||
image->x1 = cio_read(cio, 4); /* Xsiz */
|
image->x1 = cio_read(cio, 4); /* Xsiz */
|
||||||
@@ -252,7 +205,9 @@ static void read_siz_marker(FILE *file, opj_image_t *image)
|
|||||||
image->comps[i].factor = 0; /* reducing factor by component */
|
image->comps[i].factor = 0; /* reducing factor by component */
|
||||||
}
|
}
|
||||||
fseek(file, 0, SEEK_SET);
|
fseek(file, 0, SEEK_SET);
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
fin:
|
||||||
free(siz_buffer);
|
free(siz_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,50 +216,28 @@ static void setparams(opj_mj2_t *movie, opj_image_t *image) {
|
|||||||
|
|
||||||
movie->tk[0].w = int_ceildiv(image->x1 - image->x0, image->comps[0].dx);
|
movie->tk[0].w = int_ceildiv(image->x1 - image->x0, image->comps[0].dx);
|
||||||
movie->tk[0].h = int_ceildiv(image->y1 - image->y0, image->comps[0].dy);
|
movie->tk[0].h = int_ceildiv(image->y1 - image->y0, image->comps[0].dy);
|
||||||
|
|
||||||
mj2_init_stdmovie(movie);
|
mj2_init_stdmovie(movie);
|
||||||
|
|
||||||
movie->tk[0].depth = image->comps[0].prec;
|
movie->tk[0].depth = image->comps[0].prec;
|
||||||
|
|
||||||
if (image->numcomps==3) {
|
movie->tk[0].CbCr_subsampling_dx = 0;
|
||||||
if ((image->comps[0].dx == 1)
|
movie->tk[0].CbCr_subsampling_dy = 0;
|
||||||
&& (image->comps[1].dx == 1)
|
|
||||||
&& (image->comps[2].dx == 1))
|
|
||||||
movie->tk[0].CbCr_subsampling_dx = 1;
|
|
||||||
else
|
|
||||||
if ((image->comps[0].dx == 1)
|
|
||||||
&& (image->comps[1].dx == 2)
|
|
||||||
&& (image->comps[2].dx == 2))
|
|
||||||
movie->tk[0].CbCr_subsampling_dx = 2;
|
|
||||||
else
|
|
||||||
fprintf(stderr,"Image component sizes are incoherent\n");
|
|
||||||
|
|
||||||
if ((image->comps[0].dy == 1)
|
|
||||||
&& (image->comps[1].dy == 1)
|
|
||||||
&& (image->comps[2].dy == 1))
|
|
||||||
movie->tk[0].CbCr_subsampling_dy = 1;
|
|
||||||
else
|
|
||||||
if ((image->comps[0].dy == 1)
|
|
||||||
&& (image->comps[1].dy == 2)
|
|
||||||
&& (image->comps[2].dy == 2))
|
|
||||||
movie->tk[0].CbCr_subsampling_dy = 2;
|
|
||||||
else
|
|
||||||
fprintf(stderr,"Image component sizes are incoherent\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
movie->tk[0].sample_rate = 25;
|
movie->tk[0].sample_rate = 25;
|
||||||
|
|
||||||
movie->tk[0].jp2_struct.numcomps = image->numcomps; // NC
|
movie->tk[0].jp2_struct.numcomps = image->numcomps;/* NC */
|
||||||
|
|
||||||
/* Init Standard jp2 structure */
|
/* Init Standard jp2 structure */
|
||||||
|
|
||||||
movie->tk[0].jp2_struct.comps =
|
movie->tk[0].jp2_struct.comps = (opj_jp2_comps_t *)
|
||||||
(opj_jp2_comps_t *) malloc(movie->tk[0].jp2_struct.numcomps * sizeof(opj_jp2_comps_t));
|
malloc(movie->tk[0].jp2_struct.numcomps * sizeof(opj_jp2_comps_t));
|
||||||
movie->tk[0].jp2_struct.precedence = 0; /* PRECEDENCE*/
|
movie->tk[0].jp2_struct.precedence = 0; /* PRECEDENCE*/
|
||||||
movie->tk[0].jp2_struct.approx = 0; /* APPROX*/
|
movie->tk[0].jp2_struct.approx = 0; /* APPROX*/
|
||||||
movie->tk[0].jp2_struct.brand = JP2_JP2; /* BR */
|
movie->tk[0].jp2_struct.brand = JP2_JP2; /* BR */
|
||||||
movie->tk[0].jp2_struct.minversion = 0; /* MinV */
|
movie->tk[0].jp2_struct.minversion = 0; /* MinV */
|
||||||
movie->tk[0].jp2_struct.numcl = 1;
|
movie->tk[0].jp2_struct.numcl = 1;
|
||||||
movie->tk[0].jp2_struct.cl = (unsigned int *) malloc(movie->tk[0].jp2_struct.numcl * sizeof(int));
|
movie->tk[0].jp2_struct.cl = (unsigned int *)
|
||||||
|
malloc(movie->tk[0].jp2_struct.numcl * sizeof(int));
|
||||||
movie->tk[0].jp2_struct.cl[0] = JP2_JP2; /* CL0 : JP2 */
|
movie->tk[0].jp2_struct.cl[0] = JP2_JP2; /* CL0 : JP2 */
|
||||||
movie->tk[0].jp2_struct.C = 7; /* C : Always 7*/
|
movie->tk[0].jp2_struct.C = 7; /* C : Always 7*/
|
||||||
movie->tk[0].jp2_struct.UnkC = 0; /* UnkC, colorspace specified in colr box*/
|
movie->tk[0].jp2_struct.UnkC = 0; /* UnkC, colorspace specified in colr box*/
|
||||||
@@ -333,29 +266,6 @@ static void setparams(opj_mj2_t *movie, opj_image_t *image) {
|
|||||||
else
|
else
|
||||||
movie->tk[0].jp2_struct.meth = 2;
|
movie->tk[0].jp2_struct.meth = 2;
|
||||||
|
|
||||||
if (image->numcomps == 1)
|
|
||||||
movie->tk[0].jp2_struct.enumcs = 17; // Grayscale
|
|
||||||
|
|
||||||
else
|
|
||||||
if ((image->comps[0].dx == 1)
|
|
||||||
&& (image->comps[1].dx == 1)
|
|
||||||
&& (image->comps[2].dx == 1)
|
|
||||||
&& (image->comps[0].dy == 1)
|
|
||||||
&& (image->comps[1].dy == 1)
|
|
||||||
&& (image->comps[2].dy == 1))
|
|
||||||
movie->tk[0].jp2_struct.enumcs = 16; // RGB
|
|
||||||
|
|
||||||
else
|
|
||||||
if ((image->comps[0].dx == 1)
|
|
||||||
&& (image->comps[1].dx == 2)
|
|
||||||
&& (image->comps[2].dx == 2)
|
|
||||||
&& (image->comps[0].dy == 1)
|
|
||||||
&& (image->comps[1].dy == 2)
|
|
||||||
&& (image->comps[2].dy == 2))
|
|
||||||
movie->tk[0].jp2_struct.enumcs = 18; // YUV
|
|
||||||
|
|
||||||
else
|
|
||||||
movie->tk[0].jp2_struct.enumcs = 0; // Unkown profile */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
@@ -368,14 +278,14 @@ int main(int argc, char *argv[]) {
|
|||||||
FILE *mj2file, *j2kfile;
|
FILE *mj2file, *j2kfile;
|
||||||
char *j2kfilename;
|
char *j2kfilename;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
int offset, mdat_initpos;
|
int offset, mdat_initpos, failed;
|
||||||
opj_image_t img;
|
opj_image_t img;
|
||||||
opj_cio_t *cio;
|
opj_cio_t *cio;
|
||||||
mj2_cparameters_t parameters;
|
mj2_cparameters_t parameters;
|
||||||
|
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
printf("Usage: %s source_location mj2_filename\n",argv[0]);
|
printf("\nUsage: %s source_location mj2_filename\n",argv[0]);
|
||||||
printf("Example: %s input/input output.mj2\n",argv[0]);
|
printf("Example: %s input/input output.mj2\n\n",argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,6 +295,7 @@ int main(int argc, char *argv[]) {
|
|||||||
fprintf(stderr, "failed to open %s for writing\n", argv[2]);
|
fprintf(stderr, "failed to open %s for writing\n", argv[2]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
failed = 1;
|
||||||
memset(&img, 0, sizeof(opj_image_t));
|
memset(&img, 0, sizeof(opj_image_t));
|
||||||
/*
|
/*
|
||||||
configure the event callbacks (not required)
|
configure the event callbacks (not required)
|
||||||
@@ -398,6 +309,8 @@ int main(int argc, char *argv[]) {
|
|||||||
/* get a MJ2 decompressor handle */
|
/* get a MJ2 decompressor handle */
|
||||||
cinfo = mj2_create_compress();
|
cinfo = mj2_create_compress();
|
||||||
|
|
||||||
|
if(cinfo == NULL) goto fin;
|
||||||
|
|
||||||
/* catch events using our callbacks and give a local context */
|
/* catch events using our callbacks and give a local context */
|
||||||
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
|
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
|
||||||
|
|
||||||
@@ -406,7 +319,7 @@ int main(int argc, char *argv[]) {
|
|||||||
movie = (opj_mj2_t*) cinfo->mj2_handle;
|
movie = (opj_mj2_t*) cinfo->mj2_handle;
|
||||||
|
|
||||||
j2kfilename = (char*)malloc(strlen(argv[1]) + 12);/* max. '%6d' */
|
j2kfilename = (char*)malloc(strlen(argv[1]) + 12);/* max. '%6d' */
|
||||||
sprintf(j2kfilename, "%s_00001.j2k",argv[1]);
|
sprintf(j2kfilename, "%s_00000.j2k",argv[1]);
|
||||||
|
|
||||||
if(test_image(j2kfilename, ¶meters) == 0) goto fin;
|
if(test_image(j2kfilename, ¶meters) == 0) goto fin;
|
||||||
|
|
||||||
@@ -415,11 +328,18 @@ int main(int argc, char *argv[]) {
|
|||||||
mj2_setup_encoder(movie, ¶meters);
|
mj2_setup_encoder(movie, ¶meters);
|
||||||
|
|
||||||
|
|
||||||
/* Writing JP, FTYP and MDAT boxes
|
/* Writing JP, FTYP and MDAT boxes
|
||||||
Assuming that the JP and FTYP boxes won't be longer than 300 bytes */
|
Assuming that the JP and FTYP boxes won't be longer than 300 bytes
|
||||||
|
*/
|
||||||
|
|
||||||
buf = (unsigned char*) malloc (300 * sizeof(unsigned char));
|
buf = (unsigned char*) malloc (300 * sizeof(unsigned char));
|
||||||
|
|
||||||
|
if(buf == NULL) goto fin;
|
||||||
|
|
||||||
cio = opj_cio_open(movie->cinfo, buf, 300);
|
cio = opj_cio_open(movie->cinfo, buf, 300);
|
||||||
|
|
||||||
|
if(cio == NULL) goto fin;
|
||||||
|
|
||||||
mj2_write_jp(cio);
|
mj2_write_jp(cio);
|
||||||
mj2_write_ftyp(movie, cio);
|
mj2_write_ftyp(movie, cio);
|
||||||
mdat_initpos = cio_tell(cio);
|
mdat_initpos = cio_tell(cio);
|
||||||
@@ -428,7 +348,7 @@ int main(int argc, char *argv[]) {
|
|||||||
fwrite(buf,cio_tell(cio),1,mj2file);
|
fwrite(buf,cio_tell(cio),1,mj2file);
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
// Insert each j2k codestream in a JP2C box
|
/* Insert each j2k codestream in a JP2C box */
|
||||||
snum=0;
|
snum=0;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
while(1)
|
while(1)
|
||||||
@@ -436,43 +356,44 @@ int main(int argc, char *argv[]) {
|
|||||||
sample = &movie->tk[0].sample[snum];
|
sample = &movie->tk[0].sample[snum];
|
||||||
sprintf(j2kfilename,"%s_%05d.j2k",argv[1],snum);
|
sprintf(j2kfilename,"%s_%05d.j2k",argv[1],snum);
|
||||||
j2kfile = fopen(j2kfilename, "rb");
|
j2kfile = fopen(j2kfilename, "rb");
|
||||||
if (!j2kfile) {
|
if (!j2kfile)
|
||||||
if (snum==0) { // Could not open a single codestream
|
{
|
||||||
fprintf(stderr, "failed to open %s for reading\n",j2kfilename);
|
/* No more files found: done. Leave while(1) loop: */
|
||||||
return 1;
|
fprintf(stdout,"%d frames are being added to the MJ2 file\n",snum);
|
||||||
}
|
break;
|
||||||
else { // Tried to open a inexistant codestream
|
}
|
||||||
fprintf(stdout,"%d frames are being added to the MJ2 file\n",snum);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculating offset for samples and chunks
|
/* Calculating offset for samples and chunks: */
|
||||||
offset += cio_tell(cio);
|
offset += cio_tell(cio);
|
||||||
sample->offset = offset;
|
sample->offset = offset;
|
||||||
movie->tk[0].chunk[snum].offset = offset; // There will be one sample per chunk
|
/* There will be one sample per chunk: */
|
||||||
|
movie->tk[0].chunk[snum].offset = offset;
|
||||||
|
|
||||||
// Calculating sample size
|
/* Calculating sample size: */
|
||||||
fseek(j2kfile,0,SEEK_END);
|
fseek(j2kfile,0,SEEK_END);
|
||||||
sample->sample_size = ftell(j2kfile) + 8; // Sample size is codestream + JP2C box header
|
/* Sample size is codestream + JP2C box header: */
|
||||||
|
sample->sample_size = ftell(j2kfile) + 8;
|
||||||
fseek(j2kfile,0,SEEK_SET);
|
fseek(j2kfile,0,SEEK_SET);
|
||||||
|
|
||||||
// Reading siz marker of j2k image for the first codestream
|
/* Reading siz marker of j2k image for the first codestream */
|
||||||
if (snum==0)
|
if (snum==0)
|
||||||
read_siz_marker(j2kfile, &img);
|
read_siz_marker(j2kfile, &img);
|
||||||
|
|
||||||
// Writing JP2C box header
|
frame_codestream = (unsigned char*)
|
||||||
frame_codestream = (unsigned char*) malloc (sample->sample_size+8);
|
malloc (sample->sample_size+8);
|
||||||
cio = opj_cio_open(movie->cinfo, frame_codestream, sample->sample_size);
|
cio = opj_cio_open(movie->cinfo, frame_codestream, sample->sample_size);
|
||||||
cio_write(cio,sample->sample_size, 4); // Sample size
|
|
||||||
cio_write(cio,JP2_JP2C, 4); // JP2C
|
|
||||||
|
|
||||||
// Writing codestream from J2K file to MJ2 file
|
if(cio == NULL) goto fin;
|
||||||
|
|
||||||
|
/* Writing JP2C box header: */
|
||||||
|
cio_write(cio,sample->sample_size, 4);
|
||||||
|
cio_write(cio,JP2_JP2C, 4);
|
||||||
|
|
||||||
|
/* Writing codestream from J2K file to MJ2 file */
|
||||||
fread(frame_codestream+8,sample->sample_size-8,1,j2kfile);
|
fread(frame_codestream+8,sample->sample_size-8,1,j2kfile);
|
||||||
fwrite(frame_codestream,sample->sample_size,1,mj2file);
|
fwrite(frame_codestream,sample->sample_size,1,mj2file);
|
||||||
cio_skip(cio, sample->sample_size-8);
|
cio_skip(cio, sample->sample_size-8);
|
||||||
|
|
||||||
// Ending loop
|
|
||||||
fclose(j2kfile);
|
fclose(j2kfile);
|
||||||
snum++;
|
snum++;
|
||||||
movie->tk[0].sample = (mj2_sample_t*)
|
movie->tk[0].sample = (mj2_sample_t*)
|
||||||
@@ -480,37 +401,63 @@ int main(int argc, char *argv[]) {
|
|||||||
movie->tk[0].chunk = (mj2_chunk_t*)
|
movie->tk[0].chunk = (mj2_chunk_t*)
|
||||||
realloc(movie->tk[0].chunk, (snum+1) * sizeof(mj2_chunk_t));
|
realloc(movie->tk[0].chunk, (snum+1) * sizeof(mj2_chunk_t));
|
||||||
free(frame_codestream);
|
free(frame_codestream);
|
||||||
}
|
}/* while(1) */
|
||||||
|
|
||||||
// Writing the MDAT box length in header
|
/* Writing the MDAT box length in header */
|
||||||
offset += cio_tell(cio);
|
offset += cio_tell(cio);
|
||||||
buf = (unsigned char*) malloc (4 * sizeof(unsigned char));
|
buf = (unsigned char*) malloc (4 * sizeof(unsigned char));
|
||||||
cio = opj_cio_open(movie->cinfo, buf, 4);
|
|
||||||
|
if(buf == NULL) goto fin;
|
||||||
|
|
||||||
|
cio = opj_cio_open(movie->cinfo, buf, 4);
|
||||||
|
|
||||||
|
if(cio == NULL) goto fin;
|
||||||
|
|
||||||
cio_write(cio,offset-mdat_initpos,4);
|
cio_write(cio,offset-mdat_initpos,4);
|
||||||
fseek(mj2file,(long)mdat_initpos,SEEK_SET);
|
fseek(mj2file,(long)mdat_initpos,SEEK_SET);
|
||||||
fwrite(buf,4,1,mj2file);
|
fwrite(buf,4,1,mj2file);
|
||||||
fseek(mj2file,0,SEEK_END);
|
fseek(mj2file,0,SEEK_END);
|
||||||
free(buf);
|
|
||||||
|
|
||||||
// Setting movie parameters
|
/* if(cio->openmode == OPJ_STREAM_READ) */ free(buf);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* Setting movie parameters: */
|
||||||
movie->tk[0].num_samples=snum;
|
movie->tk[0].num_samples=snum;
|
||||||
movie->tk[0].num_chunks=snum;
|
movie->tk[0].num_chunks=snum;
|
||||||
setparams(movie, &img);
|
setparams(movie, &img);
|
||||||
|
|
||||||
// Writing MOOV box
|
/* Writing MOOV box */
|
||||||
buf = (unsigned char*) malloc ((TEMP_BUF+snum*20) * sizeof(unsigned char));
|
buf = (unsigned char*) malloc ((TEMP_BUF+snum*20) * sizeof(unsigned char));
|
||||||
cio = opj_cio_open(movie->cinfo, buf, (TEMP_BUF+snum*20));
|
|
||||||
mj2_write_moov(movie, cio);
|
if(buf == NULL) goto fin;
|
||||||
|
|
||||||
|
cio = opj_cio_open(movie->cinfo, buf, (TEMP_BUF+snum*20));
|
||||||
|
|
||||||
|
if(cio == NULL) goto fin;
|
||||||
|
|
||||||
|
mj2_write_moov(movie, cio);
|
||||||
fwrite(buf,cio_tell(cio),1,mj2file);
|
fwrite(buf,cio_tell(cio),1,mj2file);
|
||||||
|
|
||||||
// Ending program
|
|
||||||
free(img.comps);
|
free(img.comps);
|
||||||
|
|
||||||
|
/* if(cio->openmode == OPJ_STREAM_READ) */ free(buf);
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
failed = 0; buf = NULL;
|
||||||
|
|
||||||
fin:
|
fin:
|
||||||
fclose(mj2file);
|
fclose(mj2file);
|
||||||
mj2_destroy_compress(movie);
|
|
||||||
|
if(failed) remove(argv[2]);
|
||||||
|
|
||||||
|
if(buf) free(buf);
|
||||||
|
|
||||||
|
if(cinfo)
|
||||||
|
{
|
||||||
|
mj2_destroy_compress(movie);
|
||||||
|
free(cinfo);
|
||||||
|
}
|
||||||
free(j2kfilename);
|
free(j2kfilename);
|
||||||
|
|
||||||
return 0;
|
return failed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ IF(DOXYGEN_FOUND)
|
|||||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.dox.cmake.in
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.dox.cmake.in
|
||||||
${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox @ONLY)
|
${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox @ONLY)
|
||||||
|
|
||||||
|
# Configure the html mainpage file of the doxygen documentation with variable
|
||||||
|
# from CMake and move it
|
||||||
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mainpage.dox.cmake
|
||||||
|
${CMAKE_BINARY_DIR}/doc/mainpage.dox @ONLY)
|
||||||
|
|
||||||
# Generate new target to build the html documentation
|
# Generate new target to build the html documentation
|
||||||
ADD_CUSTOM_TARGET(doc ALL
|
ADD_CUSTOM_TARGET(doc ALL
|
||||||
${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox)
|
${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox)
|
||||||
|
|||||||
@@ -101,11 +101,12 @@ WARN_LOGFILE =
|
|||||||
# configuration options related to the input files
|
# configuration options related to the input files
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
INPUT = @OPENJPEG_SOURCE_DIR@/libopenjpeg \
|
INPUT = @OPENJPEG_SOURCE_DIR@/libopenjpeg \
|
||||||
@OPENJPEG_SOURCE_DIR@/libopenjpeg/jpwl
|
@OPENJPEG_BINARY_DIR@/doc
|
||||||
INPUT_ENCODING = UTF-8
|
INPUT_ENCODING = UTF-8
|
||||||
FILE_PATTERNS = *.h \
|
FILE_PATTERNS = *.h \
|
||||||
*.c
|
*.c \
|
||||||
RECURSIVE = NO
|
*.dox
|
||||||
|
RECURSIVE = YES
|
||||||
EXCLUDE =
|
EXCLUDE =
|
||||||
EXCLUDE_SYMLINKS = NO
|
EXCLUDE_SYMLINKS = NO
|
||||||
EXCLUDE_PATTERNS =
|
EXCLUDE_PATTERNS =
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ doc:
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
docsdir = $(docdir)-$(MAJOR_NR).$(MINOR_NR)
|
docsdir = $(docdir)-$(MAJOR_NR).$(MINOR_NR)
|
||||||
docs_DATA = $(top_builddir)/LICENSE $(top_builddir)/CHANGES
|
docs_DATA = $(top_builddir)/LICENSE
|
||||||
|
|
||||||
dist_man1_MANS = \
|
dist_man1_MANS = \
|
||||||
man/man1/image_to_j2k.1 \
|
man/man1/image_to_j2k.1 \
|
||||||
|
|||||||
62
doc/mainpage.dox.cmake
Normal file
62
doc/mainpage.dox.cmake
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* $Id: mainpage.dox.cmake 2011-09-21 Mickael Savinaud $
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2011, Mickael Savinaud, Communications & Systemes <mickael.savinaud@c-s.fr>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \mainpage OpenJPEG v@OPENJPEG_VERSION@ Documentation
|
||||||
|
*
|
||||||
|
* \section intro Introduction
|
||||||
|
* This manual documents the low-level OpenJPEG C API.\n
|
||||||
|
* The OpenJPEG library is an open-source JPEG 2000 library developed in order to promote the use of JPEG 2000.\n
|
||||||
|
* This documents is focused on the main part of the library which try to implement Part 1 and Part 2 of the JPEG2000 norm.\n
|
||||||
|
*
|
||||||
|
* \section home Home page
|
||||||
|
*
|
||||||
|
* The Home Page of the OpenJPEG library can be found at:
|
||||||
|
*
|
||||||
|
* http://code.google.com/p/openjpeg/
|
||||||
|
*
|
||||||
|
* More information about the OpenJPEG library is available here:
|
||||||
|
*
|
||||||
|
* http://www.openjpeg.org/
|
||||||
|
*
|
||||||
|
* The OpenJPEG mailing list is located here:
|
||||||
|
*
|
||||||
|
* http://groups.google.com/group/openjpeg
|
||||||
|
*
|
||||||
|
* All the source code is online and can be retrieved using svn from here:
|
||||||
|
*
|
||||||
|
* http://openjpeg.googlecode.com/svn/
|
||||||
|
*
|
||||||
|
* \section license License
|
||||||
|
* This software is released under the BSD license, anybody can use or modify the library, even for commercial applications.\n
|
||||||
|
* The only restriction is to retain the copyright in the sources or the binaries documentation.\n
|
||||||
|
* Neither the author, nor the university accept any responsibility for any kind of error or data loss which may occur during usage.
|
||||||
|
*
|
||||||
|
* \author OpenJPEG Team
|
||||||
|
*
|
||||||
|
*/
|
||||||
@@ -49,7 +49,7 @@ Valid output image extensions are
|
|||||||
.P
|
.P
|
||||||
.B image_to_j2k -h \fRPrint a help message and exit.
|
.B image_to_j2k -h \fRPrint a help message and exit.
|
||||||
.P
|
.P
|
||||||
.R See JPWL OPTIONS for special options
|
See JPWL OPTIONS for special options
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.B \-\^b " n,n"
|
.B \-\^b " n,n"
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ Valid output image extensions are
|
|||||||
.P
|
.P
|
||||||
.B j2k_to_image -h \fRPrint help message and exit
|
.B j2k_to_image -h \fRPrint help message and exit
|
||||||
.P
|
.P
|
||||||
.R See JPWL OPTIONS for special options
|
See JPWL OPTIONS for special options
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.B \-\^i "name"
|
.B \-\^i "name"
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ a library for reading and writing JPEG2000 image files.
|
|||||||
.B CLRSPC_UNKNOWN\fR or \fBCLRSPC_UNSPECIFIED\fR or \fBCLRSPC_SRGB\fR or \fBCLRSPC_GRAY\fR or \fBCLRSPC_SYCC
|
.B CLRSPC_UNKNOWN\fR or \fBCLRSPC_UNSPECIFIED\fR or \fBCLRSPC_SRGB\fR or \fBCLRSPC_GRAY\fR or \fBCLRSPC_SYCC
|
||||||
.P
|
.P
|
||||||
.SH DECOMPRESSION PARAMETERS
|
.SH DECOMPRESSION PARAMETERS
|
||||||
.p
|
.P
|
||||||
typedef struct opj_dparameters
|
typedef struct opj_dparameters
|
||||||
.br
|
.br
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
prefix=@prefix@
|
prefix=@prefix@
|
||||||
exec_prefix=@exec_prefix@
|
exec_prefix=@exec_prefix@
|
||||||
libdir=@libdir@
|
libdir=@libdir@
|
||||||
includedir=@includedir@
|
includedir=@includedir@/openjpeg-@MAJOR_NR@.@MINOR_NR@
|
||||||
|
|
||||||
Name: openjpeg
|
Name: openjpeg
|
||||||
Description: JPEG2000 Wireless (Part 11 - JPWL) library
|
Description: JPEG2000 Wireless (Part 11 - JPWL) library
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}
|
|||||||
|
|
||||||
# Install includes files
|
# Install includes files
|
||||||
INSTALL(FILES openjpeg.h
|
INSTALL(FILES openjpeg.h
|
||||||
DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR}/${OPENJPEG_INSTALL_SUBDIR} COMPONENT Headers
|
DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers
|
||||||
)
|
)
|
||||||
|
|
||||||
# install man page of the library
|
# install man page of the library
|
||||||
|
|||||||
@@ -73,10 +73,7 @@ EXTRA_DIST = \
|
|||||||
CMakeLists.txt
|
CMakeLists.txt
|
||||||
|
|
||||||
install-data-hook:
|
install-data-hook:
|
||||||
cd $(DESTDIR)$(includedir) && \
|
cd $(DESTDIR)$(includedir) && rm -f openjpeg.h
|
||||||
rm -f openjpeg.h && \
|
|
||||||
$(LN_S) openjpeg-$(MAJOR_NR).$(MINOR_NR)/openjpeg.h \
|
|
||||||
openjpeg.h
|
|
||||||
@rm -rf $(top_builddir)/report.txt
|
@rm -rf $(top_builddir)/report.txt
|
||||||
@echo -e " (LA)\t$(libdir)/libopenjpeg.la" >> $(top_builddir)/report.txt
|
@echo -e " (LA)\t$(libdir)/libopenjpeg.la" >> $(top_builddir)/report.txt
|
||||||
if BUILD_SHARED
|
if BUILD_SHARED
|
||||||
@@ -86,7 +83,6 @@ if BUILD_STATIC
|
|||||||
@echo -e " (A)\t$(base)/$(a)" >> $(top_builddir)/report.txt
|
@echo -e " (A)\t$(base)/$(a)" >> $(top_builddir)/report.txt
|
||||||
endif
|
endif
|
||||||
@echo -e " (H)\t$(includedir)/openjpeg-$(MAJOR_NR).$(MINOR_NR)/openjpeg.h" >> $(top_builddir)/report.txt
|
@echo -e " (H)\t$(includedir)/openjpeg-$(MAJOR_NR).$(MINOR_NR)/openjpeg.h" >> $(top_builddir)/report.txt
|
||||||
@echo -e " (LN)\t$(includedir)/openjpeg.h" >> $(top_builddir)/report.txt
|
|
||||||
|
|
||||||
uninstall-hook:
|
uninstall-hook:
|
||||||
rm -f $(DESTDIR)$(includedir)/openjpeg.h
|
rm -f $(DESTDIR)$(includedir)/openjpeg.h
|
||||||
|
|||||||
@@ -29,8 +29,6 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "opj_includes.h"
|
#include "opj_includes.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ unsigned char cio_bytein(opj_cio_t *cio) {
|
|||||||
* v : value to write
|
* v : value to write
|
||||||
* n : number of bytes to write
|
* n : number of bytes to write
|
||||||
*/
|
*/
|
||||||
unsigned int cio_write(opj_cio_t *cio, unsigned long long int v, int n) {
|
unsigned int cio_write(opj_cio_t *cio, unsigned int64 v, int n) {
|
||||||
int i;
|
int i;
|
||||||
for (i = n - 1; i >= 0; i--) {
|
for (i = n - 1; i >= 0; i--) {
|
||||||
if( !cio_byteout(cio, (unsigned char) ((v >> (i << 3)) & 0xff)) )
|
if( !cio_byteout(cio, (unsigned char) ((v >> (i << 3)) & 0xff)) )
|
||||||
|
|||||||
@@ -31,6 +31,13 @@
|
|||||||
|
|
||||||
#ifndef __CIO_H
|
#ifndef __CIO_H
|
||||||
#define __CIO_H
|
#define __CIO_H
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||||
|
#define int64 __int64
|
||||||
|
#else
|
||||||
|
#define int64 long long
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@file cio.h
|
@file cio.h
|
||||||
@brief Implementation of a byte input-output process (CIO)
|
@brief Implementation of a byte input-output process (CIO)
|
||||||
@@ -63,7 +70,7 @@ Write some bytes
|
|||||||
@param n Number of bytes to write
|
@param n Number of bytes to write
|
||||||
@return Returns the number of bytes written or 0 if an error occured
|
@return Returns the number of bytes written or 0 if an error occured
|
||||||
*/
|
*/
|
||||||
unsigned int cio_write(opj_cio_t *cio, unsigned long long int v, int n);
|
unsigned int cio_write(opj_cio_t *cio, unsigned int64 v, int n);
|
||||||
/**
|
/**
|
||||||
Read some bytes
|
Read some bytes
|
||||||
@param cio CIO handle
|
@param cio CIO handle
|
||||||
|
|||||||
@@ -103,18 +103,17 @@ opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ..
|
|||||||
va_list arg;
|
va_list arg;
|
||||||
int str_length/*, i, j*/; /* UniPG */
|
int str_length/*, i, j*/; /* UniPG */
|
||||||
char message[MSG_SIZE];
|
char message[MSG_SIZE];
|
||||||
memset(message, 0, MSG_SIZE);
|
|
||||||
/* initialize the optional parameter list */
|
/* initialize the optional parameter list */
|
||||||
va_start(arg, fmt);
|
va_start(arg, fmt);
|
||||||
/* check the length of the format string */
|
|
||||||
str_length = (strlen(fmt) > MSG_SIZE) ? MSG_SIZE : strlen(fmt);
|
|
||||||
/* parse the format string and put the result in 'message' */
|
/* parse the format string and put the result in 'message' */
|
||||||
vsprintf(message, fmt, arg); /* UniPG */
|
str_length = vsnprintf(message, MSG_SIZE, fmt, arg); /* UniPG */
|
||||||
/* deinitialize the optional parameter list */
|
/* deinitialize the optional parameter list */
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
|
|
||||||
/* output the message to the user program */
|
/* output the message to the user program */
|
||||||
msg_handler(message, cinfo->client_data);
|
if( str_length > -1 && str_length < MSG_SIZE )
|
||||||
|
msg_handler(message, cinfo->client_data);
|
||||||
|
else return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OPJ_TRUE;
|
return OPJ_TRUE;
|
||||||
|
|||||||
@@ -558,7 +558,17 @@ static void j2k_read_siz(opj_j2k_t *j2k) {
|
|||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
|
|
||||||
cp->tcps = (opj_tcp_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tcp_t));
|
cp->tcps = (opj_tcp_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tcp_t));
|
||||||
|
if (cp->tcps == NULL)
|
||||||
|
{
|
||||||
|
opj_event_msg(j2k->cinfo, EVT_ERROR, "Out of memory\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
cp->tileno = (int*) opj_malloc(cp->tw * cp->th * sizeof(int));
|
cp->tileno = (int*) opj_malloc(cp->tw * cp->th * sizeof(int));
|
||||||
|
if (cp->tileno == NULL)
|
||||||
|
{
|
||||||
|
opj_event_msg(j2k->cinfo, EVT_ERROR, "Out of memory\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
cp->tileno_size = 0;
|
cp->tileno_size = 0;
|
||||||
|
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
@@ -684,6 +694,12 @@ static void j2k_read_cox(opj_j2k_t *j2k, int compno) {
|
|||||||
"of resolutions of this component\nModify the cp_reduce parameter.\n\n", compno);
|
"of resolutions of this component\nModify the cp_reduce parameter.\n\n", compno);
|
||||||
j2k->state |= J2K_STATE_ERR;
|
j2k->state |= J2K_STATE_ERR;
|
||||||
}
|
}
|
||||||
|
if( tccp->numresolutions > J2K_MAXRLVLS ) {
|
||||||
|
opj_event_msg(j2k->cinfo, EVT_ERROR, "Error decoding component %d.\nThe number of resolutions is too big: %d vs max= %d. Truncating.\n\n",
|
||||||
|
compno, tccp->numresolutions, J2K_MAXRLVLS);
|
||||||
|
j2k->state |= J2K_STATE_ERR;
|
||||||
|
tccp->numresolutions = J2K_MAXRLVLS;
|
||||||
|
}
|
||||||
|
|
||||||
tccp->cblkw = cio_read(cio, 1) + 2; /* SPcox (E) */
|
tccp->cblkw = cio_read(cio, 1) + 2; /* SPcox (E) */
|
||||||
tccp->cblkh = cio_read(cio, 1) + 2; /* SPcox (F) */
|
tccp->cblkh = cio_read(cio, 1) + 2; /* SPcox (F) */
|
||||||
@@ -1269,7 +1285,7 @@ static void j2k_read_sot(opj_j2k_t *j2k) {
|
|||||||
static int backup_tileno = 0;
|
static int backup_tileno = 0;
|
||||||
|
|
||||||
/* tileno is negative or larger than the number of tiles!!! */
|
/* tileno is negative or larger than the number of tiles!!! */
|
||||||
if ((tileno < 0) || (tileno > (cp->tw * cp->th))) {
|
if ((tileno < 0) || (tileno >= (cp->tw * cp->th))) {
|
||||||
opj_event_msg(j2k->cinfo, EVT_ERROR,
|
opj_event_msg(j2k->cinfo, EVT_ERROR,
|
||||||
"JPWL: bad tile number (%d out of a maximum of %d)\n",
|
"JPWL: bad tile number (%d out of a maximum of %d)\n",
|
||||||
tileno, (cp->tw * cp->th));
|
tileno, (cp->tw * cp->th));
|
||||||
@@ -1286,8 +1302,18 @@ static void j2k_read_sot(opj_j2k_t *j2k) {
|
|||||||
|
|
||||||
/* keep your private count of tiles */
|
/* keep your private count of tiles */
|
||||||
backup_tileno++;
|
backup_tileno++;
|
||||||
};
|
}
|
||||||
|
else
|
||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
|
{
|
||||||
|
/* tileno is negative or larger than the number of tiles!!! */
|
||||||
|
if ((tileno < 0) || (tileno >= (cp->tw * cp->th))) {
|
||||||
|
opj_event_msg(j2k->cinfo, EVT_ERROR,
|
||||||
|
"JPWL: bad tile number (%d out of a maximum of %d)\n",
|
||||||
|
tileno, (cp->tw * cp->th));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (cp->tileno_size == 0) {
|
if (cp->tileno_size == 0) {
|
||||||
cp->tileno[cp->tileno_size] = tileno;
|
cp->tileno[cp->tileno_size] = tileno;
|
||||||
@@ -1325,8 +1351,18 @@ static void j2k_read_sot(opj_j2k_t *j2k) {
|
|||||||
totlen);
|
totlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
}
|
||||||
|
else
|
||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
|
{
|
||||||
|
/* totlen is negative or larger than the bytes left!!! */
|
||||||
|
if ((totlen < 0) || (totlen > (cio_numbytesleft(cio) + 8))) {
|
||||||
|
opj_event_msg(j2k->cinfo, EVT_ERROR,
|
||||||
|
"JPWL: bad tile byte size (%d bytes against %d bytes left)\n",
|
||||||
|
totlen, cio_numbytesleft(cio) + 8);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!totlen)
|
if (!totlen)
|
||||||
totlen = cio_numbytesleft(cio) + 8;
|
totlen = cio_numbytesleft(cio) + 8;
|
||||||
@@ -1477,6 +1513,24 @@ static void j2k_read_sod(opj_j2k_t *j2k) {
|
|||||||
truncate = 1; /* Case of a truncate codestream */
|
truncate = 1; /* Case of a truncate codestream */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{/* chop padding bytes: */
|
||||||
|
unsigned char *s, *e;
|
||||||
|
|
||||||
|
s = cio_getbp(cio);
|
||||||
|
e = s + len;
|
||||||
|
|
||||||
|
if(len > 8) s = e - 8;
|
||||||
|
|
||||||
|
if(e[-2] == 0x00 && e[-1] == 0x00) /* padding bytes */
|
||||||
|
{
|
||||||
|
while(e > s)
|
||||||
|
{
|
||||||
|
if(e[-2] == 0xff && e[-1] == 0xd9) break;
|
||||||
|
--len; --e; truncate = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data = j2k->tile_data[curtileno];
|
data = j2k->tile_data[curtileno];
|
||||||
data = (unsigned char*) opj_realloc(data, (j2k->tile_len[curtileno] + len) * sizeof(unsigned char));
|
data = (unsigned char*) opj_realloc(data, (j2k->tile_len[curtileno] + len) * sizeof(unsigned char));
|
||||||
|
|
||||||
@@ -1554,7 +1608,7 @@ static void j2k_write_eoc(opj_j2k_t *j2k) {
|
|||||||
|
|
||||||
static void j2k_read_eoc(opj_j2k_t *j2k) {
|
static void j2k_read_eoc(opj_j2k_t *j2k) {
|
||||||
int i, tileno;
|
int i, tileno;
|
||||||
opj_bool success;
|
opj_bool success = OPJ_FALSE;
|
||||||
|
|
||||||
/* if packets should be decoded */
|
/* if packets should be decoded */
|
||||||
if (j2k->cp->limit_decoding != DECODE_ALL_BUT_PACKETS) {
|
if (j2k->cp->limit_decoding != DECODE_ALL_BUT_PACKETS) {
|
||||||
@@ -1562,11 +1616,16 @@ static void j2k_read_eoc(opj_j2k_t *j2k) {
|
|||||||
tcd_malloc_decode(tcd, j2k->image, j2k->cp);
|
tcd_malloc_decode(tcd, j2k->image, j2k->cp);
|
||||||
for (i = 0; i < j2k->cp->tileno_size; i++) {
|
for (i = 0; i < j2k->cp->tileno_size; i++) {
|
||||||
tcd_malloc_decode_tile(tcd, j2k->image, j2k->cp, i, j2k->cstr_info);
|
tcd_malloc_decode_tile(tcd, j2k->image, j2k->cp, i, j2k->cstr_info);
|
||||||
tileno = j2k->cp->tileno[i];
|
if (j2k->cp->tileno[i] != -1)
|
||||||
success = tcd_decode_tile(tcd, j2k->tile_data[tileno], j2k->tile_len[tileno], tileno, j2k->cstr_info);
|
{
|
||||||
opj_free(j2k->tile_data[tileno]);
|
tileno = j2k->cp->tileno[i];
|
||||||
j2k->tile_data[tileno] = NULL;
|
success = tcd_decode_tile(tcd, j2k->tile_data[tileno], j2k->tile_len[tileno], tileno, j2k->cstr_info);
|
||||||
tcd_free_decode_tile(tcd, i);
|
opj_free(j2k->tile_data[tileno]);
|
||||||
|
j2k->tile_data[tileno] = NULL;
|
||||||
|
tcd_free_decode_tile(tcd, i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
success = OPJ_FALSE;
|
||||||
if (success == OPJ_FALSE) {
|
if (success == OPJ_FALSE) {
|
||||||
j2k->state |= J2K_STATE_ERR;
|
j2k->state |= J2K_STATE_ERR;
|
||||||
break;
|
break;
|
||||||
@@ -1737,6 +1796,14 @@ void j2k_destroy_decompress(opj_j2k_t *j2k) {
|
|||||||
opj_free(j2k->tile_len);
|
opj_free(j2k->tile_len);
|
||||||
}
|
}
|
||||||
if(j2k->tile_data != NULL) {
|
if(j2k->tile_data != NULL) {
|
||||||
|
if(j2k->cp != NULL) {
|
||||||
|
for (i = 0; i < j2k->cp->tileno_size; i++) {
|
||||||
|
int tileno = j2k->cp->tileno[i];
|
||||||
|
opj_free(j2k->tile_data[tileno]);
|
||||||
|
j2k->tile_data[tileno] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
opj_free(j2k->tile_data);
|
opj_free(j2k->tile_data);
|
||||||
}
|
}
|
||||||
if(j2k->default_tcp != NULL) {
|
if(j2k->default_tcp != NULL) {
|
||||||
@@ -1856,9 +1923,15 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c
|
|||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
|
|
||||||
if (id >> 8 != 0xff) {
|
if (id >> 8 != 0xff) {
|
||||||
opj_image_destroy(image);
|
if(cio_numbytesleft(cio) != 0) /* not end of file reached and no EOC */
|
||||||
opj_event_msg(cinfo, EVT_ERROR, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id);
|
{
|
||||||
return 0;
|
opj_event_msg(cinfo, EVT_ERROR, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id);
|
||||||
|
opj_image_destroy(image);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
opj_event_msg(cinfo, EVT_WARNING, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id);
|
||||||
|
j2k->state = J2K_STATE_NEOC;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
e = j2k_dec_mstab_lookup(id);
|
e = j2k_dec_mstab_lookup(id);
|
||||||
/* Check if the marker is known*/
|
/* Check if the marker is known*/
|
||||||
@@ -1877,7 +1950,10 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c
|
|||||||
(*e->handler)(j2k);
|
(*e->handler)(j2k);
|
||||||
}
|
}
|
||||||
if (j2k->state & J2K_STATE_ERR)
|
if (j2k->state & J2K_STATE_ERR)
|
||||||
|
{
|
||||||
|
opj_image_destroy(image);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (j2k->state == J2K_STATE_MT) {
|
if (j2k->state == J2K_STATE_MT) {
|
||||||
break;
|
break;
|
||||||
@@ -1949,9 +2025,15 @@ opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestre
|
|||||||
|
|
||||||
id = cio_read(cio, 2);
|
id = cio_read(cio, 2);
|
||||||
if (id >> 8 != 0xff) {
|
if (id >> 8 != 0xff) {
|
||||||
opj_image_destroy(image);
|
if(cio_numbytesleft(cio) != 0) /* no end of file reached and no EOC */
|
||||||
opj_event_msg(cinfo, EVT_ERROR, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id);
|
{
|
||||||
return 0;
|
opj_event_msg(cinfo, EVT_ERROR, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id);
|
||||||
|
opj_image_destroy(image);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
opj_event_msg(cinfo, EVT_WARNING, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id);
|
||||||
|
j2k->state = J2K_STATE_NEOC;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
e = j2k_dec_mstab_lookup(id);
|
e = j2k_dec_mstab_lookup(id);
|
||||||
if (!(j2k->state & e->states)) {
|
if (!(j2k->state & e->states)) {
|
||||||
|
|||||||
@@ -206,7 +206,10 @@ static opj_bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio) {
|
|||||||
|
|
||||||
opj_common_ptr cinfo = jp2->cinfo;
|
opj_common_ptr cinfo = jp2->cinfo;
|
||||||
|
|
||||||
jp2_read_boxhdr(cinfo, cio, &box);
|
if(jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) {
|
||||||
|
opj_event_msg(cinfo, EVT_ERROR, "Failed to read boxhdr\n");
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
if (JP2_IHDR != box.type) {
|
if (JP2_IHDR != box.type) {
|
||||||
opj_event_msg(cinfo, EVT_ERROR, "Expected IHDR Marker\n");
|
opj_event_msg(cinfo, EVT_ERROR, "Expected IHDR Marker\n");
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
@@ -279,7 +282,10 @@ static opj_bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio) {
|
|||||||
|
|
||||||
opj_common_ptr cinfo = jp2->cinfo;
|
opj_common_ptr cinfo = jp2->cinfo;
|
||||||
|
|
||||||
jp2_read_boxhdr(cinfo, cio, &box);
|
if( jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) {
|
||||||
|
opj_event_msg(cinfo, EVT_ERROR, "Failed to read boxhdr\n");
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
if (JP2_BPCC != box.type) {
|
if (JP2_BPCC != box.type) {
|
||||||
opj_event_msg(cinfo, EVT_ERROR, "Expected BPCC Marker\n");
|
opj_event_msg(cinfo, EVT_ERROR, "Expected BPCC Marker\n");
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
@@ -469,7 +475,7 @@ static opj_bool jp2_read_pclr(opj_jp2_t *jp2, opj_cio_t *cio,
|
|||||||
for(i = 0; i < nr_channels; ++i)
|
for(i = 0; i < nr_channels; ++i)
|
||||||
{
|
{
|
||||||
/* Cji */
|
/* Cji */
|
||||||
*entries++ = cio_read(cio, channel_size[i]>>3);
|
*entries++ = cio_read(cio, (channel_size[i]+7)>>3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -639,87 +645,86 @@ opj_bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio, opj_jp2_color_t *color)
|
|||||||
|
|
||||||
opj_common_ptr cinfo = jp2->cinfo;
|
opj_common_ptr cinfo = jp2->cinfo;
|
||||||
|
|
||||||
jp2_read_boxhdr(cinfo, cio, &box);
|
if( jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) return OPJ_FALSE;
|
||||||
do
|
do {
|
||||||
{
|
if (JP2_JP2H != box.type)
|
||||||
if (JP2_JP2H != box.type)
|
{
|
||||||
{
|
if (box.type == JP2_JP2C)
|
||||||
if (box.type == JP2_JP2C)
|
{
|
||||||
{
|
opj_event_msg(cinfo, EVT_ERROR, "Expected JP2H Marker\n");
|
||||||
opj_event_msg(cinfo, EVT_ERROR, "Expected JP2H Marker\n");
|
return OPJ_FALSE;
|
||||||
return OPJ_FALSE;
|
}
|
||||||
}
|
cio_skip(cio, box.length - 8);
|
||||||
cio_skip(cio, box.length - 8);
|
|
||||||
|
|
||||||
if(cio->bp >= cio->end) return OPJ_FALSE;
|
if(cio->bp >= cio->end) return OPJ_FALSE;
|
||||||
|
|
||||||
jp2_read_boxhdr(cinfo, cio, &box);
|
if( jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
} while(JP2_JP2H != box.type);
|
} while(JP2_JP2H != box.type);
|
||||||
|
|
||||||
if (!jp2_read_ihdr(jp2, cio))
|
if (!jp2_read_ihdr(jp2, cio))
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
jp2h_end = box.init_pos + box.length;
|
jp2h_end = box.init_pos + box.length;
|
||||||
|
|
||||||
if (jp2->bpc == 255)
|
if (jp2->bpc == 255)
|
||||||
{
|
{
|
||||||
if (!jp2_read_bpcc(jp2, cio))
|
if (!jp2_read_bpcc(jp2, cio))
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
jp2_read_boxhdr(cinfo, cio, &box);
|
if( jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) return OPJ_FALSE;
|
||||||
|
|
||||||
while(cio_tell(cio) < jp2h_end)
|
while(cio_tell(cio) < jp2h_end)
|
||||||
{
|
{
|
||||||
if(box.type == JP2_COLR)
|
if(box.type == JP2_COLR)
|
||||||
{
|
{
|
||||||
if( !jp2_read_colr(jp2, cio, &box, color))
|
if( !jp2_read_colr(jp2, cio, &box, color))
|
||||||
{
|
{
|
||||||
cio_seek(cio, box.init_pos + 8);
|
cio_seek(cio, box.init_pos + 8);
|
||||||
cio_skip(cio, box.length - 8);
|
cio_skip(cio, box.length - 8);
|
||||||
}
|
}
|
||||||
jp2_read_boxhdr(cinfo, cio, &box);
|
if( jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) return OPJ_FALSE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(box.type == JP2_CDEF && !jp2->ignore_pclr_cmap_cdef)
|
if(box.type == JP2_CDEF && !jp2->ignore_pclr_cmap_cdef)
|
||||||
{
|
{
|
||||||
if( !jp2_read_cdef(jp2, cio, &box, color))
|
if( !jp2_read_cdef(jp2, cio, &box, color))
|
||||||
{
|
{
|
||||||
cio_seek(cio, box.init_pos + 8);
|
cio_seek(cio, box.init_pos + 8);
|
||||||
cio_skip(cio, box.length - 8);
|
cio_skip(cio, box.length - 8);
|
||||||
}
|
}
|
||||||
jp2_read_boxhdr(cinfo, cio, &box);
|
if( jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) return OPJ_FALSE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(box.type == JP2_PCLR && !jp2->ignore_pclr_cmap_cdef)
|
if(box.type == JP2_PCLR && !jp2->ignore_pclr_cmap_cdef)
|
||||||
{
|
{
|
||||||
if( !jp2_read_pclr(jp2, cio, &box, color))
|
if( !jp2_read_pclr(jp2, cio, &box, color))
|
||||||
{
|
{
|
||||||
cio_seek(cio, box.init_pos + 8);
|
cio_seek(cio, box.init_pos + 8);
|
||||||
cio_skip(cio, box.length - 8);
|
cio_skip(cio, box.length - 8);
|
||||||
}
|
}
|
||||||
jp2_read_boxhdr(cinfo, cio, &box);
|
if( jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) return OPJ_FALSE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(box.type == JP2_CMAP && !jp2->ignore_pclr_cmap_cdef)
|
if(box.type == JP2_CMAP && !jp2->ignore_pclr_cmap_cdef)
|
||||||
{
|
{
|
||||||
if( !jp2_read_cmap(jp2, cio, &box, color))
|
if( !jp2_read_cmap(jp2, cio, &box, color))
|
||||||
{
|
{
|
||||||
|
cio_seek(cio, box.init_pos + 8);
|
||||||
|
cio_skip(cio, box.length - 8);
|
||||||
|
}
|
||||||
|
if( jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) return OPJ_FALSE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
cio_seek(cio, box.init_pos + 8);
|
cio_seek(cio, box.init_pos + 8);
|
||||||
cio_skip(cio, box.length - 8);
|
cio_skip(cio, box.length - 8);
|
||||||
}
|
if( jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) return OPJ_FALSE;
|
||||||
jp2_read_boxhdr(cinfo, cio, &box);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
cio_seek(cio, box.init_pos + 8);
|
|
||||||
cio_skip(cio, box.length - 8);
|
|
||||||
jp2_read_boxhdr(cinfo, cio, &box);
|
|
||||||
|
|
||||||
}/* while(cio_tell(cio) < box_end) */
|
}/* while(cio_tell(cio) < box_end) */
|
||||||
|
|
||||||
cio_seek(cio, jp2h_end);
|
cio_seek(cio, jp2h_end);
|
||||||
|
|
||||||
/* Part 1, I.5.3.3 : 'must contain at least one' */
|
/* Part 1, I.5.3.3 : 'must contain at least one' */
|
||||||
return (color->jp2_has_colr == 1);
|
return (color->jp2_has_colr == 1);
|
||||||
|
|
||||||
}/* jp2_read_jp2h() */
|
}/* jp2_read_jp2h() */
|
||||||
|
|
||||||
@@ -839,8 +844,10 @@ static opj_bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) {
|
|||||||
|
|
||||||
opj_common_ptr cinfo = jp2->cinfo;
|
opj_common_ptr cinfo = jp2->cinfo;
|
||||||
|
|
||||||
jp2_read_boxhdr(cinfo, cio, &box);
|
if( jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) {
|
||||||
|
opj_event_msg(cinfo, EVT_ERROR, "Failed to read boxhdr\n");
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
if (JP2_FTYP != box.type) {
|
if (JP2_FTYP != box.type) {
|
||||||
opj_event_msg(cinfo, EVT_ERROR, "Expected FTYP Marker\n");
|
opj_event_msg(cinfo, EVT_ERROR, "Expected FTYP Marker\n");
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
@@ -897,11 +904,14 @@ static opj_bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_
|
|||||||
|
|
||||||
opj_common_ptr cinfo = jp2->cinfo;
|
opj_common_ptr cinfo = jp2->cinfo;
|
||||||
|
|
||||||
jp2_read_boxhdr(cinfo, cio, &box);
|
if( jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) {
|
||||||
|
opj_event_msg(cinfo, EVT_ERROR, "Failed to read boxhdr\n");
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
do {
|
do {
|
||||||
if(JP2_JP2C != box.type) {
|
if(JP2_JP2C != box.type) {
|
||||||
cio_skip(cio, box.length - 8);
|
cio_skip(cio, box.length - 8);
|
||||||
jp2_read_boxhdr(cinfo, cio, &box);
|
if( jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
} while(JP2_JP2C != box.type);
|
} while(JP2_JP2C != box.type);
|
||||||
|
|
||||||
@@ -930,7 +940,10 @@ static opj_bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio) {
|
|||||||
|
|
||||||
opj_common_ptr cinfo = jp2->cinfo;
|
opj_common_ptr cinfo = jp2->cinfo;
|
||||||
|
|
||||||
jp2_read_boxhdr(cinfo, cio, &box);
|
if( jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) {
|
||||||
|
opj_event_msg(cinfo, EVT_ERROR, "Failed to read boxhdr\n");
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
if (JP2_JP != box.type) {
|
if (JP2_JP != box.type) {
|
||||||
opj_event_msg(cinfo, EVT_ERROR, "Expected JP Marker\n");
|
opj_event_msg(cinfo, EVT_ERROR, "Expected JP Marker\n");
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
|
|||||||
@@ -23,10 +23,16 @@ IF(WIN32)
|
|||||||
ENDIF(BUILD_SHARED_LIBS)
|
ENDIF(BUILD_SHARED_LIBS)
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME}_JPWL ${JPWL_SRCS} ${OPENJPEG_SRCS})
|
ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME}_JPWL ${JPWL_SRCS} ${OPENJPEG_SRCS})
|
||||||
|
IF(UNIX)
|
||||||
|
TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME}_JPWL m)
|
||||||
|
ENDIF(UNIX)
|
||||||
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}_JPWL
|
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}_JPWL
|
||||||
PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
|
PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
|
||||||
|
|
||||||
# Install library
|
# Install library
|
||||||
INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}_JPWL
|
INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}_JPWL
|
||||||
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
|
EXPORT OpenJPEGTargets
|
||||||
|
RUNTIME DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||||
|
LIBRARY DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
|
||||||
|
ARCHIVE DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ const unsigned short CRC16_table[256] = {
|
|||||||
|
|
||||||
void updateCRC16(unsigned short *crc, unsigned char data) {
|
void updateCRC16(unsigned short *crc, unsigned char data) {
|
||||||
*crc = CRC16_table[(*crc >> 8) & 0xFF] ^ (*crc << 8) ^ data;
|
*crc = CRC16_table[(*crc >> 8) & 0xFF] ^ (*crc << 8) ^ data;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/** file: CRC32.CPP
|
/** file: CRC32.CPP
|
||||||
@@ -155,6 +155,6 @@ const unsigned long CRC32_table[256] = {
|
|||||||
|
|
||||||
void updateCRC32(unsigned long *crc, unsigned char data) {
|
void updateCRC32(unsigned long *crc, unsigned char data) {
|
||||||
*crc = CRC32_table[(unsigned char) *crc ^ data] ^ ((*crc >> 8) & 0x00FFFFFF);
|
*crc = CRC32_table[(unsigned char) *crc ^ data] ^ ((*crc >> 8) & 0x00FFFFFF);
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
|
|||||||
jpwl_epb_ms_t *epb_mark;
|
jpwl_epb_ms_t *epb_mark;
|
||||||
jpwl_epc_ms_t *epc_mark;
|
jpwl_epc_ms_t *epc_mark;
|
||||||
jpwl_esd_ms_t *esd_mark;
|
jpwl_esd_ms_t *esd_mark;
|
||||||
|
(void)image;
|
||||||
|
|
||||||
/* find (SOC + SIZ) length */
|
/* find (SOC + SIZ) length */
|
||||||
/* I assume SIZ is always the first marker after SOC */
|
/* I assume SIZ is always the first marker after SOC */
|
||||||
@@ -405,7 +406,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
|
|||||||
|
|
||||||
/* add all the lengths of the markers which are len-ready and stay within SOC and SOT */
|
/* add all the lengths of the markers which are len-ready and stay within SOC and SOT */
|
||||||
for (mm = 0; mm < jwmarker_num; mm++) {
|
for (mm = 0; mm < jwmarker_num; mm++) {
|
||||||
if ((jwmarker[mm].pos >=0) && (jwmarker[mm].pos < sot_pos)) {
|
if ( jwmarker[mm].pos < sot_pos) { /* jwmarker[mm].pos >=0 since ulong */
|
||||||
if (jwmarker[mm].len_ready)
|
if (jwmarker[mm].len_ready)
|
||||||
left_MHmarks_len += jwmarker[mm].len + 2;
|
left_MHmarks_len += jwmarker[mm].len + 2;
|
||||||
else {
|
else {
|
||||||
@@ -632,7 +633,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
|
|||||||
pprot = j2k->cp->pprot[packspec++];
|
pprot = j2k->cp->pprot[packspec++];
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("Tile %02d, pack %02d ==> %d\n", tileno, packno, pprot);
|
/*printf("Tile %02d, pack %02d ==> %d\n", tileno, packno, pprot);*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -717,6 +718,7 @@ void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
|
|||||||
unsigned char *jpwl_buf, *orig_buf;
|
unsigned char *jpwl_buf, *orig_buf;
|
||||||
unsigned long int orig_pos;
|
unsigned long int orig_pos;
|
||||||
double epbcoding_time = 0.0, esdcoding_time = 0.0;
|
double epbcoding_time = 0.0, esdcoding_time = 0.0;
|
||||||
|
(void)image;
|
||||||
|
|
||||||
/* Order JPWL markers according to their wishlist position */
|
/* Order JPWL markers according to their wishlist position */
|
||||||
qsort((void *) jwmarker, (size_t) jwmarker_num, sizeof (jpwl_marker_t), jpwl_markcomp);
|
qsort((void *) jwmarker, (size_t) jwmarker_num, sizeof (jpwl_marker_t), jpwl_markcomp);
|
||||||
@@ -1282,6 +1284,10 @@ opj_bool jpwl_check_tile(opj_j2k_t *j2k, opj_tcd_t *tcd, int tileno) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
(void)j2k;
|
||||||
|
(void)tcd;
|
||||||
|
(void)tileno;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return OPJ_TRUE;
|
return OPJ_TRUE;
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ void jpwl_epb_write(opj_j2k_t *j2k, jpwl_epb_ms_t *epb, unsigned char *buf) {
|
|||||||
/* update markers struct */
|
/* update markers struct */
|
||||||
j2k_add_marker(j2k->cstr_info, J2K_MS_EPB, -1, epb->Lepb + 2);
|
j2k_add_marker(j2k->cstr_info, J2K_MS_EPB, -1, epb->Lepb + 2);
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
jpwl_epc_ms_t *jpwl_epc_create(opj_j2k_t *j2k, opj_bool esd_on, opj_bool red_on, opj_bool epb_on, opj_bool info_on) {
|
jpwl_epc_ms_t *jpwl_epc_create(opj_j2k_t *j2k, opj_bool esd_on, opj_bool red_on, opj_bool epb_on, opj_bool info_on) {
|
||||||
@@ -677,7 +677,7 @@ opj_bool jpwl_correct(opj_j2k_t *j2k) {
|
|||||||
id = cio_read(cio, 2);
|
id = cio_read(cio, 2);
|
||||||
|
|
||||||
/* details */
|
/* details */
|
||||||
printf("Marker@%d: %X\n", cio_tell(cio) - 2, id);
|
printf("Marker@%lld: %X\n", cio_tell(cio) - 2, id);
|
||||||
|
|
||||||
/* do an action in response to the read marker */
|
/* do an action in response to the read marker */
|
||||||
switch (id) {
|
switch (id) {
|
||||||
@@ -1190,7 +1190,7 @@ void jpwl_epc_write(opj_j2k_t *j2k, jpwl_epc_ms_t *epc, unsigned char *buf) {
|
|||||||
/* update markers struct */
|
/* update markers struct */
|
||||||
j2k_add_marker(j2k->cstr_info, J2K_MS_EPC, -1, epc->Lepc + 2);
|
j2k_add_marker(j2k->cstr_info, J2K_MS_EPC, -1, epc->Lepc + 2);
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
int jpwl_esds_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num,
|
int jpwl_esds_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num,
|
||||||
int comps, unsigned char addrm, unsigned char ad_size,
|
int comps, unsigned char addrm, unsigned char ad_size,
|
||||||
|
|||||||
@@ -135,6 +135,10 @@ typedef enum COLOR_SPACE {
|
|||||||
CLRSPC_SYCC = 3 /**< YUV */
|
CLRSPC_SYCC = 3 /**< YUV */
|
||||||
} OPJ_COLOR_SPACE;
|
} OPJ_COLOR_SPACE;
|
||||||
|
|
||||||
|
#define ENUMCS_SRGB 16
|
||||||
|
#define ENUMCS_GRAY 17
|
||||||
|
#define ENUMCS_SYCC 18
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Supported codec
|
Supported codec
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -83,8 +83,10 @@ Allocate memory aligned to a 16 byte boundry
|
|||||||
#else /* Not _WIN32 */
|
#else /* Not _WIN32 */
|
||||||
#if defined(__sun)
|
#if defined(__sun)
|
||||||
#define HAVE_MEMALIGN
|
#define HAVE_MEMALIGN
|
||||||
|
#elif defined(__FreeBSD__)
|
||||||
|
#define HAVE_POSIX_MEMALIGN
|
||||||
/* Linux x86_64 and OSX always align allocations to 16 bytes */
|
/* Linux x86_64 and OSX always align allocations to 16 bytes */
|
||||||
#elif !defined(__amd64__) && !defined(__APPLE__)
|
#elif !defined(__amd64__) && !defined(__APPLE__) && !defined(_AIX)
|
||||||
#define HAVE_MEMALIGN
|
#define HAVE_MEMALIGN
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1577,6 +1577,7 @@ void t1_decode_cblks(
|
|||||||
opj_free(cblk->segs);
|
opj_free(cblk->segs);
|
||||||
} /* cblkno */
|
} /* cblkno */
|
||||||
opj_free(precinct->cblks.dec);
|
opj_free(precinct->cblks.dec);
|
||||||
|
precinct->cblks.dec = NULL;
|
||||||
} /* precno */
|
} /* precno */
|
||||||
} /* bandno */
|
} /* bandno */
|
||||||
} /* resno */
|
} /* resno */
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ static int t2_encode_packet(opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterato
|
|||||||
@param cblksty
|
@param cblksty
|
||||||
@param first
|
@param first
|
||||||
*/
|
*/
|
||||||
static void t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int first);
|
static opj_bool t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int first);
|
||||||
/**
|
/**
|
||||||
Decode a packet of a tile from a source buffer
|
Decode a packet of a tile from a source buffer
|
||||||
@param t2 T2 handle
|
@param t2 T2 handle
|
||||||
@@ -296,9 +296,17 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera
|
|||||||
return (c - dest);
|
return (c - dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int first) {
|
static opj_bool t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int first) {
|
||||||
opj_tcd_seg_t* seg;
|
opj_tcd_seg_t* seg;
|
||||||
cblk->segs = (opj_tcd_seg_t*) opj_realloc(cblk->segs, (index + 1) * sizeof(opj_tcd_seg_t));
|
opj_tcd_seg_t* segs;
|
||||||
|
segs = (opj_tcd_seg_t*) opj_realloc(cblk->segs, (index + 1) * sizeof(opj_tcd_seg_t));
|
||||||
|
|
||||||
|
if (segs == NULL)
|
||||||
|
{
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
cblk->segs = segs;
|
||||||
|
|
||||||
seg = &cblk->segs[index];
|
seg = &cblk->segs[index];
|
||||||
seg->data = NULL;
|
seg->data = NULL;
|
||||||
seg->dataindex = 0;
|
seg->dataindex = 0;
|
||||||
@@ -316,6 +324,8 @@ static void t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int fi
|
|||||||
} else {
|
} else {
|
||||||
seg->maxpasses = 109;
|
seg->maxpasses = 109;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return OPJ_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile,
|
static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile,
|
||||||
@@ -462,12 +472,22 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
|
|||||||
cblk->numlenbits += increment;
|
cblk->numlenbits += increment;
|
||||||
segno = 0;
|
segno = 0;
|
||||||
if (!cblk->numsegs) {
|
if (!cblk->numsegs) {
|
||||||
t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 1);
|
if (!t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 1))
|
||||||
|
{
|
||||||
|
opj_event_msg(t2->cinfo, EVT_ERROR, "Out of memory\n");
|
||||||
|
bio_destroy(bio);
|
||||||
|
return -999;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
segno = cblk->numsegs - 1;
|
segno = cblk->numsegs - 1;
|
||||||
if (cblk->segs[segno].numpasses == cblk->segs[segno].maxpasses) {
|
if (cblk->segs[segno].numpasses == cblk->segs[segno].maxpasses) {
|
||||||
++segno;
|
++segno;
|
||||||
t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0);
|
if (!t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0))
|
||||||
|
{
|
||||||
|
opj_event_msg(t2->cinfo, EVT_ERROR, "Out of memory\n");
|
||||||
|
bio_destroy(bio);
|
||||||
|
return -999;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
n = cblk->numnewpasses;
|
n = cblk->numnewpasses;
|
||||||
@@ -478,7 +498,12 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
|
|||||||
n -= cblk->segs[segno].numnewpasses;
|
n -= cblk->segs[segno].numnewpasses;
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
++segno;
|
++segno;
|
||||||
t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0);
|
if (!t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0))
|
||||||
|
{
|
||||||
|
opj_event_msg(t2->cinfo, EVT_ERROR, "Out of memory\n");
|
||||||
|
bio_destroy(bio);
|
||||||
|
return -999;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} while (n > 0);
|
} while (n > 0);
|
||||||
}
|
}
|
||||||
@@ -714,7 +739,11 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj
|
|||||||
} else {
|
} else {
|
||||||
e = 0;
|
e = 0;
|
||||||
}
|
}
|
||||||
if(e == -999) return -999;
|
if(e == -999)
|
||||||
|
{
|
||||||
|
pi_destroy(pi, cp, tileno);
|
||||||
|
return -999;
|
||||||
|
}
|
||||||
/* progression in resolution */
|
/* progression in resolution */
|
||||||
image->comps[pi[pino].compno].resno_decoded =
|
image->comps[pi[pino].compno].resno_decoded =
|
||||||
(e > 0) ?
|
(e > 0) ?
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _ISOC99_SOURCE /* lrintf is C99 */
|
||||||
#include "opj_includes.h"
|
#include "opj_includes.h"
|
||||||
|
|
||||||
void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t * img) {
|
void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t * img) {
|
||||||
@@ -333,8 +334,10 @@ void tcd_malloc_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int c
|
|||||||
cblk->y0 = int_max(cblkystart, prc->y0);
|
cblk->y0 = int_max(cblkystart, prc->y0);
|
||||||
cblk->x1 = int_min(cblkxend, prc->x1);
|
cblk->x1 = int_min(cblkxend, prc->x1);
|
||||||
cblk->y1 = int_min(cblkyend, prc->y1);
|
cblk->y1 = int_min(cblkyend, prc->y1);
|
||||||
cblk->data = (unsigned char*) opj_calloc(8192+2, sizeof(unsigned char));
|
cblk->data = (unsigned char*) opj_calloc(9728+2, sizeof(unsigned char));
|
||||||
/* FIXME: mqc_init_enc and mqc_byteout underrun the buffer if we don't do this. Why? */
|
/* FIXME: mqc_init_enc and mqc_byteout underrun the buffer if we don't do this. Why? */
|
||||||
|
cblk->data[0] = 0;
|
||||||
|
cblk->data[1] = 0;
|
||||||
cblk->data += 2;
|
cblk->data += 2;
|
||||||
cblk->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof(opj_tcd_layer_t));
|
cblk->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof(opj_tcd_layer_t));
|
||||||
cblk->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(opj_tcd_pass_t));
|
cblk->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(opj_tcd_pass_t));
|
||||||
@@ -594,6 +597,8 @@ void tcd_init_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int cur
|
|||||||
cblk->y1 = int_min(cblkyend, prc->y1);
|
cblk->y1 = int_min(cblkyend, prc->y1);
|
||||||
cblk->data = (unsigned char*) opj_calloc(8192+2, sizeof(unsigned char));
|
cblk->data = (unsigned char*) opj_calloc(8192+2, sizeof(unsigned char));
|
||||||
/* FIXME: mqc_init_enc and mqc_byteout underrun the buffer if we don't do this. Why? */
|
/* FIXME: mqc_init_enc and mqc_byteout underrun the buffer if we don't do this. Why? */
|
||||||
|
cblk->data[0] = 0;
|
||||||
|
cblk->data[1] = 0;
|
||||||
cblk->data += 2;
|
cblk->data += 2;
|
||||||
cblk->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof(opj_tcd_layer_t));
|
cblk->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof(opj_tcd_layer_t));
|
||||||
cblk->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(opj_tcd_pass_t));
|
cblk->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(opj_tcd_pass_t));
|
||||||
@@ -614,7 +619,7 @@ void tcd_malloc_decode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp) {
|
|||||||
tcd->image = image;
|
tcd->image = image;
|
||||||
tcd->tcd_image->tw = cp->tw;
|
tcd->tcd_image->tw = cp->tw;
|
||||||
tcd->tcd_image->th = cp->th;
|
tcd->tcd_image->th = cp->th;
|
||||||
tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_malloc(cp->tw * cp->th * sizeof(opj_tcd_tile_t));
|
tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_calloc(cp->tw * cp->th, sizeof(opj_tcd_tile_t));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Allocate place to store the decoded data = final image
|
Allocate place to store the decoded data = final image
|
||||||
@@ -690,6 +695,12 @@ void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp,
|
|||||||
opj_tccp_t *tccp = &tcp->tccps[compno];
|
opj_tccp_t *tccp = &tcp->tccps[compno];
|
||||||
opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
|
opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
|
||||||
|
|
||||||
|
if (tccp->numresolutions <= 0)
|
||||||
|
{
|
||||||
|
cp->tileno[tileno] = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* border of each tile component (global) */
|
/* border of each tile component (global) */
|
||||||
tilec->x0 = int_ceildiv(tile->x0, image->comps[compno].dx);
|
tilec->x0 = int_ceildiv(tile->x0, image->comps[compno].dx);
|
||||||
tilec->y0 = int_ceildiv(tile->y0, image->comps[compno].dy);
|
tilec->y0 = int_ceildiv(tile->y0, image->comps[compno].dy);
|
||||||
@@ -1376,10 +1387,23 @@ opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno
|
|||||||
|
|
||||||
t1_time = opj_clock(); /* time needed to decode a tile */
|
t1_time = opj_clock(); /* time needed to decode a tile */
|
||||||
t1 = t1_create(tcd->cinfo);
|
t1 = t1_create(tcd->cinfo);
|
||||||
|
if (t1 == NULL)
|
||||||
|
{
|
||||||
|
opj_event_msg(tcd->cinfo, EVT_ERROR, "Out of memory\n");
|
||||||
|
t1_destroy(t1);
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
for (compno = 0; compno < tile->numcomps; ++compno) {
|
for (compno = 0; compno < tile->numcomps; ++compno) {
|
||||||
opj_tcd_tilecomp_t* tilec = &tile->comps[compno];
|
opj_tcd_tilecomp_t* tilec = &tile->comps[compno];
|
||||||
/* The +3 is headroom required by the vectorized DWT */
|
/* The +3 is headroom required by the vectorized DWT */
|
||||||
tilec->data = (int*) opj_aligned_malloc((((tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0))+3) * sizeof(int));
|
tilec->data = (int*) opj_aligned_malloc((((tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0))+3) * sizeof(int));
|
||||||
|
if (tilec->data == NULL)
|
||||||
|
{
|
||||||
|
opj_event_msg(tcd->cinfo, EVT_ERROR, "Out of memory\n");
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
t1_decode_cblks(t1, tilec, &tcd->tcp->tccps[compno]);
|
t1_decode_cblks(t1, tilec, &tcd->tcp->tccps[compno]);
|
||||||
}
|
}
|
||||||
t1_destroy(t1);
|
t1_destroy(t1);
|
||||||
@@ -1394,13 +1418,15 @@ opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno
|
|||||||
int numres2decode;
|
int numres2decode;
|
||||||
|
|
||||||
if (tcd->cp->reduce != 0) {
|
if (tcd->cp->reduce != 0) {
|
||||||
tcd->image->comps[compno].resno_decoded =
|
if ( tile->comps[compno].numresolutions < ( tcd->cp->reduce - 1 ) ) {
|
||||||
tile->comps[compno].numresolutions - tcd->cp->reduce - 1;
|
|
||||||
if (tcd->image->comps[compno].resno_decoded < 0) {
|
|
||||||
opj_event_msg(tcd->cinfo, EVT_ERROR, "Error decoding tile. The number of resolutions to remove [%d+1] is higher than the number "
|
opj_event_msg(tcd->cinfo, EVT_ERROR, "Error decoding tile. The number of resolutions to remove [%d+1] is higher than the number "
|
||||||
" of resolutions in the original codestream [%d]\nModify the cp_reduce parameter.\n", tcd->cp->reduce, tile->comps[compno].numresolutions);
|
" of resolutions in the original codestream [%d]\nModify the cp_reduce parameter.\n", tcd->cp->reduce, tile->comps[compno].numresolutions);
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
tcd->image->comps[compno].resno_decoded =
|
||||||
|
tile->comps[compno].numresolutions - tcd->cp->reduce - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
numres2decode = tcd->image->comps[compno].resno_decoded + 1;
|
numres2decode = tcd->image->comps[compno].resno_decoded + 1;
|
||||||
@@ -1459,6 +1485,11 @@ opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno
|
|||||||
if(!imagec->data){
|
if(!imagec->data){
|
||||||
imagec->data = (int*) opj_malloc(imagec->w * imagec->h * sizeof(int));
|
imagec->data = (int*) opj_malloc(imagec->w * imagec->h * sizeof(int));
|
||||||
}
|
}
|
||||||
|
if (!imagec->data)
|
||||||
|
{
|
||||||
|
opj_event_msg(tcd->cinfo, EVT_ERROR, "Out of memory\n");
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
if(tcd->tcp->tccps[compno].qmfbid == 1) {
|
if(tcd->tcp->tccps[compno].qmfbid == 1) {
|
||||||
for(j = res->y0; j < res->y1; ++j) {
|
for(j = res->y0; j < res->y1; ++j) {
|
||||||
for(i = res->x0; i < res->x1; ++i) {
|
for(i = res->x0; i < res->x1; ++i) {
|
||||||
@@ -1492,32 +1523,51 @@ opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno
|
|||||||
|
|
||||||
void tcd_free_decode(opj_tcd_t *tcd) {
|
void tcd_free_decode(opj_tcd_t *tcd) {
|
||||||
opj_tcd_image_t *tcd_image = tcd->tcd_image;
|
opj_tcd_image_t *tcd_image = tcd->tcd_image;
|
||||||
|
int i = 0;
|
||||||
|
for (i = 0; i < tcd_image->tw * tcd_image->th; i++)
|
||||||
|
{
|
||||||
|
tcd_free_decode_tile(tcd, i);
|
||||||
|
}
|
||||||
|
|
||||||
opj_free(tcd_image->tiles);
|
opj_free(tcd_image->tiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tcd_free_decode_tile(opj_tcd_t *tcd, int tileno) {
|
void tcd_free_decode_tile(opj_tcd_t *tcd, int tileno) {
|
||||||
int compno,resno,bandno,precno;
|
int compno,resno,bandno,precno,cblkno;
|
||||||
|
|
||||||
opj_tcd_image_t *tcd_image = tcd->tcd_image;
|
opj_tcd_image_t *tcd_image = tcd->tcd_image;
|
||||||
|
|
||||||
opj_tcd_tile_t *tile = &tcd_image->tiles[tileno];
|
opj_tcd_tile_t *tile = &tcd_image->tiles[tileno];
|
||||||
for (compno = 0; compno < tile->numcomps; compno++) {
|
if (tile->comps != NULL) {
|
||||||
opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
|
for (compno = 0; compno < tile->numcomps; compno++) {
|
||||||
for (resno = 0; resno < tilec->numresolutions; resno++) {
|
opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
|
||||||
opj_tcd_resolution_t *res = &tilec->resolutions[resno];
|
for (resno = 0; resno < tilec->numresolutions; resno++) {
|
||||||
for (bandno = 0; bandno < res->numbands; bandno++) {
|
opj_tcd_resolution_t *res = &tilec->resolutions[resno];
|
||||||
opj_tcd_band_t *band = &res->bands[bandno];
|
for (bandno = 0; bandno < res->numbands; bandno++) {
|
||||||
for (precno = 0; precno < res->ph * res->pw; precno++) {
|
opj_tcd_band_t *band = &res->bands[bandno];
|
||||||
opj_tcd_precinct_t *prec = &band->precincts[precno];
|
for (precno = 0; precno < res->ph * res->pw; precno++) {
|
||||||
if (prec->imsbtree != NULL) tgt_destroy(prec->imsbtree);
|
opj_tcd_precinct_t *prec = &band->precincts[precno];
|
||||||
if (prec->incltree != NULL) tgt_destroy(prec->incltree);
|
if (prec->cblks.dec != NULL) {
|
||||||
|
for (cblkno = 0; cblkno < prec->cw * prec->ch; ++cblkno) {
|
||||||
|
opj_tcd_cblk_dec_t* cblk = &prec->cblks.dec[cblkno];
|
||||||
|
opj_free(cblk->data);
|
||||||
|
opj_free(cblk->segs);
|
||||||
|
}
|
||||||
|
opj_free(prec->cblks.dec);
|
||||||
|
}
|
||||||
|
if (prec->imsbtree != NULL) tgt_destroy(prec->imsbtree);
|
||||||
|
if (prec->incltree != NULL) tgt_destroy(prec->incltree);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
opj_free(band->precincts);
|
||||||
}
|
}
|
||||||
opj_free(band->precincts);
|
|
||||||
}
|
}
|
||||||
|
opj_free(tilec->resolutions);
|
||||||
}
|
}
|
||||||
opj_free(tilec->resolutions);
|
opj_free(tile->comps);
|
||||||
|
tile->comps = NULL;
|
||||||
}
|
}
|
||||||
opj_free(tile->comps);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
prefix=@CMAKE_INSTALL_PREFIX@
|
prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
bindir=@OPENJPEG_INSTALL_BIN_DIR@
|
bindir=${prefix}/@OPENJPEG_INSTALL_BIN_DIR@
|
||||||
datadir=@OPENJPEG_INSTALL_DATA_DIR@
|
datadir=${prefix}/@OPENJPEG_INSTALL_DATA_DIR@
|
||||||
libdir=@OPENJPEG_INSTALL_LIB_DIR@
|
libdir=${prefix}/@OPENJPEG_INSTALL_LIB_DIR@
|
||||||
includedir=@OPENJPEG_INSTALL_INCLUDE_DIR@
|
includedir=${prefix}/@OPENJPEG_INSTALL_INCLUDE_DIR@
|
||||||
|
|
||||||
Name: openjpeg
|
Name: openjpeg
|
||||||
Description: JPEG2000 files library
|
Description: JPEG2000 files library
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
prefix=@prefix@
|
prefix=@prefix@
|
||||||
exec_prefix=@exec_prefix@
|
exec_prefix=@exec_prefix@
|
||||||
libdir=@libdir@
|
libdir=@libdir@
|
||||||
includedir=@includedir@
|
includedir=@includedir@/openjpeg-@MAJOR_NR@.@MINOR_NR@
|
||||||
|
|
||||||
Name: openjpeg
|
Name: openjpeg
|
||||||
Description: JPEG2000 library
|
Description: JPEG2000 library
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ ENDIF(NOT HAVE_LIBPNG)
|
|||||||
|
|
||||||
ADD_SUBDIRECTORY(conformance)
|
ADD_SUBDIRECTORY(conformance)
|
||||||
ADD_SUBDIRECTORY(nonregression)
|
ADD_SUBDIRECTORY(nonregression)
|
||||||
|
ADD_SUBDIRECTORY(unit)
|
||||||
|
|
||||||
IF(BUILD_JPIP)
|
IF(BUILD_JPIP)
|
||||||
IF(JPIP_SERVER)
|
IF(JPIP_SERVER)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ j2k_to_image -i @INPUT_NR_PATH@/buxR.j2k -o @TEMP_PATH@/buxR.j2k.pgx
|
|||||||
j2k_to_image -i @INPUT_NR_PATH@/Cannotreaddatawithnosizeknown.j2k -o @TEMP_PATH@/Cannotreaddatawithnosizeknown.j2k.pgx
|
j2k_to_image -i @INPUT_NR_PATH@/Cannotreaddatawithnosizeknown.j2k -o @TEMP_PATH@/Cannotreaddatawithnosizeknown.j2k.pgx
|
||||||
j2k_to_image -i @INPUT_NR_PATH@/cthead1.j2k -o @TEMP_PATH@/cthead1.j2k.pgx
|
j2k_to_image -i @INPUT_NR_PATH@/cthead1.j2k -o @TEMP_PATH@/cthead1.j2k.pgx
|
||||||
j2k_to_image -i @INPUT_NR_PATH@/CT_Phillips_JPEG2K_Decompr_Problem.j2k -o @TEMP_PATH@/CT_Phillips_JPEG2K_Decompr_Problem.j2k.pgx
|
j2k_to_image -i @INPUT_NR_PATH@/CT_Phillips_JPEG2K_Decompr_Problem.j2k -o @TEMP_PATH@/CT_Phillips_JPEG2K_Decompr_Problem.j2k.pgx
|
||||||
!j2k_to_image -i @INPUT_NR_PATH@/illegalcolortransform.j2k -o @TEMP_PATH@/illegalcolortransform.j2k.pgx
|
j2k_to_image -i @INPUT_NR_PATH@/illegalcolortransform.j2k -o @TEMP_PATH@/illegalcolortransform.j2k.pgx
|
||||||
j2k_to_image -i @INPUT_NR_PATH@/j2k32.j2k -o @TEMP_PATH@/j2k32.j2k.pgx
|
j2k_to_image -i @INPUT_NR_PATH@/j2k32.j2k -o @TEMP_PATH@/j2k32.j2k.pgx
|
||||||
j2k_to_image -i @INPUT_NR_PATH@/kakadu_v4-4_openjpegv2_broken.j2k -o @TEMP_PATH@/kakadu_v4-4_openjpegv2_broken.j2k.pgx
|
j2k_to_image -i @INPUT_NR_PATH@/kakadu_v4-4_openjpegv2_broken.j2k -o @TEMP_PATH@/kakadu_v4-4_openjpegv2_broken.j2k.pgx
|
||||||
j2k_to_image -i @INPUT_NR_PATH@/MarkerIsNotCompliant.j2k -o @TEMP_PATH@/MarkerIsNotCompliant.j2k.pgx
|
j2k_to_image -i @INPUT_NR_PATH@/MarkerIsNotCompliant.j2k -o @TEMP_PATH@/MarkerIsNotCompliant.j2k.pgx
|
||||||
@@ -64,3 +64,4 @@ j2k_to_image -i @INPUT_NR_PATH@/relax.jp2 -o @TEMP_PATH@/relax.jp2.pgx
|
|||||||
j2k_to_image -i @INPUT_NR_PATH@/test_lossless.j2k -o @TEMP_PATH@/test_lossless.j2k.pgx
|
j2k_to_image -i @INPUT_NR_PATH@/test_lossless.j2k -o @TEMP_PATH@/test_lossless.j2k.pgx
|
||||||
j2k_to_image -i @INPUT_NR_PATH@/text_GBR.jp2 -o @TEMP_PATH@/text_GBR.jp2.pgx
|
j2k_to_image -i @INPUT_NR_PATH@/text_GBR.jp2 -o @TEMP_PATH@/text_GBR.jp2.pgx
|
||||||
j2k_to_image -i @INPUT_NR_PATH@/issue104_jpxstream.jp2 -o @TEMP_PATH@/issue104_jpxstream.jp2.pgx
|
j2k_to_image -i @INPUT_NR_PATH@/issue104_jpxstream.jp2 -o @TEMP_PATH@/issue104_jpxstream.jp2.pgx
|
||||||
|
j2k_to_image -i @INPUT_NR_PATH@/file409752.jp2 -o @TEMP_PATH@/file409752.jp2.pgx
|
||||||
|
|||||||
9
tests/unit/CMakeLists.txt
Normal file
9
tests/unit/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# UNIT TESTS
|
||||||
|
|
||||||
|
add_executable(testempty1 testempty1.c)
|
||||||
|
add_executable(testempty2 testempty2.c)
|
||||||
|
target_link_libraries(testempty1 openjpeg)
|
||||||
|
target_link_libraries(testempty2 openjpeg)
|
||||||
|
|
||||||
|
add_test(testempty1 ${EXECUTABLE_OUTPUT_PATH}/testempty1)
|
||||||
|
add_test(testempty2 ${EXECUTABLE_OUTPUT_PATH}/testempty2)
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user