Compare commits

..

60 Commits
master ... v2

Author SHA1 Message Date
Mathieu Malaterre f6cb0c86e2 [v2] remove ref to png.h file on win32 2012-03-16 16:47:44 +00:00
Mathieu Malaterre a937c91694 [v2] do not make freeimage compulsary when not needed. 2012-03-11 13:57:26 +00:00
Antonin Descampe c49becae30 fixed version number of openjpeg 2.0.0 in openjpeg.h 2011-07-03 17:58:59 +00:00
Antonin Descampe 9e0e3611c5 [V2] fixed dllexport definition (credit to vincent torri) 2011-04-13 11:01:12 +00:00
Antonin Descampe 9fba123a7a Removed folders mj2, JavaOpenJpeg, jpwl, OPJViewer (not compliant with v2). Removed obsolete windows project files. Removed obsolete Makefiles (only build method currently supported with v2 branch: cmake). Renamed ChangeLog to CHANGES. Renamed License.txt to LICENSE. Removed obsolete README files. 2011-04-12 23:36:01 +00:00
Antonin Descampe fef7d00dc8 Fixed internal function names conflict with Jasper (http://code.google.com/p/openjpeg/issues/detail?id=30) 2011-04-12 17:24:30 +00:00
Antonin Descampe a916dcd052 Fix leak in jp2_read_header_procedure() (from even.rouault, see issue 29 on googlecode) 2010-11-25 12:15:07 +00:00
Mathieu Malaterre cc01949777 The original v1.3 branch had:
((int*)tiledp)[(j * tile_w) + i] = tmp / 2;
while v2 had:
((OPJ_INT32*)tiledp)[(j * tile_w) + i] = tmp >> 1;
Divide by two and a right shift operation are only equivalent when the data
is unsigned. In this case the data is signed, so the right shift operation
is incorrectly clearing the sign bit.
Patch from: Sheet Spotter
2010-10-07 17:45:04 +00:00
Antonin Descampe 287be4e683 minor bugs fixed (see issue 31 on googlecode - Thanks to winfried) 2010-10-05 20:58:04 +00:00
Antonin Descampe dea5c48227 fixed problems with partial decodes (non-zero value for cp_reduce) that can cause corrupted images and crashes (issue 41) - thanks to Sheet Spotter 2010-10-05 20:25:01 +00:00
Antonin Descampe 68e1771ae5 fixed minor problems that prevented the solution file from building in Windows (issue 40) - thanks to Sheet Spotter 2010-10-05 20:22:17 +00:00
Luis Ibanez 6ab100903e The lrintf function should use "long" instead of "int"
for the type of its internal variable.
2010-08-22 18:58:28 +00:00
Luis Ibanez 3e5715a994 BUG: The _asm directive is not available in Visual Studio 9, 64bits.
An alternative vainilla implementation has been added here, based
on code from VXL, vnl_math.h.
2010-08-22 00:30:23 +00:00
Luis Ibanez 9f446c88e8 Fix contributed by Bill Lorensen, to make it build in MinGW. 2010-08-22 00:29:14 +00:00
Luis Ibanez 2f9e80da9c BUG: Fixing case in which the pointer the data buffers doesn't
get positioned at the beginning of the buffer after a new
     buffer load. This case only happens when the pointer happens
     to be at the end of the buffer when the request for the new
     block arrives.  Fix contributed by Bill Hoffman.
2010-08-20 21:33:43 +00:00
Mathieu Malaterre 871cd3968f For backward compatibility 2010-08-11 09:45:39 +00:00
Mathieu Malaterre e5bfc65137 Fix case 2010-08-11 08:47:58 +00:00
Mathieu Malaterre 315179c719 fix compilation with freeimage 2010-07-01 17:41:44 +00:00
Mathieu Malaterre cab60a170d Prevent segfault later down in the pipeline 2010-07-01 17:40:57 +00:00
Mathieu Malaterre 889aa9227b backport from trunk 2010-07-01 17:35:20 +00:00
Mathieu Malaterre 8dcd3318c2 Attempt to fix win32 compilation 2010-06-23 13:22:03 +00:00
Mathieu Malaterre f71e6e7879 Finish fixing up bugs with png i/o 2010-06-22 19:27:35 +00:00
Mathieu Malaterre 3a44c91ea3 add more test. prevent segfault 2010-06-22 19:06:01 +00:00
Mathieu Malaterre 786dee8782 Import j2k_dump from trunk (much faster) 2010-06-22 18:26:15 +00:00
Mathieu Malaterre 5badc82fa9 Start merging change from svn trunk 2010-06-22 17:29:21 +00:00
Mathieu Malaterre ecd70f033c Start using cmake API for easy packaging 2010-06-21 13:54:49 +00:00
Mathieu Malaterre 0c69d6e1a8 Fix installation 2010-06-21 13:41:12 +00:00
Mathieu Malaterre 306e58761a minor change 2010-06-21 12:52:56 +00:00
Mathieu Malaterre eb1baa78fc test all codecs. Adding forgotten file to search for freeimage 2010-06-21 12:48:43 +00:00
Mathieu Malaterre 414b680e53 increase coverage by testing all codecs 2010-06-21 12:30:28 +00:00
Mathieu Malaterre b1342da5c5 make j2k_to_image return errors 2010-06-21 12:26:06 +00:00
Mathieu Malaterre 27850206b5 add some more documentation 2010-06-21 12:15:51 +00:00
Mathieu Malaterre 5bffbfc638 add some documentation on how to use it 2010-06-21 12:13:35 +00:00
Mathieu Malaterre 49f47e2b00 adding a template ctest file 2010-06-21 12:10:49 +00:00
Mathieu Malaterre 1f348833dd Minor tweaks to cmake files 2010-06-21 11:50:46 +00:00
Luis Ibanez f509865242 Addression Windows warnings about mismatch between signed and unsigned. 2010-06-12 22:51:15 +00:00
Luis Ibanez 173ad641aa ENH: Fixing compilation warnings on gcc 4.4. 2010-06-02 04:16:09 +00:00
Luis Ibanez 3b28bfcb3c ENH: Disable the set of CMAKE_C_FLAGS. It precluded the use of flags for performing code coverage. 2010-06-02 04:15:27 +00:00
Luis Ibanez 04c131a315 ENH: Added custom configuration for CTest. This allows to filter out
files for Code Coverage, and to filter out acceptable warnings
     messages.
2010-05-26 23:40:46 +00:00
Luis Ibanez 40c092bbc3 ENH: Enabling the lines that configure testing for the Dashboard. 2010-05-26 23:16:15 +00:00
Luis Ibanez 576f380eba ENH: Adding configuration for submitting builds to the CDash Dasboard 2010-05-26 23:10:49 +00:00
Francois-Olivier Devaux 8a634d0fe3 [v2.0] Fixed problem with Borland C++ Builder (Borland C do not have lrintf). Thanks Marek Mauder for this fix. 2010-04-08 20:20:34 +00:00
Francois-Olivier Devaux f9e6b81176 [v2.0] Fixed pi.c bug (issue 15 on google code). Thanks to Anton Lionel for catching this. 2010-04-08 18:43:29 +00:00
Francois-Olivier Devaux a346da0599 [v2.0] Fixed MJ2 codec bugs (issues 23-24 on google code). Thanks to Winfried for these patches. 2010-04-08 18:01:45 +00:00
Francois-Olivier Devaux b2d22d6bc0 Added support for "jpc" codestreams which are equivalent to "j2c" codestreams [v2.0]. Thanks to Winfried for this patch 2010-03-26 16:09:46 +00:00
Francois-Olivier Devaux 73b4d32638 Code improvements using 'g++-4.4.0' to trace the code (v2.0). Thanks to Winfried for this patch. 2010-03-24 11:21:19 +00:00
Francois-Olivier Devaux 67b5ab3c04 Fixed small compatibility issues with win32 in codec (moved include <strings.h>) 2010-03-07 21:10:47 +00:00
Francois-Olivier Devaux 935baae8fc Updated makefiles for v1.4 and v2.0 2010-03-05 21:28:38 +00:00
Francois-Olivier Devaux 324c949cfd * [FOD] Fixed libopenjpeg Makefile 2010-02-16 11:08:55 +00:00
Francois-Olivier Devaux dc9459029f [FOD] Created a new constant in openjpeg.h to differentiate the case when the colorspace is not supported by the library and when it is not specified in the codestream. Suggested by Matteo Italia. 2010-01-20 15:44:59 +00:00
Antonin Descampe ca3f19c7e3 V2 branch : modified the xcode project name for V2 2009-09-10 15:02:51 +00:00
Antonin Descampe 5238a26db5 V2 branch : removed t1_generate_luts.c from xcode project file 2009-09-10 13:35:04 +00:00
Antonin Descampe ec400c4fa5 V2 branch :
- found a bug in tcd.c that was preventing to find the correct threshold in tcd_rateallocate.c for high-precision images. Applied a temporary patch but a better solution should be found.
- Modified the way raw images with more that 8bpp are read and written
2009-09-10 13:34:19 +00:00
Antonin Descampe b1d8788a46 fixed minor bugs which were triggering warnings at compilation (different signedness, wrong pointer type, etc) 2009-09-10 13:10:09 +00:00
Mathieu Malaterre 1915409c92 ENH: attempt to recommit license with proper eol (match svn info) 2008-08-02 16:49:04 +00:00
Mathieu Malaterre c5ec4896fe ENH: remove INLINE from forward decl. Fix CMakeLists.txt for UNIX platforms 2008-08-02 16:40:10 +00:00
Antonin Descampe fcede9f913 2008-08-01 15:01:24 +00:00
Antonin Descampe 46c3dc4bdf removed t1_generate_luts.c, useless in version 2 ; updated XCode project file for mac users. 2008-08-01 14:10:34 +00:00
Antonin Descampe 7caaea18b7 Deleting obsolete files and directories, adding v2-specific files and directories, updating existing files to v2. See README.v2 for more info 2008-07-31 18:47:41 +00:00
Antonin Descampe 8407e057c9 Creating a branch of openjpeg trunk to host v2 2008-07-31 11:24:31 +00:00
536 changed files with 40849 additions and 257621 deletions

View File

@ -1,30 +0,0 @@
<!--
IMPORTANT: Do NOT use GitHub to post any questions or support requests!
They will be closed immediately and ignored.
Questions should go to the OpenJPEG mailing list at
https://groups.google.com/g/openjpeg or other support forums.
GitHub issues are for bug reports and suggestions for new features.
The OpenJPEG project is made of contributions from various individuals and
organizations, each with their own focus. The issue you are facing is
not necessarily in the priority list of those contributors and consequently
there is no guarantee that it will be addressed in a timely manner.
-->
## Expected behavior and actual behavior.
...to fill...
## Steps to reproduce the problem.
...to fill...
## Operating system
...to fill...
## openjpeg version
...to fill...

View File

@ -1,24 +0,0 @@
name: ABI check
on: [push, pull_request, workflow_dispatch]
jobs:
abi_check:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Requirements
run: |
sudo apt update
sudo apt install -y gcc g++ libelf-dev elfutils texinfo exuberant-ctags libtiff-dev libwebp-dev libzstd-dev
- name: Build
run: |
./tools/travis-ci/install.sh
./tools/travis-ci/run.sh
./tools/travis-ci/abi-check.sh
env:
OPJ_CI_ABI_CHECK: 1

View File

@ -1,189 +0,0 @@
name: Build
on: [push, pull_request, workflow_dispatch]
jobs:
regular:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Requirements
run: |
sudo apt update
sudo apt install -y gcc g++ libtiff-dev libwebp-dev libzstd-dev
- name: Build and run tests
run: |
./tools/travis-ci/install.sh
./tools/travis-ci/run.sh
env:
OPJ_CI_ARCH: x86_64
OPJ_CI_BUILD_CONFIGURATION: Release
OPJ_CI_PERF_TESTS: 1
OPJ_CI_BUILD_FUZZERS: 1
OPJ_CI_INCLUDE_IF_DEPLOY: 1
OPJ_NONCOMMERCIAL: 1
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: build/openjpeg-*.tar.gz
asan:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Requirements
run: |
sudo apt update
sudo apt install -y gcc g++
- name: Build and run tests
run: |
./tools/travis-ci/install.sh
./tools/travis-ci/run.sh
env:
OPJ_CI_ARCH: x86_64
OPJ_CI_BUILD_CONFIGURATION: Debug
OPJ_CI_ASAN: 1
OPJ_NONCOMMERCIAL: 1
clang_32bit:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Requirements
run: |
sudo apt update
sudo apt install -y clang gcc-multilib
- name: Build and run tests
run: |
./tools/travis-ci/install.sh
./tools/travis-ci/run.sh
env:
OPJ_CI_CC: clang
OPJ_CI_CXX: clang++
OPJ_CI_INSTRUCTION_SETS: "-mavx2"
OPJ_CI_BUILD_CONFIGURATION: Release
OPJ_CI_ARCH: i386
OPJ_NUM_THREADS: 2
OPJ_NONCOMMERCIAL: 1
mingw_64:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Requirements
run: |
sudo apt update
sudo apt install -y gcc-mingw-w64-base binutils-mingw-w64-x86-64 gcc-mingw-w64-x86-64 gcc-mingw-w64 g++-mingw-w64-x86-64
- name: Build and run tests
run: |
./tools/travis-ci/install.sh
./tools/travis-ci/run.sh
env:
OPJ_CI_CC: x86_64-w64-mingw32-gcc
OPJ_CI_CXX: x86_64-w64-mingw32-g++
OPJ_CI_ARCH: x86_64
OPJ_CI_BUILD_CONFIGURATION: Release
OPJ_NONCOMMERCIAL: 1
macos:
runs-on: macos-latest
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build and run tests
run: |
./tools/travis-ci/install.sh
./tools/travis-ci/run.sh
env:
OPJ_CI_ARCH: x86_64
OPJ_CI_BUILD_CONFIGURATION: Release
OPJ_CI_INCLUDE_IF_DEPLOY: 1
#OPJ_NONCOMMERCIAL: 1
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: build/openjpeg-*.zip
windows_build:
runs-on: windows-2019
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
strategy:
matrix:
include:
- VS_VER: 2019
OPJ_CI_ARCH: x64
OPJ_CI_INCLUDE_IF_DEPLOY: 1
- VS_VER: 2019
OPJ_CI_ARCH: x86
OPJ_CI_INCLUDE_IF_DEPLOY: 1
- VS_VER: 2019
OPJ_CI_ARCH: x64
# We do have specific failures noted in tools/travis-ci/knownfailures-windows-vs2015-x64-avx2-Release-3rdP.txt
# not sure why that happens
OPJ_CI_INSTRUCTION_SETS: "/arch:AVX2"
env:
VS_VER: ${{ matrix.VS_VER }}
OPJ_CI_ARCH: ${{ matrix.OPJ_CI_ARCH }}
OPJ_CI_INCLUDE_IF_DEPLOY: ${{ matrix.OPJ_CI_INCLUDE_IF_DEPLOY }}
OPJ_CI_INSTRUCTION_SETS: ${{ matrix.OPJ_CI_INSTRUCTION_SETS }}
#OPJ_NONCOMMERCIAL: 1
steps:
- name: Setup git
run: |
git config --global core.autocrlf false
git config --system core.longpaths true
- name: Checkout
uses: actions/checkout@v2
- name: Set compiler environment
shell: cmd
run: |
if "%VS_VER%" == "2019" CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=%OPJ_CI_ARCH%
echo PATH=%PATH%>> %GITHUB_ENV%
echo INCLUDE=%INCLUDE%>> %GITHUB_ENV%
echo LIB=%LIB%>> %GITHUB_ENV%
echo LIBPATH=%LIBPATH%>> %GITHUB_ENV%
- name: Install wget
shell: cmd
run: |
choco install wget --no-progress
- name: Build and run tests
run: |
./tools/travis-ci/install.sh
./tools/travis-ci/run.sh
shell: bash
- name: Release
uses: softprops/action-gh-release@v1
if: ${{startsWith(github.ref, 'refs/tags/') && env.OPJ_CI_INCLUDE_IF_DEPLOY == 1}}
with:
files: build/openjpeg-*.zip

View File

@ -1,26 +0,0 @@
name: CIFuzz
on: [pull_request]
jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'openjpeg'
dry-run: false
language: c
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'openjpeg'
fuzz-seconds: 600
dry-run: false
language: c
- name: Upload Crash
uses: actions/upload-artifact@v1
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts

View File

@ -1,26 +0,0 @@
name: Code Style
on: [push, pull_request, workflow_dispatch]
jobs:
code_style:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install Requirements
run: |
sudo apt update
sudo apt install -y gcc g++ flip
- name: Run check
run: |
./tools/travis-ci/install.sh
./tools/travis-ci/run.sh
env:
OPJ_CI_CHECK_STYLE: 1
OPJ_CI_SKIP_TESTS: 1

21
.gitignore vendored
View File

@ -1,21 +0,0 @@
# Ignore files and directories made by `cmake .`.
CMakeFiles/
Makefile
cmake_install.cmake
/CMakeCache.txt
/CPackConfig.cmake
/CPackSourceConfig.cmake
/CTestCustom.cmake
/LICENSE.txt
/OpenJPEGConfig.cmake
/libopenjp2.pc
/src/bin/common/opj_apps_config.h
/src/lib/openjp2/opj_config.h
/src/lib/openjp2/opj_config_private.h
scripts/opjstyle*
# Ignore directories made by `make`.
/bin/
build
SDK
*.lha

View File

@ -1,163 +0,0 @@
language: cpp
matrix:
include:
# OSX
# OPJ_NONCOMMERCIAL=0 because Kakadu install hangs (cf https://travis-ci.org/github/uclouvain/openjpeg/builds/769447606)
# - os: osx
# compiler: clang
# env: OPJ_NONCOMMERCIAL=0 OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release OPJ_CI_INCLUDE_IF_DEPLOY=1
# Test code style
- os: linux
compiler: clang-3.8
env: OPJ_CI_CC=clang-3.8 OPJ_CI_CXX=clang-3.8 OPJ_CI_CHECK_STYLE=1 OPJ_CI_SKIP_TESTS=1
addons:
apt:
sources:
- llvm-toolchain-precise-3.8
- ubuntu-toolchain-r-test
packages:
- clang-3.8
- flip
# Performance test with GCC
# Disabled because tests fail
# - os: linux
# compiler: g++
# dist: precise
# env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release OPJ_CI_INCLUDE_IF_DEPLOY=1 OPJ_CI_PERF_TESTS=1
# Test compilation with AVX2
- os: linux
# "sudo: yes" and "dist: trusty" give us a worker with the AVX2 instruction set
sudo: yes
dist: trusty
compiler: clang-3.8
env: OPJ_CI_CC=clang-3.8 OPJ_CI_CXX=clang-3.8 OPJ_CI_INSTRUCTION_SETS="-mavx2" OPJ_CI_BUILD_CONFIGURATION=Release
addons:
apt:
sources:
- llvm-toolchain-precise-3.8
- ubuntu-toolchain-r-test
packages:
- clang-3.8
# Test multi-threading
# Disabled because tests fail (cf https://travis-ci.org/github/uclouvain/openjpeg/builds/769447606)
# - os: linux
# compiler: g++
# dist: precise
# env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release OPJ_NUM_THREADS=2
# Test 32-bit compilation
# Disabled because tests fail (cf https://travis-ci.org/github/uclouvain/openjpeg/builds/769447606)
# - os: linux
# compiler: g++
# env: OPJ_CI_ARCH=i386 OPJ_CI_BUILD_CONFIGURATION=Release
# dist: trusty
# addons:
# apt:
# packages:
# - gcc-multilib
# - g++-multilib
# Profile code (gcc -pg)
# Disabled because tests fail (cf https://travis-ci.org/github/uclouvain/openjpeg/builds/769447606)
# - os: linux
# compiler: g++
# env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Debug OPJ_CI_PROFILE=1
# dist: trusty
# addons:
# apt:
# packages:
# - valgrind
# Test under ASAN
# Temporarily disabled since broken. See https://github.com/uclouvain/openjpeg/issues/1091
# - os: linux
# compiler: clang
# env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Debug OPJ_CI_ASAN=1
# Test with CLang 3.8
- os: linux
compiler: clang-3.8
env: OPJ_CI_CC=clang-3.8 OPJ_CI_CXX=clang-3.8 OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release OPJ_CI_PERF_TESTS=1 OPJ_CI_BUILD_FUZZERS=1
dist: trusty
addons:
apt:
sources:
- llvm-toolchain-precise-3.8
- ubuntu-toolchain-r-test
packages:
- clang-3.8
# Test with mingw 32 bit
- os: linux
compiler: x86_64-w64-mingw32-g++
env: OPJ_CI_CC=x86_64-w64-mingw32-gcc OPJ_CI_CXX=x86_64-w64-mingw32-g++ OPJ_CI_ARCH=i386 OPJ_CI_BUILD_CONFIGURATION=Release
dist: trusty
addons:
apt:
packages:
- gcc-mingw-w64-base
- binutils-mingw-w64-i686
- gcc-mingw-w64-i686
- gcc-mingw-w64
- g++-mingw-w64-i686
- gcc-multilib
- g++-multilib
# Test with mingw 64 bit
- os: linux
compiler: x86_64-w64-mingw32-g++
env: OPJ_CI_CC=x86_64-w64-mingw32-gcc OPJ_CI_CXX=x86_64-w64-mingw32-g++ OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
dist: trusty
addons:
apt:
packages:
- gcc-mingw-w64-base
- binutils-mingw-w64-x86-64
- gcc-mingw-w64-x86-64
- gcc-mingw-w64
- g++-mingw-w64-x86-64
# Test with gcc 4.8
- os: linux
compiler: g++-4.8
env: OPJ_CI_CC=gcc-4.8 OPJ_CI_CXX=g++-4.8 OPJ_CI_ABI_CHECK=1
dist: xenial
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.8
- g++-4.8
- libelf-dev
- elfutils
- texinfo
- exuberant-ctags
install:
- "./tools/travis-ci/install.sh"
script:
- "./tools/travis-ci/run.sh"
- "./tools/travis-ci/abi-check.sh"
before_deploy:
- export OPJ_RELEASE_PKG_FILE=$(ls build/openjpeg-${TRAVIS_TAG}*)
- echo "deploying $OPJ_RELEASE_PKG_FILE to GitHub releases"
deploy:
provider: releases
api_key:
secure: dJXdzoFwk9wYWIKztnXKlVIr1QDmeXtk3oK+2MEzy22fBTKPuphU/cYMvhi5B7sWDwm77f43vbAYO6z7IFmuThwhkuVMD/o+lUyCqGffGeiU1pKpxEvB+LbO/C5asdSnor3RfYdOyo3x4cNlhNtfhXIn7FcAg371yEY6VSIP87adoQcuE+taig0cYWcrNWYGHirHlzEz1utnKwCT/nlhV4nSIWxjwYUp3nt8PAw3RbqQkPPNBniW92g6JA25vLRc3HMD18ISCfNLC2fI6a/dTR+vd+bCySA7JvqeDZnv8SxbVIabu5T+A5CHzHbdp2l2kynPwqHOO47pGa+VfisXEwSsOpa+4EZsPLdwOhaFFnvDwKwR3EjI1TkRVd26IcK61Y5zVZQgalnXBowBEZoI4fT/oEPF7VZMjN3sy/do1U6d5kO0UGqCHCJIVwPeELhwq5z7Ld04K7dSFFVenZhhQKCwxI1o8vgkGNJUWD2Ii6ZLrZKYZ0lC65hr2d39e/KoK3Yh5KHF0cVn6ppBTcUjYr/tdHHO43rwoaf3r1CdAQAYpFvfi3900hl9I/GPwky0YJ6W2QDS2vincwaqWDQ0+WNGf4AKSdx5kCgQU45PSfDb/lxAyXkqmBuI3h/C2ellleaWVL9sGtNRWa/w6WseGMGwfCXgN82XRVM2bgP6pYg=
file_glob: true
file: "${OPJ_RELEASE_PKG_FILE}"
skip_cleanup: true
on:
repo: uclouvain/openjpeg
tags: true
condition: "$OPJ_CI_INCLUDE_IF_DEPLOY = 1"

View File

@ -1,21 +0,0 @@
# Authors of OpenJPEG
See also [THANKS](https://github.com/uclouvain/openjpeg/blob/master/THANKS.md)
David Janssens designed and implemented the first version of OpenJPEG.
Kaori Hagihara designed and implemented the first version of OpenJPIP.
Jerome Fimes implemented the alpha version of OpenJPEG 2.0.
Giuseppe Baruffa added the JPWL functionalities.
Mickaël Savinaud implemented the final OpenJPEG 2.0 version based on a big merge between 1.5 version and alpha version of 2.0.
Mathieu Malaterre participated to the OpenJPEG 2.0 version and improved the libraries and utilities.
Yannick Verschueren,
Herve Drolon,
Francois-Olivier Devaux,
Antonin Descampe
improved the libraries and utilities.

View File

@ -1,889 +0,0 @@
# Changelog
## [v2.5.0](https://github.com/uclouvain/openjpeg/releases/v2.5.0) (2022-05-13)
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.4.0...v2.5.0)
**Merged pull requests:**
- tools/travis-ci/install.sh: git clone with https:// to fix 'The unaut… [\#1419](https://github.com/uclouvain/openjpeg/pull/1419) ([rouault](https://github.com/rouault))
- Java Support 1.8 now... [\#1418](https://github.com/uclouvain/openjpeg/pull/1418) ([jiapei100](https://github.com/jiapei100))
- Separate fuzz targets to increase coverage [\#1416](https://github.com/uclouvain/openjpeg/pull/1416) ([Navidem](https://github.com/Navidem))
- CMakeLists.txt: do not set INSTALL\_NAME\_DIR for MacOS builds for CMake \>= 3.0 \(fixes \#1404\) [\#1410](https://github.com/uclouvain/openjpeg/pull/1410) ([rouault](https://github.com/rouault))
- Avoid integer overflows in DWT. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44544 [\#1408](https://github.com/uclouvain/openjpeg/pull/1408) ([rouault](https://github.com/rouault))
- Updated "added support for partial bitstream decoding" [\#1407](https://github.com/uclouvain/openjpeg/pull/1407) ([Neopallium](https://github.com/Neopallium))
- opj\_encoder\_set\_extra\_options\(\): add a GUARD\_BITS=value option [\#1403](https://github.com/uclouvain/openjpeg/pull/1403) ([rouault](https://github.com/rouault))
- More overflow related bug fixes [\#1402](https://github.com/uclouvain/openjpeg/pull/1402) ([Eharve14](https://github.com/Eharve14))
- opj\_j2k\_setup\_encoder\(\): validate number of tiles to avoid illegal values and potential overflow \(fixes \#1399\) [\#1401](https://github.com/uclouvain/openjpeg/pull/1401) ([rouault](https://github.com/rouault))
- Missed conversion from unsigned int to OPJ\_INT32 [\#1398](https://github.com/uclouvain/openjpeg/pull/1398) ([Eharve14](https://github.com/Eharve14))
- Added check for integer overflow in get\_num\_images [\#1397](https://github.com/uclouvain/openjpeg/pull/1397) ([Eharve14](https://github.com/Eharve14))
- Added overflow check for CVE-2021-29338 [\#1396](https://github.com/uclouvain/openjpeg/pull/1396) ([Eharve14](https://github.com/Eharve14))
- Fix integer overflow in num\_images [\#1395](https://github.com/uclouvain/openjpeg/pull/1395) ([baparham](https://github.com/baparham))
- Remove duplicate assignments in function tiftoimage [\#1392](https://github.com/uclouvain/openjpeg/pull/1392) ([stweil](https://github.com/stweil))
- Fix some typos \(found by codespell\) [\#1390](https://github.com/uclouvain/openjpeg/pull/1390) ([stweil](https://github.com/stweil))
- CI: Add CIFuzz action [\#1386](https://github.com/uclouvain/openjpeg/pull/1386) ([DavidKorczynski](https://github.com/DavidKorczynski))
- Feature/decimation [\#1384](https://github.com/uclouvain/openjpeg/pull/1384) ([msheby](https://github.com/msheby))
- API: deprecate 'bpp' member in favor of 'prec' [\#1383](https://github.com/uclouvain/openjpeg/pull/1383) ([rouault](https://github.com/rouault))
- Added support for high throughput \(HTJ2K\) decoding. [\#1381](https://github.com/uclouvain/openjpeg/pull/1381) ([rouault](https://github.com/rouault))
- verify-indentation.sh: fix for pull request from bar/master to foo/master [\#1380](https://github.com/uclouvain/openjpeg/pull/1380) ([rouault](https://github.com/rouault))
- Change integer for version libtiff 4.3.0 [\#1377](https://github.com/uclouvain/openjpeg/pull/1377) ([Jamaika1](https://github.com/Jamaika1))
- Port continuous integration to github actions [\#1376](https://github.com/uclouvain/openjpeg/pull/1376) ([rouault](https://github.com/rouault))
- Avoid integer overflows in DWT. [\#1375](https://github.com/uclouvain/openjpeg/pull/1375) ([rouault](https://github.com/rouault))
- LGTM warning: Comparison result is always the same [\#1373](https://github.com/uclouvain/openjpeg/pull/1373) ([DimitriPapadopoulos](https://github.com/DimitriPapadopoulos))
- A couple typos found by codespell [\#1371](https://github.com/uclouvain/openjpeg/pull/1371) ([DimitriPapadopoulos](https://github.com/DimitriPapadopoulos))
- cmake: add install interface include directory [\#1370](https://github.com/uclouvain/openjpeg/pull/1370) ([madebr](https://github.com/madebr))
- fix issues 1368: exist a issues of freeing uninitialized pointer in src/bin/jp2/opj\_decompress.cthat will cause a segfault [\#1369](https://github.com/uclouvain/openjpeg/pull/1369) ([xiaoxiaoafeifei](https://github.com/xiaoxiaoafeifei))
- opj\_j2k\_is\_imf\_compliant: Fix out of bounds access [\#1366](https://github.com/uclouvain/openjpeg/pull/1366) ([sebras](https://github.com/sebras))
- opj\_j2k\_is\_imf\_compliant: Fix argument formatting for warnings. [\#1365](https://github.com/uclouvain/openjpeg/pull/1365) ([sebras](https://github.com/sebras))
- CMakeLists.txt/appveyor.yml: update version number to 2.5.0… [\#1361](https://github.com/uclouvain/openjpeg/pull/1361) ([rouault](https://github.com/rouault))
- .travis.yml: try to fix gcc 4.8 config by updating to xenial [\#1360](https://github.com/uclouvain/openjpeg/pull/1360) ([rouault](https://github.com/rouault))
- Add support for enabling generation of TLM markers in encoder [\#1359](https://github.com/uclouvain/openjpeg/pull/1359) ([rouault](https://github.com/rouault))
- Fix various compiler warnings [\#1358](https://github.com/uclouvain/openjpeg/pull/1358) ([rouault](https://github.com/rouault))
- fix \#1345: don't remove big endian test for other platforms [\#1354](https://github.com/uclouvain/openjpeg/pull/1354) ([msabwat](https://github.com/msabwat))
- Remove obsolete components JPWL, JP3D and MJ2 [\#1350](https://github.com/uclouvain/openjpeg/pull/1350) ([rouault](https://github.com/rouault))
- tools/travis-ci/install.sh: fix links to Kakadu and jpylyzer binaries [\#1348](https://github.com/uclouvain/openjpeg/pull/1348) ([rouault](https://github.com/rouault))
- emscripten: disable big endian test [\#1345](https://github.com/uclouvain/openjpeg/pull/1345) ([msabwat](https://github.com/msabwat))
- Fix cmake file with DESTDIR [\#1321](https://github.com/uclouvain/openjpeg/pull/1321) ([ffontaine](https://github.com/ffontaine))
- CMakeLists.txt: Don't require a C++ compiler [\#1317](https://github.com/uclouvain/openjpeg/pull/1317) ([ffontaine](https://github.com/ffontaine))
- Import files tiff and yuv\(raw\) [\#1316](https://github.com/uclouvain/openjpeg/pull/1316) ([Jamaika1](https://github.com/Jamaika1))
- Fix year in NEWS [\#1312](https://github.com/uclouvain/openjpeg/pull/1312) ([stweil](https://github.com/stweil))
- Fix lcms2 static linking using pgk config [\#867](https://github.com/uclouvain/openjpeg/pull/867) ([pseiderer](https://github.com/pseiderer))
- fix static build only against tiff and its indirect dependencies [\#866](https://github.com/uclouvain/openjpeg/pull/866) ([tSed](https://github.com/tSed))
**Closed issues:**
- integer constant is too large for 'long' type [\#61](https://github.com/uclouvain/openjpeg/issues/61)
- Openjpeg3D lossy compression not working [\#501](https://github.com/uclouvain/openjpeg/issues/501)
- mj2: Array overflow [\#485](https://github.com/uclouvain/openjpeg/issues/485)
- OPJ fails to decode image that KDU manages correctly [\#419](https://github.com/uclouvain/openjpeg/issues/419)
- yuvtoimage\(\) bug in v1 and v2 for 16-Bit: please apply ASAP [\#384](https://github.com/uclouvain/openjpeg/issues/384)
- JP3D: Fix CVE-2013-4289 CVE-2013-4290 [\#298](https://github.com/uclouvain/openjpeg/issues/298)
- MJ2 libraries are installed in lib [\#204](https://github.com/uclouvain/openjpeg/issues/204)
- MJ2: realloc is misused and may leak memory [\#168](https://github.com/uclouvain/openjpeg/issues/168)
- MJ2 wrapper not functional [\#143](https://github.com/uclouvain/openjpeg/issues/143)
- JPWL is broken in trunk [\#137](https://github.com/uclouvain/openjpeg/issues/137)
- MJ2 files not using OPENJPEG API correctly [\#53](https://github.com/uclouvain/openjpeg/issues/53)
- Maximum bit depth supported by the OpenJPEG implementation of JP3D [\#9](https://github.com/uclouvain/openjpeg/issues/9)
- does openjpeg support either visually lossless or numerically lossless jpeg2000 compression? [\#1406](https://github.com/uclouvain/openjpeg/issues/1406)
- extract jpeg2000 tile without decompression [\#1405](https://github.com/uclouvain/openjpeg/issues/1405)
- openjpeg doesn't install a relocatable shared lib on macOS [\#1404](https://github.com/uclouvain/openjpeg/issues/1404)
- pull request - the cinema industry awaits! [\#1400](https://github.com/uclouvain/openjpeg/issues/1400)
- Integer overflows in j2K [\#1399](https://github.com/uclouvain/openjpeg/issues/1399)
- why lossly compression performance worse than jpeg when compress png [\#1393](https://github.com/uclouvain/openjpeg/issues/1393)
- cect [\#1389](https://github.com/uclouvain/openjpeg/issues/1389)
- the docs don't describe bpp and prec in opj\_image\_comp very well [\#1379](https://github.com/uclouvain/openjpeg/issues/1379)
- converting .png to .jp2 by opj\_compress is different from the original image [\#1378](https://github.com/uclouvain/openjpeg/issues/1378)
- Comparison result is always the same [\#1372](https://github.com/uclouvain/openjpeg/issues/1372)
- Exist a issues of freeing uninitialized pointer in src/bin/jp2/opj\_decompress.cthat will cause a segfault [\#1368](https://github.com/uclouvain/openjpeg/issues/1368)
- \[TEST NOT RUNNING\]: bigendian test [\#1355](https://github.com/uclouvain/openjpeg/issues/1355)
- opj\_decompress 2.4.0 built with library 2.3.0. [\#1352](https://github.com/uclouvain/openjpeg/issues/1352)
- New library htjpeg2000 [\#1351](https://github.com/uclouvain/openjpeg/issues/1351)
- Integer Overflow in num\_images [\#1338](https://github.com/uclouvain/openjpeg/issues/1338)
- All IMF Profile Selections Result in PART1 [\#1337](https://github.com/uclouvain/openjpeg/issues/1337)
- grayscale image [\#1334](https://github.com/uclouvain/openjpeg/issues/1334)
- error C2169: 'lrintf': intrinsic function, cannot be defined [\#1333](https://github.com/uclouvain/openjpeg/issues/1333)
- Generate lower-case extension [\#1332](https://github.com/uclouvain/openjpeg/issues/1332)
- color of reconstructed png file much darker [\#1330](https://github.com/uclouvain/openjpeg/issues/1330)
- CVE-2019-6988, CVE-2018-20846 and CVE-2018-16376 [\#1328](https://github.com/uclouvain/openjpeg/issues/1328)
- opj 2.4.0: opj\_free missing in opj3d [\#1327](https://github.com/uclouvain/openjpeg/issues/1327)
- Not able to compress volumetric data [\#1326](https://github.com/uclouvain/openjpeg/issues/1326)
- HTML documents are not installed in specified place [\#1322](https://github.com/uclouvain/openjpeg/issues/1322)
- Can't find openjpeg.h when cross-compile. [\#1320](https://github.com/uclouvain/openjpeg/issues/1320)
- OpenJPEG is available with EasyConfig [\#1319](https://github.com/uclouvain/openjpeg/issues/1319)
- Building Test Programs [\#1318](https://github.com/uclouvain/openjpeg/issues/1318)
- Builds are not reproducible [\#1275](https://github.com/uclouvain/openjpeg/issues/1275)
- strange behaviour of opj\_jp3d\_compress/decompress utility [\#1274](https://github.com/uclouvain/openjpeg/issues/1274)
- Potential heap-based buffer overflow in function t2\_encode\_packet in src/lib/openmj2/t2.c and src/lib/openjp3d/t2.c [\#1272](https://github.com/uclouvain/openjpeg/issues/1272)
- Function tgatoimage in src/bin/jpwl/convert.c need to check that the file is big enough to avoid excessive memory allocations [\#1271](https://github.com/uclouvain/openjpeg/issues/1271)
- memory & cpu are exhausted when converting jp2 file into png [\#1250](https://github.com/uclouvain/openjpeg/issues/1250)
- Cannot compress PGX into JP3D despite following the directions? [\#1134](https://github.com/uclouvain/openjpeg/issues/1134)
- sscanf buffer overflow in opj\_jp3d\_compress.c [\#1130](https://github.com/uclouvain/openjpeg/issues/1130)
- integer underflow may lead to writing garbage [\#1089](https://github.com/uclouvain/openjpeg/issues/1089)
- sscanf buffer overflow [\#1087](https://github.com/uclouvain/openjpeg/issues/1087)
- strcpy overflows [\#1086](https://github.com/uclouvain/openjpeg/issues/1086)
- sprintf buffer overflows [\#1084](https://github.com/uclouvain/openjpeg/issues/1084)
- strcpy buffer overflow [\#1083](https://github.com/uclouvain/openjpeg/issues/1083)
- integer overflow in malloc\(\) [\#1082](https://github.com/uclouvain/openjpeg/issues/1082)
- out of bounds writes [\#1078](https://github.com/uclouvain/openjpeg/issues/1078)
- out of bounds writes [\#1077](https://github.com/uclouvain/openjpeg/issues/1077)
- divide by zero, perhaps multiplication overflow [\#1076](https://github.com/uclouvain/openjpeg/issues/1076)
- missing format string parameter [\#1075](https://github.com/uclouvain/openjpeg/issues/1075)
- leaks from cppcheck in lib folder [\#1038](https://github.com/uclouvain/openjpeg/issues/1038)
- How to initialize DEBUG\_PROFILE in color.c? [\#958](https://github.com/uclouvain/openjpeg/issues/958)
- JP3D sample files [\#865](https://github.com/uclouvain/openjpeg/issues/865)
- BIG\_ENDIAN bug in jpwl.c [\#839](https://github.com/uclouvain/openjpeg/issues/839)
- OpenJPEG fails to decode partial j2c where kdu succeeds [\#715](https://github.com/uclouvain/openjpeg/issues/715)
- building mj2 binaries fails [\#652](https://github.com/uclouvain/openjpeg/issues/652)
- openmj2\mj2.c: Out of bounds [\#646](https://github.com/uclouvain/openjpeg/issues/646)
- bin\mj2\opj\_mj2\_decompress.c 101 wrong check / leak [\#608](https://github.com/uclouvain/openjpeg/issues/608)
## [v2.4.0](https://github.com/uclouvain/openjpeg/releases/v2.4.0) (2020-12-28)
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.3.1...v2.4.0)
**Closed issues:**
- OPENJPEG\_INSTALL\_DOC\_DIR does not control a destination directory where HTML docs would be installed. [\#1309](https://github.com/uclouvain/openjpeg/issues/1309)
- Heap-buffer-overflow in lib/openjp2/pi.c:312 [\#1302](https://github.com/uclouvain/openjpeg/issues/1302)
- Heap-buffer-overflow in lib/openjp2/t2.c:973 [\#1299](https://github.com/uclouvain/openjpeg/issues/1299)
- Heap-buffer-overflow in lib/openjp2/pi.c:623 [\#1293](https://github.com/uclouvain/openjpeg/issues/1293)
- Global-buffer-overflow in lib/openjp2/dwt.c:1980 [\#1286](https://github.com/uclouvain/openjpeg/issues/1286)
- Heap-buffer-overflow in lib/openjp2/tcd.c:2417 [\#1284](https://github.com/uclouvain/openjpeg/issues/1284)
- Heap-buffer-overflow in lib/openjp2/mqc.c:499 [\#1283](https://github.com/uclouvain/openjpeg/issues/1283)
- Openjpeg could not encode 32bit RGB float image [\#1281](https://github.com/uclouvain/openjpeg/issues/1281)
- Openjpeg could not encode 32bit RGB float image [\#1280](https://github.com/uclouvain/openjpeg/issues/1280)
- ISO/IEC 15444-1:2019 \(E\) compared with 'cio.h' [\#1277](https://github.com/uclouvain/openjpeg/issues/1277)
- Test-suite failure due to hash mismatch [\#1264](https://github.com/uclouvain/openjpeg/issues/1264)
- Heap use-after-free [\#1261](https://github.com/uclouvain/openjpeg/issues/1261)
- Memory leak when failing to allocate object... [\#1259](https://github.com/uclouvain/openjpeg/issues/1259)
- Memory leak of Tier 1 handle when OpenJPEG fails to set it as TLS... [\#1257](https://github.com/uclouvain/openjpeg/issues/1257)
- Any plan to build release for CVE-2020-8112/CVE-2020-6851 [\#1247](https://github.com/uclouvain/openjpeg/issues/1247)
- failing to convert 16-bit file: opj\_t2\_encode\_packet\(\): only 5251 bytes remaining in output buffer. 5621 needed. [\#1243](https://github.com/uclouvain/openjpeg/issues/1243)
- CMake+VS2017 Compile OK, thirdparty Compile OK, but thirdparty not install [\#1239](https://github.com/uclouvain/openjpeg/issues/1239)
- New release to solve CVE-2019-6988 ? [\#1238](https://github.com/uclouvain/openjpeg/issues/1238)
- Many tests fail to pass after the update of libtiff to version 4.1.0 [\#1233](https://github.com/uclouvain/openjpeg/issues/1233)
- Another heap buffer overflow in libopenjp2 [\#1231](https://github.com/uclouvain/openjpeg/issues/1231)
- Heap buffer overflow in libopenjp2 [\#1228](https://github.com/uclouvain/openjpeg/issues/1228)
- Endianness of binary volume \(JP3D\) [\#1224](https://github.com/uclouvain/openjpeg/issues/1224)
- New release to resolve CVE-2019-12973 [\#1222](https://github.com/uclouvain/openjpeg/issues/1222)
- how to set the block size,like 128,256 ? [\#1216](https://github.com/uclouvain/openjpeg/issues/1216)
- compress YUV files to motion jpeg2000 standard [\#1213](https://github.com/uclouvain/openjpeg/issues/1213)
- Repair/update Java wrapper, and include in release [\#1208](https://github.com/uclouvain/openjpeg/issues/1208)
- abc [\#1206](https://github.com/uclouvain/openjpeg/issues/1206)
- Slow decoding [\#1202](https://github.com/uclouvain/openjpeg/issues/1202)
- Installation question [\#1201](https://github.com/uclouvain/openjpeg/issues/1201)
- Typo in test\_decode\_area - \*ptilew is assigned instead of \*ptileh [\#1195](https://github.com/uclouvain/openjpeg/issues/1195)
- Creating a J2K file with one POC is broken [\#1191](https://github.com/uclouvain/openjpeg/issues/1191)
- Make fails on Arch Linux [\#1174](https://github.com/uclouvain/openjpeg/issues/1174)
- Heap buffer overflow in opj\_t1\_clbl\_decode\_processor\(\) triggered with Ghostscript [\#1158](https://github.com/uclouvain/openjpeg/issues/1158)
- opj\_stream\_get\_number\_byte\_left: Assertion `p\_stream-\>m\_byte\_offset \>= 0' failed. [\#1151](https://github.com/uclouvain/openjpeg/issues/1151)
- The fuzzer ignores too many inputs [\#1079](https://github.com/uclouvain/openjpeg/issues/1079)
- out of bounds read [\#1068](https://github.com/uclouvain/openjpeg/issues/1068)
**Merged pull requests:**
- Change defined WIN32 [\#1310](https://github.com/uclouvain/openjpeg/pull/1310) ([Jamaika1](https://github.com/Jamaika1))
- docs: fix simple typo, producted -\> produced [\#1308](https://github.com/uclouvain/openjpeg/pull/1308) ([timgates42](https://github.com/timgates42))
- Set ${OPENJPEG\_INSTALL\_DOC\_DIR} to DESTINATION of HTMLs [\#1307](https://github.com/uclouvain/openjpeg/pull/1307) ([lemniscati](https://github.com/lemniscati))
- Use INC\_DIR for OPENJPEG\_INCLUDE\_DIRS \(fixes uclouvain\#1174\) [\#1306](https://github.com/uclouvain/openjpeg/pull/1306) ([matthew-sharp](https://github.com/matthew-sharp))
- pi.c: avoid out of bounds access with POC \(fixes \#1302\) [\#1304](https://github.com/uclouvain/openjpeg/pull/1304) ([rouault](https://github.com/rouault))
- Encoder: grow again buffer size [\#1303](https://github.com/uclouvain/openjpeg/pull/1303) ([zodf0055980](https://github.com/zodf0055980))
- opj\_j2k\_write\_sod\(\): avoid potential heap buffer overflow \(fixes \#1299\) \(probably master only\) [\#1301](https://github.com/uclouvain/openjpeg/pull/1301) ([rouault](https://github.com/rouault))
- pi.c: avoid out of bounds access with POC \(refs https://github.com/uclouvain/openjpeg/issues/1293\#issuecomment-737122836\) [\#1300](https://github.com/uclouvain/openjpeg/pull/1300) ([rouault](https://github.com/rouault))
- opj\_t2\_encode\_packet\(\): avoid out of bound access of \#1297, but likely not the proper fix [\#1298](https://github.com/uclouvain/openjpeg/pull/1298) ([rouault](https://github.com/rouault))
- opj\_t2\_encode\_packet\(\): avoid out of bound access of \#1294, but likely not the proper fix [\#1296](https://github.com/uclouvain/openjpeg/pull/1296) ([rouault](https://github.com/rouault))
- opj\_j2k\_setup\_encoder\(\): validate POC compno0 and compno1 \(fixes \#1293\) [\#1295](https://github.com/uclouvain/openjpeg/pull/1295) ([rouault](https://github.com/rouault))
- Encoder: avoid global buffer overflow on irreversible conversion when… [\#1292](https://github.com/uclouvain/openjpeg/pull/1292) ([rouault](https://github.com/rouault))
- Decoding: deal with some SPOT6 images that have tiles with a single tile-part with TPsot == 0 and TNsot == 0, and with missing EOC [\#1291](https://github.com/uclouvain/openjpeg/pull/1291) ([rouault](https://github.com/rouault))
- Free p\_tcd\_marker\_info to avoid memory leak [\#1288](https://github.com/uclouvain/openjpeg/pull/1288) ([zodf0055980](https://github.com/zodf0055980))
- Encoder: grow again buffer size [\#1287](https://github.com/uclouvain/openjpeg/pull/1287) ([zodf0055980](https://github.com/zodf0055980))
- Encoder: avoid uint32 overflow when allocating memory for codestream buffer \(fixes \#1243\) [\#1276](https://github.com/uclouvain/openjpeg/pull/1276) ([rouault](https://github.com/rouault))
- Java compatibility from 1.5 to 1.6 [\#1263](https://github.com/uclouvain/openjpeg/pull/1263) ([jiapei100](https://github.com/jiapei100))
- opj\_decompress: fix double-free on input directory with mix of valid and invalid images [\#1262](https://github.com/uclouvain/openjpeg/pull/1262) ([rouault](https://github.com/rouault))
- openjp2: Plug image leak when failing to allocate codestream index. [\#1260](https://github.com/uclouvain/openjpeg/pull/1260) ([sebras](https://github.com/sebras))
- openjp2: Plug memory leak when setting data as TLS fails. [\#1258](https://github.com/uclouvain/openjpeg/pull/1258) ([sebras](https://github.com/sebras))
- openjp2: Error out if failing to create Tier 1 handle. [\#1256](https://github.com/uclouvain/openjpeg/pull/1256) ([sebras](https://github.com/sebras))
- Testing for invalid values of width, height, numcomps [\#1254](https://github.com/uclouvain/openjpeg/pull/1254) ([szukw000](https://github.com/szukw000))
- Single-threaded performance improvements in forward DWT for 5-3 and 9-7 \(and other improvements\) [\#1253](https://github.com/uclouvain/openjpeg/pull/1253) ([rouault](https://github.com/rouault))
- Add support for multithreading in encoder [\#1248](https://github.com/uclouvain/openjpeg/pull/1248) ([rouault](https://github.com/rouault))
- Add support for generation of PLT markers in encoder [\#1246](https://github.com/uclouvain/openjpeg/pull/1246) ([rouault](https://github.com/rouault))
- Fix warnings about signed/unsigned casts in pi.c [\#1244](https://github.com/uclouvain/openjpeg/pull/1244) ([rouault](https://github.com/rouault))
- opj\_decompress: add sanity checks to avoid segfault in case of decoding error [\#1240](https://github.com/uclouvain/openjpeg/pull/1240) ([rouault](https://github.com/rouault))
- ignore wrong icc [\#1236](https://github.com/uclouvain/openjpeg/pull/1236) ([szukw000](https://github.com/szukw000))
- Implement writing of IMF profiles [\#1235](https://github.com/uclouvain/openjpeg/pull/1235) ([rouault](https://github.com/rouault))
- tests: add alternate checksums for libtiff 4.1 [\#1234](https://github.com/uclouvain/openjpeg/pull/1234) ([rouault](https://github.com/rouault))
- opj\_tcd\_init\_tile\(\): avoid integer overflow [\#1232](https://github.com/uclouvain/openjpeg/pull/1232) ([rouault](https://github.com/rouault))
- tests/fuzzers: link fuzz binaries using $LIB\_FUZZING\_ENGINE. [\#1230](https://github.com/uclouvain/openjpeg/pull/1230) ([Dor1s](https://github.com/Dor1s))
- opj\_j2k\_update\_image\_dimensions\(\): reject images whose coordinates are beyond INT\_MAX \(fixes \#1228\) [\#1229](https://github.com/uclouvain/openjpeg/pull/1229) ([rouault](https://github.com/rouault))
- Fix resource leaks [\#1226](https://github.com/uclouvain/openjpeg/pull/1226) ([dodys](https://github.com/dodys))
- abi-check.sh: fix false positive ABI error, and display output error log [\#1218](https://github.com/uclouvain/openjpeg/pull/1218) ([rouault](https://github.com/rouault))
- pi.c: avoid integer overflow, resulting in later invalid access to memory in opj\_t2\_decode\_packets\(\) [\#1217](https://github.com/uclouvain/openjpeg/pull/1217) ([rouault](https://github.com/rouault))
- Add check to validate SGcod/SPcoc/SPcod parameter values. [\#1211](https://github.com/uclouvain/openjpeg/pull/1211) ([sebras](https://github.com/sebras))
- Fix buffer overflow reading an image file less than four characters [\#1196](https://github.com/uclouvain/openjpeg/pull/1196) ([robert-ancell](https://github.com/robert-ancell))
- compression: emit POC marker when only one single POC is requested \(f… [\#1192](https://github.com/uclouvain/openjpeg/pull/1192) ([rouault](https://github.com/rouault))
- Fix several potential vulnerabilities [\#1185](https://github.com/uclouvain/openjpeg/pull/1185) ([Young-X](https://github.com/Young-X))
- openjp2/j2k: Report error if all wanted components are not decoded. [\#1164](https://github.com/uclouvain/openjpeg/pull/1164) ([sebras](https://github.com/sebras))
## [v2.3.1](https://github.com/uclouvain/openjpeg/releases/v2.3.1) (2019-04-02)
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.3.0...v2.3.1)
**Closed issues:**
- v2.2.0 regression for decoding images where TNsot == 0 [\#1120](https://github.com/uclouvain/openjpeg/issues/1120)
- Int overflow in jp3d [\#1162](https://github.com/uclouvain/openjpeg/issues/1162)
- Heap buffer overflow in opj\_j2k\_update\_image\_data\(\) triggered with Ghostscript [\#1157](https://github.com/uclouvain/openjpeg/issues/1157)
- LINUX install doesn't work when building shared libraries is disabled [\#1155](https://github.com/uclouvain/openjpeg/issues/1155)
- OPENJPEG null ptr dereference in openjpeg-2.3.0/src/bin/jp2/convert.c:2243 [\#1152](https://github.com/uclouvain/openjpeg/issues/1152)
- How to drop certain subbands/layers in DWT [\#1147](https://github.com/uclouvain/openjpeg/issues/1147)
- where is the MQ-Coder ouput stream in t2.c? [\#1146](https://github.com/uclouvain/openjpeg/issues/1146)
- OpenJPEG 2.3 \(and 2.2?\) multi component image fails to decode with KDU v7.10 [\#1132](https://github.com/uclouvain/openjpeg/issues/1132)
- Missing checks for header\_info.height and header\_info.width in function pnmtoimage in src/bin/jpwl/convert.c, which can lead to heap buffer overflow [\#1126](https://github.com/uclouvain/openjpeg/issues/1126)
- Assertion Failure in jp2.c [\#1125](https://github.com/uclouvain/openjpeg/issues/1125)
- Division-by-zero vulnerabilities in the function pi\_next\_pcrl, pi\_next\_cprl and pi\_next\_rpcl in src/lib/openjp3d/pi.c [\#1123](https://github.com/uclouvain/openjpeg/issues/1123)
- Precinct switch \(-c\) doesn't right-shift last record to remaining resolution levels [\#1117](https://github.com/uclouvain/openjpeg/issues/1117)
- Sample: encode J2K a data using streams??? [\#1114](https://github.com/uclouvain/openjpeg/issues/1114)
- HIGH THROUGHPUT JPEG 2000 \(HTJ2K\) [\#1112](https://github.com/uclouvain/openjpeg/issues/1112)
- How to build openjpeg for arm linux? [\#1108](https://github.com/uclouvain/openjpeg/issues/1108)
- crash [\#1106](https://github.com/uclouvain/openjpeg/issues/1106)
- JP2000 returning OPJ\_CLRSPC\_UNKNOWN color space [\#1103](https://github.com/uclouvain/openjpeg/issues/1103)
- Compilation successful but install unsuccessful: Calling executables throws libraries missing error [\#1102](https://github.com/uclouvain/openjpeg/issues/1102)
- fprintf format string requires 1 parameter but only 0 are given [\#1093](https://github.com/uclouvain/openjpeg/issues/1093)
- fprintf format string requires 1 parameter but only 0 are given [\#1092](https://github.com/uclouvain/openjpeg/issues/1092)
- sprintf buffer overflow [\#1088](https://github.com/uclouvain/openjpeg/issues/1088)
- sprintf buffer overflow [\#1085](https://github.com/uclouvain/openjpeg/issues/1085)
- Infinite loop when reading jp2 [\#1081](https://github.com/uclouvain/openjpeg/issues/1081)
- missing format string parameter [\#1074](https://github.com/uclouvain/openjpeg/issues/1074)
- Excessive Iteration in opj\_t1\_encode\_cblks \(src/lib/openjp2/t1.c\) [\#1059](https://github.com/uclouvain/openjpeg/issues/1059)
- Out-of-bound left shift in opj\_j2k\_setup\_encoder \(src/lib/openjp2/j2k.c\) [\#1057](https://github.com/uclouvain/openjpeg/issues/1057)
- Encode image on Unsplash [\#1054](https://github.com/uclouvain/openjpeg/issues/1054)
- Integer overflow in opj\_t1\_encode\_cblks \(src/lib/openjp2/t1.c\) [\#1053](https://github.com/uclouvain/openjpeg/issues/1053)
- Signed Integer Overflow - 68065512 [\#1048](https://github.com/uclouvain/openjpeg/issues/1048)
- Similar vulnerable functions related to CVE-2017-14041 [\#1044](https://github.com/uclouvain/openjpeg/issues/1044)
- \[ERROR\] COD marker already read. No more than one COD marker per tile. [\#1043](https://github.com/uclouvain/openjpeg/issues/1043)
- failing to install latest version of openjpeg from source [\#1041](https://github.com/uclouvain/openjpeg/issues/1041)
- Trouble compressing large raw image [\#1032](https://github.com/uclouvain/openjpeg/issues/1032)
- Download and installed code from 2.3 archive. Installing 2.2? [\#1030](https://github.com/uclouvain/openjpeg/issues/1030)
- missing fclose [\#1029](https://github.com/uclouvain/openjpeg/issues/1029)
- NULL Pointer Access in function imagetopnm of convert.c\(jp2\):1289 [\#860](https://github.com/uclouvain/openjpeg/issues/860)
- NULL Pointer Access in function imagetopnm of convert.c:2226\(jp2\) [\#859](https://github.com/uclouvain/openjpeg/issues/859)
- Heap Buffer Overflow in function imagetotga of convert.c\(jp2\):942 [\#858](https://github.com/uclouvain/openjpeg/issues/858)
**Merged pull requests:**
- abi-check.sh: fix broken download URL [\#1188](https://github.com/uclouvain/openjpeg/pull/1188) ([rouault](https://github.com/rouault))
- opj\_t1\_encode\_cblks: fix UBSAN signed integer overflow [\#1187](https://github.com/uclouvain/openjpeg/pull/1187) ([rouault](https://github.com/rouault))
- convertbmp: detect invalid file dimensions early \(CVE-2018-6616\) [\#1172](https://github.com/uclouvain/openjpeg/pull/1172) ([hlef](https://github.com/hlef))
- color\_apply\_icc\_profile: avoid potential heap buffer overflow [\#1170](https://github.com/uclouvain/openjpeg/pull/1170) ([rouault](https://github.com/rouault))
- Fix multiple potential vulnerabilities and bugs [\#1168](https://github.com/uclouvain/openjpeg/pull/1168) ([Young-X](https://github.com/Young-X))
- Fix several memory and resource leaks [\#1163](https://github.com/uclouvain/openjpeg/pull/1163) ([nforro](https://github.com/nforro))
- Fix some potential overflow issues [\#1161](https://github.com/uclouvain/openjpeg/pull/1161) ([stweil](https://github.com/stweil))
- jp3d/jpwl convert: fix write stack buffer overflow [\#1160](https://github.com/uclouvain/openjpeg/pull/1160) ([hlef](https://github.com/hlef))
- Int overflow fixed [\#1159](https://github.com/uclouvain/openjpeg/pull/1159) ([ichlubna](https://github.com/ichlubna))
- Update knownfailures- files given current configurations [\#1149](https://github.com/uclouvain/openjpeg/pull/1149) ([rouault](https://github.com/rouault))
- CVE-2018-5785: fix issues with zero bitmasks [\#1148](https://github.com/uclouvain/openjpeg/pull/1148) ([hlef](https://github.com/hlef))
- openjp2/jp2: Fix two format strings [\#1143](https://github.com/uclouvain/openjpeg/pull/1143) ([stweil](https://github.com/stweil))
- Changes in pnmtoimage if image data are missing [\#1141](https://github.com/uclouvain/openjpeg/pull/1141) ([szukw000](https://github.com/szukw000))
- Relative path to header files is hardcoded in OpenJPEGConfig.cmake.in file [\#1140](https://github.com/uclouvain/openjpeg/pull/1140) ([bukatlib](https://github.com/bukatlib))
- Cast on uint ceildiv [\#1136](https://github.com/uclouvain/openjpeg/pull/1136) ([reverson](https://github.com/reverson))
- Add -DBUILD\_PKGCONFIG\_FILES to install instructions [\#1133](https://github.com/uclouvain/openjpeg/pull/1133) ([robe2](https://github.com/robe2))
- Fix some typos in code comments and documentation [\#1128](https://github.com/uclouvain/openjpeg/pull/1128) ([stweil](https://github.com/stweil))
- Fix regression in reading files with TNsot == 0 \(refs \#1120\) [\#1121](https://github.com/uclouvain/openjpeg/pull/1121) ([rouault](https://github.com/rouault))
- Use local type declaration for POSIX standard type only for MS compiler [\#1119](https://github.com/uclouvain/openjpeg/pull/1119) ([stweil](https://github.com/stweil))
- Fix Mac builds [\#1104](https://github.com/uclouvain/openjpeg/pull/1104) ([rouault](https://github.com/rouault))
- jp3d: Replace sprintf\(\) by snprintf\(\) in volumetobin\(\) [\#1101](https://github.com/uclouvain/openjpeg/pull/1101) ([kbabioch](https://github.com/kbabioch))
- opj\_mj2\_extract: Rename output\_location to output\_prefix [\#1096](https://github.com/uclouvain/openjpeg/pull/1096) ([kbabioch](https://github.com/kbabioch))
- mj2: Add missing variable to format string in fprintf\(\) invocation in meta\_out.c [\#1094](https://github.com/uclouvain/openjpeg/pull/1094) ([kbabioch](https://github.com/kbabioch))
- Convert files to UTF-8 encoding [\#1090](https://github.com/uclouvain/openjpeg/pull/1090) ([stweil](https://github.com/stweil))
- fix unchecked integer multiplication overflow [\#1080](https://github.com/uclouvain/openjpeg/pull/1080) ([setharnold](https://github.com/setharnold))
- Fixed typos [\#1062](https://github.com/uclouvain/openjpeg/pull/1062) ([radarhere](https://github.com/radarhere))
- Note that seek uses SEEK\_SET behavior. [\#1055](https://github.com/uclouvain/openjpeg/pull/1055) ([ideasman42](https://github.com/ideasman42))
- Some Doxygen tags are removed [\#1050](https://github.com/uclouvain/openjpeg/pull/1050) ([szukw000](https://github.com/szukw000))
- Fix resource leak \(CID 179466\) [\#1047](https://github.com/uclouvain/openjpeg/pull/1047) ([stweil](https://github.com/stweil))
- Changed cmake version test to allow for cmake 2.8.11.x [\#1042](https://github.com/uclouvain/openjpeg/pull/1042) ([radarhere](https://github.com/radarhere))
- Add missing fclose\(\) statement in error condition. [\#1037](https://github.com/uclouvain/openjpeg/pull/1037) ([gfiumara](https://github.com/gfiumara))
## [v2.3.0](https://github.com/uclouvain/openjpeg/releases/v2.3.0) (2017-10-04)
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.2.0...v2.3.0)
**Implemented enhancements:**
- Sub-tile decoding: only decode precincts and codeblocks that intersect the window specified in opj_set_decode_area() [\#990](https://github.com/uclouvain/openjpeg/pull/990) ([rouault](https://github.com/rouault))
- Sub-tile decoding: only apply IDWT on areas that participate to the window of interest [\#1001](https://github.com/uclouvain/openjpeg/pull/1001) ([rouault](https://github.com/rouault))
- Sub-tile decoding: memory use reduction and perf improvements [\#1010](https://github.com/uclouvain/openjpeg/pull/1010) ([rouault](https://github.com/rouault))
- Add capability to decode only a subset of all components of an image. [\#1022](https://github.com/uclouvain/openjpeg/pull/1022) ([rouault](https://github.com/rouault))
**Fixed bugs:**
- Setting x offset of decode region to -1 causes opj\_decompress to go into infinite loop [\#736](https://github.com/uclouvain/openjpeg/issues/736)
- Problem decoding multiple tiles with get\_decoded\_tile when cmap/pclr/cdef boxes are present in jp2 file [\#484](https://github.com/uclouvain/openjpeg/issues/484)
- set reduce\_factor\_may\_fail [\#474](https://github.com/uclouvain/openjpeg/issues/474)
- opj\_compress.exe, command line parser, infinite loop [\#469](https://github.com/uclouvain/openjpeg/issues/469)
- Various memory access issues found via fuzzing [\#448](https://github.com/uclouvain/openjpeg/issues/448)
- Multiple warnings when building OpenJPEG \(trunk\) [\#442](https://github.com/uclouvain/openjpeg/issues/442)
- Bulk fuzz-testing report [\#427](https://github.com/uclouvain/openjpeg/issues/427)
- remove all printf from openjpeg / use proper function pointer for logging [\#371](https://github.com/uclouvain/openjpeg/issues/371)
- minor changes, clean-up [\#349](https://github.com/uclouvain/openjpeg/issues/349)
- image-\>numcomps \> 4 [\#333](https://github.com/uclouvain/openjpeg/issues/333)
- Improve support for region of interest [\#39](https://github.com/uclouvain/openjpeg/issues/39)
- Public function to tell kernel type used \(5x3 vs 9x7\) [\#3](https://github.com/uclouvain/openjpeg/issues/3)
- elf binary in source package ? [\#1026](https://github.com/uclouvain/openjpeg/issues/1026)
- opj\_cio\_open [\#1025](https://github.com/uclouvain/openjpeg/issues/1025)
- Building with Visual Studio 2015 [\#1023](https://github.com/uclouvain/openjpeg/issues/1023)
- tcd.cpp\>:1617:33: error: assigning to 'OPJ\_INT32 \*' \(aka 'int \*'\) from incompatible type 'void \*' [\#1021](https://github.com/uclouvain/openjpeg/issues/1021)
- j2k.cpp \> comparison of address of 'p\_j2k-\>m\_cp.tcps\[0\].m\_data' not equal to a null pointer is always true [\#1020](https://github.com/uclouvain/openjpeg/issues/1020)
- Openjpeg 2.2.0 always build shared library even though -DBUILD\_SHARED\_LIBS:bool=off [\#1019](https://github.com/uclouvain/openjpeg/issues/1019)
- missing fclose [\#1018](https://github.com/uclouvain/openjpeg/issues/1018)
- Use opj\_image\_data\_free instead of opj\_free for image-\>comps\[\].data [\#1014](https://github.com/uclouvain/openjpeg/issues/1014)
- malloc poison on some compilers - cross compiling [\#1013](https://github.com/uclouvain/openjpeg/issues/1013)
- Add OPJ\_VERSION\_MAJOR, OPJ\_VERSION\_MINOR, OPJ\_VERSION\_MICRO macros in openjpeg.h [\#1011](https://github.com/uclouvain/openjpeg/issues/1011)
- Encode: do not perform rate control for single-tile lossless [\#1009](https://github.com/uclouvain/openjpeg/issues/1009)
- opj\_set\_decoded\_resolution\_factor\(\): bad interaction with opj\_set\_decode\_area\(\) and/or opj\_decode\(\) [\#1006](https://github.com/uclouvain/openjpeg/issues/1006)
- memory allocation failure with .pgx file [\#999](https://github.com/uclouvain/openjpeg/issues/999)
- Unable to fuzz with raw image as input [\#998](https://github.com/uclouvain/openjpeg/issues/998)
- stack-based buffer overflow write in pgxtoimage \(/convert.c\) [\#997](https://github.com/uclouvain/openjpeg/issues/997)
- freeze with a crafted bmp [\#996](https://github.com/uclouvain/openjpeg/issues/996)
- invalid memory write in tgatoimage \(convert.c\) [\#995](https://github.com/uclouvain/openjpeg/issues/995)
- static build on Windows fails [\#994](https://github.com/uclouvain/openjpeg/issues/994)
- another heap-based buffer overflow in opj\_t2\_encode\_packet \(t2.c\) [\#993](https://github.com/uclouvain/openjpeg/issues/993)
- heap-based buffer overflow in opj\_t2\_encode\_packet \(t2.c\) [\#992](https://github.com/uclouvain/openjpeg/issues/992)
- heap-based buffer overflow in opj\_write\_bytes\_LE \(cio.c\) \(unfixed \#985\) [\#991](https://github.com/uclouvain/openjpeg/issues/991)
- heap overflow in opj\_compress [\#988](https://github.com/uclouvain/openjpeg/issues/988)
- heap overflow in opj\_decompress [\#987](https://github.com/uclouvain/openjpeg/issues/987)
- heap-based buffer overflow in opj\_bio\_byteout \(bio.c\) [\#986](https://github.com/uclouvain/openjpeg/issues/986)
- heap-based buffer overflow in opj\_write\_bytes\_LE \(cio.c\) [\#985](https://github.com/uclouvain/openjpeg/issues/985)
- memory allocation failure in opj\_aligned\_alloc\_n \(opj\_malloc.c\) [\#983](https://github.com/uclouvain/openjpeg/issues/983)
- heap-base buffer overflow in opj\_mqc\_flush \(mqc.c\) [\#982](https://github.com/uclouvain/openjpeg/issues/982)
- Decode fails for JP2s with ICC profile [\#981](https://github.com/uclouvain/openjpeg/issues/981)
- Unit tests failing on Ubuntu 17.04 [\#916](https://github.com/uclouvain/openjpeg/issues/916)
- Encoder crashes on small images [\#901](https://github.com/uclouvain/openjpeg/issues/901)
- openjpeg-1.5.3 fails to compile [\#830](https://github.com/uclouvain/openjpeg/issues/830)
- opj\_compress crops image \(win\) or creates a jp2 which cannot be decompressed \(lin\) [\#716](https://github.com/uclouvain/openjpeg/issues/716)
- -d flag is silently ignored when decoding a single tile [\#693](https://github.com/uclouvain/openjpeg/issues/693)
- transition away from dev-utils [\#628](https://github.com/uclouvain/openjpeg/issues/628)
- update instructions to build with Visual Studio and 64-Bit Visual C++ Toolset. [\#1028](https://github.com/uclouvain/openjpeg/pull/1028) ([quangnh89](https://github.com/quangnh89))
- Add missing newline at end of file [\#1024](https://github.com/uclouvain/openjpeg/pull/1024) ([stweil](https://github.com/stweil))
- merge master into coverity\_scan to update coverity results [\#1008](https://github.com/uclouvain/openjpeg/pull/1008) ([detonin](https://github.com/detonin))
- Use more const qualifiers [\#984](https://github.com/uclouvain/openjpeg/pull/984) ([stweil](https://github.com/stweil))
- Changes in converttif.c for PPC64 [\#980](https://github.com/uclouvain/openjpeg/pull/980) ([szukw000](https://github.com/szukw000))
## [v2.2.0](https://github.com/uclouvain/openjpeg/releases/v2.2.0) (2017-08-10)
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.1.2...v2.2.0)
**Implemented enhancements:**
- Memory consumption reduction at decoding side [\#968](https://github.com/uclouvain/openjpeg/pull/968) ([rouault](https://github.com/rouault))
- T1 & DWT multithreading decoding optimizations [\#786](https://github.com/uclouvain/openjpeg/pull/786) ([rouault](https://github.com/rouault))
- Tier1 decoder speed optimizations [\#783](https://github.com/uclouvain/openjpeg/pull/783) ([rouault](https://github.com/rouault))
- Inverse DWT 5x3: lift implementation / SSE accelerated version [\#953](https://github.com/uclouvain/openjpeg/issues/953)
- install static libraries [\#969](https://github.com/uclouvain/openjpeg/pull/969) ([jeroen](https://github.com/jeroen))
- IDWT 5x3 single-pass lifting and SSE2/AVX2 implementation [\#957](https://github.com/uclouvain/openjpeg/pull/957) ([rouault](https://github.com/rouault))
- build both shared and static library [\#954](https://github.com/uclouvain/openjpeg/pull/954) ([jeroen](https://github.com/jeroen))
- T1 flag optimizations \(\#172\) [\#945](https://github.com/uclouvain/openjpeg/pull/945) ([rouault](https://github.com/rouault))
- CMake: add stronger warnings for openjp2 lib/bin by default, and error out on declaration-after-statement [\#936](https://github.com/uclouvain/openjpeg/pull/936) ([rouault](https://github.com/rouault))
- Quiet mode for opj\_decompress via -quiet long parameter. [\#928](https://github.com/uclouvain/openjpeg/pull/928) ([RussellMcOrmond](https://github.com/RussellMcOrmond))
- Implement predictive termination check [\#800](https://github.com/uclouvain/openjpeg/pull/800) ([rouault](https://github.com/rouault))
**Fixed bugs:**
- Several issues spotted by Google OSS Fuzz - [see here](https://github.com/search?l=&q=OSS+Fuzz+author-date%3A2017-07-04..2017-08-01+repo%3Auclouvain%2Fopenjpeg&ref=advsearch&type=Commits&utf8=%E2%9C%93)
- Missing fclose [\#976](https://github.com/uclouvain/openjpeg/issues/976)
- Heap buffer overflow read in openjpeg imagetopnm [\#970](https://github.com/uclouvain/openjpeg/issues/970)
- opj\_decompress opj\_j2k\_update\_image\_data\(\) Segment falut [\#948](https://github.com/uclouvain/openjpeg/issues/948)
- Generic Crash in 1.5.0 [\#941](https://github.com/uclouvain/openjpeg/issues/941)
- Segmentation Faults [\#940](https://github.com/uclouvain/openjpeg/issues/940)
- Assertions thrown [\#939](https://github.com/uclouvain/openjpeg/issues/939)
- Floating Point Errors [\#938](https://github.com/uclouvain/openjpeg/issues/938)
- Division by zero crash [\#937](https://github.com/uclouvain/openjpeg/issues/937)
- malformed jp2 can cause heap-buffer-overflow [\#909](https://github.com/uclouvain/openjpeg/issues/909)
- NULL dereference can cause by malformed file [\#908](https://github.com/uclouvain/openjpeg/issues/908)
- Out of bound read in opj\_j2k\_add\_mct [\#907](https://github.com/uclouvain/openjpeg/issues/907)
- Check bpno\_plus\_one in opj\_t1\_decode\_cblk [\#903](https://github.com/uclouvain/openjpeg/issues/903)
- Undefined-shift in opj\_j2k\_read\_siz [\#902](https://github.com/uclouvain/openjpeg/issues/902)
- opj\_compress v2.1.2 can create images opj\_decompress cannot read [\#891](https://github.com/uclouvain/openjpeg/issues/891)
- Improper usage of opj\_int\_ceildiv can cause overflows [\#889](https://github.com/uclouvain/openjpeg/issues/889)
- Undefined shift in opj\_get\_all\_encoding\_parameters [\#885](https://github.com/uclouvain/openjpeg/issues/885)
- Denial of service \(crash\) due to use-after-free when decoding an illegal JPEG2000 image file v2.1.2 \(2017-04 [\#880](https://github.com/uclouvain/openjpeg/issues/880)
- Denial of service \(crash\) when decoding an illegal JPEG2000 image file v2.1.2 \(2017-03\) [\#879](https://github.com/uclouvain/openjpeg/issues/879)
- bug png 2 j2k [\#868](https://github.com/uclouvain/openjpeg/issues/868)
- Inconsistent compression using cinema settings on folder of non-compliant image [\#864](https://github.com/uclouvain/openjpeg/issues/864)
- Openjpeg-2.1.2 Heap Buffer Overflow Vulnerability due to Insufficient check [\#862](https://github.com/uclouvain/openjpeg/issues/862)
- Heap Buffer Overflow in function pnmtoimage of convert.c [\#861](https://github.com/uclouvain/openjpeg/issues/861)
- CVE-2016-9112 FPE\(Floating Point Exception\) in lib/openjp2/pi.c:523 [\#855](https://github.com/uclouvain/openjpeg/issues/855)
- CVE-2016-5139, CVE-2016-5152, CVE-2016-5158, CVE-2016-5159 [\#854](https://github.com/uclouvain/openjpeg/issues/854)
- Undefined Reference error [\#853](https://github.com/uclouvain/openjpeg/issues/853)
- opj\_compress with lossy compression results in strange pixel values [\#851](https://github.com/uclouvain/openjpeg/issues/851)
- CVE-2016-1626 and CVE-2016-1628 [\#850](https://github.com/uclouvain/openjpeg/issues/850)
- Out-of-Bounds Write in opj\_mqc\_byteout of mqc.c [\#835](https://github.com/uclouvain/openjpeg/issues/835)
- WARNING in tgt\_create tree-\>numnodes == 0, no tree created. [\#794](https://github.com/uclouvain/openjpeg/issues/794)
- Potential overflow when precision is larger than 32 [\#781](https://github.com/uclouvain/openjpeg/issues/781)
- division-by-zero in function opj\_pi\_next\_rpcl of pi.c \(line 366\) [\#780](https://github.com/uclouvain/openjpeg/issues/780)
- division-by-zero in function opj\_pi\_next\_rpcl of pi.c \(line 363\) [\#779](https://github.com/uclouvain/openjpeg/issues/779)
- division-by-zero in function opj\_pi\_next\_pcrl of pi.c \(line 447\) [\#778](https://github.com/uclouvain/openjpeg/issues/778)
- division-by-zero in function opj\_pi\_next\_pcrl of pi.c \(line 444\) [\#777](https://github.com/uclouvain/openjpeg/issues/777)
- Encoding the following file with 32x32 tiling produces jp2 image with artifact [\#737](https://github.com/uclouvain/openjpeg/issues/737)
- division-by-zero \(SIGFPE\) error in opj\_pi\_next\_cprl function \(line 526 of pi.c\) [\#732](https://github.com/uclouvain/openjpeg/issues/732)
- division-by-zero \(SIGFPE\) error in opj\_pi\_next\_cprl function \(line 523 of pi.c\) [\#731](https://github.com/uclouvain/openjpeg/issues/731)
- OpenJpeg 2.1 and 1.4 fails to decompress this file correctly [\#721](https://github.com/uclouvain/openjpeg/issues/721)
- MQ Encode :uninitialized memory access when first pass does not output any bytes [\#709](https://github.com/uclouvain/openjpeg/issues/709)
- Out-of-bounds read in opj\_j2k\_update\_image\_data and opj\_tgt\_reset function [\#704](https://github.com/uclouvain/openjpeg/issues/704)
- Remove opj\_aligned\_malloc / opj\_aligned\_realloc / opj\_aligned\_free? [\#689](https://github.com/uclouvain/openjpeg/issues/689)
- There is an issue with rendering some type of jpeg file. Please ref the link. [\#672](https://github.com/uclouvain/openjpeg/issues/672)
- Null Dereference in tcd\_malloc\_decode\_tile [\#657](https://github.com/uclouvain/openjpeg/issues/657)
- ETS-C1P0-p0\_12.j2k-compare2ref & NR-C1P0-p0\_12.j2k-compare2base failing under windows [\#655](https://github.com/uclouvain/openjpeg/issues/655)
- Memory leak [\#631](https://github.com/uclouvain/openjpeg/issues/631)
- Test 481 reports error in valgrind memcheck [\#612](https://github.com/uclouvain/openjpeg/issues/612)
- reserved identifier violation [\#587](https://github.com/uclouvain/openjpeg/issues/587)
- Buffer overflow when compressing some 16 bits images of the test suite [\#539](https://github.com/uclouvain/openjpeg/issues/539)
- Heap-buffer-overflow in opj\_dwt\_decode\_1 [\#480](https://github.com/uclouvain/openjpeg/issues/480)
- Automated fuzz testing [\#468](https://github.com/uclouvain/openjpeg/issues/468)
- Expected to find EPH marker [\#425](https://github.com/uclouvain/openjpeg/issues/425)
- read: segment too long \(6182\) with max \(35872\) for codeblock 0 \(p=19, b=2, r=5, c=1\) [\#284](https://github.com/uclouvain/openjpeg/issues/284)
- building 64bit version has lots of warnings [\#244](https://github.com/uclouvain/openjpeg/issues/244)
- Wrong encoding of small tiles with high level number [\#239](https://github.com/uclouvain/openjpeg/issues/239)
- Errors raised in pi.c by VS11 analyzer [\#190](https://github.com/uclouvain/openjpeg/issues/190)
- Undocumented optimization found in v2 branch of openjpeg [\#183](https://github.com/uclouvain/openjpeg/issues/183)
- T1 optimisations jpeg2000 [\#172](https://github.com/uclouvain/openjpeg/issues/172)
- Remove OPJ\_NOSANITIZE in opj\_bio\_read\(\) and opj\_bio\_write\(\) \(\#761\) [\#955](https://github.com/uclouvain/openjpeg/pull/955) ([rouault](https://github.com/rouault))
- Fix bypass pterm termall and lossless decomposition issue \(\#891, \#892\) [\#949](https://github.com/uclouvain/openjpeg/pull/949) ([rouault](https://github.com/rouault))
- Escape quotes to ensure README renders on GitHub correctly [\#914](https://github.com/uclouvain/openjpeg/pull/914) ([alexwlchan](https://github.com/alexwlchan))
- Remove spurious .R macros from manpages [\#899](https://github.com/uclouvain/openjpeg/pull/899) ([jwilk](https://github.com/jwilk))
- Remove warnings related to empty tag-trees. [\#893](https://github.com/uclouvain/openjpeg/pull/893) ([rouault](https://github.com/rouault))
**Maintenance-related tasks:**
- Submit OpenJPEG to oss-fuzz [\#965](https://github.com/uclouvain/openjpeg/issues/965)
- Updates for Doxygen to suppress warnings [\#849](https://github.com/uclouvain/openjpeg/issues/849)
- Remove useless knownfailures \(since LAZY encoding is fixed\) [\#964](https://github.com/uclouvain/openjpeg/pull/964) ([rouault](https://github.com/rouault))
- Enable AVX2 at runtime on Travis-CI and AppVeyor [\#963](https://github.com/uclouvain/openjpeg/pull/963) ([rouault](https://github.com/rouault))
- Tests: test opj\_compress in VSC mode \(related to \#172\) [\#935](https://github.com/uclouvain/openjpeg/pull/935) ([rouault](https://github.com/rouault))
- Reformat: apply reformattin on .h files \(\#128\) [\#926](https://github.com/uclouvain/openjpeg/pull/926) ([rouault](https://github.com/rouault))
- Add mechanisms to reformat and check code style, and reformat whole codebase \(\#128\) [\#919](https://github.com/uclouvain/openjpeg/pull/919) ([rouault](https://github.com/rouault))
- Add profiling of CPU and memory usage \(\#912\) [\#918](https://github.com/uclouvain/openjpeg/pull/918) ([rouault](https://github.com/rouault))
- Add performance benchmarking scripts [\#917](https://github.com/uclouvain/openjpeg/pull/917) ([rouault](https://github.com/rouault))
- Fix retrieval of jpylyzer in AppVeyor [\#915](https://github.com/uclouvain/openjpeg/pull/915) ([rouault](https://github.com/rouault))
## [v2.1.2](https://github.com/uclouvain/openjpeg/releases/v2.1.2) (2016-09-28)
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.1.1...v2.1.2)
**Closed issues:**
- null ptr dereference in convert.c:1331 [\#843](https://github.com/uclouvain/openjpeg/issues/843)
- Out-of-Bounds Read in function bmp24toimage of convertbmp.c [\#833](https://github.com/uclouvain/openjpeg/issues/833)
- Disable automatic compilation of t1\_generate\_luts in CMakeLists.txt [\#831](https://github.com/uclouvain/openjpeg/issues/831)
- CVE-2016-7163 Integer overflow in opj\_pi\_create\_decode [\#826](https://github.com/uclouvain/openjpeg/issues/826)
- Security Advisory for OpenJPEG [\#810](https://github.com/uclouvain/openjpeg/issues/810)
- Add dashboard with static lib [\#804](https://github.com/uclouvain/openjpeg/issues/804)
- hidden visibility for the static library / building with -DOPJ\_STATIC against shared lib [\#802](https://github.com/uclouvain/openjpeg/issues/802)
- Optimization when building library from source [\#799](https://github.com/uclouvain/openjpeg/issues/799)
- unsigned int16 on Solaris 11.2/sparc [\#796](https://github.com/uclouvain/openjpeg/issues/796)
- appveyor [\#793](https://github.com/uclouvain/openjpeg/issues/793)
- FFMpeg will not link to 2.1.1 release built as shared library [\#766](https://github.com/uclouvain/openjpeg/issues/766)
- API change since v2: opj\_event\_mgr\_t not available [\#754](https://github.com/uclouvain/openjpeg/issues/754)
- openjpeg.h needs dependencies [\#673](https://github.com/uclouvain/openjpeg/issues/673)
- "master" does not build on ubuntu [\#658](https://github.com/uclouvain/openjpeg/issues/658)
- Package 'openjp2', required by 'libopenjpip', not found [\#594](https://github.com/uclouvain/openjpeg/issues/594)
**Merged pull requests:**
- Fix PNM file reading [\#847](https://github.com/uclouvain/openjpeg/pull/847) ([mayeut](https://github.com/mayeut))
- Fix some issues reported by Coverity Scan [\#846](https://github.com/uclouvain/openjpeg/pull/846) ([stweil](https://github.com/stweil))
- Fix potential out-of-bounds read \(coverity\) [\#844](https://github.com/uclouvain/openjpeg/pull/844) ([stweil](https://github.com/stweil))
- Remove TODO for overflow check [\#842](https://github.com/uclouvain/openjpeg/pull/842) ([mayeut](https://github.com/mayeut))
- Add overflow checks for opj\_aligned\_malloc [\#841](https://github.com/uclouvain/openjpeg/pull/841) ([mayeut](https://github.com/mayeut))
- Flags in T1 shall be unsigned [\#840](https://github.com/uclouvain/openjpeg/pull/840) ([mayeut](https://github.com/mayeut))
- Fix some warnings [\#838](https://github.com/uclouvain/openjpeg/pull/838) ([mayeut](https://github.com/mayeut))
- Fix issue 833. [\#834](https://github.com/uclouvain/openjpeg/pull/834) ([trylab](https://github.com/trylab))
- Add overflow checks for opj\_aligned\_malloc [\#832](https://github.com/uclouvain/openjpeg/pull/832) ([mayeut](https://github.com/mayeut))
- Add test for issue 820 [\#829](https://github.com/uclouvain/openjpeg/pull/829) ([mayeut](https://github.com/mayeut))
- Add test for issue 826 [\#827](https://github.com/uclouvain/openjpeg/pull/827) ([mayeut](https://github.com/mayeut))
- Fix coverity 113065 \(CWE-484\) [\#824](https://github.com/uclouvain/openjpeg/pull/824) ([mayeut](https://github.com/mayeut))
- Add sanity check for tile coordinates [\#823](https://github.com/uclouvain/openjpeg/pull/823) ([mayeut](https://github.com/mayeut))
- Add test for PR 818 [\#822](https://github.com/uclouvain/openjpeg/pull/822) ([mayeut](https://github.com/mayeut))
- Update to libpng 1.6.25 [\#821](https://github.com/uclouvain/openjpeg/pull/821) ([mayeut](https://github.com/mayeut))
- CVE-2016-8332: fix incrementing of "l\_tcp-\>m\_nb\_mcc\_records" in opj\_j2k\_read\_mcc [\#820](https://github.com/uclouvain/openjpeg/pull/820) ([mayeut](https://github.com/mayeut))
- Add overflow check in opj\_tcd\_init\_tile [\#819](https://github.com/uclouvain/openjpeg/pull/819) ([mayeut](https://github.com/mayeut))
- Fix leak & invalid behavior of opj\_jp2\_read\_ihdr [\#818](https://github.com/uclouvain/openjpeg/pull/818) ([mayeut](https://github.com/mayeut))
- Add overflow check in opj\_j2k\_update\_image\_data [\#817](https://github.com/uclouvain/openjpeg/pull/817) ([mayeut](https://github.com/mayeut))
- Change 'restrict' define to 'OPJ\_RESTRICT' [\#816](https://github.com/uclouvain/openjpeg/pull/816) ([mayeut](https://github.com/mayeut))
- Switch to clang 3.8 [\#814](https://github.com/uclouvain/openjpeg/pull/814) ([mayeut](https://github.com/mayeut))
- Fix an integer overflow issue [\#809](https://github.com/uclouvain/openjpeg/pull/809) ([trylab](https://github.com/trylab))
- Update to lcms 2.8 [\#808](https://github.com/uclouvain/openjpeg/pull/808) ([mayeut](https://github.com/mayeut))
- Update to libpng 1.6.24 [\#807](https://github.com/uclouvain/openjpeg/pull/807) ([mayeut](https://github.com/mayeut))
- Reenable clang-3.9 build on travis [\#806](https://github.com/uclouvain/openjpeg/pull/806) ([mayeut](https://github.com/mayeut))
- Bit fields type [\#805](https://github.com/uclouvain/openjpeg/pull/805) ([smuehlst](https://github.com/smuehlst))
- Add compilation test for standalone inclusion of openjpeg.h [\#798](https://github.com/uclouvain/openjpeg/pull/798) ([mayeut](https://github.com/mayeut))
- jpwl: Remove non-portable data type u\_int16\_t \(fix issue \#796\) [\#797](https://github.com/uclouvain/openjpeg/pull/797) ([stweil](https://github.com/stweil))
- Fix dependency for pkg-config \(issue \#594\) [\#795](https://github.com/uclouvain/openjpeg/pull/795) ([stweil](https://github.com/stweil))
- Add .gitignore [\#787](https://github.com/uclouvain/openjpeg/pull/787) ([stweil](https://github.com/stweil))
## [v2.1.1](https://github.com/uclouvain/openjpeg/releases/tag/v2.1.1) (2016-07-05)
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.2.1...v2.1.1)
**Implemented enhancements:**
- opj\_malloc replacement [\#625](https://github.com/uclouvain/openjpeg/issues/625)
- backport "-p" and "-force-rgb" options in 1.5 [\#606](https://github.com/uclouvain/openjpeg/issues/606)
- Use travis-ci matrix build [\#581](https://github.com/uclouvain/openjpeg/issues/581)
- Add Coverity Scan analysis [\#580](https://github.com/uclouvain/openjpeg/issues/580)
- Unnecessary rate distortion calculations [\#479](https://github.com/uclouvain/openjpeg/issues/479)
- Add images from various security issues to test suite [\#415](https://github.com/uclouvain/openjpeg/issues/415)
- Coding speed for 9/7 on 32bits platforms \(x86/ARM\) can be improved with a quick fix [\#220](https://github.com/uclouvain/openjpeg/issues/220)
**Fixed bugs:**
- Out-of-Bounds Access in function opj\_tgt\_reset of tgt.c [\#775](https://github.com/uclouvain/openjpeg/issues/775)
- Heap Buffer Overflow in function color\_cmyk\_to\_rgb of color.c [\#774](https://github.com/uclouvain/openjpeg/issues/774)
- division-by-zero \(SIGFPE\) error in opj\_tcd\_init\_tile function \(line 730 of tcd.c\) [\#733](https://github.com/uclouvain/openjpeg/issues/733)
- Out-Of-Bounds Read in sycc422\_to\_rgb function [\#726](https://github.com/uclouvain/openjpeg/issues/726)
- Heap Corruption in opj\_free function [\#725](https://github.com/uclouvain/openjpeg/issues/725)
- Out-Of-Bounds Read in opj\_tcd\_free\_tile function [\#724](https://github.com/uclouvain/openjpeg/issues/724)
- Cannot handle box of undefined size [\#653](https://github.com/uclouvain/openjpeg/issues/653)
- Compilation fails without platform-supplied aligned malloc [\#642](https://github.com/uclouvain/openjpeg/issues/642)
- HP compiler warns about redeclaration of static function [\#640](https://github.com/uclouvain/openjpeg/issues/640)
- Implementation-defined behavior of malloc causes different behavior on Linux and AIX [\#635](https://github.com/uclouvain/openjpeg/issues/635)
- Build on AIX fails because "opj\_includes.h" is included after system headers [\#633](https://github.com/uclouvain/openjpeg/issues/633)
- Compiling with SSE2 on Linux 32-bit causes crashes in OpenJPEG [\#624](https://github.com/uclouvain/openjpeg/issues/624)
- Build on AIX fails because of "restrict" pointers [\#620](https://github.com/uclouvain/openjpeg/issues/620)
- bug in new tif conversion code [\#609](https://github.com/uclouvain/openjpeg/issues/609)
- bin/jp2/convert.c line 1085 Resource leak [\#607](https://github.com/uclouvain/openjpeg/issues/607)
- bin/jp2/convert.c memory leak [\#601](https://github.com/uclouvain/openjpeg/issues/601)
- Resource leak in opj\_j2k\_create\_cstr\_index in case of failure [\#599](https://github.com/uclouvain/openjpeg/issues/599)
- Resource leak in opj\_j2k\_encode in case of failure [\#598](https://github.com/uclouvain/openjpeg/issues/598)
- Resource leak in opj\_j2k\_decode\_one\_tile in case of failure [\#597](https://github.com/uclouvain/openjpeg/issues/597)
- Resource Leak [\#573](https://github.com/uclouvain/openjpeg/issues/573)
- opj\_compress fails to compress lossless on gcc/x86 \(-m32\) [\#571](https://github.com/uclouvain/openjpeg/issues/571)
- Use-after-free in opj\_j2k\_write\_mco [\#563](https://github.com/uclouvain/openjpeg/issues/563)
- openjpeg-master-2015-07-30 failed to compile on LINUX [\#556](https://github.com/uclouvain/openjpeg/issues/556)
- PNG images are always read as RGB\(A\) images [\#536](https://github.com/uclouvain/openjpeg/issues/536)
- g4\_colr.j2c not handled properly [\#532](https://github.com/uclouvain/openjpeg/issues/532)
- Bigendian: opj\_compress + opj\_decompress fails [\#518](https://github.com/uclouvain/openjpeg/issues/518)
- Suspicious code in j2k.c [\#517](https://github.com/uclouvain/openjpeg/issues/517)
- Decode times almost double\(!!\) on Visual Studio 2013, 2015 [\#505](https://github.com/uclouvain/openjpeg/issues/505)
- opj\_data/input/nonregression/issue226.j2k [\#500](https://github.com/uclouvain/openjpeg/issues/500)
- opj\_setup\_encoder always returns true [\#497](https://github.com/uclouvain/openjpeg/issues/497)
- Double free in j2k\_read\_ppm\_v3 parsing \(\(presumably invalid\) image. [\#496](https://github.com/uclouvain/openjpeg/issues/496)
- Invalid write in opj\_j2k\_update\_image\_data [\#495](https://github.com/uclouvain/openjpeg/issues/495)
- Undefined printf format specifier %ud used in code [\#494](https://github.com/uclouvain/openjpeg/issues/494)
- Potential double free on malloc failure in opj\_j2k\_copy\_default\_tcp\_and\_create\_tcp\(\) [\#492](https://github.com/uclouvain/openjpeg/issues/492)
- Do not link with -ffast-math [\#488](https://github.com/uclouvain/openjpeg/issues/488)
- Heap-buffer-overflow in opj\_dwt\_decode [\#486](https://github.com/uclouvain/openjpeg/issues/486)
- opj\_dump fails on Windows 7, 64 bits [\#482](https://github.com/uclouvain/openjpeg/issues/482)
- SIGSEGV in opj\_j2k\_update\_image\_data via pdfium\_test [\#481](https://github.com/uclouvain/openjpeg/issues/481)
- Heap-buffer-overflow in opj\_j2k\_tcp\_destroy [\#477](https://github.com/uclouvain/openjpeg/issues/477)
- Invalid image causes write past end of heap buffer [\#476](https://github.com/uclouvain/openjpeg/issues/476)
- Assertion `l\_res-\>x0 \>= 0' fails when parsing invalid images [\#475](https://github.com/uclouvain/openjpeg/issues/475)
- Bug on opj\_write\_bytes\_BE function [\#472](https://github.com/uclouvain/openjpeg/issues/472)
- Refactor j2k\_read\_ppm\_v3 function [\#470](https://github.com/uclouvain/openjpeg/issues/470)
- compression: strange precinct dimensions [\#466](https://github.com/uclouvain/openjpeg/issues/466)
- \(:- Console message in opj\_decompress -:\) [\#465](https://github.com/uclouvain/openjpeg/issues/465)
- opj\_decompress fails to decompress any files [\#463](https://github.com/uclouvain/openjpeg/issues/463)
- bio-\>ct is unnecessarily set to zero in opj\_bio\_flush method [\#461](https://github.com/uclouvain/openjpeg/issues/461)
- Maximal unsigned short is 65535, not 65536 [\#460](https://github.com/uclouvain/openjpeg/issues/460)
- OpenJpeg fails to encode components with different precision properly [\#459](https://github.com/uclouvain/openjpeg/issues/459)
- component precision upscaling isn't correct in opj\_decompress [\#458](https://github.com/uclouvain/openjpeg/issues/458)
- Multiple precision components won't get encoded to jp2 if 1 component is unsigned 1 bit [\#457](https://github.com/uclouvain/openjpeg/issues/457)
- Incorrect code in ../bin/jp2/convert.c, function rawtoimage\_common\(...\) [\#456](https://github.com/uclouvain/openjpeg/issues/456)
- \[OpenJPEG-trunk\] opj\_stream\_get\_number\_byte\_left throws assert [\#455](https://github.com/uclouvain/openjpeg/issues/455)
- NR-DEC-kodak\_2layers\_lrcp.j2c-31-decode-md5 fails randomly when running tests in parallel [\#454](https://github.com/uclouvain/openjpeg/issues/454)
- compare\_raw\_files doesn't report an error on invalid arguments / missing input files [\#453](https://github.com/uclouvain/openjpeg/issues/453)
- Forward discrete wavelet transform: implement periodic symmetric extension at boundaries [\#452](https://github.com/uclouvain/openjpeg/issues/452)
- Bug in tiff reading method in convert.c [\#449](https://github.com/uclouvain/openjpeg/issues/449)
- Image in pdf don't display [\#447](https://github.com/uclouvain/openjpeg/issues/447)
- Multiple issues causing opj\_decompress to segfault [\#446](https://github.com/uclouvain/openjpeg/issues/446)
- opj\_compress: 40% of encode time is spent freeing data [\#445](https://github.com/uclouvain/openjpeg/issues/445)
- Multiple warnings when configuring OpenJPEG on MacOS with CMake 3.x \(trunk\) [\#443](https://github.com/uclouvain/openjpeg/issues/443)
- valgrind memleak found [\#437](https://github.com/uclouvain/openjpeg/issues/437)
- global-buffer-overflow src/lib/openjp2/t1.c:1146 opj\_t1\_getwmsedec [\#436](https://github.com/uclouvain/openjpeg/issues/436)
- Warning introduced on trunk r2923 & r2924 [\#435](https://github.com/uclouvain/openjpeg/issues/435)
- heap-buffer-overflow in opj\_t1\_decode\_cblks [\#432](https://github.com/uclouvain/openjpeg/issues/432)
- Heap-buffer-overflow in opj\_tcd\_init\_decode\_tile [\#431](https://github.com/uclouvain/openjpeg/issues/431)
- Heap-buffer-overflow in opj\_j2k\_tcp\_destroy [\#430](https://github.com/uclouvain/openjpeg/issues/430)
- Heap-buffer-overflow in opj\_jp2\_apply\_pclr [\#429](https://github.com/uclouvain/openjpeg/issues/429)
- issue412 revisited [\#428](https://github.com/uclouvain/openjpeg/issues/428)
- Image distorted \(sides look cankered\) [\#423](https://github.com/uclouvain/openjpeg/issues/423)
- openjpeg-2.x-trunk-r2918 is broken in color.c [\#422](https://github.com/uclouvain/openjpeg/issues/422)
- Heap-buffer-overflow in opj\_tcd\_init\_decode\_tile [\#420](https://github.com/uclouvain/openjpeg/issues/420)
- Heap-use-after-free in opj\_t1\_decode\_cblks [\#418](https://github.com/uclouvain/openjpeg/issues/418)
- UNKNOWN in opj\_read\_bytes\_LE [\#417](https://github.com/uclouvain/openjpeg/issues/417)
- Transparency problem [\#416](https://github.com/uclouvain/openjpeg/issues/416)
- Image with per channel alpha \(cdef\) does not decode properly [\#414](https://github.com/uclouvain/openjpeg/issues/414)
- OpenJPEG crashes with attached image [\#413](https://github.com/uclouvain/openjpeg/issues/413)
- Palette image with cdef fails to decompress [\#412](https://github.com/uclouvain/openjpeg/issues/412)
- Invalid member values from opj\_read\_header or opj\_decode ? [\#411](https://github.com/uclouvain/openjpeg/issues/411)
- MD5 Checksum hangs under valgrind on MacOS X [\#410](https://github.com/uclouvain/openjpeg/issues/410)
- Heap-buffer-overflow in opj\_tcd\_get\_decoded\_tile\_size [\#408](https://github.com/uclouvain/openjpeg/issues/408)
- C++ style comments in trunk/src/lib/openjp2/j2k.c [\#407](https://github.com/uclouvain/openjpeg/issues/407)
- Backport bugfixes from trunk to 2.1 branch [\#405](https://github.com/uclouvain/openjpeg/issues/405)
- Heap-buffer-overflow in parse\_cmdline\_encoder [\#403](https://github.com/uclouvain/openjpeg/issues/403)
- Heap-buffer-overflow in opj\_v4dwt\_interleave\_h [\#400](https://github.com/uclouvain/openjpeg/issues/400)
- Heap-buffer-overflow in opj\_dwt\_decode [\#399](https://github.com/uclouvain/openjpeg/issues/399)
- Heap-use-after-free in opj\_t1\_decode\_cblks [\#398](https://github.com/uclouvain/openjpeg/issues/398)
- Heap-buffer-overflow in opj\_jp2\_apply\_cdef [\#397](https://github.com/uclouvain/openjpeg/issues/397)
- Heap-buffer-overflow in opj\_t2\_read\_packet\_header [\#396](https://github.com/uclouvain/openjpeg/issues/396)
- Heap-buffer-overflow in opj\_t2\_read\_packet\_header [\#395](https://github.com/uclouvain/openjpeg/issues/395)
- Heap-buffer-overflow in opj\_dwt\_decode\_1 [\#394](https://github.com/uclouvain/openjpeg/issues/394)
- Heap-double-free in j2k\_read\_ppm\_v3 [\#393](https://github.com/uclouvain/openjpeg/issues/393)
- Security hole in j2k.c [\#392](https://github.com/uclouvain/openjpeg/issues/392)
- Security: double-free in opj\_tcd\_code\_block\_dec\_deallocate [\#391](https://github.com/uclouvain/openjpeg/issues/391)
- check for negative-size params in code [\#390](https://github.com/uclouvain/openjpeg/issues/390)
- Heap-buffer-overflow in opj\_t2\_read\_packet\_header [\#389](https://github.com/uclouvain/openjpeg/issues/389)
- Heap overflow in OpenJpeg 1.5.2 [\#388](https://github.com/uclouvain/openjpeg/issues/388)
- openjpip.so.6 file too short [\#387](https://github.com/uclouvain/openjpeg/issues/387)
- Corrupted JP3D file [\#386](https://github.com/uclouvain/openjpeg/issues/386)
- variable assigned to itself [\#383](https://github.com/uclouvain/openjpeg/issues/383)
- Null pointer dereferencing [\#382](https://github.com/uclouvain/openjpeg/issues/382)
- bad use of case statement [\#381](https://github.com/uclouvain/openjpeg/issues/381)
- Release 2.1 as a Ubuntu package [\#380](https://github.com/uclouvain/openjpeg/issues/380)
- Bug in libopenjpwl.pc [\#374](https://github.com/uclouvain/openjpeg/issues/374)
- inconsistent tile numbering in decode output message [\#370](https://github.com/uclouvain/openjpeg/issues/370)
- error in code block calculations [\#369](https://github.com/uclouvain/openjpeg/issues/369)
- r2872 fails to compile due to "attempt to use poisoned malloc" error in j2k.c [\#368](https://github.com/uclouvain/openjpeg/issues/368)
- OSX build gives libopenjp2.6.dylib with not-absolute install name id [\#367](https://github.com/uclouvain/openjpeg/issues/367)
- opj\_decompress gives error but successfully decompress in OPJ 2.1 [\#366](https://github.com/uclouvain/openjpeg/issues/366)
- pngtoimage\(\) and imagetopng\(\) have wrong byte order for 16-Bit image [\#365](https://github.com/uclouvain/openjpeg/issues/365)
- PDF crash in chrome - part2 \(due to attachment limit\) [\#364](https://github.com/uclouvain/openjpeg/issues/364)
- PDF crash in chrome - part1 [\#363](https://github.com/uclouvain/openjpeg/issues/363)
- PDF crash in chrome - part0 [\#362](https://github.com/uclouvain/openjpeg/issues/362)
- Compilation fails on Windows with mingw32 gcc4.8 [\#361](https://github.com/uclouvain/openjpeg/issues/361)
- security issue [\#360](https://github.com/uclouvain/openjpeg/issues/360)
- improve memory management [\#359](https://github.com/uclouvain/openjpeg/issues/359)
- how to compress a yuv420 raw data using opj\_compress [\#357](https://github.com/uclouvain/openjpeg/issues/357)
- Some memory allocation are not checked [\#355](https://github.com/uclouvain/openjpeg/issues/355)
- Static library symbols shall be marked as hidden [\#354](https://github.com/uclouvain/openjpeg/issues/354)
- opj\_compress rejects valid bmp files [\#353](https://github.com/uclouvain/openjpeg/issues/353)
- opj\_compress crashes when number of resolutions is set to zero [\#352](https://github.com/uclouvain/openjpeg/issues/352)
- Compilation error under Visual Studio 2003 [\#351](https://github.com/uclouvain/openjpeg/issues/351)
- opj\_compress description example error \[Low priority\] [\#350](https://github.com/uclouvain/openjpeg/issues/350)
- opj\_write\_bytes\_BE is wrong in trunk [\#345](https://github.com/uclouvain/openjpeg/issues/345)
- PART1ONLY option in release.sh doesn't work properly [\#332](https://github.com/uclouvain/openjpeg/issues/332)
- openjpeg crash error [\#330](https://github.com/uclouvain/openjpeg/issues/330)
- openjpeg decompress error [\#329](https://github.com/uclouvain/openjpeg/issues/329)
- openjpeg decompress issue [\#326](https://github.com/uclouvain/openjpeg/issues/326)
- limited tif support [\#322](https://github.com/uclouvain/openjpeg/issues/322)
- asoc value of 65536 is allowed [\#321](https://github.com/uclouvain/openjpeg/issues/321)
- opj\_skip\_from\_file error [\#314](https://github.com/uclouvain/openjpeg/issues/314)
- Heavy quota usage in openjpeg [\#309](https://github.com/uclouvain/openjpeg/issues/309)
- Verify -help actually match letter [\#307](https://github.com/uclouvain/openjpeg/issues/307)
- g3\_colr.j2c not handled [\#288](https://github.com/uclouvain/openjpeg/issues/288)
- reopen/fix issue 165 [\#280](https://github.com/uclouvain/openjpeg/issues/280)
- kakadu conformance tests [\#279](https://github.com/uclouvain/openjpeg/issues/279)
- missing break after case statement in opj\_dwt\_decode\_real [\#274](https://github.com/uclouvain/openjpeg/issues/274)
- Run Coverity on trunk [\#270](https://github.com/uclouvain/openjpeg/issues/270)
- NR-ENC-random-issue-0005.tif-12-encode [\#259](https://github.com/uclouvain/openjpeg/issues/259)
- Use new add\_test signature to handle cross compilation [\#258](https://github.com/uclouvain/openjpeg/issues/258)
- Loss decoding quality in 2.0.0 [\#254](https://github.com/uclouvain/openjpeg/issues/254)
- Decompress that worked in 1.5.1 fails in 2.0 [\#252](https://github.com/uclouvain/openjpeg/issues/252)
- Expected endianness with raw input is not documented leading to SEGFAULT [\#251](https://github.com/uclouvain/openjpeg/issues/251)
- OpenJPEG writes to stderr [\#246](https://github.com/uclouvain/openjpeg/issues/246)
- Inconsistent logging of tile index [\#245](https://github.com/uclouvain/openjpeg/issues/245)
- patch for openjpeg-trunk-r2347 and BIG\_ENDIAN [\#242](https://github.com/uclouvain/openjpeg/issues/242)
- CMAP: MTYP == 0 \(direct use\) not handled properly [\#235](https://github.com/uclouvain/openjpeg/issues/235)
- Black Pixel [\#233](https://github.com/uclouvain/openjpeg/issues/233)
- opj\_compress runtime error after fresh Linux install due to apparent failure to execute ldconfig [\#219](https://github.com/uclouvain/openjpeg/issues/219)
- openjp2 debug works, release build does not [\#217](https://github.com/uclouvain/openjpeg/issues/217)
- openjpeg-branch15-r2299 and openjpeg-trunk-r2299 fail to decode a JP2 file [\#212](https://github.com/uclouvain/openjpeg/issues/212)
- openjpeg-trunk issue with Win7 [\#201](https://github.com/uclouvain/openjpeg/issues/201)
- undefined reference to `opj\_version' [\#200](https://github.com/uclouvain/openjpeg/issues/200)
- In tgt.c we used fprintf not the openjpeg message reporter [\#184](https://github.com/uclouvain/openjpeg/issues/184)
- Windows binaries not working under WinXP [\#176](https://github.com/uclouvain/openjpeg/issues/176)
- add ability to use intel ipp \(performance primitive\) within OpenJPEG [\#164](https://github.com/uclouvain/openjpeg/issues/164)
- Migration guide v2 [\#160](https://github.com/uclouvain/openjpeg/issues/160)
- Cannot decompress JPEG2000Aware3.18.7.3Win32\_kdutranscode6.3.1.j2k [\#158](https://github.com/uclouvain/openjpeg/issues/158)
- Cannot decompress JPEG2000Aware3.18.7.3Win32.j2k [\#157](https://github.com/uclouvain/openjpeg/issues/157)
- openjpeg@googlegroups.com has disappeared [\#153](https://github.com/uclouvain/openjpeg/issues/153)
- OpenJPEG 1.5.0 crashes on a ridiculously big file... [\#151](https://github.com/uclouvain/openjpeg/issues/151)
- opj\_image vs free [\#146](https://github.com/uclouvain/openjpeg/issues/146)
- Windows .dll file invalid [\#140](https://github.com/uclouvain/openjpeg/issues/140)
- Problem with second layer of a 2 layer coded LRCP \(with precincts\) [\#135](https://github.com/uclouvain/openjpeg/issues/135)
- version 1.4 crashes when opening PDF file with JPEG2000 images [\#133](https://github.com/uclouvain/openjpeg/issues/133)
- Setup a win64 dashboard [\#132](https://github.com/uclouvain/openjpeg/issues/132)
- J2KP4files/codestreams\_profile0/p0\_13.j2k question jpeg2000 [\#131](https://github.com/uclouvain/openjpeg/issues/131)
- Out of memory: Kill process 11204 \(opj\_server\) score 917 or sacrifice child [\#123](https://github.com/uclouvain/openjpeg/issues/123)
- FILE\* in opj API is unsafe [\#120](https://github.com/uclouvain/openjpeg/issues/120)
- third-party lib order [\#119](https://github.com/uclouvain/openjpeg/issues/119)
- openjpeg-1.5.0-Darwin-powerpc.dmg is huge ! [\#113](https://github.com/uclouvain/openjpeg/issues/113)
- misleading info in JP2 box lead to wrong number of components [\#110](https://github.com/uclouvain/openjpeg/issues/110)
- Image\_to\_j2k says that j2k files is generated but no file is on the HDD [\#109](https://github.com/uclouvain/openjpeg/issues/109)
- Error in openjpegV1.4 on compiling image\_to\_j2k: crash on reading bmp file [\#108](https://github.com/uclouvain/openjpeg/issues/108)
- Update to abi-compliance-checker 1.96 [\#106](https://github.com/uclouvain/openjpeg/issues/106)
- Decode error on the attached JPEG...works in KDU and with JASPER...please help! [\#101](https://github.com/uclouvain/openjpeg/issues/101)
- Mac binaries v1.4 is broken [\#95](https://github.com/uclouvain/openjpeg/issues/95)
- jp2\_read\_boxhdr\(\) has size bug in version 1 [\#92](https://github.com/uclouvain/openjpeg/issues/92)
- Support for Java JAI Imageio [\#90](https://github.com/uclouvain/openjpeg/issues/90)
- encoding test failing [\#86](https://github.com/uclouvain/openjpeg/issues/86)
- source archive on demand [\#85](https://github.com/uclouvain/openjpeg/issues/85)
- CMakeLists.txt and Makefile.am for JPIP are buggy [\#84](https://github.com/uclouvain/openjpeg/issues/84)
- pclr-cmap-cdef [\#82](https://github.com/uclouvain/openjpeg/issues/82)
- Error when compiling openjpeg\_v1\_4\_sources\_r697 [\#79](https://github.com/uclouvain/openjpeg/issues/79)
- J2K codec issue on Windows Mobile [\#77](https://github.com/uclouvain/openjpeg/issues/77)
- image\_to\_j2k.exe crashes on large .bmp file [\#75](https://github.com/uclouvain/openjpeg/issues/75)
- fatal error C1900 building the project on windows [\#65](https://github.com/uclouvain/openjpeg/issues/65)
- same option but different size [\#54](https://github.com/uclouvain/openjpeg/issues/54)
- Missing openjpegConfigure.h [\#38](https://github.com/uclouvain/openjpeg/issues/38)
- Not an issue in openjpeg, but ... [\#37](https://github.com/uclouvain/openjpeg/issues/37)
- OpenJPEG-1.3.0 pclr, cmap and cdef [\#27](https://github.com/uclouvain/openjpeg/issues/27)
- realloc maybe too big \(t2.c\) [\#26](https://github.com/uclouvain/openjpeg/issues/26)
- libopenjpeg/opj\_malloc.h breaks on FreeBSD/Darwin systems [\#20](https://github.com/uclouvain/openjpeg/issues/20)
- image\_to\_j2k not outputting to win32 console properly [\#18](https://github.com/uclouvain/openjpeg/issues/18)
- \[OpenJPEG\] OpenJPEG\_v13: tiled image part 2 [\#17](https://github.com/uclouvain/openjpeg/issues/17)
- JP2 Color Space modification by Matteo Italia [\#13](https://github.com/uclouvain/openjpeg/issues/13)
- Patch submission \( exotic video formats, and a few things \) [\#12](https://github.com/uclouvain/openjpeg/issues/12)
- 16 bits lossy compression [\#10](https://github.com/uclouvain/openjpeg/issues/10)
- pnm file formats not accepting bitdepth greater than 8 bpp [\#8](https://github.com/uclouvain/openjpeg/issues/8)
- Heap corruption in j2k encoder [\#5](https://github.com/uclouvain/openjpeg/issues/5)
- JPWL crash in marker reallocation\(+patch\), segfault while decoding image with main header protection [\#4](https://github.com/uclouvain/openjpeg/issues/4)
- a couple of small errors in libopenjpeg detected by coverity [\#1](https://github.com/uclouvain/openjpeg/issues/1)
**Closed issues:**
- Shared library build broken on ubuntu [\#728](https://github.com/uclouvain/openjpeg/issues/728)
- opj\_includes.h shouldn't define `\_\_attribute\_\_` [\#727](https://github.com/uclouvain/openjpeg/issues/727)
- Possible website problems due to Jekyll upgrade [\#713](https://github.com/uclouvain/openjpeg/issues/713)
- Stable Release? [\#712](https://github.com/uclouvain/openjpeg/issues/712)
- Meta Issue : try to fix some of these critical bugs before thinking about optimizing the library [\#710](https://github.com/uclouvain/openjpeg/issues/710)
- Tiled encoding broken for images with non power of 2 dimensions [\#702](https://github.com/uclouvain/openjpeg/issues/702)
- install\_name \(still\) not set on OS X [\#700](https://github.com/uclouvain/openjpeg/issues/700)
- Add section in wiki describing where one can get test images [\#699](https://github.com/uclouvain/openjpeg/issues/699)
- Make EvenManager into singleton [\#698](https://github.com/uclouvain/openjpeg/issues/698)
- Remove old branches from repo [\#696](https://github.com/uclouvain/openjpeg/issues/696)
- MQ Coder encode: Conditional jump or move depends on uninitialised value\(s\) [\#695](https://github.com/uclouvain/openjpeg/issues/695)
- Can we add these files to our test suite ? [\#688](https://github.com/uclouvain/openjpeg/issues/688)
- -t and -d command line flags for decode are not documented on OpenJPEG website [\#685](https://github.com/uclouvain/openjpeg/issues/685)
- Decoding at the precinct level [\#676](https://github.com/uclouvain/openjpeg/issues/676)
- Support unscaled 10 bit data for 2K cinema @ 48 FPS, as per DCI standard [\#671](https://github.com/uclouvain/openjpeg/issues/671)
- Use parallel jobs in ctest [\#664](https://github.com/uclouvain/openjpeg/issues/664)
- \[Security\]Multiple Memory error [\#663](https://github.com/uclouvain/openjpeg/issues/663)
- lossy encoding a 16 bit TIF file : severe artifacts in decompressed image [\#660](https://github.com/uclouvain/openjpeg/issues/660)
- opj\_compress and opj\_decompress : get\_next\_file method uses hard-coded unix path separator [\#630](https://github.com/uclouvain/openjpeg/issues/630)
- Uninitialized variable [\#629](https://github.com/uclouvain/openjpeg/issues/629)
- Use of enum variable for bit flags prevents compilation as C++ source [\#619](https://github.com/uclouvain/openjpeg/issues/619)
- Serious problem with quantization during lossy encoding [\#615](https://github.com/uclouvain/openjpeg/issues/615)
- Decompression does not work with sequential data source [\#613](https://github.com/uclouvain/openjpeg/issues/613)
- potential overflow in opj\_tcd\_tile\_t [\#605](https://github.com/uclouvain/openjpeg/issues/605)
- Logical condition [\#596](https://github.com/uclouvain/openjpeg/issues/596)
- file9.jp2 does not dump correctly on 1.5 [\#595](https://github.com/uclouvain/openjpeg/issues/595)
- opj\_compress man page is missing documentation of -jpip option [\#593](https://github.com/uclouvain/openjpeg/issues/593)
- opj\_compress fails to compress lossless on gcc/x86 \(-m32\) in 1.5 branch [\#591](https://github.com/uclouvain/openjpeg/issues/591)
- Example: opj\_compress -i image.j2k -o image.pgm [\#577](https://github.com/uclouvain/openjpeg/issues/577)
- Mismatching delete [\#575](https://github.com/uclouvain/openjpeg/issues/575)
- Compilation fails on Win7 [\#546](https://github.com/uclouvain/openjpeg/issues/546)
- NR-JP2-file5.jp2-compare2base fails with third party libcms [\#540](https://github.com/uclouvain/openjpeg/issues/540)
- CTest spits out an error at the end of the test run [\#516](https://github.com/uclouvain/openjpeg/issues/516)
- opj\_uint\_adds\(\) is questionable [\#515](https://github.com/uclouvain/openjpeg/issues/515)
- Might consider renaming this method: [\#491](https://github.com/uclouvain/openjpeg/issues/491)
- opj\_compress run twice gives different fiile sizes for same file [\#490](https://github.com/uclouvain/openjpeg/issues/490)
- Android Support [\#483](https://github.com/uclouvain/openjpeg/issues/483)
- Add SSE2/SSE41 implementations for mct.c [\#451](https://github.com/uclouvain/openjpeg/issues/451)
- Reduce encoder code block memory usage for non 64x64 code block sizes [\#444](https://github.com/uclouvain/openjpeg/issues/444)
- valgrind "Uninitialized Memory Read" & "Uninitialized Memory Conditional" found [\#438](https://github.com/uclouvain/openjpeg/issues/438)
- No way to debug opj\_tcd\_init\_encode\_tile or opj\_tcd\_init\_decode\_tile [\#433](https://github.com/uclouvain/openjpeg/issues/433)
- Add option to call dsymutil on built binaries [\#409](https://github.com/uclouvain/openjpeg/issues/409)
- Allow opj\_compress and opj\_decompress to read/write images over stdin/stdout [\#379](https://github.com/uclouvain/openjpeg/issues/379)
- reduce memory significantly for single tile RGB encoding [\#375](https://github.com/uclouvain/openjpeg/issues/375)
- Switch code repo to github and start using pull request workflow [\#373](https://github.com/uclouvain/openjpeg/issues/373)
- This is a BigTIFF file. This format not supported [\#125](https://github.com/uclouvain/openjpeg/issues/125)
- Add a test suite to check the convert functions [\#99](https://github.com/uclouvain/openjpeg/issues/99)
- Add build config to the dashboard to verify the autotools build [\#88](https://github.com/uclouvain/openjpeg/issues/88)
**Merged pull requests:**
- Correct abi-check.sh for PR [\#791](https://github.com/uclouvain/openjpeg/pull/791) ([mayeut](https://github.com/mayeut))
- Update tcd.c [\#790](https://github.com/uclouvain/openjpeg/pull/790) ([maddin200](https://github.com/maddin200))
- Update lcms2 [\#773](https://github.com/uclouvain/openjpeg/pull/773) ([mayeut](https://github.com/mayeut))
- Use lowercase for cmake commands consistently [\#769](https://github.com/uclouvain/openjpeg/pull/769) ([julienmalik](https://github.com/julienmalik))
- Ignore clang's summary warning [\#768](https://github.com/uclouvain/openjpeg/pull/768) ([julienmalik](https://github.com/julienmalik))
- Fix UBSan gcc warning for first arg to memset non null [\#767](https://github.com/uclouvain/openjpeg/pull/767) ([julienmalik](https://github.com/julienmalik))
- Update to libtiff-4.0.6 [\#764](https://github.com/uclouvain/openjpeg/pull/764) ([mayeut](https://github.com/mayeut))
- Fix warnings [\#763](https://github.com/uclouvain/openjpeg/pull/763) ([mayeut](https://github.com/mayeut))
- Check SSIZ is valid in opj\_j2k\_read\_siz [\#762](https://github.com/uclouvain/openjpeg/pull/762) ([mayeut](https://github.com/mayeut))
- Fix unsigned int overflow reported by UBSan [\#761](https://github.com/uclouvain/openjpeg/pull/761) ([mayeut](https://github.com/mayeut))
- Fix unsigned int overflow reported by UBSan [\#759](https://github.com/uclouvain/openjpeg/pull/759) ([mayeut](https://github.com/mayeut))
- Fix negative shift left reported by UBSan [\#758](https://github.com/uclouvain/openjpeg/pull/758) ([mayeut](https://github.com/mayeut))
- Fix negative shift left reported by UBSan [\#757](https://github.com/uclouvain/openjpeg/pull/757) ([mayeut](https://github.com/mayeut))
- Add clang 3.9 build to Travis matrix [\#753](https://github.com/uclouvain/openjpeg/pull/753) ([julienmalik](https://github.com/julienmalik))
- Fix implicit floating bool conversion [\#752](https://github.com/uclouvain/openjpeg/pull/752) ([julienmalik](https://github.com/julienmalik))
- Do not define \_\_attribute\_\_ in opj\_includes.h [\#751](https://github.com/uclouvain/openjpeg/pull/751) ([mayeut](https://github.com/mayeut))
- Allow to read/write 3/5/7/9/11/13/15 bpp TIF files [\#750](https://github.com/uclouvain/openjpeg/pull/750) ([mayeut](https://github.com/mayeut))
- Fix heap-buffer-overflow in color\_esycc\_to\_rgb [\#748](https://github.com/uclouvain/openjpeg/pull/748) ([mayeut](https://github.com/mayeut))
- update libpng to from 1.6.17 to 1.6.21 [\#747](https://github.com/uclouvain/openjpeg/pull/747) ([julienmalik](https://github.com/julienmalik))
- Update cmake & jpylyzer for travis builds [\#746](https://github.com/uclouvain/openjpeg/pull/746) ([julienmalik](https://github.com/julienmalik))
- Fix Out-Of-Bounds Read in sycc42x\_to\_rgb function [\#745](https://github.com/uclouvain/openjpeg/pull/745) ([mayeut](https://github.com/mayeut))
- cppcheck fix for openjp2 [\#740](https://github.com/uclouvain/openjpeg/pull/740) ([julienmalik](https://github.com/julienmalik))
- Fix uninitialized variable reported by cppcheck [\#735](https://github.com/uclouvain/openjpeg/pull/735) ([julienmalik](https://github.com/julienmalik))
- Remove dead code in opj\_dump [\#734](https://github.com/uclouvain/openjpeg/pull/734) ([julienmalik](https://github.com/julienmalik))
- issue \#695 MQ Encode: ensure that bp pointer never points to uninitialized memory [\#708](https://github.com/uclouvain/openjpeg/pull/708) ([boxerab](https://github.com/boxerab))
- Fix issue 135 [\#706](https://github.com/uclouvain/openjpeg/pull/706) ([mayeut](https://github.com/mayeut))
- Fix implementation of opj\_calloc [\#705](https://github.com/uclouvain/openjpeg/pull/705) ([stweil](https://github.com/stweil))
- \[git/2.1 regression\] Fix opj\_write\_tile\(\) failure when numresolutions=1 [\#690](https://github.com/uclouvain/openjpeg/pull/690) ([rouault](https://github.com/rouault))
- Fix fatal crash on 64 bit Linux [\#687](https://github.com/uclouvain/openjpeg/pull/687) ([stweil](https://github.com/stweil))
- \[libtiff\] Add missing include statement for ssize\_t [\#686](https://github.com/uclouvain/openjpeg/pull/686) ([mayeut](https://github.com/mayeut))
- Fix duplicate article in comments [\#684](https://github.com/uclouvain/openjpeg/pull/684) ([stweil](https://github.com/stweil))
- Fix grammar in comment [\#679](https://github.com/uclouvain/openjpeg/pull/679) ([stweil](https://github.com/stweil))
- Remove whitespace and CR at line endings [\#678](https://github.com/uclouvain/openjpeg/pull/678) ([stweil](https://github.com/stweil))
- Fix typos [\#665](https://github.com/uclouvain/openjpeg/pull/665) ([jwilk](https://github.com/jwilk))
- Add missing source for the JPIP library and executables \(issue \#658\) [\#659](https://github.com/uclouvain/openjpeg/pull/659) ([stweil](https://github.com/stweil))
- Fix undefined size jp2 box handling [\#654](https://github.com/uclouvain/openjpeg/pull/654) ([mayeut](https://github.com/mayeut))
- opj\_decompress: Update error message [\#651](https://github.com/uclouvain/openjpeg/pull/651) ([stweil](https://github.com/stweil))
- Fix support of posix\_memalloc for Linux [\#648](https://github.com/uclouvain/openjpeg/pull/648) ([stweil](https://github.com/stweil))
- Fix typo in comments [\#647](https://github.com/uclouvain/openjpeg/pull/647) ([stweil](https://github.com/stweil))
- Avoid pointer arithmetic with \(void \*\) pointers [\#644](https://github.com/uclouvain/openjpeg/pull/644) ([smuehlst](https://github.com/smuehlst))
- Fix HP compiler warning about redeclaration of function \(\#640\) [\#641](https://github.com/uclouvain/openjpeg/pull/641) ([smuehlst](https://github.com/smuehlst))
- Fix format strings and unneeded assignment [\#638](https://github.com/uclouvain/openjpeg/pull/638) ([stweil](https://github.com/stweil))
- Fix repository for JPEG2000 test data [\#637](https://github.com/uclouvain/openjpeg/pull/637) ([stweil](https://github.com/stweil))
- Update allocation functions [\#636](https://github.com/uclouvain/openjpeg/pull/636) ([mayeut](https://github.com/mayeut))
- Fix OpenJPEG GitHub issue \#633. [\#634](https://github.com/uclouvain/openjpeg/pull/634) ([smuehlst](https://github.com/smuehlst))
- travis-ci: Include add ons in matrix [\#632](https://github.com/uclouvain/openjpeg/pull/632) ([mayeut](https://github.com/mayeut))
- Add Appveyor [\#627](https://github.com/uclouvain/openjpeg/pull/627) ([mayeut](https://github.com/mayeut))
- Use Travis-ci to run ABI check [\#626](https://github.com/uclouvain/openjpeg/pull/626) ([mayeut](https://github.com/mayeut))
- Fix warnings for C++ [\#623](https://github.com/uclouvain/openjpeg/pull/623) ([stweil](https://github.com/stweil))
- Fixed problem that C++ compilation failed because of enum variable. [\#622](https://github.com/uclouvain/openjpeg/pull/622) ([smuehlst](https://github.com/smuehlst))
- Added missing casts for return values of opj\_malloc\(\)/opj\_calloc\(\). [\#618](https://github.com/uclouvain/openjpeg/pull/618) ([smuehlst](https://github.com/smuehlst))
- Add check for seek support before trying TPsot==TNsot workaround [\#617](https://github.com/uclouvain/openjpeg/pull/617) ([mayeut](https://github.com/mayeut))
- Fix some typos found by codespell [\#610](https://github.com/uclouvain/openjpeg/pull/610) ([stweil](https://github.com/stweil))
- Correct leak in color\_cielab\_to\_rgb [\#590](https://github.com/uclouvain/openjpeg/pull/590) ([mayeut](https://github.com/mayeut))
- Add Travis-ci build matrix [\#584](https://github.com/uclouvain/openjpeg/pull/584) ([mayeut](https://github.com/mayeut))
- Correct lossless issue on linux x86 [\#579](https://github.com/uclouvain/openjpeg/pull/579) ([mayeut](https://github.com/mayeut))
- Travis-ci update [\#578](https://github.com/uclouvain/openjpeg/pull/578) ([mayeut](https://github.com/mayeut))
- Correct CMake version requirements [\#572](https://github.com/uclouvain/openjpeg/pull/572) ([mayeut](https://github.com/mayeut))
- Add tests for CMYK/esYCC/CIELab [\#567](https://github.com/uclouvain/openjpeg/pull/567) ([mayeut](https://github.com/mayeut))
- Add support for CIELab, EYCC and CMYK [\#559](https://github.com/uclouvain/openjpeg/pull/559) ([szukw000](https://github.com/szukw000))
- Remove printf/fprintf to stdout/stderr throughout openjp2 lib [\#558](https://github.com/uclouvain/openjpeg/pull/558) ([mayeut](https://github.com/mayeut))
- better -ffast-math handling [\#555](https://github.com/uclouvain/openjpeg/pull/555) ([rdieter](https://github.com/rdieter))
- Add jpylyzer tests for JP2 compression [\#552](https://github.com/uclouvain/openjpeg/pull/552) ([mayeut](https://github.com/mayeut))
- Add COC/QCC in main header when needed [\#551](https://github.com/uclouvain/openjpeg/pull/551) ([mayeut](https://github.com/mayeut))
- Use \_\_emul under msvc x86 for fast 64 = 32 \* 32 [\#550](https://github.com/uclouvain/openjpeg/pull/550) ([mayeut](https://github.com/mayeut))
- Update convert for PNG output [\#549](https://github.com/uclouvain/openjpeg/pull/549) ([mayeut](https://github.com/mayeut))
- Remove some warnings when building [\#548](https://github.com/uclouvain/openjpeg/pull/548) ([mayeut](https://github.com/mayeut))
- Switch to libpng-1.6.17 [\#547](https://github.com/uclouvain/openjpeg/pull/547) ([mayeut](https://github.com/mayeut))
- Add some missing static keywords [\#545](https://github.com/uclouvain/openjpeg/pull/545) ([mayeut](https://github.com/mayeut))
- Switch to libcms2 mm2/Little-CMS@0e8234e090d6aab33f90e2eb0296f30aa0705e57 [\#544](https://github.com/uclouvain/openjpeg/pull/544) ([mayeut](https://github.com/mayeut))
- Prevent overflow when coding 16 bits images [\#543](https://github.com/uclouvain/openjpeg/pull/543) ([mayeut](https://github.com/mayeut))
- Switch to libcms2-2.6 [\#542](https://github.com/uclouvain/openjpeg/pull/542) ([mayeut](https://github.com/mayeut))
- Update PNG support [\#538](https://github.com/uclouvain/openjpeg/pull/538) ([mayeut](https://github.com/mayeut))
- Various Minor fixes [\#537](https://github.com/uclouvain/openjpeg/pull/537) ([mayeut](https://github.com/mayeut))
- Update TIFF conversion to support more bit depth. [\#535](https://github.com/uclouvain/openjpeg/pull/535) ([mayeut](https://github.com/mayeut))
- Add checks for odd looking cmap & for cmap outside jp2h box [\#534](https://github.com/uclouvain/openjpeg/pull/534) ([mayeut](https://github.com/mayeut))
- Refactor opj\_j2k\_read\_ppm & opj\_j2k\_read\_ppt [\#533](https://github.com/uclouvain/openjpeg/pull/533) ([mayeut](https://github.com/mayeut))
- Add option to force component splitting in imagetopnm [\#531](https://github.com/uclouvain/openjpeg/pull/531) ([mayeut](https://github.com/mayeut))
- fix Suspicious code in j2k.c \#517 [\#529](https://github.com/uclouvain/openjpeg/pull/529) ([renevanderark](https://github.com/renevanderark))
- Update zlib to version 1.2.8 [\#528](https://github.com/uclouvain/openjpeg/pull/528) ([mayeut](https://github.com/mayeut))
- Fix opj\_write\_bytes\_BE \(\#518\) [\#521](https://github.com/uclouvain/openjpeg/pull/521) ([manisandro](https://github.com/manisandro))
- Correctly decode files with incorrect tile-part header fields \(TPsot==TNsot\) [\#514](https://github.com/uclouvain/openjpeg/pull/514) ([mayeut](https://github.com/mayeut))
- Fixed typos [\#510](https://github.com/uclouvain/openjpeg/pull/510) ([radarhere](https://github.com/radarhere))
- Formatted the readme file [\#507](https://github.com/uclouvain/openjpeg/pull/507) ([htmfilho](https://github.com/htmfilho))
## [version.2.1](https://github.com/uclouvain/openjpeg/releases/tag/version.2.1) (2014-04-29)
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.2.0.1...version.2.1)
## [version.2.0.1](https://github.com/uclouvain/openjpeg/releases/tag/version.2.0.1) (2014-04-22)
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.5.2...version.2.0.1)
## [version.1.5.2](https://github.com/uclouvain/openjpeg/releases/tag/version.1.5.2) (2014-03-28)
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.2.0...version.1.5.2)
## [version.2.0](https://github.com/uclouvain/openjpeg/releases/tag/version.2.0) (2014-03-28)
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.5.1...version.2.0)
## [version.1.5.1](https://github.com/uclouvain/openjpeg/releases/tag/version.1.5.1) (2012-09-13)
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.5...version.1.5.1)
## [version.1.5](https://github.com/uclouvain/openjpeg/releases/tag/version.1.5) (2012-02-07)
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.3...version.1.5)
## [version.1.3](https://github.com/uclouvain/openjpeg/releases/tag/version.1.3) (2011-07-03)
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.4...version.1.3)
## [version.1.4](https://github.com/uclouvain/openjpeg/releases/tag/version.1.4) (2011-07-03)
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.2...version.1.4)
## [version.1.2](https://github.com/uclouvain/openjpeg/releases/tag/version.1.2) (2007-06-04)
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.1...version.1.2)
## [version.1.1](https://github.com/uclouvain/openjpeg/releases/tag/version.1.1) (2007-01-31)
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.0...version.1.1)
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

612
CHANGES Normal file
View File

@ -0,0 +1,612 @@
What's New for OpenJPEG
* : fixed
- : removed
! : changed
+ : added
April 13, 2011
* [antonin] fixed dllexport definition (credit to vincent torri)
April 12, 2011
- [antonin] Removed folders mj2, JavaOpenJpeg, jpwl, OPJViewer (not compliant with v2). Removed obsolete windows project files. Removed obsolete Makefiles (only build method currently supported with v2 branch: cmake). Renamed ChangeLog to CHANGES. Renamed License.txt to LICENSE. Removed obsolete README files.
* [antonin] Fixed internal function names conflict with Jasper (http://code.google.com/p/openjpeg/issues/detail?id=30)
November 25, 2010
* [antonin] Fix leak in jp2_read_header_procedure() (from even.rouault, see issue 29 on googlecode)
Jun 22, 2010
+ [MM] Import j2k_dump from trunk (much faster!)
Jun 21, 2010
* [MM] Move CMake files to CMake folder
* [MM] Remove some warnings in code
* [MM] j2k_to_image properly return error code
* [MM] increase coverage by testing all codecs
* [MM] fix installation. Place in subfolder to handle both API
* [MM] Start using cmake API for easy packaging
April 8, 2010
* [FOD] Fixed problem with Borland C++ Builder (Borland C do not have lrintf). Thanks Marek Mauder for this fix.
* [FOD] Fixed pi.c bug (issue 15 on google code). Thanks to Anton Lionel for catching this.
* [FOD] Fixed MJ2 codec bugs (issues 23-24 on google code). Thanks to Winfried for these patches.
March 26, 2010
+ [FOD] Added support for "jpc" codestreams which are equivalent to "j2c" codestreams. Thanks to Winfried for this patch
March 24, 2010
* [FOD] Code improvements using 'g++-4.4.0' to trace the code. Thanks to Winfried for this patch.
March 7, 2010
* [FOD] Fixed small compatibility issues with win32 in codec (moved include <strings.h>)
March 5,2010
! [FOD] Updated makefiles for v1.4 and v2.0
February 16, 2010
* [FOD] Fixed libopenjpeg Makefile
January 20, 2010
! [FOD] Created a new constant in openjpeg.h to differentiate the case when the colorspace is not supported by the library and when it is not specified in the codestream. Suggested by Matteo Italia.
September 10, 2009
* [antonin] fixed minor bugs which were triggering warnings at compilation (different signedness, wrong pointer type, etc)
August 21, 2008
* [antonin] found a bug in tcd.c that was preventing to find the correct threshold in tcd_rateallocate.c for high-precision images. Applied a temporary patch but a better solution should be found.
August 8, 2008
! [FOD] Modified the way raw images with more that 8bpp are read and written
August 2nd, 2008
* [Mathieu Malaterre] remove INLINE from forward decl. Fix CMakeLists.txt for UNIX platforms
August 1st, 2008
- [antonin] removed t1_generate_luts.c, useless in version 2.
! [antonin] updated XCode project file for mac users.
---------------------------
July 31, 2008
CREATION OF A OPJ V2 BRANCH
---------------------------
July 31, 2008
+ [antonin] created a branch for openjpeg version 2. Modifications that have been applied to the trunk after revision 483 should be re-applied on the branch (version 2 has been developed based on revision 483).
July 9, 2008
+ [Parvatha] Added the default lossless parameter to opj_set_default_encoder_parameters in openjpeg.c.
June 12, 2008
* [antonin] fixed a bug in dirent.h that prevented codec on Linux Alpha Systems to compile correctly. Thanks to RobinC.
May 22, 2008
* [antonin] fixed a bug in j2k.c (j2k_write_sod) that allowed to get negative rates, thanks zhong1985624 for pointing this.
May 22, 2008
* [antonin] additional test to avoid crash due to invalid image size, patch by Christopher Layne
May 20, 2008
* [antonin] memory leak fixed in openjpeg.c (opj_destroy_cstr_info()), patch by Carsten Juttner
March 12, 2008
+ [GB] help line for the -F option in j2k_to_image
March 4, 2008
! [FOD] Changed Java files copyright in JavaOpenJPEG module
February 28, 2008
* [FOD] Fixed openjpeg.c for proper initialization of codec context structures (dinfo in opj_create_compress()
and opj_create_decompress(). Bug fix suggested by Andrey V. Kiselev
* [FOD] Clean up of opj_aligned_malloc(), to just forgo the use of posix_memalign(),
as apparently memalign() is what is working better for everyone. Patch by Callum.
February 28, 2008
- [FOD] Removed the J2KViewer module, which has been replaced by OPJViewer
* [FOD] Fixed the error handling of j2k_decode in jp2.c, thanks to Robin Cornelius
February 11, 2008
* [GB] Minor style modifications to comply with c99 compiler flag; removed Microsoft-specific "union-in-struct" syntax; Re-enabled cstr_info struct creation when -W switch is specified
! [GB] Changed a number of things in opjviewer (e.g., decoding thread does not execute GUI calls anymore), to have it running under linux --> it is better than before, but still crashes
February 5, 2008
! [Parvatha] In convert.c, corrected imagetobmp() conversion for grayscale. In tcd.c, corrected Rate modification in
tcd_init_encode(). Thanks to Jeremy Furtek and Jérôme Fimes.
January 31, 2008
! [GB] In opjviewer, unification of JPEG 2000 family handlers (*.jp2, *.mj2, *.j2k) in a single file
January 22, 2008
! [FOD] In image.c, changed the opj_image_create0() memory allocation from malloc() to calloc() in order
to avoid segfaults when freeing the memory allocated for the coding of bad images.
Thanks to Christopher Layne for this improvement.
January 17, 2008
+ [antonin] Initial commit of Xcode project directory (XCode 2.5 for macosx)
available targets : libopenjpeg (stat and dyn), image_to_j2k, j2k_to_image
January 16, 2008
* [antonin] fixed opj_malloc.h for macosx (bugfix provided by janpeder, thanks)
January 11, 2008
+ [FOD] Added missing files to JavaOpenJPEG project (files from Patrick Piscaglia)
January 4, 2008
* [Parvatha] Patch by Callum Lerwick. Fixed bug during encoding using tile option in tcd.c
----------------------
December 21, 2007
VERSION 1.3.0 RELEASED
----------------------
December 21, 2007
* [FOD] Bug fixed by David Bruken. Fixed memory allocation issue in opj_malloc.h
! [FOD] Possible errors in pi_create_encode handled
December 19, 2007
* [Antonin] changed variables names alpha, beta, gamma, delta in dwt.c to avoid re-declarations on Macosx
! [Parvatha] In pi.c, removed the Recursive function pi_check_next_level() and modified the code.
* [FOD] Fixed allocation problem in pi.c
December 19, 2007
+ [FOD] In mqc.h, changed MQC_NUMCTXS from 32 to 19 as there are only 19 possible contexts
December 10, 2007
+ [FOD] First import of JAVAOpenJPEG, a Java wrapper of OpenJPEG, developed by Patrick Piscaglia of Telemis (www.telemis.com).
Thank you Patrick for this new module !
November 29, 2007
! [GB] Added index.h and index.c in VC6 projects; wrapped index.h in the C++ preprocessor; modified OPJViewer project and some files.
November 14, 2007
+ [FOD] Created the file index.c in the codec directory. This file handles the creation of index files,
at encoding and decoding.
* [FOD] Fixed bugs during the creation of the index (PCRL progression order)
* [FOD] Fixed the maximum number of resolutions a user can discard while decoding.
Added an error state in J2K_STATE (j2k.c)
November 14, 2007
! [FOD] - First Patch by Callum Lerwick. Instead of reinventing realloc, j2k_read_sod now just uses opj_realloc in j2k.c
- Second Patch by Callum Lerwick. This patch rearranges the largest memory allocations so they're allocated as
late as possible, and freed as soon as possible. This cuts memory usage by about half on two large test images.
- Third Patch by Callum Lerwick. The opj_tcd_cblk array is one of the largest allocations, because it
contains a bunch of static buffers. This also makes it a major source of cache thrashing. This patch allocates
the buffers from the heap, and dynamically sizes them in the decoder. I have not yet managed to dynamically size
them in the encoder, getting the decoder to do it was tricky enough... I also split opj_tcd_cblk_t into separate
encode and decode versions. A lot of fields were not used by both, so this cuts its size even further.
* [FOD] Avoided ABI breakage
November 13, 2007
! [FOD] Patch by Dzonatas and Callum Lerwick.
Fp/vectorization patch which basically converts most of the irreversible decode codepath to floating point,
eliminating a few rounds of int/fp conversion, resulting in a vast performance improvement,
and an increase in accuracy.
November 8, 2007
! [FOD] In t1.c, small change to avoid calling twice t1_getwmsedec()
Patches from Callum Lewick:
- Basic gcc optimization flags in cmake and makefile match.
- Fixed some spelling errors in dwt.c.
November 5, 2007
*+ [GB] Fixed a bug which prevented JPWL from working on multi-tiled images; added some more fields in the interface info structures
(keep a list of markers, save start packet number for each tile)
October 23, 2007
* [GB] Improved success for the linux build; OPJViewer shows all the COM contents
October 18, 2007
* [FOD] Changed the ROI parameter in the image_to_j2k codec to make it correspond to the documentation (i.e. -ROI c=0,U=25)
* [FOD] Patch from Callum Lewick. Memset patch.
The main idea of the patch is that currently opj_malloc clears all allocations, which unnecessarily
dirties up the cache and eats bandwidth. This patch makes it no longer do so, and I've painstakingly determined which allocations actually need
to be cleared and changed them to use opj_calloc() instead. I previously tried to just get rid of the opj_*alloc wrappers but that
idea was nixed, so this time I'm trying it with macros. I also put in a gcc pragma that helps enforce their use. Which got messy. :) It caught a
few places they weren't used but it also revealed that the mj2 tools are not very cleanly separated from the library. It includes all the
internal headers, but it wasn't using the malloc wrappers. I figured the binaries should be "external" and have minimal knowledge of the
internals of the library. I patched them to not include opj_includes.h, and include only the internal headers they actually need. However,
they're using the opj_clock() function, which is in with the malloc wrappers. So I decided to move the malloc wrappers to their own header.
But mj2.c seems to want to be "internal", so I patched it to use the wrappers. Note that this patch changes the semantics of opj_malloc, it no longer
clears the memory it allocates. If you need it to be cleared, you must use opj_calloc instead, or memset it yourself. It is also somewhat
invasive, please test it extensively. I've been pounding on it all summer with my test suite, Second Life, and valgrind, and it checks out clean.
October 12, 2007
* [FOD] Changed the way the image structure is allocated when the decoding parameters include some resolutions to discard.
This should have a significant impact for the decoding of huge images when some resolutions are discarder (-r parameter)
Warning: The output image size is now reduced when discarding resolutions !
October 10, 2007
* [FOD] Patch from Callum Lewick. Clean up of j2klib.h for the aligned malloc stuff.
It makes it work right with mingw, as _mm_malloc() isn't a macro, attempts to pave the way to using cmake
to check for this stuff and combines a patch from Dana Fagerstrom at Sun that makes it use memalign() on Solaris
convert.c: Changed some error comments for TIFF images
September 27, 2007
* [FOD] Patch from Callum Lewick. Fixed dwt.c where an alignment in buffer was problematic under x86_64.
September 25, 2007
* [Mathieu Malaterre] BUG: Fix previous patch from Callum Lerwick. I have no
clue what CMAKE_INSTALL_LIBDIR refers too. Bump up cmake 2.2 restriction to
cmake 2.4 because of previous patch (not backward compatible). Properly set the SOVERSION in a cross plateform way (yes WIN32 is a platform)
September 19, 2007
* [Parvatha] Fixed issues with generation of SOP marker.
September 18, 2007
* [Parvatha] Fixed issues with Reading and Writing TIF images in convert.c to avoid segmentation fault.
* [Parvatha] Fixed issues relating to using user specified rates for CINEMA option for multiple images.
September 17, 2007
* [FOD] Fixed issues with cstr_info when codestream has components with different number of resolutions.
! [FOD] OpenJPEG library interface modified to retain compatibility with version 1.2
September 12, 2007
* [FOD] Patch from Callum Lerwick.
Fixed the library linking so it links with the soversion properly set.
Fixes up the install targets so that it interacts properly with RPM.
Install target for MJ2. Sets some necessary and useful CFLAGS if gcc is in use.
* [FOD] Updated the MJ2 codec to be compatible with the recent changes in the OpenJPEG library
September 11, 2007
* [GB] JPWL encoding is finalized correctly into the JP2 file format; added an additional structure in opj_codestream_info, to keep a record of the written markers
September 8, 2007
* [GB] Adapted the JPWL and OPJViewer code to new interface; fixed a samll bug in JPWL which created large EPBs even when null protection was specified
September 7, 2007
+ [FOD] Indexes can now be generated when decoding J2K codestreams.
* [Mathieu Malaterre] Upon failure, properly return error code (!=0).
* [Mathieu Malaterre] CMake: Add cmake code to do testing if user has properly setup a testimages directory
September 6, 2007
+ [Mathieu Malaterre] CMake: start compiling mj2, jpwl and jp3d
+ [Mathieu Malaterre] CMake: output all executable/libs into one single directory
+ [Mathieu Malaterre] CMake: start compiling index_create
+ [Mathieu Malaterre] OpenJPEG.rc update copyright year
+ [Mathieu Malaterre] CMake: add Java j2kviewer but do not compile it using cmake since cmake has too poor support for Java. Should create a custom command running ant instead.
+ [Mathieu Malaterre] CMake: Add doxygen output
+ [GB] One more field in the codestream_info struct for recording the number of packets per tile part; JPWL now distributes the EPBs in all the tile part headers
+ [Mathieu Malaterre] CMake: Add very simple tests (simply run command line with no option)
* [Mathieu Malaterre] Fix unitialized read in img_fol (we may need a smarter initialize than memset)
September 4, 2007
+ [GB] Added some fields in the codestream_info structure: they are used to record the position of single tile parts.
Changed also the write_index function in the codec, to reflect the presence of this new information.
September 3, 2007
+ [GB] Added the knowledge of JPSEC SEC and INSEC markers (you have to compile the JPWL project). Management of these markers is limited to skipping them without crashing:
no real security function at this stage. Deprecated USE_JPSEC will be removed next
August 31, 2007
* [GB] Fixed save capabilities in OPJViewer due to recent code upgrade
August 30, 2007
* [FOD] Changed the OpenJPEG library interface to enable users to access information regarding the codestream (also called codestream index).
This index is usefull for all applications requiring to have a scalable acces to the codestream (like JPIP applications, ...)
Currently, this information is only available when encoding an image.
+ [FOD] Added the information regarding the end of packet position in the index
August 28, 2007
* [FOD] Fixed wrong destructors called in openjpeg.c
* [FOD] Fixed bug in j2k_decode_jpt_stream
August 24, 2007
* [Parvatha] The end of main header is calculated after TLM and POC marker for Dcinema.
August 21, 2007
+ [FOD] Added support for Visual Studio 2005
* [FOD] Robustified MJ2 codecs
* [Parvatha] Solved problems with codec reading from image file directory when filename had more than one "." in name
* [Callum Lerwick] Minor cleanup patch, that gets rid of a bunch of "old style declaration" warnings from Intel's compiler
* [Callum Lerwick] Aligned malloc using Intel's _mm_malloc(). Cleanup on the t1 memory allocation, getting rid of some leftover debug code
* [Callum Lerwick] Memory leaks fixed
* [Callum Lerwick] Reworks of t1_updateflags to get rid of the shift operation
* [Callum Lerwick] mqc_setcurctx moved to the header to allow it to be inlined into the t1.
* [Callum Lerwick] Consolidated some calls to mqc_setcurctx.
* [Callum Lerwick] Cleaned up t1_generate_luts to output the proper types.
* [Callum Lerwick] Replaced the large ctxno_mag lookup table with a small bit of inline-able branchless code
* [Callum Lerwick] Moved the orient flipping into the ctxno_zc table.
August 20, 2007
+ [FOD] Added support for the TGA file format in the codec
August 08, 2007
* [Parvatha] Fixed the DCinema filesize allocation. It now includes the SOT marker size
August 02, 2007
+ [GB] Added a basic saving capability to OPJViewer
July 18, 2007
! [FOD] Updated libtiff library version to 3.8.2 (for WIN32)
* [FOD] Updated BMP and PxM truncation when decoding J2K files with more than 8 bits
July 17, 2007
* [FOD] Fixed raw option for images with more than three components
July 17, 2007
+ [FOD] Added support for RAW images. This module has been developped by the University of Perugia team. Thanks to them ! [image_to_j2k.c j2k_to_image.c convert.c convert.h]
July 13, 2007
! [FOD] Modified the memory allocation for codestreams containing multiple tiles. The memory is now allocated for each tile indenpendently,
leading to an important decrease of the virtual memory needed. [j2k.c tcd.h tcd.c]
! [FOD] Modified old comments about the ability to decode mega-images and comments about the disk size necessary to do this. [image_to_j2k.c and frames_to_mj2.c]
* [FOD] Added 2000 bytes for the memory allocation in cio.c for the minimum size of headers (useful in case of very small images) [cio.c]
July 12, 2007
* [GB] fixed a bug in JPWL module, which prevented to exploit the full error correction capability of RS codes (e.g. it gave up at 5 errors,
even if 6 were correctable); defined a JPWL_MAXIMUM_EPB_ROOM for better customization of the maximum dimension of EPBs (the dimension
is pre-calculated on an hypothesis, if it goes beyond 65535 there will be problems, thus we give a little less than the max, let's say 65450)
July 8, 2007
* [ANTONIN] fixed the size of the memory allocation in cio.c (confusion between bits and bytes)
June 21, 2007
* [FOD] Output image color space set when decoding a JP2 file in jp2.c
+ [GB] Previous, home, and next frame buttons for exploring MJ2 files in OPJViewer
June 18, 2007
* [GB] Reload image doesn't crash in OPJViewer; more settings saved to registry
June 16, 2007
+ [GB] Possibility to disable parsing in OPJViewer; also, saves common settings to the registry
June 15, 2007
* [FOD] Fixed the generation of index files
----------------------
MAY 4, 2007
VERSION 1.2.0 RELEASED
----------------------
May 4, 2007
* [FOD] Bugs corrected in decoding of command line (getopt.c), in the handling of 16 bit files (t1.c and tcd.c) and the calculation of elapsed time for multiple tiles parts (tcd.c and tdc.h).
June 2, 2007
+ [GB] OPJViewer opens now BMP, PNG, GIF, PNM, TIFF (with wxWidgets internals); added an encoder settings tab, for future integration with "save file as..." in JPEG 2000 format
May 31, 2007
* [FOD] Fixed the handling of 16bit TIFF files for cinema compression. Modified "convert.c"
* [FOD] Fixed the parameters used for cinema compression (9-7 transform used instead of 5-3). Modified "image_to_j2k.c"
May 24, 2007
* [FOD] Bug fixed by Sylvain Munaut. Change in the reading of the POC marker. Since COD/COC can be anywhere in the header, the decoder cannot always know while decoding the POC marker
the value of numlayers and numresolution.
May 23, 2007
! [FOD] Patch suggested by Callum Lerwick <seg@haxxed.com>: "This makes the t1 data arrays dynamic, which greatly reduces cache thrashing. Also, some minor cleanup to prevent unnecessary casts"
May 22, 2007
! [FOD] Patch suggested by Callum Lerwick <seg@haxxed.com>: "Some formatting cleanups,
so that the long function definitions and calls fit on screen. Use of prefix increment which is theoretically faster, in practice any sane compiler can optimize a postfix
increment but its best not to count on such things. Consolidation of some redundant calculations in the inner loops, which becomes very useful in the future autovectorize patch."
! [FOD] Patch suggested by Callum Lerwick <seg@haxxed.com>: "This changes the flag code in t1 to use a flag_t type, which can then be changed to reduce RAM usage. It is now typedef to a short."
! [FOD] Patch suggested by Callum Lerwick <seg@haxxed.com>: "This patch makes the t1 LUTs static. I actually intend this as a prelude to possibly eliminating some or all of the LUTs entirely."
May 11, 2007
- [FOD] JP3D library Binaries removed from SVN.
! [FOD] MJ2 codec updated from LibOpenJPEG version 0.97 to LibOpenJPEG version 1. Hence, the MJ2 codec will now take advantage of all the improvements and optimizations done on the LibOpenJPEG library.
! [FOD] Possibility to choose to apply MCT (multiple component transform) enabled, and new decoding_limit: DECODE_ALL_BUT_PACKETS (openjpeg.h)
April 26, 2007
+ [gdcm] Add basic steps on how to use CMake for building examples (README.cmake)
April 25, 2007
+ [FOD] Modification of the openjpeg.h file to avoid and ABI break with v1.1, removed the dangerous #IFDEF JPWL and added tcp_mct in cparameters.
April 23, 2007
+ [GB] Enable/disable image decoding in OPJViewer
April 12,2007
* [Parvatha] Fixed Error in tiftoimage(). Modification in convert.c.
April 10,2007
+ [Parvatha] Accepting "j2c" as format for Encoding and Decoding. Modification in image_to_j2k.c.
* [Parvatha] Modified imagetotif() to read images with signed data. Modification in convert.c.
April 5, 2007
! [FOD] fix.h optimized. Thanks a lot to Dzonatas <dzonatas at dzonux.net> !
! [FOD] dwt.c optimized. Thanks a lot to Dzonatas <dzonatas at dzonux.net> !
! [FOD] t1.c optimized. Thanks a lot to Callum Lerwick <seg at haxxed.com> !
April 4,2007
+ [Parvatha] Digital cinema compliance for 4K chosen by "-cinema4K" option. Modification in image_to_j2k.c.
+ [Parvatha] Bit rate limitation for each color component. Modification in image_to_j2k.c, t2.c.
* [Parvatha] Modified and tested Progression order change "-POC" option. Modification in image_to_j2k.c, j2k.c, pi.c.
+ [Parvatha] Function j2k_check_poc_val() to check for possible loss of packets in case of wrong POC declaration. Modification in j2k.c.
+ [Parvatha] Structure T2_MODE. This tells if the t2_encode_packets() is called during Threshold calculation or in Final pass. Modification in j2k.h, tcd.c
March 30, 2007
* [GB] OPJViewer should now work under Linux, at least with not big j2k files. Tested under Suse 10.1 64 bit.
March 29, 2007
* [Parvatha] Enable accepting file names with `-´ symbol .Modification getopt.c
* [Parvatha] Rsiz profile name generation to be STD_RSIZ for profiles which are not DCI compliant.Modification in image_to_j2k.c
! [Parvatha] renamed convert_progression_order to j2k_convert_progression_order. Modification j2k.c
* [Parvatha] Calculation of number of tile part in each tile in j2k_calculate_tp. Modification j2k.c
! [Parvatha] j2k_setup_encoder to set bit rate limitation for digital cinema compliance with quality option. Modification in j2k.c
* [Parvatha] Equation to check multiple tile precincts. Modification pi.c
! [Parvatha] array size generation of pi->include in pi_initialise_encode().Modification in pi.c
* [Parvatha] modification in pi_create_encode for tile part generation.Modification in pi.c
+ [Parvatha] In tcd_rateallocate a variable stable_threshold which holds the valid threshold value.
This is used to avoid error in case of a wrong threshold value in the last iteration. Modification in tcd.c.
March 28, 2007
* [FOD] Fixed an historical bug in t1.c that leaded to the inclusion of useless 0xFF in the codestream. Thanks to Sylvain, Pascal and Parvatha !
March 27, 2007
+ [GB] Improved parsing in OPJViewer, as well some minor aesthetic modifications; support for image rendering with bit depths lower than 8 bits;
can display an arbitrary frame of an MJ2 file (only in B/W, though); can reload a file; better resizing capabilities
* [GB] Following to Hervé's suggestions, all the exit() calls, added by JPWL strict checking in t2.c and j2k.c,
have been substituted with (object free'ing + opj_evt_message(EVT_ERROR) + return)
+ [GB] Added linking to TIFF library in the JPWL VC6 workspaces
March 23, 2007
* [antonin] Fixed Makefile.osx and changed Readme.osx accordingly
March 21, 2007
* [Parvatha] Fixed j2k_prog_order_list[]. Modifications in j2k.c.
* [Parvatha] Fixed t1_decode_cblks. Modifications in t1.c.
March 20, 2007
+ [Parvatha] Added feature for generation of tile parts. Modifications in image_to_j2k.c, openjpeg.c, j2k.c, pi.c
+ [Parvatha] Added function j2k_write_tlm(),to generate TLM marker for a Digital cinema compliant codestream. Modifications in j2k.c.
March 14, 2007
* [FOD] Fixed linux makefile, with help from David Fries and Guido
March 7, 2007
+ [Parvatha] Added option for Digital cinema profile compliant codestream. This can be chosen by "-cinema2K" or "-cinema4K" for a 2K and 4K compliance respectively. The feature for tileparts has not been implemented in this version. Modification in image_to_j2k.c
+ [Parvatha] Added the Digital Cinema profiles (CINEMA2K and CINEMA4K) to the list of profiles recognized in the codestream SIZ marker segment. Modification in openjpeg.h,j2k.c
+ [Parvatha] Added feature for constant quality within bitrate defined in Digital cinema standards. Modification in tcd.c
! [Parvatha] Modified the method of generation of buffer length. Modification in cio.c
March 1, 2007
* [FOD] Modified codec projects (*.dsp) and makefile to include the tiff library (modified codec/image_to_j2k.dsp codec/j2k_to_image.dsp and codec/makefile)
+ [GB] Zoom capability and decoder settings dialog in OPJViewer; modified JPWL library .dsp project in order to create a library with embedded JPWL functions
February 28, 2007
+ [Parvatha] Enabled compression of TIF image format to j2k by tifftoimage() and decompression of codestream to TIF image format using imagetotif(). Modifications in image_to_j2k.c, j2k_to_image.c, convert.c, convert.h
* [antonin] fixed a bug in context numerotation that prevented the RESET switch to work correctly : mqc_reset_enc in mqc.c
* [Fod] Corrected codec Makefile by adding the compilation of "compat/getopt.c"
February 27, 2007
* [Parvatha] Made get_file_format function more robust. Modifications in image_to_j2k.c, j2k_to_image.c, getopt.c, getopt.h
February 26, 2007
+ [Parvatha] Option to read images from a Folder whose path is specified in the Input parameters by "-ImgDir" along with output decod format specified by "-OutFor" . Modifications in image_to_j2k.c, j2k_to_image.c, getopt.c, getopt.h
+ [Parvatha] Enabling use of multi character input parameters in the codec. Modifications in image_to_j2k.c, j2k_to_image.c, getopt.c, getopt.h
----------------------
February 23, 2007
VERSION 1.1.1 RELEASED
----------------------
February 23, 2007
* [GB] Fixed a copy-and-paste type assignment error (bool instead of int) in the JPWL section of decoder parameters structure in openjpeg.h; minor type-casting in jpwl_lib.c.
As a result, now OPJViewer should run correctly when built against the most current SVN trunk of LibOpenJPEG.lib
+ [GB] Linux makefile for the JPWL module; newlines at end of JPWL files
February 22, 2007
+ [FOD] Added the OPJViewer Module (/OPJViewer), developed by Giuseppe Baruffa of the university of Perugia
February 21, 2007
+ [FOD] Algorithmic optimizations in t1.c, thanks to Guido J. !
February 19, 2007
+ [FOD] Added OPJ_LIMIT_DECODING enabling us to limit the decoding to main header (modified openjpeg.c, openjpeg.h, j2k.c and j2k.h)
February 13, 2007
! [FOD] David Fries suggestions. In image_to_j2k and j2k_to_image, strncpy() functions: instead of specifying the path size macro, let the compiler read the length out of the array entry.
! [FOD] David Fries suggestions. Makefile modified. -fPIC flag used for 64-bit compilation. Move operation (rather than copy) for the dist library creation, and -p flag added.
January 31, 2007
! [FOD] Extra tokens at the end of #endif directive corrected in openjpeg.c, j2k.c and image_to_j2k.c -> no more warnings in linux compilation
! [FOD] Linux Makefile added for the codec
January 30, 2007
! [FOD] Use of OPJ_PATH_LEN (defined as 4096) to be the maximum allowed size for filenames instead of MAX_PATH which is not always defined. This caused some programs using OpenJPEG to crash. Modifications in openjpeg.h j2k_to_image.c and image_to_j2k.c
! [FOD] Correction of the syntax usage in MJ2_codec/mj2_to_frames.c
January 23, 2007
! [FOD] Modification in the context numbers, to reflect what has been specified in standard, in libopenjpeg/t1.h
December 07, 2006
+ [Giuseppe Baruffa] Antonin verified that the MacOS build suffered from a missing definition of the "min" macro; I've added this definition (properly #ifndef'ed) into both jpwl.h and rs.h
December 05, 2006
* [Giuseppe Baruffa] Better fix of the TPH EPBs bug in JPWL module
* [GB] Fixed the UEP bug in JPWL module; now, during a UEP specification, RS protection or CRC check can be switched off for selected range of packets, and consequently reswitched on without confusing the decoder
+ [GB] Added some lines in the help of JPWL_image_to_j2k, specifying that when using error protection on data packets, this must be paired with header protection, i.e. there cannot be packet protection without header protection
December 04, 2006
+ [Francois-Olivier Devaux] New tag: version1.0 (includes codec and libopenjpeg directories)
Total update of JPWL module
- [FOD] removed directories jpwl/decoder, jpwl/encoder, jpwl/decoder_02, jpwl/encoder_02
+ [FOD] added in JPWL directory crc.h, jpwl.h, rs.h, crc.c, jpwl.c, jpwl_lib.c, rs.c, JPWL_image_to_j2k.dsp, JPWL_j2k_to_image.dsp, LibOpenJPEG_JPWL.dsp, JPWL_image_to_j2k.dsw, JPWL_j2k_to_image.dsw
! [FOD] Modifications of libopenjpeg to integrate JPWL module (in libopenjpeg directory): j2k.c, j2k.h, openjpeg.c, openjpeg.h, opj_includes.g, t2.c
! [FOD] Modification of codec to integrate JPWL module (in codec directory): image_to_j2k.c, j2k_to_image.c
* [FOD] Corrected incorrect fprintf() formatting in codec/convert.c
* [FOD] Code optimization usinq vsprintf() command in libopenjpeg/event.c
* [Giuseppe Baruffa] Fixed a bug in TPH EPBs parameters: now, "last in current header" information is correctly signaled
October 31, 2006
* [Antonin] fixed a bug in the computation of the mantissa (mu)
+ [Antonin] added the ability to specify the rate as "float" (before : integer)
August 18, 2006
* [Antonin] fixed a bug in j2k_to_image.c, that prevented the -l option to work correctly.
August 4, 2006
* [Antonin] fixed a bug in pi.c, line 473, that appeared when more than 100 precincts were generated in a resolution level.
July 28, 2006
+ [Antonin Descampe] added a readme in /mj2 to warn people that it only works with opj0.97
July 21, 2006
* [Mathieu Malaterre] Install exe and lib and include correctly
* [Mathieu Malaterre] Fixed mem leaks and greyscale bmp
* [Mathieu Malaterre] Fix pgx name length + random memory access
! [Mathieu Malaterre] API is now const
March 19, 2006
* [Antonin] fixed a bug in t1.c that prevented in some cases a true lossless compression (thanks to Don Mimlitch for reporting this bug)
February 12, 2006
- [Herve Drolon] removed unneeded working variables in opj_tcd_t
February 04, 2006
* [galt] fixed a bug in codec/convert.c::imagetobmp
February 01, 2006
! [Herve Drolon] changed function definitions of INT and FIX modules to 'inline'
+ [Herve Drolon] added a VERSION resource to the DLL version of OpenJPEG
January 31, 2006
* [Mathieu Malaterre] Fix compilation using default openjpeg.dsw
* [Herve Drolon] fixed various minor warnings occuring under icc9 and bcc32
- [Mathieu Malaterre] Remove all references to OPJ_EXPORT, no declspec in header file anymore
+ [Mathieu Malaterre] Add a def.in file which is a template for Module Definition
+ [Herve Drolon] added MSVC project and compiler directives to build a 'standard' WIN32 DLL
! [Mathieu Malaterre] Update CMake to match the new shared lib system (no more def file)
January 27, 2006
* [Antonin Descampe] fixed a two initialization problems in t1.c and tcd.c
January 26, 2006
* [Herve Drolon] fixed various minor warnings occuring under gcc
* [__david__] fixed a segfault in codec/image_to_j2k.c & codec/j2k_to_image.c
* [__david__] fixed help option in codec/j2k_to_image & codec/image_to_j2k
January 25, 2006
! [Mathieu Malaterre] Sync with ITK repository, also add ref to doxygen
! [Mathieu Malaterre] Add a lot of comments on the CMake build system
! [Mathieu Malaterre] Fix MINGW32 and BORLAND compilation problems.
January 25, 2006
* [Antonin Descampe] fixed a problem in convert.c when multiple comments
+ [Antonin Descampe] added cmake files to the project
! [Antonin Descampe] fix.c : replaced "WIN32" by "_MSC_VER" for int64
+ [Antonin Descampe] added "OPJ_EXPORT" in openjpeg.h to generate shared lib with win32
! [Antonin Descampe] removed all CtrlM from files
January 24, 2006
! [Antonin Descampe] event.c : replaced "WIN32" by "_MSC_VER" for i2a
January 20, 2006
* [Antonin Descampe] fixed various minor warnings with gdcm patches
January 19, 2006
* [Herve Drolon] fixed a bug in jp2_read_ihdr (need to allocate jp2->comps)
January 18, 2006
* [Herve Drolon] changed the name of j2k_realloc to opj_realloc
* [Herve Drolon] fixed a bug in opj_cio_open when saving 48-bit images (wrong buffer size calculation)
December 8, 2005
* [Antonin Descampe] fixed a bug when specifying a rate '-r' => no distortion info was available in the index
* [Antonin Descampe] fixed a bug in t1_getwmsedec (stepsize was divided by 8192)
December 5, 2005 - 1.1.0

View File

@ -0,0 +1,21 @@
#
# For further details regarding this file,
# see http://www.vtk.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest
#
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 50)
SET(CTEST_CUSTOM_COVERAGE_EXCLUDE
${CTEST_CUSTOM_COVERAGE_EXCLUDE}
# Exclude files from the Testing directories
".*/Testing/.*"
)
SET(CTEST_CUSTOM_WARNING_EXCEPTION
${CTEST_CUSTOM_WARNING_EXCEPTION}
# Suppress warning caused by intentional messages about deprecation
".*warning,.* is deprecated"
)

52
CMake/FindFreeImage.cmake Normal file
View File

@ -0,0 +1,52 @@
#
# Try to find the FreeImage library and include path.
# Once done this will define
#
# FREEIMAGE_FOUND
# FREEIMAGE_INCLUDE_PATH
# FREEIMAGE_LIBRARY
#
IF (WIN32)
FIND_PATH( FREEIMAGE_INCLUDE_PATH FreeImage.h
${OPENJPEG_SOURCE_DIR}/libs/FreeImage
DOC "The directory where FreeImage.h resides")
FIND_LIBRARY( FREEIMAGE_LIBRARY
NAMES FreeImage freeimage freeimage.s
PATHS
${OPENJPEG_SOURCE_DIR}/libs/FreeImage
DOC "The FreeImage library")
ELSE (WIN32)
FIND_PATH( FREEIMAGE_INCLUDE_PATH FreeImage.h
/usr/include
/usr/local/include
/sw/include
/opt/local/include
DOC "The directory where FreeImage.h resides")
FIND_LIBRARY( FREEIMAGE_LIBRARY
NAMES FreeImage freeimage
PATHS
/usr/lib64
/usr/lib
/usr/local/lib64
/usr/local/lib
/sw/lib
/opt/local/lib
DOC "The FreeImage library")
ENDIF (WIN32)
SET(FREEIMAGE_LIBRARIES ${FREEIMAGE_LIBRARY})
IF (FREEIMAGE_INCLUDE_PATH AND FREEIMAGE_LIBRARY)
SET( FREEIMAGE_FOUND TRUE CACHE BOOL "Set to TRUE if GLEW is found, FALSE otherwise")
ELSE (FREEIMAGE_INCLUDE_PATH AND FREEIMAGE_LIBRARY)
SET( FREEIMAGE_FOUND FALSE CACHE BOOL "Set to TRUE if GLEW is found, FALSE otherwise")
ENDIF (FREEIMAGE_INCLUDE_PATH AND FREEIMAGE_LIBRARY)
MARK_AS_ADVANCED(
FREEIMAGE_FOUND
FREEIMAGE_LIBRARY
FREEIMAGE_LIBRARIES
FREEIMAGE_INCLUDE_PATH)

View File

@ -0,0 +1,3 @@
SET(CMAKE_MODULE_PATH "${OPENJPEG_SOURCE_DIR}/CMake")
FIND_PACKAGE(FreeImage REQUIRED)
ADD_DEFINITIONS ( -DFREEIMAGE_LIB )

View File

@ -5,46 +5,45 @@
# This file is configured by OPENJPEG and used by the UseOPENJPEG.cmake
# module to load OPENJPEG's settings for an external project.
@OPENJPEG_CONFIG_INSTALL_ONLY@
@PACKAGE_INIT@
# The OPENJPEG version number.
set(OPENJPEG_MAJOR_VERSION "@OPENJPEG_VERSION_MAJOR@")
set(OPENJPEG_MINOR_VERSION "@OPENJPEG_VERSION_MINOR@")
set(OPENJPEG_BUILD_VERSION "@OPENJPEG_VERSION_BUILD@")
SET(OPENJPEG_MAJOR_VERSION "@OPENJPEG_VERSION_MAJOR@")
SET(OPENJPEG_MINOR_VERSION "@OPENJPEG_VERSION_MINOR@")
SET(OPENJPEG_BUILD_VERSION "@OPENJPEG_VERSION_BUILD@")
# The libraries.
set(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARY_NAME@")
SET(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARIES@")
# The CMake macros dir.
set(OPENJPEG_CMAKE_DIR "@OPENJPEG_INSTALL_PACKAGE_DIR@")
SET(OPENJPEG_CMAKE_DIR "@OPENJPEG_CMAKE_DIR_CONFIG@")
# The configuration options.
set(OPENJPEG_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
SET(OPENJPEG_BUILD_SHARED_LIBS "@OPENJPEG_BUILD_SHARED_LIBS@")
# 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)
if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
# This is an install tree
include(${SELF_DIR}/OpenJPEGTargets.cmake)
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/../../@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_ROOT})
set(OPENJPEG_LIBRARIES openjpeg)
set(INC_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@/@OPENJPEG_INSTALL_SUBDIR@")
get_filename_component(OPENJPEG_INCLUDE_DIRS "${INC_DIR}" ABSOLUTE)
else()
else(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
if(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
# This is a build tree
set( OPENJPEG_INCLUDE_DIRS @OPENJPEG_INCLUDE_PATH@)
SET( OPENJPEG_INCLUDE_DIRS @OPENJPEG_INCLUDE_PATH@)
include(${SELF_DIR}/OpenJPEGExports.cmake)
else()
else(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
message(FATAL_ERROR "ooops")
endif()
endif()
endif(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
endif(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
set(OPENJPEG_USE_FILE ${SELF_DIR}/UseOPENJPEG.cmake)
# Backward compatible part:
set(OPENJPEG_FOUND TRUE)
SET(OPENJPEG_FOUND TRUE)

View File

@ -0,0 +1,51 @@
cmake_minimum_required(VERSION 2.8)
# simply copy this file anywhere on your system and execute like this:
# ctest -S mymachine_openjpeg.cmake -V
# This will retrieve/compile/run tests/upload to cdash OpenJPEG
# results will be available at: http://my.cdash.org/index.php?project=OPENJPEG
# Begin User inputs:
set( CTEST_SITE "mymachine" ) # generally the output of hostname
set( CTEST_DASHBOARD_ROOT "/tmp" ) # writable path
set( CTEST_CMAKE_GENERATOR "Unix Makefiles" ) # What is your compilation apps ?
set( CTEST_BUILD_CONFIGURATION Debug) # What type of build do you want ?
set( ENV{CFLAGS} "-Wall" ) # just for fun...
# For testing we need to define the path to J2KP4files
# wget http://www.crc.ricoh.com/~gormish/jpeg2000conformance/j2kp4files_v1_5.zip
# unzip j2kp4files_v1_5.zip
set( CACHE_CONTENTS "
BUILD_TESTING:BOOL=TRUE
JPEG2000_CONFORMANCE_DATA_ROOT:PATH=${CTEST_SOURCE_DIRECTORY}/J2KP4files" )
# End User inputs:
# You do not need to change anything after that:
# 1. openjpeg specific:
set( CTEST_PROJECT_NAME "OPENJPEG" )
set( CTEST_SOURCE_NAME OpenJPEG)
set( CTEST_BUILD_NAME "${CMAKE_SYSTEM}-${CTEST_CMAKE_GENERATOR}-${CTEST_BUILD_CONFIGURATION}")
set( CTEST_BINARY_NAME "${CTEST_SOURCE_NAME}-${CTEST_BUILD_NAME}")
# 2. cdash/openjpeg specific:
# svn checkout http://openjpeg.googlecode.com/svn/trunk/ openjpeg-read-only
set( CTEST_SVN_URL "http://openjpeg.googlecode.com/svn/")
set( CTEST_UPDATE_COMMAND "svn")
#set( CTEST_CHECKOUT_COMMAND "${CTEST_UPDATE_COMMAND} co ${CTEST_SVN_URL}/trunk ${CTEST_SOURCE_NAME}")
set( CTEST_CHECKOUT_COMMAND "${CTEST_UPDATE_COMMAND} co ${CTEST_SVN_URL}/branches/v2 ${CTEST_SOURCE_NAME}")
# 3. cmake specific:
set( CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_SOURCE_NAME}")
set( CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_BINARY_NAME}")
set( CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
ctest_empty_binary_directory( "${CTEST_BINARY_DIRECTORY}" )
file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" "${CACHE_CONTENTS}")
# Perform the Nightly build
ctest_start(Nightly)
ctest_update(SOURCE "${CTEST_SOURCE_DIRECTORY}")
ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}")
ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}")
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}")
ctest_submit()

View File

@ -6,366 +6,199 @@
# you will eventually like to prefix the library to avoid linking confusion
# For this purpose you can define a CMake var: OPENJPEG_NAMESPACE to whatever you like
# e.g.:
# set(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
cmake_minimum_required(VERSION 2.8.5)
# SET(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
if(COMMAND CMAKE_POLICY)
cmake_policy(SET CMP0003 NEW)
if (NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
cmake_policy(SET CMP0042 NEW)
endif()
endif()
IF(COMMAND CMAKE_POLICY)
CMAKE_POLICY(SET CMP0003 NEW)
ENDIF(COMMAND CMAKE_POLICY)
if(NOT OPENJPEG_NAMESPACE)
set(OPENJPEG_NAMESPACE "OPENJPEG")
set(OPENJPEG_STANDALONE 1)
endif()
IF(NOT OPENJPEG_NAMESPACE)
SET(OPENJPEG_NAMESPACE "OPENJPEG")
SET(OPENJPEG_STANDALONE 1)
ENDIF(NOT OPENJPEG_NAMESPACE)
# In all cases:
#string(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
set(OPENJPEG_LIBRARY_NAME openjp2)
STRING(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
project(${OPENJPEG_NAMESPACE} C)
PROJECT(${OPENJPEG_NAMESPACE} C)
# Do full dependency headers.
include_regular_expression("^.*$")
INCLUDE_REGULAR_EXPRESSION("^.*$")
#-----------------------------------------------------------------------------
# OPENJPEG version number, useful for packaging and doxygen doc:
set(OPENJPEG_VERSION_MAJOR 2)
set(OPENJPEG_VERSION_MINOR 5)
set(OPENJPEG_VERSION_BUILD 0)
set(OPENJPEG_VERSION
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
set(PACKAGE_VERSION
SET(OPENJPEG_VERSION_MAJOR 2)
SET(OPENJPEG_VERSION_MINOR 0)
SET(OPENJPEG_VERSION_BUILD 0)
SET(OPENJPEG_VERSION
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
# Because autotools does not support X.Y notation for SOVERSION, we have to use
# two numbering, 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
# 2.0.1 | 6
# 2.1 | 7
# 2.1.1 | 7
# 2.1.2 | 7
# 2.2.0 | 7
# 2.3.0 | 7
# 2.3.1 | 7
# 2.4.0 | 7
# 2.5.0 | 7
# above is the recommendation by the OPJ team. If you really need to override this default,
# you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
# cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg
if(NOT OPENJPEG_SOVERSION)
set(OPENJPEG_SOVERSION 7)
endif(NOT OPENJPEG_SOVERSION)
set(OPENJPEG_LIBRARY_PROPERTIES
# This setting of SOVERSION assumes that any API change
# will increment either the minor or major version number of openjpeg
SET(OPENJPEG_LIBRARY_PROPERTIES
VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
SOVERSION "${OPENJPEG_SOVERSION}"
SOVERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}"
)
# --------------------------------------------------------------------------
# Path to additional CMake modules
set(CMAKE_MODULE_PATH
${${OPENJPEG_NAMESPACE}_SOURCE_DIR}/cmake
${CMAKE_MODULE_PATH})
# --------------------------------------------------------------------------
# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
# warnings
if(WIN32)
if(NOT BORLAND)
if(NOT CYGWIN)
if(NOT MINGW)
if(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
add_definitions(
-D_CRT_FAR_MAPPINGS_NO_DEPRECATE
-D_CRT_IS_WCTYPE_NO_DEPRECATE
-D_CRT_MANAGED_FP_NO_DEPRECATE
-D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_DEPRECATE_GLOBALS
-D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
-D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
-D_CRT_VCCLRIT_NO_DEPRECATE
-D_SCL_SECURE_NO_DEPRECATE
)
endif()
endif()
endif()
endif()
endif()
# You will also need to define a value for the following variables:
# OPENJPEG_INSTALL_BIN_DIR - binary dir (executables)
# OPENJPEG_INSTALL_LIB_DIR - library dir (libs)
# OPENJPEG_INSTALL_DATA_DIR - share dir (say, examples, data, etc)
# OPENJPEG_INSTALL_INCLUDE_DIR - include dir (headers)
# --------------------------------------------------------------------------
# Install directories
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME)
include(GNUInstallDirs)
# Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
option(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
STRING(TOLOWER ${PROJECT_NAME} projectname)
SET(subdir "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
set(OPENJPEG_INSTALL_SUBDIR "${PROJECT_NAME}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
IF(NOT OPENJPEG_INSTALL_BIN_DIR)
SET(OPENJPEG_INSTALL_BIN_DIR "bin")
ENDIF(NOT OPENJPEG_INSTALL_BIN_DIR)
if(NOT OPENJPEG_INSTALL_JNI_DIR)
if(WIN32)
set(OPENJPEG_INSTALL_JNI_DIR ${CMAKE_INSTALL_BINDIR})
else()
set(OPENJPEG_INSTALL_JNI_DIR ${CMAKE_INSTALL_LIBDIR})
endif()
endif()
IF(NOT OPENJPEG_INSTALL_LIB_DIR)
SET(OPENJPEG_INSTALL_LIB_DIR "lib")
ENDIF(NOT OPENJPEG_INSTALL_LIB_DIR)
if(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
set(OPENJPEG_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${OPENJPEG_INSTALL_SUBDIR}")
endif()
IF(NOT OPENJPEG_INSTALL_DATA_DIR)
SET(OPENJPEG_INSTALL_DATA_DIR "share/${subdir}")
ENDIF(NOT OPENJPEG_INSTALL_DATA_DIR)
if (APPLE)
if (${CMAKE_VERSION} VERSION_LESS 3.0)
# For cmake >= 3.0, we turn on CMP0042 and
# https://cmake.org/cmake/help/v3.0/policy/CMP0042.html mentions
# "Projects wanting @rpath in a targets install name may remove any setting of the INSTALL_NAME_DIR and CMAKE_INSTALL_NAME_DIR variables"
list(APPEND OPENJPEG_LIBRARY_PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}")
endif()
option(OPJ_USE_DSYMUTIL "Call dsymutil on binaries after build." OFF)
endif()
IF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
SET(OPENJPEG_INSTALL_INCLUDE_DIR "include/${subdir}")
ENDIF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
IF(NOT OPENJPEG_INSTALL_DOC_DIR)
SET(OPENJPEG_INSTALL_DOC_DIR "share/doc/${subdir}")
ENDIF(NOT OPENJPEG_INSTALL_DOC_DIR)
IF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
SET(OPENJPEG_INSTALL_PACKAGE_DIR ${OPENJPEG_INSTALL_LIB_DIR}/${subdir}
CACHE INTERNAL "")
ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
#-----------------------------------------------------------------------------
# Big endian test:
if (NOT EMSCRIPTEN)
include (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
TEST_BIG_ENDIAN(OPJ_BIG_ENDIAN)
endif()
# Test for some required system information.
INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
#-----------------------------------------------------------------------------
# Setup file for setting custom ctest vars
configure_file(
${${OPENJPEG_NAMESPACE}_SOURCE_DIR}/cmake/CTestCustom.cmake.in
${${OPENJPEG_NAMESPACE}_BINARY_DIR}/CTestCustom.cmake
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/CMake/CTestCustom.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
@ONLY
)
#-----------------------------------------------------------------------------
# OpenJPEG build configuration options.
option(BUILD_SHARED_LIBS "Build OpenJPEG shared library and link executables against it." ON)
option(BUILD_STATIC_LIBS "Build OpenJPEG static library." ON)
set (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
set (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
mark_as_advanced(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
OPTION(BUILD_SHARED_LIBS "Build OpenJPEG with shared libraries." OFF)
OPTION(ENABLE_PROFILING "Enable profiling for the library" OFF)
#-----------------------------------------------------------------------------
SET (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
SET (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
#-----------------------------------------------------------------------------
# For the codec...
OPTION(BUILD_EXAMPLES "Build the Examples (codec...)." OFF)
# configure name mangling to allow multiple libraries to coexist
# peacefully
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
set(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
SET(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
@ONLY)
endif()
@ONLY IMMEDIATE)
ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
#-----------------------------------------------------------------------------
# Compiler specific flags:
if(CMAKE_COMPILER_IS_GNUCC)
# For all builds, make sure openjpeg is std99 compliant:
# set(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
# Do not use ffast-math for all build, it would produce incorrect results, only set for release:
set(OPENJPEG_LIBRARY_COMPILE_OPTIONS ${OPENJPEG_LIBRARY_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>")
set(OPENJP2_COMPILE_OPTIONS ${OPENJP2_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>" -Wall -Wextra -Wconversion -Wunused-parameter -Wdeclaration-after-statement -Werror=declaration-after-statement)
endif()
# Configure files with settings for use by the build.
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/opj_configure.h.in
${CMAKE_CURRENT_BINARY_DIR}/opj_configure.h)
#-----------------------------------------------------------------------------
# opj_config.h generation (1/2)
# Check if some include files are provided by the system
include(EnsureFileInclude)
# These files are mandatory
ensure_file_include("string.h" HAVE_STRING_H YES)
ensure_file_include("memory.h" HAVE_MEMORY_H YES)
ensure_file_include("stdlib.h" HAVE_STDLIB_H YES)
ensure_file_include("stdio.h" HAVE_STDIO_H YES)
ensure_file_include("math.h" HAVE_MATH_H YES)
ensure_file_include("float.h" HAVE_FLOAT_H YES)
ensure_file_include("time.h" HAVE_TIME_H YES)
ensure_file_include("stdarg.h" HAVE_STDARG_H YES)
ensure_file_include("ctype.h" HAVE_CTYPE_H YES)
ensure_file_include("assert.h" HAVE_ASSERT_H YES)
# For the following files, we provide an alternative, they are not mandatory
ensure_file_include("stdint.h" OPJ_HAVE_STDINT_H NO)
ensure_file_include("inttypes.h" OPJ_HAVE_INTTYPES_H NO)
# why check this one ? for openjpip ?
include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
# Enable Large file support
include(TestLargeFiles)
OPJ_TEST_LARGE_FILES(OPJ_HAVE_LARGEFILES)
# Allocating Aligned Memory Blocks
include(CheckIncludeFiles)
check_include_files(malloc.h OPJ_HAVE_MALLOC_H)
include(CheckSymbolExists)
# _aligned_alloc https://msdn.microsoft.com/en-us/library/8z34s9c6.aspx
check_symbol_exists(_aligned_malloc malloc.h OPJ_HAVE__ALIGNED_MALLOC)
# posix_memalign (needs _POSIX_C_SOURCE >= 200112L on Linux)
set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L)
check_symbol_exists(posix_memalign stdlib.h OPJ_HAVE_POSIX_MEMALIGN)
unset(CMAKE_REQUIRED_DEFINITIONS)
# memalign (obsolete)
check_symbol_exists(memalign malloc.h OPJ_HAVE_MEMALIGN)
#-----------------------------------------------------------------------------
# Build Library
if(BUILD_JPIP_SERVER)
find_package(CURL REQUIRED)
find_package(FCGI REQUIRED)
find_package(Threads REQUIRED)
if(NOT CMAKE_USE_PTHREADS_INIT)
message(FATAL_ERROR "Only pthread are supported")
endif()
endif()
add_subdirectory(src/lib)
option(BUILD_LUTS_GENERATOR "Build utility to generate t1_luts.h" OFF)
if(UNIX)
option(BUILD_UNIT_TESTS "Build unit tests (bench_dwt, test_sparse_array, etc..)" OFF)
endif()
#-----------------------------------------------------------------------------
# Build Applications
option(BUILD_CODEC "Build the CODEC executables" ON)
option(BUILD_JPIP "Build the JPIP library and executables." OFF)
if(BUILD_JPIP)
option(BUILD_JPIP_SERVER "Build the JPIP server." OFF)
endif()
option(BUILD_VIEWER "Build the OPJViewer executable (C++)" OFF)
option(BUILD_JAVA "Build the openjpeg jar (Java)" OFF)
mark_as_advanced(BUILD_VIEWER)
mark_as_advanced(BUILD_JAVA)
if(BUILD_CODEC)
# OFF: It will only build 3rd party libs if they are not found on the system
# ON: 3rd party libs will ALWAYS be build, and used
option(BUILD_THIRDPARTY "Build the thirdparty executables if it is needed" OFF)
add_subdirectory(thirdparty)
add_subdirectory(src/bin)
endif ()
add_subdirectory(wrapping)
#-----------------------------------------------------------------------------
# opj_config.h generation (2/2)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/opj_config.h.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/src/lib/openjp2/opj_config.h
@ONLY
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/opj_config_private.h.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/src/lib/openjp2/opj_config_private.h
@ONLY
)
#-----------------------------------------------------------------------------
# build documentation in doc subdir:
if(BUILD_DOC)
add_subdirectory(doc)
endif()
#-----------------------------------------------------------------------------
# Build Testing
option(BUILD_TESTING "Build the tests." OFF)
if(BUILD_TESTING)
if(BUILD_CODEC)
enable_testing()
include(CTest)
# Search openjpeg data needed for the tests
# They could be found via git on the OpenJPEG GitHub code project
# git clone https://github.com/uclouvain/openjpeg-data.git
find_path(OPJ_DATA_ROOT README-OPJ-Data
PATHS $ENV{OPJ_DATA_ROOT} ${CMAKE_SOURCE_DIR}/../data
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
)
# Add repository where to find tests
add_subdirectory(tests)
else()
message(FATAL_ERROR "You need build codec to run the tests")
endif()
endif()
#-----------------------------------------------------------------------------
# install all targets referenced as OPENJPEGTargets (relocatable with CMake 3.0+)
install(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
if (${CMAKE_VERSION} VERSION_LESS 3.0)
set(PACKAGE_INIT)
set(PACKAGE_CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_FULL_INCLUDEDIR})
configure_file( ${${OPENJPEG_NAMESPACE}_SOURCE_DIR}/cmake/OpenJPEGConfig.cmake.in
${${OPENJPEG_NAMESPACE}_BINARY_DIR}/OpenJPEGConfig.cmake
@ONLY
# Always build the library
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
SUBDIRS(
libopenjpeg
# mj2
#j2kviewer/src
)
else()
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/OpenJPEGConfig.cmake.in
${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
INSTALL_DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}
PATH_VARS CMAKE_INSTALL_INCLUDEDIR)
endif()
install( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}
#IF(NOT UNIX)
#SUBDIRS(
# jpwl
# jp3d
# indexer_JPIP
# )
#ENDIF(NOT UNIX)
#-----------------------------------------------------------------------------
# Build example only if requested
IF(BUILD_EXAMPLES)
SUBDIRS(codec)
ENDIF(BUILD_EXAMPLES)
#-----------------------------------------------------------------------------
# For the documentation
OPTION(BUILD_DOCUMENTATION "Build the doxygen documentation" OFF)
IF(BUILD_DOCUMENTATION)
SUBDIRS(doc)
ENDIF(BUILD_DOCUMENTATION)
#-----------------------------------------------------------------------------
# For openjpeg team if they ever want CDash+CMake
OPTION(BUILD_TESTING "Build the tests." OFF)
IF(BUILD_TESTING)
ENABLE_TESTING()
INCLUDE(CTest)
ENDIF(BUILD_TESTING)
IF(BUILD_TESTING)
SET(CMAKE_MODULE_PATH "${OPENJPEG_SOURCE_DIR}/CMake")
FIND_PACKAGE(FreeImage)
SUBDIRS(
test_V2_tile_handling
)
if(FREEIMAGE_FOUND)
INCLUDE_DIRECTORIES( ${FREEIMAGE_INCLUDE_PATH} )
SUBDIRS(
test_Free_image_V2_tile_handling
)
endif(FREEIMAGE_FOUND)
ENDIF(BUILD_TESTING)
# Adding test with dataset from:
# http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
# -> wget http://www.crc.ricoh.com/~gormish/jpeg2000conformance/j2kp4files_v1_5.zip
# http://www.jpeg.org/jpeg2000guide/testimages/testimages.html
#-----------------------------------------------------------------------------
# Adding JPEG2000_CONFORMANCE_DATA_ROOT
FIND_PATH(JPEG2000_CONFORMANCE_DATA_ROOT testimages.html
${OPENJPEG_SOURCE_DIR}/../jpeg2000testimages
$ENV{JPEG2000_CONFORMANCE_DATA_ROOT}
)
#-----------------------------------------------------------------------------
# Compiler specific flags:
IF(CMAKE_COMPILER_IS_GNUCC)
# For all builds, make sure openjpeg is std99 compliant:
# SET(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
# Do not use ffast-math for all build, it would produce incorrect results, only set for release:
SET(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
include (cmake/OpenJPEGCPack.cmake)
# install all targets referenced as OPENJPEGTargets
install(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
CONFIGURE_FILE( ${OPENJPEG_SOURCE_DIR}/CMake/OpenJPEGConfig.cmake.in
${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
@ONLY
)
INSTALL( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}
)
#-----------------------------------------------------------------------------
# pkgconfig support
# enabled by default on Unix or if using GCC, disabled by default on other platforms
if(UNIX OR CMAKE_COMPILER_IS_GNUCC)
option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" ON)
else()
option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" OFF)
endif()
if(BUILD_PKGCONFIG_FILES)
macro(set_variable_from_rel_or_absolute_path var root rel_or_abs_path)
if(IS_ABSOLUTE "${rel_or_abs_path}")
set(${var} "${rel_or_abs_path}")
else()
set(${var} "${root}/${rel_or_abs_path}")
endif()
endmacro()
set_variable_from_rel_or_absolute_path("bindir" "\\\${prefix}" "${CMAKE_INSTALL_BINDIR}")
set_variable_from_rel_or_absolute_path("mandir" "\\\${prefix}" "${CMAKE_INSTALL_MANDIR}")
set_variable_from_rel_or_absolute_path("docdir" "\\\${prefix}" "${CMAKE_INSTALL_DOCDIR}")
set_variable_from_rel_or_absolute_path("libdir" "\\\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
set_variable_from_rel_or_absolute_path("includedir" "\\\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}/${OPENJPEG_INSTALL_SUBDIR}")
# install in lib and not share (CMAKE_INSTALL_LIBDIR takes care of it for multi-arch)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/libopenjp2.pc.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/libopenjp2.pc @ONLY)
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjp2.pc DESTINATION
${CMAKE_INSTALL_LIBDIR}/pkgconfig )
#
if(BUILD_JPIP)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjpip/libopenjpip.pc.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/libopenjpip.pc @ONLY)
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjpip.pc DESTINATION
${CMAKE_INSTALL_LIBDIR}/pkgconfig )
endif()
endif()
#-----------------------------------------------------------------------------
# build our version of astyle
SET (WITH_ASTYLE FALSE CACHE BOOL "If you plan to contribute you should reindent with scripts/prepare-commit.sh (using 'our' astyle)")

View File

@ -1,32 +0,0 @@
Check-list OpenJPEG Release
* update MAJOR, MINOR, BUILD, SOVERSION in CMakeLists.txt
* update MAJOR, MINOR, BUILD in appveyor.yml
* update CHANGELOG with
`github_changelog_generator --token TOKEN_HERE --exclude-labels gcode_fixed,OpjVersion-1.x --release-url "https://github.com/uclouvain/openjpeg/releases/%s" --since-tag v2.3.1 --future-release v2.4.0 --output append2changelog.md --user uclouvain --project openjpeg --exclude-tags version.1.0` . TOKEN_HERE is created at https://github.com/settings/tokens
* update NEWS.md
* git tag -a v2.4.0 -m "OpenJPEG v2.4.0 release"
* git push origin --tags
* add post to OpenJPEG website in gh-pages branch in _posts/ subdirectory. See commit https://github.com/uclouvain/openjpeg/commit/6563d704f5fb896209dd862ccfc6b97eb9183c5c
* change binversion of openjpeg website in _config.yml in gh-pages branch
* update release description if needed
* update openjpeg.json with latest release
* update OPJ_LATEST_VERSION in abi-check.sh, uncomment and update OPJ_PREVIOUS_VERSION in abi-check.sh, and push
* locally run: OPJ_CI_ABI_CHECK=1 ./tools/travis-ci/abi-check.sh
* cd ~/abi-check/work/abi-check/
* put the sources of the new version in src/openjpeg/2.X.0/version.-2.X.0.tar.gz
* PATH=$PWD/../../tools/abi-tracker/bin:$PWD/../../tools/wdiff/bin:$PWD/../../tools:$PATH abi-monitor -v 2.X.0 -build ./openjpeg.json
* PATH=$PWD/../../tools/abi-tracker/bin:$PWD/../../tools/wdiff/bin:$PWD/../../tools:$PATH abi-tracker -build ./openjpeg.json
* rm -rf src/openjpeg/current
* rm -rf build_logs
* git add --all .
* git commit -m "Update ABI/API compatibility reports after 2.X.0 release"
* git push
* cd ~/openjpeg/openjpeg
* comment back OPJ_PREVIOUS_VERSION and push
* build doc and update Doxygen on website
* manual build on Windows:
- cmake .. -G "Visual Studio 15 2017" -A x64 -DCMAKE_CONFIGURATION_TYPES=Release -DBUILD_THIRDPARTY=ON -D CPACK_GENERATOR:STRING=ZIP -D CPACK_PACKAGE_FILE_NAME:STRING=openjpeg-v2.4.0-windows-x64
- cmake --build . --target package --config Release
* send email to ML opj, comp.compression, iiif
* tweet

View File

@ -1,138 +0,0 @@
# OpenJPEG installation
The build method maintained by OpenJPEG is [CMake](https://cmake.org/).
## UNIX/LINUX - MacOS (terminal) - WINDOWS (cygwin, MinGW)
To build the library, type from source tree directory:
```
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
```
Binaries are then located in the 'bin' directory.
To install the library, type with root privileges:
```
make install
make clean
```
To build the html documentation, you need doxygen to be installed on your system.
It will create an "html" directory in TOP\_LEVEL/build/doc)
```
make doc
```
Main available cmake flags:
* To specify the install path: '-DCMAKE\_INSTALL\_PREFIX=/path'
* 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.
* PKG_CONFIG files are by default built for Unix compile, you can force to build on other platforms by adding: '-DBUILD_PKGCONFIG_FILES=on'
* To build the CODEC executables: '-DBUILD\_CODEC:bool=on' (default: 'ON')
* To build opjstyle (internal version of astyle) for OpenJPEG development: '-DWITH_ASTYLE=ON'
* [OBSOLETE] To build the MJ2 executables: '-DBUILD\_MJ2:bool=on' (default: 'OFF')
* [OBSOLETE] To build the JPWL executables and JPWL library: '-DBUILD\_JPWL:bool=on' (default: 'OFF')
* [OBSOLETE] To build the JPIP client (java compiler recommended) library and executables: '-DBUILD\_JPIP:bool=on' (default: 'OFF')
* [OBSOLETE] To build the JPIP server (need fcgi) library and executables: '-DBUILD\_JPIP\_SERVER:bool=on' (default: 'OFF')
* To enable testing (and automatic result upload to http://my.cdash.org/index.php?project=OPENJPEG):
```
cmake . -DBUILD_TESTING:BOOL=ON -DOPJ_DATA_ROOT:PATH='path/to/the/data/directory' -DBUILDNAME:STRING='name_of_the_build'
make
make Experimental
```
Note : test data is available on the following github repo: https://github.com/uclouvain/openjpeg-data
If '-DOPJ\_DATA\_ROOT:PATH' option is omitted, test files will be automatically searched in '${CMAKE\_SOURCE\_DIR}/../data'.
Note 2 : to execute the encoding test suite, kakadu binaries are needed to decode encoded image and compare it to the baseline. Kakadu binaries are freely available for non-commercial purposes at http://www.kakadusoftware.com. kdu\_expand will need to be in your PATH for cmake to find it.
Note 3 : OpenJPEG encoder and decoder (not the library itself !) depends on several libraries: png, tiff, lcms, z. If these libraries are not found on the system, they are automatically built from the versions available in the source tree. You can force the use of these embedded version with BUILD\_THIRDPARTY:BOOL=ON. On a Debian-like system you can also simply install these libraries with:
```
sudo apt-get install liblcms2-dev libtiff-dev libpng-dev libz-dev
```
Note 4 : On MacOS, if it does not work, try adding the following flag to the cmake command :
```
-DCMAKE_OSX_ARCHITECTURES:STRING=i386
```
## MacOS (XCode) - WINDOWS (VisualStudio, etc)
You can use cmake to generate the project files for the IDE you are using (VC2010, XCode, etc).
Type `cmake --help` for available generators on your platform.
Examples for Windows with Visual Studio C++ compiler:
If using directly the cl compiler:
```
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="%USERPROFILE%" -DCMAKE_LIBRARY_PATH:path="%USERPROFILE%" -DCMAKE_INCLUDE_PATH:path="%USERPROFILE%\include" ..
```
To compile a 64-bit application, open 64-Bit Visual C\+\+ toolset on the command line and run cmake. For further information, please refer to: [How to: Enable a 64-Bit Visual C\+\+ Toolset on the Command Line](https://msdn.microsoft.com/en-us/library/x4d2c09s.aspx).
If you do not want directly use the cl compiler, you could use:
```
cmake -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="%USERPROFILE%" -DCMAKE_LIBRARY_PATH:path="%USERPROFILE%" -DCMAKE_INCLUDE_PATH:path="%USERPROFILE%\include" ..
```
To create Visual Studio solution (.sln) and project files (.vcproj / .vcxproj):
```
cmake -G "Visual Studio 14 2015" -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="%USERPROFILE%" -DCMAKE_LIBRARY_PATH:path="%USERPROFILE%" -DCMAKE_INCLUDE_PATH:path="%USERPROFILE%\include" ..
```
64-bit application:
```
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="%USERPROFILE%" -DCMAKE_LIBRARY_PATH:path="%USERPROFILE%" -DCMAKE_INCLUDE_PATH:path="%USERPROFILE%\include" ..
```
# Enabling CPU specific optimizations
For Intel/AMD processors, OpenJPEG implements optimizations using the SSE4.1
instruction set (for example, for the 9x7 inverse MCT transform) and the AVX2
instruction set (for example, for the 5x3 inverse discrete wavelet transform).
Currently, those optimizations are only available if OpenJPEG is built to
use those instruction sets (and the resulting binary will only run on compatible
CPUs)
With gcc/clang, it is possible to enable those instruction sets with the following :
```
cmake -DCMAKE_C_FLAGS="-O3 -msse4.1 -DNDEBUG" ..
```
```
cmake -DCMAKE_C_FLAGS="-O3 -mavx2 -DNDEBUG" ..
```
(AVX2 implies SSE4.1)
Or if the binary is dedicated to run on the machine where it has
been compiled :
```
cmake -DCMAKE_C_FLAGS="-O3 -march=native -DNDEBUG" ..
```
# Modifying OpenJPEG
Before committing changes, run:
```scripts/prepare-commit.sh```
# Using OpenJPEG
To use openjpeg exported cmake file, simply create your application doing:
```
$ cat CMakeLists.txt
find_package(OpenJPEG REQUIRED)
include_directories(${OPENJPEG_INCLUDE_DIRS})
add_executable(myapp myapp.c)
target_link_libraries(myapp ${OPENJPEG_LIBRARIES})
```

19
LICENSE
View File

@ -1,19 +1,10 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2003-2014, Antonin Descampe
* Copyright (c) 2003-2009, Francois-Olivier Devaux
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
* Copyright (c) 2012, CS Systemes d'Information, France
*
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@ -1,55 +0,0 @@
USE_CLIB2=YES
ifeq ($(USE_CLIB2), YES)
LIBC=clib2
CODEC=OFF
else
LIBC=newlib
CODEC=ON
endif
all: build
build:
mkdir build && \
cd build && \
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CROSSCOMPILING=ON \
-DCMAKE_TOOLCHAIN_FILE=$(realpath amigaos4.cmake) \
-DCMAKE_C_FLAGS="-mcrt=${LIBC} -O2 -fPIC" \
-DCMAKE_MODULE_LINKER_FLAGS="-mcrt=${LIBC} -lpthread -athread=native" \
-DBUILD_TESTING=OFF \
-DBUILD_CODEC=${CODEC} \
-DBUILD_SHARED_LIBS=OFF && \
make
clean:
@echo "Clean the build"
@rm -rf build
cleanall: clean
@echo "Clean the build and the release files"
@rm -rf SDK
@rm libopenjpeg.lha
release:
@echo "Create release folders..."
@mkdir -p SDK/local/common/include
@mkdir -p SDK/local/clib2/lib
@mkdir -p SDK/local/newlib/lib SDK/local/newlib/bin
@echo "Building clib2 based libraries..."
@make -f Makefile.os4 USE_CLIB2=YES
@cp ./build/bin/libopenjp2.a SDK/local/clib2/lib/
@cp ./src/lib/openjp2/openjpeg.h SDK/local/common/include/
@echo "Clean build and libraries files..."
@make -f Makefile.os4 clean
@echo "Building newlib based libraries..."
@make -f Makefile.os4 USE_CLIB2=NO
@cp ./build/bin/libopenjp2.a SDK/local/newlib/lib/
@cp ./build/bin/opj_* SDK/local/newlib/bin/
@echo "Creating the lha release file..."
@lha -aeq libopenjpeg.lha SDK/

130
NEWS.md
View File

@ -1,130 +0,0 @@
# OpenJPEG NEWS
More details in the [CHANGELOG](https://github.com/uclouvain/openjpeg/blob/master/CHANGELOG.md)
## OpenJPEG 2.5.0 (May 2022)
No API/ABI break compared to v2.4.0, but additional symbols for subset of components decoding (hence the MINOR version bump).
* Encoder: add support for generation of TLM markers [\#1359](https://github.com/uclouvain/openjpeg/pull/1359)
* Decoder: add support for high throughput \(HTJ2K\) decoding. [\#1381](https://github.com/uclouvain/openjpeg/pull/1381)
* Decoder: add support for partial bitstream decoding [\#1407](https://github.com/uclouvain/openjpeg/pull/1407)
* Bug fixes (including security fixes)
## OpenJPEG 2.4.0 (December 2020)
No API/ABI break compared to v2.3.1, but additional symbols for subset of components decoding (hence the MINOR version bump).
* Encoder: add support for multithreading [\#1248](https://github.com/uclouvain/openjpeg/pull/1248)
* Encoder: add support for generation of PLT markers [\#1246](https://github.com/uclouvain/openjpeg/pull/1246)
* Encoder: single-threaded performance improvements in forward DWT for 5-3 and 9-7 (and other improvements) [\#1253](https://github.com/uclouvain/openjpeg/pull/1253)
* Encoder: support IMF profiles [\#1235](https://github.com/uclouvain/openjpeg/pull/1235)
* Many bug fixes (including security fixes)
## OpenJPEG 2.3.1 (April 2019)
No API/ABI break compared to v2.3.0
* Many bug fixes (including security fixes)
## OpenJPEG 2.3.0 (October 2017)
No API/ABI break compared to v2.2.0 but additional symbols for subset of components decoding (hence the MINOR version bump).
* Sub-tile decoding: when setting a window of interest through the API function opj_set_decode_area(), only codeblocks that intersect this window are now decoded (i.e. MCT, IDWT, and entropy decoding are only done on the window of interest). Moreover, memory allocation now depends on the size of the window of interest (instead of the full tile size).
[\#990](https://github.com/uclouvain/openjpeg/pull/990) [\#1001](https://github.com/uclouvain/openjpeg/pull/1001) [\#1010](https://github.com/uclouvain/openjpeg/pull/1010)
* Ability to decode only a subset of components. This adds the following function `opj_set_decoded_components(opj_codec_t p_codec, OPJ_UINT32 numcomps, const OPJ_UINT32 comps_indices, OPJ_BOOL apply_color_transforms)` and equivalent `opj_decompress -c compno[,compno]*`
option.
[\#1022](https://github.com/uclouvain/openjpeg/pull/1022)
* Many bug fixes (including security fixes)
## OpenJPEG 2.2.0 (August 2017)
No API/ABI break compared to v2.1.2 but additional symbols for multithreading support (hence the MINOR version bump).
### Codebase improvements
* Memory consumption reduction at decoding side [\#968](https://github.com/uclouvain/openjpeg/pull/968)
* Multi-threading support at decoding side [\#786](https://github.com/uclouvain/openjpeg/pull/786)
* Tier-1 speed optimizations (encoder and decoder) [\#945](https://github.com/uclouvain/openjpeg/pull/945)
* Tier-1 decoder further optimization [\#783](https://github.com/uclouvain/openjpeg/pull/783)
* Inverse 5x3 DWT speed optimization: single-pass lifting and SSE2/AVX2 implementation [\#957](https://github.com/uclouvain/openjpeg/pull/957)
* Fixed a bug that prevented OpenJPEG to compress losslessly in some situations [\#949](https://github.com/uclouvain/openjpeg/pull/949)
* Fixed BYPASS/LAZY, RESTART/TERMALL and PTERM mode switches
* Many other bug fixes (including security fixes)
### Maintenance improvements
* Benchmarking scripts to automatically compare the speed of latest OpenJPEG build with latest release and/or Kakadu binaries [\#917](https://github.com/uclouvain/openjpeg/pull/917)
* CPU and RAM usage profiling scripts [\#918](https://github.com/uclouvain/openjpeg/pull/918)
* Codebase reformatting (with astyle) and scripts to automatically check that new commits comply with formatting guidelines [\#919](https://github.com/uclouvain/openjpeg/pull/919)
* Register OpenJPEG at Google OSS Fuzz initiative, so as to automatically have OpenJPEG tested against Google fuzzer [\#965](https://github.com/uclouvain/openjpeg/issues/965)
## OpenJPEG 2.1.2 (September 2016)
* Bug fixes (including security fixes)
* No API/ABI break compared to v2.1.1
## OpenJPEG 2.1.1 (July 2016)
* Huge amount of critical bugfixes
* Speed improvements
* No API/ABI break compared to v2.1
## OpenJPEG 2.1.0 (April 2014)
### New Features
* Digital Cinema profiles have been fixed and updated
* New option to disable MCT if needed
* extended RAW support: it is now possible to input raw images
with subsampled color components (422, 420, etc)
* New way to deal with profiles
### API/ABI modifications
(see [here](http://www.openjpeg.org/abi-check/timeline/openjpeg/) for details)
* Removed deprecated functions
* opj_stream_create_default_file_stream(FILE*,...)
* opj_stream_create_file_stream(FILE*,...)
* opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data)
* Added
* opj_stream_create_default_file_stream(char*,...)
* opj_stream_create_file_stream(char*,...)
* opj_stream_destroy(opj_stream_t*)
* opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data,
... opj_stream_free_user_data_fn p_function)
* JPEG 2000 profiles and Part-2 extensions defined through '#define'
* Changed
* 'alpha' field added to 'opj_image_comp' structure
* 'OPJ_CLRSPC_EYCC' added to enum COLOR_SPACE
* 'OPJ_CLRSPC_CMYK' added to enum COLOR_SPACE
* 'OPJ_CODEC_JPP' and 'OPJ_CODEC_JPX' added to CODEC_FORMAT
(not yet used in use)
* 'max_cs_size' and 'rsiz' fields added to opj_cparameters_t
### Misc
* OpenJPEG is now officially conformant with JPEG 2000 Part-1
and will soon become official reference software at the
JPEG committee.
* Huge amount of bug fixes. See CHANGES for details.
## OpenJPEG 2.0.0
### New Features
* streaming capabilities
* merge JP3D
### API modifications
(see [here](http://www.openjpeg.org/abi-check/timeline/openjpeg/) for details)
* Use a 64bits capable API
### Misc
* removed autotools build system
* folders hierarchies reorganisation
* Huge amount of bug fixes. See CHANGES for details.

109
OpenJPEG.rc Normal file
View File

@ -0,0 +1,109 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// French (France) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
#ifdef _WIN32
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
#pragma code_page(1252)
#endif //_WIN32
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,0,0
PRODUCTVERSION 1,1,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "Comments", "The OpenJPEG library is an open-source JPEG 2000 codec. \0"
VALUE "CompanyName", "OpenJPEG\0"
VALUE "FileDescription", "OpenJPEG\0"
VALUE "FileVersion", "1, 1, 0, 0\0"
VALUE "InternalName", "OpenJPEG\0"
VALUE "LegalCopyright", "Copyright © 2002-2007, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium\0"
VALUE "LegalTrademarks", "See http://www.openjpeg.org for details\0"
VALUE "OriginalFilename", "OpenJPEG.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "OpenJPEG\0"
VALUE "ProductVersion", "1, 1, 0, 0\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END
#endif // !_MAC
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // French (France) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

9
README.cmake Normal file
View File

@ -0,0 +1,9 @@
Basic instructions on how to build using CMake (CMake 2.4.5 or newer is required)
svn co http://www.openjpeg.org/svn/trunk
cd trunk
mkdir bin
cd bin
cmake .. -DBUILD_EXAMPLES:BOOL=ON
make
./bin/j2k_to_image

View File

@ -1,83 +0,0 @@
# OPENJPEG Library and Applications
## What is OpenJPEG ?
OpenJPEG is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the use of [JPEG 2000](http://www.jpeg.org/jpeg2000), a still-image compression standard from the Joint Photographic Experts Group ([JPEG](http://www.jpeg.org)). Since April 2015, it is officially recognized by ISO/IEC and ITU-T as a [JPEG 2000 Reference Software](http://www.itu.int/rec/T-REC-T.804-201504-I!Amd2).
## Who can use the code ?
[![badge-license]][link-license]
Anyone. As the OpenJPEG code is released under the [BSD 2-clause "Simplified" License][link-license], anyone can use or modify the code, even for commercial applications. The only restriction is to retain the copyright in the sources or in the binaries documentation. Of course, if you modified the code in a way that might be of interest for other users, you are encouraged to share it (through a [github pull request](https://github.com/uclouvain/openjpeg/pulls) or by filling an [issue](https://github.com/uclouvain/openjpeg/issues)) but this is not a requirement.
## How to install and use OpenJPEG ?
API Documentation needs a major refactoring. Meanwhile, you can check [installation](https://github.com/uclouvain/openjpeg/wiki/Installation) instructions and [codec documentation](https://github.com/uclouvain/openjpeg/wiki/DocJ2KCodec).
## Current Status
[![badge-build]][link-build]
[![badge-msvc-build]][link-msvc-build]
[![badge-coverity]][link-coverity]
## Who are the developers ?
The library is developed and maintained by the Image and Signal Processing Group ([ISPGroup](http://sites.uclouvain.be/ispgroup/)), in the Université catholique de Louvain ([UCL](http://www.uclouvain.be/en-index.html), with the support of the [CNES](https://cnes.fr/), the [CS](http://www.c-s.fr/) company and the [intoPIX](http://www.intopix.com) company. The JPWL module has been developed by the Digital Signal Processing Lab ([DSPLab](http://dsplab.diei.unipg.it/)) of the University of Perugia, Italy ([UNIPG](http://www.unipg.it/)).
## Details on folders hierarchy
* src
* lib
* openjp2: contains the sources of the openjp2 library (Part 1 & 2)
* openjpip: complete client-server architecture for remote browsing of jpeg 2000 images.
* bin: contains all applications that use the openjpeg library
* common: common files to all applications
* jp2: a basic codec
* jpip: OpenJPIP applications (server and dec server)
* java: a Java client viewer for JPIP
* wx
* OPJViewer: gui for displaying j2k files (based on wxWidget)
* wrapping
* java: java jni to use openjpeg in a java program
* thirdparty: thirdparty libraries used by some applications. These libraries will be built only if there are not found on the system. Note that libopenjpeg itself does not have any dependency.
* doc: doxygen documentation setup file and man pages
* tests: configuration files and utilities for the openjpeg test suite. All test images are located in [openjpeg-data](https://github.com/uclouvain/openjpeg-data) repository.
* cmake: cmake related files
* scripts: scripts for developers
See [LICENSE][link-license] for license and copyright information.
See [INSTALL](https://github.com/uclouvain/openjpeg/blob/master/INSTALL.md) for installation procedures.
See [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) for user visible changes in successive releases.
## Deprecated components
The openjpwl, openjp3d and openmj2 components have been removed after the
2.4.0 release. Their building and working state is unknown. People interested
in them should start from the 2.4.0 tag.
## API/ABI
An API/ABI timeline is automatically updated [here][link-api-timeline].
OpenJPEG strives to provide a stable API/ABI for your applications. As such it
only exposes a limited subset of its functions. It uses a mechanism of
exporting/hiding functions. If you are unsure which functions you can use in
your applications, you should compile OpenJPEG using something similar to gcc:
`-fvisibility=hidden` compilation flag.
See also: http://gcc.gnu.org/wiki/Visibility
On windows, MSVC directly supports export/hiding function and as such the only
API available is the one supported by OpenJPEG.
[comment-license]: https://img.shields.io/github/license/uclouvain/openjpeg.svg "https://img.shields.io/badge/license-BSD--2--Clause-blue.svg"
[badge-license]: https://img.shields.io/badge/license-BSD--2--Clause-blue.svg "BSD 2-clause \"Simplified\" License"
[link-license]: https://github.com/uclouvain/openjpeg/blob/master/LICENSE "BSD 2-clause \"Simplified\" License"
[badge-build]: https://github.com/uclouvain/openjpeg/actions/workflows/build.yml/badge.svg "Build Status"
[link-build]: https://github.com/uclouvain/openjpeg/actions/workflows/build.yml "Build Status"
[badge-msvc-build]: https://ci.appveyor.com/api/projects/status/github/uclouvain/openjpeg?branch=master&svg=true "Windows Build Status"
[link-msvc-build]: https://ci.appveyor.com/project/detonin/openjpeg/branch/master "Windows Build Status"
[badge-coverity]: https://scan.coverity.com/projects/6383/badge.svg "Coverity Scan Build Status"
[link-coverity]: https://scan.coverity.com/projects/uclouvain-openjpeg "Coverity Scan Build Status"
[link-api-timeline]: http://www.openjpeg.org/abi-check/timeline/openjpeg "OpenJPEG API/ABI timeline"

26
README.v2 Normal file
View File

@ -0,0 +1,26 @@
Preliminary notes
-----------------
The Version 2 of openjpeg has been currently added as a branch on the repository.
All the trunk has been copied and files that needed to change have been patched. In comparison with the trunk, the 'jp3d' directory has been removed because it's based on a modified version of libopenjpeg version 1 and there is no plan to make it reach the version 2 status. Idem with the 'indexer_JPIP', which is obsolete and should be rewritten from scratch.
At the time of the branch creation, the following files and directories have been updated (or added) for version 2 :
* libopenjpeg/
* codec/
* test_Free_image_V2_tile_handling/ : a test program that uses libopenjpeg v2 and libfreeimage (see libs) to implement a basic codec.
* test_V2_tile_handling/ : a test program that generates a random image and (de)compresses it with libopenjpeg v2.
* CMakeLists.txt
* Free_CMakeImport.cmake
* opj_configure.h.in
Other files and directories from the trunk (project files, jpwl/, OPJViewer/, ...) have also been copied in the branch and should be modified progressively to comply with v2. Check the Changelog for updates on this topic.
Enjoy v2 and feel free to contribute !
Instructions to compile v2
--------------------------
to be added.

View File

@ -1,39 +0,0 @@
# OpenJPEG THANKS file
Many people have contributed to OpenJPEG by reporting problems, suggesting various improvements,
or submitting actual code. Here is a list of these people. Help me keep
it complete and exempt of errors.
* Giuseppe Baruffa
* Ben Boeckel
* Aaron Boxer
* David Burken
* Matthieu Darbois
* Rex Dieter
* Herve Drolon
* Antonin Descampe
* Francois-Olivier Devaux
* Parvatha Elangovan
* Jerôme Fimes
* Bob Friesenhahn
* Kaori Hagihara
* Luc Hermitte
* Luis Ibanez
* David Janssens
* Hans Johnson
* Callum Lerwick
* Ke Liu (Tencent's Xuanwu LAB)
* Sebastien Lugan
* Benoit Macq
* Mathieu Malaterre
* Julien Malik
* Arnaud Maye
* Vincent Nicolas
* Aleksander Nikolic (Cisco Talos)
* Glenn Pearson
* Even Rouault
* Dzonatas Sol
* Winfried Szukalski
* Vincent Torri
* Yannick Verschueren
* Peter Wimmer

View File

@ -1,9 +0,0 @@
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_SYSTEM_PROCESSOR ppc)
SET(CMAKE_C_COMPILER /opt/ppc-amigaos/bin/ppc-amigaos-gcc)
SET(CMAKE_CXX_COMPILER /opt/ppc-amigaos/bin/ppc-amigaos-g++)
SET(CMAKE_FIND_LIBRARY_SUFFIXES "*.a")
SET(CMAKE_FIND_ROOT_PATH /opt/sdk)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View File

@ -1,41 +0,0 @@
version: 2.5.0.{build}
branches:
except:
- coverity_scan
skip_tags: false
clone_depth: 50
environment:
matrix:
- OPJ_CI_ARCH: x64
OPJ_CI_VSCOMNTOOLS: $(VS140COMNTOOLS)
OPJ_CI_INSTRUCTION_SETS: "/arch:AVX2"
- OPJ_CI_ARCH: x86
OPJ_CI_VSCOMNTOOLS: $(VS140COMNTOOLS)
OPJ_CI_INCLUDE_IF_DEPLOY: 1
- OPJ_CI_ARCH: x64
OPJ_CI_VSCOMNTOOLS: $(VS140COMNTOOLS)
OPJ_CI_INCLUDE_IF_DEPLOY: 1
- OPJ_CI_ARCH: x86
OPJ_CI_VSCOMNTOOLS: $(VS100COMNTOOLS)
install:
- cmd: c:\cygwin\bin\bash ./tools/travis-ci/install.sh
build_script:
- cmd: >-
"%OPJ_CI_VSCOMNTOOLS%..\..\VC\vcvarsall.bat" %OPJ_CI_ARCH%
bash ./tools/travis-ci/run.sh
test: off
#before_deploy:
#- cmd: c:\cygwin\bin\bash ./tools/travis-ci/before_deploy.sh
#deploy:
# #release: openjpeg-$(appveyor_repo_tag_name)
# description: 'OpenJPEG $(appveyor_repo_tag_name) has been released. More info [here](https://github.com/uclouvain/openjpeg/blob/$(appveyor_repo_tag_name)/NEWS) and a detailed view [here](https://github.com/uclouvain/openjpeg/blob/$(appveyor_repo_tag_name)/CHANGES).'
# provider: GitHub
# auth_token:
# secure: XUL+IoRRw8U/4tupa/fMpinxurft7WRQHZiWHMLO5iuFbwZ+C3vCjVVVM+5Ebky7 # your encrypted token from GitHub
# artifact: /.*\.zip/ # upload all zip packages to release assets
# draft: true
# prerelease: false
# on:
# appveyor_repo_tag: true # deploy on tag push only
# OPJ_CI_INCLUDE_IF_DEPLOY: 1

View File

@ -1,40 +0,0 @@
#----------------------------------------------------------------------
#
# For further details regarding this file,
# see http://www.cmake.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest
#
# and
# http://www.kitware.com/blog/home/post/27
#
#----------------------------------------------------------------------
set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000)
set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 2000)
set(CTEST_CUSTOM_COVERAGE_EXCLUDE
${CTEST_CUSTOM_COVERAGE_EXCLUDE}
# Exclude files from the Testing directories
".*/tests/.*"
# Exclude files from the ThirdParty Utilities directories
".*/thirdparty/.*"
)
set(CTEST_CUSTOM_WARNING_EXCEPTION
${CTEST_CUSTOM_WARNING_EXCEPTION}
# Ignore clang's summary warning, assuming prior text has matched some
# other warning expression:
"[0-9,]+ warnings? generated."
# Suppress warning caused by intentional messages about deprecation
".*warning,.* is deprecated"
# java also warns about deprecated API
".*java.*deprecation"
".*deprecation.*"
# suppress warnings caused by 3rd party libs:
".*thirdparty.*"
"libtiff.*has no symbols"
"libpng.*has no symbols"
)

View File

@ -1,26 +0,0 @@
# Ensure that an include file is provided by the system
# Add the check about the mandatory status to the check_include_file macro
# provided by cmake
include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
macro(ensure_file_include INCLUDE_FILENAME VARIABLE_NAME MANDATORY_STATUS)
#message(WARNING "INCLUDE_FILENAME=${INCLUDE_FILENAME} \n"
# "VARIABLE_NAME=${VARIABLE_NAME} \n"
# "MANDATORY_STATUS=${MANDATORY_STATUS}")
CHECK_INCLUDE_FILE(${INCLUDE_FILENAME} ${VARIABLE_NAME})
#message(WARNING "INCLUDE_FILENAME=${INCLUDE_FILENAME} \n"
# "VARIABLE_NAME=${VARIABLE_NAME} \n"
# "VARIABLE_NAME_VALUE=${${VARIABLE_NAME}} \n"
# "MANDATORY_STATUS=${MANDATORY_STATUS}")
if (NOT ${${VARIABLE_NAME}})
if (${MANDATORY_STATUS})
message(FATAL_ERROR "The file ${INCLUDE_FILENAME} is mandatory but not found on your system")
endif()
endif()
endmacro()

View File

@ -1,16 +0,0 @@
# cppcheck
#
# Copyright (c) 2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
find_program(CPPCHECK_EXECUTABLE
cppcheck
)
mark_as_advanced(
CPPCHECK_EXECUTABLE
)

View File

@ -1,20 +0,0 @@
# Look for the header file.
find_path(FCGI_INCLUDE_DIR NAMES fastcgi.h)
# Look for the library.
find_library(FCGI_LIBRARY NAMES fcgi)
# Handle the QUIETLY and REQUIRED arguments and set FCGI_FOUND to TRUE if all listed variables are TRUE.
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FCGI DEFAULT_MSG FCGI_LIBRARY FCGI_INCLUDE_DIR)
# Copy the results to the output variables.
if(FCGI_FOUND)
set(FCGI_LIBRARIES ${FCGI_LIBRARY})
set(FCGI_INCLUDE_DIRS ${FCGI_INCLUDE_DIR})
else()
set(FCGI_LIBRARIES)
set(FCGI_INCLUDE_DIRS)
endif()
mark_as_advanced(FCGI_INCLUDE_DIR FCGI_LIBRARY)

View File

@ -1,12 +0,0 @@
#
# this module looks for JPYLYZER
# http://jpylyzer.openpreservation.org
#
find_program(JPYLYZER_EXECUTABLE
jpylyzer
)
mark_as_advanced(
JPYLYZER_EXECUTABLE
)

View File

@ -1,24 +0,0 @@
#
# this module looks for KAKADU
# http://www.kakadusoftware.com/
#
#
# Copyright (c) 2006-2014 Mathieu Malaterre <mathieu.malaterre@gmail.com>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
find_program(KDU_EXPAND_EXECUTABLE
kdu_expand
)
find_program(KDU_COMPRESS_EXECUTABLE
kdu_compress
)
mark_as_advanced(
KDU_EXPAND_EXECUTABLE
KDU_COMPRESS_EXECUTABLE
)

View File

@ -1,31 +0,0 @@
# - Find LCMS library
# Find the native LCMS includes and library
# Once done this will define
#
# LCMS_INCLUDE_DIR - Where to find lcms.h, etc.
# LCMS_LIBRARIES - Libraries to link against to use LCMS.
# LCMS_FOUND - If false, do not try to use LCMS.
#
# also defined, but not for general use are
# LCMS_LIBRARY, where to find the LCMS library.
#=============================================================================
#=============================================================================
find_path(LCMS_INCLUDE_DIR lcms.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
set(LCMS_NAMES ${LCMS_NAMES} lcms liblcms liblcms_static)
find_library(LCMS_LIBRARY NAMES ${LCMS_NAMES} )
mark_as_advanced(LCMS_INCLUDE_DIR LCMS_LIBRARY)
# handle the QUIETLY and REQUIRED arguments and set LCMS_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS DEFAULT_MSG LCMS_LIBRARY LCMS_INCLUDE_DIR)
if(LCMS_FOUND)
set( LCMS_INCLUDE_DIRS ${LCMS_INCLUDE_DIR})
set( LCMS_LIBRARIES ${LCMS_LIBRARY} )
endif()

View File

@ -1,31 +0,0 @@
# - Find LCMS2 library
# Find the native LCMS2 includes and library
# Once done this will define
#
# LCMS2_INCLUDE_DIR - Where to find lcms2.h, etc.
# LCMS2_LIBRARIES - Libraries to link against to use LCMS2.
# LCMS2_FOUND - If false, do not try to use LCMS2.
#
# also defined, but not for general use are
# LCMS2_LIBRARY - Where to find the LCMS2 library.
#=============================================================================
#=============================================================================
find_path(LCMS2_INCLUDE_DIR lcms2.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
set(LCMS2_NAMES ${LCMS2_NAMES} lcms2 liblcms2 liblcms2_static)
find_library(LCMS2_LIBRARY NAMES ${LCMS2_NAMES} )
mark_as_advanced(LCMS2_INCLUDE_DIR LCMS2_LIBRARY)
# handle the QUIETLY and REQUIRED arguments and set LCMS2_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS2 DEFAULT_MSG LCMS2_LIBRARY LCMS2_INCLUDE_DIR)
if(LCMS2_FOUND)
set( LCMS2_INCLUDE_DIRS ${LCMS2_INCLUDE_DIR})
set( LCMS2_LIBRARIES ${LCMS2_LIBRARY} )
endif()

View File

@ -1,9 +0,0 @@
# JPIP test driver
#message(STATUS "${D_URL}")
file(DOWNLOAD
"${D_URL}"
"${D_FILE}"
LOG log
EXPECTED_MD5 "${EXPECTED_MD5}"
)
message(STATUS "LOG: ${log}")

View File

@ -1,72 +0,0 @@
# package bundler
if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
if(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake")
set(CMAKE_INSTALL_MFC_LIBRARIES 0)
set(CMAKE_INSTALL_DEBUG_LIBRARIES 0)
if(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
endif()
include(${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake)
endif()
set(OPJ_PACKAGE_DESCRIPTION_SUMMARY "OpenJPEG - OpenJPEG a JPEG 2000 implementation.")
set(OPJ_PACKAGE_CONTACT "openjpeg users <openjpeg@googlegroups.com>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${OPJ_PACKAGE_DESCRIPTION_SUMMARY})
set(CPACK_PACKAGE_VENDOR "OpenJPEG Team")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
"${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" COPYONLY
)
# 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_PACKAGE_VERSION_MAJOR "${OPENJPEG_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${OPENJPEG_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${OPENJPEG_VERSION_BUILD}")
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}")
# 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()
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
endif()
endif()
if(${CPACK_SYSTEM_NAME} MATCHES Windows)
if(CMAKE_CL_64)
set(CPACK_SYSTEM_NAME win64-x64)
else()
set(CPACK_SYSTEM_NAME win32-x86)
endif()
endif()
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()
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
endif()
endif()
set(CPACK_BUNDLE_NAME "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
if(APPLE)
configure_file(${CMAKE_ROOT}/Templates/AppleInfo.plist
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
set(CPACK_BUNDLE_PLIST
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
#include(BundleUtilities)
endif()
include(CPack)
endiF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")

View File

@ -1,11 +0,0 @@
#include <sys/types.h>
/* Cause a compile-time error if off_t is smaller than 64 bits */
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ];
int main(int argc, char **argv)
{
return 0;
}

View File

@ -1,23 +0,0 @@
#cmakedefine _LARGEFILE_SOURCE
#cmakedefine _LARGE_FILES
#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
/* Cause a compile-time error if off_t is smaller than 64 bits,
* and make sure we have ftello / fseeko.
*/
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ];
FILE *fp = fopen(argv[0],"r");
off_t offset = ftello( fp );
fseeko( fp, offset, SEEK_CUR );
fclose(fp);
return 0;
}

View File

@ -1,134 +0,0 @@
# - Define macro to check large file support
#
# OPJ_TEST_LARGE_FILES(VARIABLE)
#
# VARIABLE will be set to true if off_t is 64 bits, and fseeko/ftello present.
# This macro will also defines the necessary variable enable large file support, for instance
# _LARGE_FILES
# _LARGEFILE_SOURCE
# _FILE_OFFSET_BITS 64
# OPJ_HAVE_FSEEKO
#
# However, it is YOUR job to make sure these defines are set in a #cmakedefine so they
# end up in a config.h file that is included in your source if necessary!
#
# Adapted from Gromacs project (http://www.gromacs.org/)
# by Julien Malik
#
macro(OPJ_TEST_LARGE_FILES VARIABLE)
if(NOT DEFINED ${VARIABLE})
# On most platforms it is probably overkill to first test the flags for 64-bit off_t,
# and then separately fseeko. However, in the future we might have 128-bit filesystems
# (ZFS), so it might be dangerous to indiscriminately set e.g. _FILE_OFFSET_BITS=64.
message(STATUS "Checking for 64-bit off_t")
# First check without any special flags
try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c")
if(FILE64_OK)
message(STATUS "Checking for 64-bit off_t - present")
endif()
if(NOT FILE64_OK)
# Test with _FILE_OFFSET_BITS=64
try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c"
COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64" )
if(FILE64_OK)
message(STATUS "Checking for 64-bit off_t - present with _FILE_OFFSET_BITS=64")
set(_FILE_OFFSET_BITS 64)
endif()
endif()
if(NOT FILE64_OK)
# Test with _LARGE_FILES
try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c"
COMPILE_DEFINITIONS "-D_LARGE_FILES" )
if(FILE64_OK)
message(STATUS "Checking for 64-bit off_t - present with _LARGE_FILES")
set(_LARGE_FILES 1)
endif()
endif()
if(NOT FILE64_OK)
# Test with _LARGEFILE_SOURCE
try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c"
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" )
if(FILE64_OK)
message(STATUS "Checking for 64-bit off_t - present with _LARGEFILE_SOURCE")
set(_LARGEFILE_SOURCE 1)
endif()
endif()
#if(NOT FILE64_OK)
# # now check for Windows stuff
# try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
# "${PROJECT_SOURCE_DIR}/cmake/TestWindowsFSeek.c")
# if(FILE64_OK)
# message(STATUS "Checking for 64-bit off_t - present with _fseeki64")
# set(HAVE__FSEEKI64 1)
# endif()
#endif()
if(NOT FILE64_OK)
message(STATUS "Checking for 64-bit off_t - not present")
endif()
set(_FILE_OFFSET_BITS ${_FILE_OFFSET_BITS} CACHE INTERNAL "Result of test for needed _FILE_OFFSET_BITS=64")
set(_LARGE_FILES ${_LARGE_FILES} CACHE INTERNAL "Result of test for needed _LARGE_FILES")
set(_LARGEFILE_SOURCE ${_LARGEFILE_SOURCE} CACHE INTERNAL "Result of test for needed _LARGEFILE_SOURCE")
# Set the flags we might have determined to be required above
configure_file("${PROJECT_SOURCE_DIR}/cmake/TestLargeFiles.c.cmake.in"
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
message(STATUS "Checking for fseeko/ftello")
# Test if ftello/fseeko are available
try_compile(FSEEKO_COMPILE_OK
"${PROJECT_BINARY_DIR}"
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
if(FSEEKO_COMPILE_OK)
message(STATUS "Checking for fseeko/ftello - present")
endif()
if(NOT FSEEKO_COMPILE_OK)
# glibc 2.2 needs _LARGEFILE_SOURCE for fseeko (but not for 64-bit off_t...)
try_compile(FSEEKO_COMPILE_OK
"${PROJECT_BINARY_DIR}"
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c"
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" )
if(FSEEKO_COMPILE_OK)
message(STATUS "Checking for fseeko/ftello - present with _LARGEFILE_SOURCE")
set(_LARGEFILE_SOURCE ${_LARGEFILE_SOURCE} CACHE INTERNAL "Result of test for needed _LARGEFILE_SOURCE")
endif()
endif()
if(FSEEKO_COMPILE_OK)
set(OPJ_HAVE_FSEEKO ON CACHE INTERNAL "Result of test for fseeko/ftello")
else()
message(STATUS "Checking for fseeko/ftello - not found")
set(OPJ_HAVE_FSEEKO OFF CACHE INTERNAL "Result of test for fseeko/ftello")
endif()
if(FILE64_OK AND FSEEKO_COMPILE_OK)
message(STATUS "Large File support - found")
set(${VARIABLE} ON CACHE INTERNAL "Result of test for large file support")
else()
message(STATUS "Large File support - not found")
set(${VARIABLE} OFF CACHE INTERNAL "Result of test for large file support")
endif()
endif()
endmacro()

View File

@ -1,11 +0,0 @@
#include <stdio.h>
int main()
{
__int64 off=0;
_fseeki64(NULL, off, SEEK_SET);
return 0;
}

View File

@ -1,39 +0,0 @@
{
<Appears with libpng uses with Ubuntu10.04 (hulk)>
Memcheck:Cond
fun:deflate
obj:/lib/libpng12.so.0.42.0
obj:/lib/libpng12.so.0.42.0
obj:/lib/libpng12.so.0.42.0
fun:png_write_row
fun:imagetopng
fun:main
}
{
<Appears with libpng uses with Ubuntu10.04 (hulk)>
Memcheck:Value8
fun:crc32
obj:/lib/libpng12.so.0.42.0
fun:png_write_chunk
obj:/lib/libpng12.so.0.42.0
obj:/lib/libpng12.so.0.42.0
obj:/lib/libpng12.so.0.42.0
obj:/lib/libpng12.so.0.42.0
fun:png_write_row
fun:imagetopng
fun:main
}
{
<Appears with libpng uses with Ubuntu10.04 (hulk)>
Memcheck:Param
write(buf)
fun:__write_nocancel
fun:_IO_file_write@@GLIBC_2.2.5
fun:_IO_do_write@@GLIBC_2.2.5
fun:_IO_file_close_it@@GLIBC_2.2.5
fun:fclose@@GLIBC_2.2.5
fun:imagetopng
fun:main
}

94
codec/CMakeLists.txt Normal file
View File

@ -0,0 +1,94 @@
# Build the demo app, small examples
# First thing define the common source:
SET(common_SRCS
convert.c
index.c
)
# Then check if getopt is present:
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
SET(DONT_HAVE_GETOPT 1)
IF(UNIX) #I am pretty sure only *nix sys have this anyway
CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
# Seems like we need the contrary:
IF(CMAKE_HAVE_GETOPT_H)
SET(DONT_HAVE_GETOPT 0)
ENDIF(CMAKE_HAVE_GETOPT_H)
ENDIF(UNIX)
# If not getopt was found then add it to the lib:
IF(DONT_HAVE_GETOPT)
ADD_DEFINITIONS(-DDONT_HAVE_GETOPT)
SET(common_SRCS
${common_SRCS}
compat/getopt.c
)
ENDIF(DONT_HAVE_GETOPT)
# Headers file are located here:
INCLUDE_DIRECTORIES(
${OPENJPEG_SOURCE_DIR}/libopenjpeg
)
# Do the proper thing when building static...if only there was configured
# headers or def files instead
IF(NOT BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DOPJ_STATIC)
ENDIF(NOT BUILD_SHARED_LIBS)
FIND_PACKAGE(TIFF REQUIRED)
FIND_PACKAGE(PNG REQUIRED)
INCLUDE_DIRECTORIES( ${PNG_INCLUDE_DIR} )
INCLUDE_DIRECTORIES( ${TIFF_INCLUDE_DIR} )
# Loop over all executables:
FOREACH(exe j2k_to_image image_to_j2k j2k_dump)
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
TARGET_LINK_LIBRARIES(${exe} ${OPJ_PREFIX}openjpeg ${TIFF_LIBRARIES} ${PNG_LIBRARIES})
ADD_TEST(${exe} ${EXECUTABLE_OUTPUT_PATH}/${exe})
# calling those exe without option will make them fail always:
SET_TESTS_PROPERTIES(${exe} PROPERTIES WILL_FAIL TRUE)
# On unix you need to link to the math library:
IF(UNIX)
TARGET_LINK_LIBRARIES(${exe} m)
ENDIF(UNIX)
# Install exe
INSTALL(TARGETS ${exe}
EXPORT OpenJPEGTargets
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
)
ENDFOREACH(exe)
if(BUILD_TESTING)
# Do testing here, once we know the examples are being built:
FILE(GLOB_RECURSE OPENJPEG_DATA_IMAGES_GLOB
"${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2k"
"${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2c"
"${JPEG2000_CONFORMANCE_DATA_ROOT}/*.jp2"
)
foreach(filename ${OPENJPEG_DATA_IMAGES_GLOB})
get_filename_component(filename_temp ${filename} NAME)
get_filename_component(filename_ext ${filename} EXT)
execute_process(COMMAND ${EXECUTABLE_OUTPUT_PATH}/j2k_dump -i ${filename}
OUTPUT_VARIABLE dump_success
OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${filename_temp}.dump
ERROR_QUIET
)
if(dump_success)
file(READ ${CMAKE_CURRENT_BINARY_DIR}/${filename_temp}.dump numcomp_file)
string(REGEX REPLACE ".*numcomps=([0-9]+).*" "\\1"
numcomps "${numcomp_file}")
#message( "found:${output_variable} for ${filename_temp}" )
endif()
ADD_TEST(dump-${filename_temp} ${EXECUTABLE_OUTPUT_PATH}/j2k_dump -i ${filename})
foreach(codec_type ppm pgx bmp tif raw tga png)
ADD_TEST(j2i-${filename_temp}-${codec_type} ${EXECUTABLE_OUTPUT_PATH}/j2k_to_image -i ${filename} -o ${filename_temp}.${codec_type})
ADD_TEST(i2j-${filename_temp}-${codec_type} ${EXECUTABLE_OUTPUT_PATH}/image_to_j2k -i ${filename_temp}.${codec_type} -o ${filename_temp}.${codec_type}${filename_ext})
#if(UNIX)
# ADD_TEST(cmp-${filename_temp}-${codec_type} cmp ${filename} ${filename_temp}.${codec_type}${filename_ext})
#endif(UNIX)
endforeach(codec_type)
endforeach(filename)
endif(BUILD_TESTING)

257
codec/compat/getopt.c Normal file
View File

@ -0,0 +1,257 @@
/*
* Copyright (c) 1987, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*/
/* last review : october 29th, 2002 */
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int opterr = 1, /* if error message should be printed */
optind = 1, /* index into parent argv vector */
optopt, /* character checked for validity */
optreset; /* reset getopt */
const char *optarg; /* argument associated with option */
typedef struct option
{
const char *name;
int has_arg;
int *flag;
int val;
}option_t;
#define BADCH (int)'?'
#define BADARG (int)':'
#define EMSG ""
/*
* getopt --
* Parse argc/argv argument vector.
*/
int getopt(int nargc, char *const *nargv, const char *ostr) {
# define __progname nargv[0]
static const char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
if (optind >= nargc || *(place = nargv[optind]) != '-') {
place = EMSG;
return (-1);
}
if (place[1] && *++place == '-') { /* found "--" */
++optind;
place = EMSG;
return (-1);
}
} /* option letter okay? */
if ((optopt = (int) *place++) == (int) ':' ||
!(oli = strchr(ostr, optopt))) {
/*
* if the user didn't specify '-' as an option,
* assume it means -1.
*/
if (optopt == (int) '-')
return (-1);
if (!*place)
++optind;
if (opterr && *ostr != ':') {
fprintf(stderr,
"%s: illegal option -- %c\n", __progname, optopt);
return (BADCH);
}
}
if (*++oli != ':') { /* don't need argument */
optarg = NULL;
if (!*place)
++optind;
} else { /* need an argument */
if (*place) /* no white space */
optarg = place;
else if (nargc <= ++optind) { /* no arg */
place = EMSG;
if (*ostr == ':')
return (BADARG);
if (opterr) {
fprintf(stderr,
"%s: option requires an argument -- %c\n",
__progname, optopt);
return (BADCH);
}
} else /* white space */
optarg = nargv[optind];
place = EMSG;
++optind;
}
return (optopt); /* dump back option letter */
}
int getopt_long(int argc, char * const argv[], const char *optstring,
struct option *longopts, int totlen) {
static int lastidx,lastofs;
char *tmp;
int i,len;
char param = 1;
again:
if (optind>argc || !argv[optind] || *argv[optind]!='-')
return -1;
if (argv[optind][0]=='-' && argv[optind][1]==0) {
if(optind >= (argc - 1)){ /* no more input parameters */
param = 0;
}
else{ /* more input parameters */
if(argv[optind + 1][0] == '-'){
param = 0; /* Missing parameter after '-' */
}
else{
param = 2;
}
}
}
if (param == 0) {
++optind;
return (BADCH);
}
if (argv[optind][0]=='-') { /* long option */
char* arg=argv[optind]+1;
const struct option* o;
o=longopts;
len=sizeof(longopts[0]);
if (param > 1){
arg = argv[optind+1];
optind++;
}
else
arg = argv[optind]+1;
if(strlen(arg)>1){
for (i=0;i<totlen;i=i+len,o++) {
if (!strcmp(o->name,arg)) { /* match */
if (o->has_arg == 0) {
if ((argv[optind+1])&&(!(argv[optind+1][0]=='-'))){
fprintf(stderr,"%s: option does not require an argument. Ignoring %s\n",arg,argv[optind+1]);
++optind;
}
}else{
optarg=argv[optind+1];
if(optarg){
if (optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
if (opterr) {
fprintf(stderr,"%s: option requires an argument\n",arg);
return (BADCH);
}
}
}
if (!optarg && o->has_arg==1) { /* no argument there */
if (opterr) {
fprintf(stderr,"%s: option requires an argument \n",arg);
return (BADCH);
}
}
++optind;
}
++optind;
if (o->flag)
*(o->flag)=o->val;
else
return o->val;
return 0;
}
}//(end for)String not found in the list
fprintf(stderr,"Invalid option %s\n",arg);
++optind;
return (BADCH);
}else{ /*Single character input parameter*/
if (*optstring==':') return ':';
if (lastidx!=optind) {
lastidx=optind; lastofs=0;
}
optopt=argv[optind][lastofs+1];
if ((tmp=strchr(optstring,optopt))) {/*Found input parameter in list*/
if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */
++optind;
goto again;
}
if (tmp[1]==':') { /* argument expected */
if (tmp[2]==':' || argv[optind][lastofs+2]) { /* "-foo", return "oo" as optarg */
if (!*(optarg=argv[optind]+lastofs+2)) optarg=0;
goto found;
}
optarg=argv[optind+1];
if(optarg){
if (optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
if (opterr) {
fprintf(stderr,"%s: option requires an argument\n",arg);
return (BADCH);
}
}
}
if (!optarg) { /* missing argument */
if (opterr) {
fprintf(stderr,"%s: option requires an argument\n",arg);
return (BADCH);
}
}
++optind;
}else {/*Argument not expected*/
++lastofs;
return optopt;
}
found:
++optind;
return optopt;
} else { /* not found */
fprintf(stderr,"Invalid option %s\n",arg);
++optind;
return (BADCH);
}//end of not found
}// end of single character
}//end '-'
fprintf(stderr,"Invalid option\n");
++optind;
return (BADCH);;
}//end function

29
codec/compat/getopt.h Normal file
View File

@ -0,0 +1,29 @@
/* last review : october 29th, 2002 */
#ifndef _GETOPT_H_
#define _GETOPT_H_
typedef struct option
{
const char *name;
int has_arg;
int *flag;
int val;
}option_t;
#define NO_ARG 0
#define REQ_ARG 1
#define OPT_ARG 2
extern int opterr;
extern int optind;
extern int optopt;
extern int optreset;
extern char *optarg;
extern int getopt(int nargc, char *const *nargv, const char *ostr);
extern int getopt_long(int argc, char * const argv[], const char *optstring,
const struct option *longopts, int totlen);
#endif /* _GETOPT_H_ */

2518
codec/convert.c Normal file

File diff suppressed because it is too large Load Diff

78
codec/convert.h Normal file
View File

@ -0,0 +1,78 @@
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* 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.
*/
#ifndef __J2K_CONVERT_H
#define __J2K_CONVERT_H
/**@name RAW image encoding parameters */
/*@{*/
typedef struct raw_cparameters {
/** width of the raw image */
int rawWidth;
/** height of the raw image */
int rawHeight;
/** components of the raw image */
int rawComp;
/** bit depth of the raw image */
int rawBitDepth;
/** signed/unsigned raw image */
bool rawSigned;
/*@}*/
} raw_cparameters_t;
/* TGA conversion */
opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters);
int imagetotga(opj_image_t * image, const char *outfile);
/* BMP conversion */
opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters);
int imagetobmp(opj_image_t *image, const char *outfile);
/* TIFF to image conversion*/
opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters);
int imagetotif(opj_image_t *image, const char *outfile);
/**
Load a single image component encoded in PGX file format
@param filename Name of the PGX file to load
@param parameters *List ?*
@return Returns a greyscale image if successful, returns NULL otherwise
*/
opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters);
int imagetopgx(opj_image_t *image, const char *outfile);
opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters);
int imagetopnm(opj_image_t *image, const char *outfile);
/* RAW conversion */
int imagetoraw(opj_image_t * image, const char *outfile);
opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp);
#endif /* __J2K_CONVERT_H */

File diff suppressed because it is too large Load Diff

1797
codec/image_to_j2k.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,391 +1,391 @@
/*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2003-2007, Francois-Olivier Devaux
* 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.
*/
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "openjpeg.h"
#include "index.h"
/* ------------------------------------------------------------------------------------ */
/**
Write a structured index to a file
@param cstr_info Codestream information
@param index Index filename
@return Returns 0 if successful, returns 1 otherwise
*/
int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
int tileno, compno, layno, resno, precno, pack_nb, x, y;
FILE *stream = NULL;
double total_disto = 0;
/* UniPG>> */
int tilepartno;
char disto_on, numpix_on;
#ifdef USE_JPWL
if (!strcmp(index, JPWL_PRIVATEINDEX_NAME))
return 0;
#endif /* USE_JPWL */
/* <<UniPG */
if (!cstr_info)
return 1;
stream = fopen(index, "w");
if (!stream) {
fprintf(stderr, "failed to open index file [%s] for writing\n", index);
return 1;
}
if (cstr_info->tile[0].distotile)
disto_on = 1;
else
disto_on = 0;
if (cstr_info->tile[0].numpix)
numpix_on = 1;
else
numpix_on = 0;
fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
fprintf(stream, "%d\n", cstr_info->prog);
fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
fprintf(stream, "%d\n", cstr_info->numcomps);
fprintf(stream, "%d\n", cstr_info->numlayers);
fprintf(stream, "%d\n", cstr_info->numdecompos[0]); /* based on component 0 */
for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
fprintf(stream, "[%d,%d] ",
(1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 and component 0 */
}
fprintf(stream, "\n");
/* UniPG>> */
fprintf(stream, "%d\n", cstr_info->main_head_start);
/* <<UniPG */
fprintf(stream, "%d\n", cstr_info->main_head_end);
fprintf(stream, "%d\n", cstr_info->codestream_size);
fprintf(stream, "\nINFO ON TILES\n");
fprintf(stream, "tileno start_pos end_hd end_tile nbparts");
if (disto_on)
fprintf(stream," disto");
if (numpix_on)
fprintf(stream," nbpix");
if (disto_on && numpix_on)
fprintf(stream," disto/nbpix");
fprintf(stream, "\n");
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
fprintf(stream, "%4d %9d %9d %9d %9d",
cstr_info->tile[tileno].tileno,
cstr_info->tile[tileno].start_pos,
cstr_info->tile[tileno].end_header,
cstr_info->tile[tileno].end_pos,
cstr_info->tile[tileno].num_tps);
if (disto_on)
fprintf(stream," %9e", cstr_info->tile[tileno].distotile);
if (numpix_on)
fprintf(stream," %9d", cstr_info->tile[tileno].numpix);
if (disto_on && numpix_on)
fprintf(stream," %9e", cstr_info->tile[tileno].distotile / cstr_info->tile[tileno].numpix);
fprintf(stream, "\n");
}
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
int start_pos, end_ph_pos, end_pos;
double disto = 0;
int max_numdecompos = 0;
pack_nb = 0;
for (compno = 0; compno < cstr_info->numcomps; compno++) {
if (max_numdecompos < cstr_info->numdecompos[compno])
max_numdecompos = cstr_info->numdecompos[compno];
}
fprintf(stream, "\nTILE %d DETAILS\n", tileno);
fprintf(stream, "part_nb tileno start_pack num_packs start_pos end_tph_pos end_pos\n");
for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
fprintf(stream, "%4d %9d %9d %9d %9d %11d %9d\n",
tilepartno, tileno,
cstr_info->tile[tileno].tp[tilepartno].tp_start_pack,
cstr_info->tile[tileno].tp[tilepartno].tp_numpacks,
cstr_info->tile[tileno].tp[tilepartno].tp_start_pos,
cstr_info->tile[tileno].tp[tilepartno].tp_end_header,
cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
);
if (cstr_info->prog == LRCP) { /* LRCP */
fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos");
if (disto_on)
fprintf(stream, " disto");
fprintf(stream,"\n");
for (layno = 0; layno < cstr_info->numlayers; layno++) {
for (resno = 0; resno < max_numdecompos + 1; resno++) {
for (compno = 0; compno < cstr_info->numcomps; compno++) {
int prec_max;
if (resno > cstr_info->numdecompos[compno])
break;
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
for (precno = 0; precno < prec_max; precno++) {
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
fprintf(stream, "%4d %6d %7d %5d %6d %6d %6d %6d %7d",
pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos);
if (disto_on)
fprintf(stream, " %8e", disto);
fprintf(stream, "\n");
total_disto += disto;
pack_nb++;
}
}
}
}
} /* LRCP */
else if (cstr_info->prog == RLCP) { /* RLCP */
fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos\n");
if (disto_on)
fprintf(stream, " disto");
fprintf(stream,"\n");
for (resno = 0; resno < max_numdecompos + 1; resno++) {
for (layno = 0; layno < cstr_info->numlayers; layno++) {
for (compno = 0; compno < cstr_info->numcomps; compno++) {
int prec_max;
if (resno > cstr_info->numdecompos[compno])
break;
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
for (precno = 0; precno < prec_max; precno++) {
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d %9d %7d",
pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos);
if (disto_on)
fprintf(stream, " %8e", disto);
fprintf(stream, "\n");
total_disto += disto;
pack_nb++;
}
}
}
}
} /* RLCP */
else if (cstr_info->prog == RPCL) { /* RPCL */
fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos");
if (disto_on)
fprintf(stream, " disto");
fprintf(stream,"\n");
for (resno = 0; resno < max_numdecompos + 1; resno++) {
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
for (precno = 0; precno < numprec; precno++) {
/* I suppose components have same XRsiz, YRsiz */
int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
int x1 = x0 + cstr_info->tile_x;
int y1 = y0 + cstr_info->tile_y;
for (compno = 0; compno < cstr_info->numcomps; compno++) {
int pcnx = cstr_info->tile[tileno].pw[resno];
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
int precno_y = (int) floor( (float)precno/(float)pcnx );
if (resno > cstr_info->numdecompos[compno])
break;
for(y = y0; y < y1; y++) {
if (precno_y*pcy == y ) {
for (x = x0; x < x1; x++) {
if (precno_x*pcx == x ) {
for (layno = 0; layno < cstr_info->numlayers; layno++) {
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d %9d %7d",
pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos);
if (disto_on)
fprintf(stream, " %8e", disto);
fprintf(stream, "\n");
total_disto += disto;
pack_nb++;
}
}
}/* x = x0..x1 */
}
} /* y = y0..y1 */
} /* precno */
} /* compno */
} /* resno */
} /* RPCL */
else if (cstr_info->prog == PCRL) { /* PCRL */
/* I suppose components have same XRsiz, YRsiz */
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
int x1 = x0 + cstr_info->tile_x;
int y1 = y0 + cstr_info->tile_y;
/* Count the maximum number of precincts */
int max_numprec = 0;
for (resno = 0; resno < max_numdecompos + 1; resno++) {
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
if (numprec > max_numprec)
max_numprec = numprec;
}
fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos");
if (disto_on)
fprintf(stream, " disto");
fprintf(stream,"\n");
for (precno = 0; precno < max_numprec; precno++) {
for (compno = 0; compno < cstr_info->numcomps; compno++) {
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
int pcnx = cstr_info->tile[tileno].pw[resno];
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
int precno_y = (int) floor( (float)precno/(float)pcnx );
if (precno >= numprec)
continue;
for(y = y0; y < y1; y++) {
if (precno_y*pcy == y ) {
for (x = x0; x < x1; x++) {
if (precno_x*pcx == x ) {
for (layno = 0; layno < cstr_info->numlayers; layno++) {
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos);
if (disto_on)
fprintf(stream, " %8e", disto);
fprintf(stream, "\n");
total_disto += disto;
pack_nb++;
}
}
}/* x = x0..x1 */
}
} /* y = y0..y1 */
} /* resno */
} /* compno */
} /* precno */
} /* PCRL */
else { /* CPRL */
/* Count the maximum number of precincts */
int max_numprec = 0;
for (resno = 0; resno < max_numdecompos + 1; resno++) {
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
if (numprec > max_numprec)
max_numprec = numprec;
}
fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos");
if (disto_on)
fprintf(stream, " disto");
fprintf(stream,"\n");
for (compno = 0; compno < cstr_info->numcomps; compno++) {
/* I suppose components have same XRsiz, YRsiz */
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
int x1 = x0 + cstr_info->tile_x;
int y1 = y0 + cstr_info->tile_y;
for (precno = 0; precno < max_numprec; precno++) {
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
int pcnx = cstr_info->tile[tileno].pw[resno];
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
int precno_y = (int) floor( (float)precno/(float)pcnx );
if (precno >= numprec)
continue;
for(y = y0; y < y1; y++) {
if (precno_y*pcy == y ) {
for (x = x0; x < x1; x++) {
if (precno_x*pcx == x ) {
for (layno = 0; layno < cstr_info->numlayers; layno++) {
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos);
if (disto_on)
fprintf(stream, " %8e", disto);
fprintf(stream, "\n");
total_disto += disto;
pack_nb++;
}
}
}/* x = x0..x1 */
}
} /* y = y0..y1 */
} /* resno */
} /* precno */
} /* compno */
} /* CPRL */
} /* tileno */
if (disto_on) {
fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */
fprintf(stream, "%.8e\n", total_disto); /* SE totale */
}
/* UniPG>> */
/* print the markers' list */
if (cstr_info->marknum) {
fprintf(stream, "\nMARKER LIST\n");
fprintf(stream, "%d\n", cstr_info->marknum);
fprintf(stream, "type\tstart_pos length\n");
for (x = 0; x < cstr_info->marknum; x++)
fprintf(stream, "%X\t%9d %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len);
}
/* <<UniPG */
fclose(stream);
fprintf(stderr,"Generated index file %s\n", index);
return 0;
}
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2003-2007, Francois-Olivier Devaux
* 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.
*/
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "openjpeg.h"
#include "index.h"
/* ------------------------------------------------------------------------------------ */
/**
Write a structured index to a file
@param cstr_info Codestream information
@param index Index filename
@return Returns 0 if successful, returns 1 otherwise
*/
int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
int tileno, compno, layno, resno, precno, pack_nb, x, y;
FILE *stream = NULL;
double total_disto = 0;
/* UniPG>> */
int tilepartno;
char disto_on, numpix_on;
#ifdef USE_JPWL
if (!strcmp(index, JPWL_PRIVATEINDEX_NAME))
return 0;
#endif /* USE_JPWL */
/* <<UniPG */
if (!cstr_info)
return 1;
stream = fopen(index, "w");
if (!stream) {
fprintf(stderr, "failed to open index file [%s] for writing\n", index);
return 1;
}
if (cstr_info->tile[0].distotile)
disto_on = 1;
else
disto_on = 0;
if (cstr_info->tile[0].numpix)
numpix_on = 1;
else
numpix_on = 0;
fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
fprintf(stream, "%d\n", cstr_info->prog);
fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
fprintf(stream, "%d\n", cstr_info->numcomps);
fprintf(stream, "%d\n", cstr_info->numlayers);
fprintf(stream, "%d\n", cstr_info->numdecompos[0]); /* based on component 0 */
for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
fprintf(stream, "[%d,%d] ",
(1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 and component 0 */
}
fprintf(stream, "\n");
/* UniPG>> */
fprintf(stream, "%d\n", cstr_info->main_head_start);
/* <<UniPG */
fprintf(stream, "%d\n", cstr_info->main_head_end);
fprintf(stream, "%d\n", cstr_info->codestream_size);
fprintf(stream, "\nINFO ON TILES\n");
fprintf(stream, "tileno start_pos end_hd end_tile nbparts");
if (disto_on)
fprintf(stream," disto");
if (numpix_on)
fprintf(stream," nbpix");
if (disto_on && numpix_on)
fprintf(stream," disto/nbpix");
fprintf(stream, "\n");
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
fprintf(stream, "%4d %9d %9d %9d %9d",
cstr_info->tile[tileno].tileno,
cstr_info->tile[tileno].start_pos,
cstr_info->tile[tileno].end_header,
cstr_info->tile[tileno].end_pos,
cstr_info->tile[tileno].num_tps);
if (disto_on)
fprintf(stream," %9e", cstr_info->tile[tileno].distotile);
if (numpix_on)
fprintf(stream," %9d", cstr_info->tile[tileno].numpix);
if (disto_on && numpix_on)
fprintf(stream," %9e", cstr_info->tile[tileno].distotile / cstr_info->tile[tileno].numpix);
fprintf(stream, "\n");
}
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
int start_pos, end_ph_pos, end_pos;
double disto = 0;
int max_numdecompos = 0;
pack_nb = 0;
for (compno = 0; compno < cstr_info->numcomps; compno++) {
if (max_numdecompos < cstr_info->numdecompos[compno])
max_numdecompos = cstr_info->numdecompos[compno];
}
fprintf(stream, "\nTILE %d DETAILS\n", tileno);
fprintf(stream, "part_nb tileno start_pack num_packs start_pos end_tph_pos end_pos\n");
for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
fprintf(stream, "%4d %9d %9d %9d %9d %11d %9d\n",
tilepartno, tileno,
cstr_info->tile[tileno].tp[tilepartno].tp_start_pack,
cstr_info->tile[tileno].tp[tilepartno].tp_numpacks,
cstr_info->tile[tileno].tp[tilepartno].tp_start_pos,
cstr_info->tile[tileno].tp[tilepartno].tp_end_header,
cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
);
if (cstr_info->prog == LRCP) { /* LRCP */
fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos");
if (disto_on)
fprintf(stream, " disto");
fprintf(stream,"\n");
for (layno = 0; layno < cstr_info->numlayers; layno++) {
for (resno = 0; resno < max_numdecompos + 1; resno++) {
for (compno = 0; compno < cstr_info->numcomps; compno++) {
int prec_max;
if (resno > cstr_info->numdecompos[compno])
break;
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
for (precno = 0; precno < prec_max; precno++) {
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
fprintf(stream, "%4d %6d %7d %5d %6d %6d %6d %6d %7d",
pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos);
if (disto_on)
fprintf(stream, " %8e", disto);
fprintf(stream, "\n");
total_disto += disto;
pack_nb++;
}
}
}
}
} /* LRCP */
else if (cstr_info->prog == RLCP) { /* RLCP */
fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos\n");
if (disto_on)
fprintf(stream, " disto");
fprintf(stream,"\n");
for (resno = 0; resno < max_numdecompos + 1; resno++) {
for (layno = 0; layno < cstr_info->numlayers; layno++) {
for (compno = 0; compno < cstr_info->numcomps; compno++) {
int prec_max;
if (resno > cstr_info->numdecompos[compno])
break;
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
for (precno = 0; precno < prec_max; precno++) {
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d %9d %7d",
pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos);
if (disto_on)
fprintf(stream, " %8e", disto);
fprintf(stream, "\n");
total_disto += disto;
pack_nb++;
}
}
}
}
} /* RLCP */
else if (cstr_info->prog == RPCL) { /* RPCL */
fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos");
if (disto_on)
fprintf(stream, " disto");
fprintf(stream,"\n");
for (resno = 0; resno < max_numdecompos + 1; resno++) {
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
for (precno = 0; precno < numprec; precno++) {
/* I suppose components have same XRsiz, YRsiz */
int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
int x1 = x0 + cstr_info->tile_x;
int y1 = y0 + cstr_info->tile_y;
for (compno = 0; compno < cstr_info->numcomps; compno++) {
int pcnx = cstr_info->tile[tileno].pw[resno];
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
int precno_y = (int) floor( (float)precno/(float)pcnx );
if (resno > cstr_info->numdecompos[compno])
break;
for(y = y0; y < y1; y++) {
if (precno_y*pcy == y ) {
for (x = x0; x < x1; x++) {
if (precno_x*pcx == x ) {
for (layno = 0; layno < cstr_info->numlayers; layno++) {
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d %9d %7d",
pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos);
if (disto_on)
fprintf(stream, " %8e", disto);
fprintf(stream, "\n");
total_disto += disto;
pack_nb++;
}
}
}/* x = x0..x1 */
}
} /* y = y0..y1 */
} /* precno */
} /* compno */
} /* resno */
} /* RPCL */
else if (cstr_info->prog == PCRL) { /* PCRL */
/* I suppose components have same XRsiz, YRsiz */
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
int x1 = x0 + cstr_info->tile_x;
int y1 = y0 + cstr_info->tile_y;
// Count the maximum number of precincts
int max_numprec = 0;
for (resno = 0; resno < max_numdecompos + 1; resno++) {
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
if (numprec > max_numprec)
max_numprec = numprec;
}
fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos");
if (disto_on)
fprintf(stream, " disto");
fprintf(stream,"\n");
for (precno = 0; precno < max_numprec; precno++) {
for (compno = 0; compno < cstr_info->numcomps; compno++) {
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
int pcnx = cstr_info->tile[tileno].pw[resno];
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
int precno_y = (int) floor( (float)precno/(float)pcnx );
if (precno >= numprec)
continue;
for(y = y0; y < y1; y++) {
if (precno_y*pcy == y ) {
for (x = x0; x < x1; x++) {
if (precno_x*pcx == x ) {
for (layno = 0; layno < cstr_info->numlayers; layno++) {
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos);
if (disto_on)
fprintf(stream, " %8e", disto);
fprintf(stream, "\n");
total_disto += disto;
pack_nb++;
}
}
}/* x = x0..x1 */
}
} /* y = y0..y1 */
} /* resno */
} /* compno */
} /* precno */
} /* PCRL */
else { /* CPRL */
// Count the maximum number of precincts
int max_numprec = 0;
for (resno = 0; resno < max_numdecompos + 1; resno++) {
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
if (numprec > max_numprec)
max_numprec = numprec;
}
fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos");
if (disto_on)
fprintf(stream, " disto");
fprintf(stream,"\n");
for (compno = 0; compno < cstr_info->numcomps; compno++) {
/* I suppose components have same XRsiz, YRsiz */
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
int x1 = x0 + cstr_info->tile_x;
int y1 = y0 + cstr_info->tile_y;
for (precno = 0; precno < max_numprec; precno++) {
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
int pcnx = cstr_info->tile[tileno].pw[resno];
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
int precno_y = (int) floor( (float)precno/(float)pcnx );
if (precno >= numprec)
continue;
for(y = y0; y < y1; y++) {
if (precno_y*pcy == y ) {
for (x = x0; x < x1; x++) {
if (precno_x*pcx == x ) {
for (layno = 0; layno < cstr_info->numlayers; layno++) {
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos);
if (disto_on)
fprintf(stream, " %8e", disto);
fprintf(stream, "\n");
total_disto += disto;
pack_nb++;
}
}
}/* x = x0..x1 */
}
} /* y = y0..y1 */
} /* resno */
} /* precno */
} /* compno */
} /* CPRL */
} /* tileno */
if (disto_on) {
fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */
fprintf(stream, "%.8e\n", total_disto); /* SE totale */
}
/* UniPG>> */
/* print the markers' list */
if (cstr_info->marknum) {
fprintf(stream, "\nMARKER LIST\n");
fprintf(stream, "%d\n", cstr_info->marknum);
fprintf(stream, "type\tstart_pos length\n");
for (x = 0; x < cstr_info->marknum; x++)
fprintf(stream, "%X\t%9d %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len);
}
/* <<UniPG */
fclose(stream);
fprintf(stderr,"Generated index file %s\n", index);
return 0;
}

View File

@ -1,49 +1,49 @@
/*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2003-2007, Francois-Olivier Devaux
* 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.
*/
#ifndef __J2K_INDEX_H
#define __J2K_INDEX_H
#ifdef __cplusplus
extern "C" {
#endif
/**
Write a structured index to a file
@param cstr_info Codestream information
@param index Index filename
@return Returns 0 if successful, returns 1 otherwise
*/
int write_index_file(opj_codestream_info_t *cstr_info, char *index);
#ifdef __cplusplus
}
#endif
#endif /* __J2K_INDEX_H */
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2003-2007, Francois-Olivier Devaux
* 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.
*/
#ifndef __J2K_INDEX_H
#define __J2K_INDEX_H
#ifdef __cplusplus
extern "C" {
#endif
/**
Write a structured index to a file
@param cstr_info Codestream information
@param index Index filename
@return Returns 0 if successful, returns 1 otherwise
*/
int write_index_file(opj_codestream_info_t *cstr_info, char *index);
#ifdef __cplusplus
}
#endif
#endif /* __J2K_INDEX_H */

495
codec/j2k_dump.c Normal file
View File

@ -0,0 +1,495 @@
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2006-2007, Parvatha Elangovan
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define USE_OPJ_DEPRECATED
#include "openjpeg.h"
#include "j2k.h"
#include "jp2.h"
#include "compat/getopt.h"
#include "convert.h"
#include "dirent.h"
#include "index.h"
#ifndef WIN32
#include <strings.h>
#define _stricmp strcasecmp
#define _strnicmp strncasecmp
#endif
/* ----------------------------------------------------------------------- */
#define J2K_CFMT 0
#define JP2_CFMT 1
#define JPT_CFMT 2
#define PXM_DFMT 10
#define PGX_DFMT 11
#define BMP_DFMT 12
#define YUV_DFMT 13
#define TIF_DFMT 14
#define RAW_DFMT 15
#define TGA_DFMT 16
/* ----------------------------------------------------------------------- */
typedef struct dircnt{
/** Buffer for holding images read from Directory*/
char *filename_buf;
/** Pointer to the buffer*/
char **filename;
}dircnt_t;
typedef struct img_folder{
/** The directory path of the folder containing input images*/
char *imgdirpath;
/** Output format*/
const char *out_format;
/** Enable option*/
char set_imgdir;
/** Enable Cod Format for output*/
char set_out_format;
}img_fol_t;
void decode_help_display() {
fprintf(stdout,"HELP\n----\n\n");
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
/* UniPG>> */
fprintf(stdout,"List of parameters for the JPEG 2000 "
#ifdef USE_JPWL
"+ JPWL "
#endif /* USE_JPWL */
"decoder:\n");
/* <<UniPG */
fprintf(stdout,"\n");
fprintf(stdout,"\n");
fprintf(stdout," -ImgDir \n");
fprintf(stdout," Image file Directory path \n");
fprintf(stdout," -i <compressed file>\n");
fprintf(stdout," REQUIRED only if an Input image directory not specified\n");
fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
fprintf(stdout," is identified based on its suffix.\n");
fprintf(stdout,"\n");
}
/* -------------------------------------------------------------------------- */
int get_num_images(char *imgdirpath){
DIR *dir;
struct dirent* content;
int num_images = 0;
/*Reading the input images from given input directory*/
dir= opendir(imgdirpath);
if(!dir){
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
return 0;
}
while((content=readdir(dir))!=NULL){
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
continue;
num_images++;
}
return num_images;
}
int load_images(dircnt_t *dirptr, char *imgdirpath){
DIR *dir;
struct dirent* content;
int i = 0;
/*Reading the input images from given input directory*/
dir= opendir(imgdirpath);
if(!dir){
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
return 1;
}else {
fprintf(stderr,"Folder opened successfully\n");
}
while((content=readdir(dir))!=NULL){
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
continue;
strcpy(dirptr->filename[i],content->d_name);
i++;
}
return 0;
}
int get_file_format(char *filename) {
unsigned int i;
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "j2k", "jp2", "jpt", "j2c", "jpc" };
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
char * ext = strrchr(filename, '.');
if (ext == NULL)
return -1;
ext++;
if(ext) {
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
if(_strnicmp(ext, extension[i], 3) == 0) {
return format[i];
}
}
}
return -1;
}
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
char *temp_p, temp1[OPJ_PATH_LEN]="";
strcpy(image_filename,dirptr->filename[imageno]);
fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
parameters->decod_format = get_file_format(image_filename);
if (parameters->decod_format == -1)
return 1;
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
strncpy(parameters->infile, infilename, sizeof(infilename));
//Set output file
strcpy(temp_ofname,strtok(image_filename,"."));
while((temp_p = strtok(NULL,".")) != NULL){
strcat(temp_ofname,temp1);
sprintf(temp1,".%s",temp_p);
}
if(img_fol->set_out_format==1){
sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
strncpy(parameters->outfile, outfilename, sizeof(outfilename));
}
return 0;
}
/* -------------------------------------------------------------------------- */
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
/* parse the command line */
int totlen;
option_t long_option[]={
{"ImgDir",REQ_ARG, NULL ,'y'},
};
const char optlist[] = "i:h";
totlen=sizeof(long_option);
img_fol->set_out_format = 0;
while (1) {
int c = getopt_long(argc, argv,optlist,long_option,totlen);
if (c == -1)
break;
switch (c) {
case 'i': /* input file */
{
char *infile = optarg;
parameters->decod_format = get_file_format(infile);
switch(parameters->decod_format) {
case J2K_CFMT:
case JP2_CFMT:
case JPT_CFMT:
break;
default:
fprintf(stderr,
"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
infile);
return 1;
}
strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
}
break;
/* ----------------------------------------------------- */
case 'h': /* display an help description */
decode_help_display();
return 1;
/* ------------------------------------------------------ */
case 'y': /* Image Directory path */
{
img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
strcpy(img_fol->imgdirpath,optarg);
img_fol->set_imgdir=1;
}
break;
/* ----------------------------------------------------- */
default:
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
break;
}
}
/* check for possible errors */
if(img_fol->set_imgdir==1){
if(!(parameters->infile[0]==0)){
fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
return 1;
}
if(img_fol->set_out_format == 0){
fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
return 1;
}
if(!((parameters->outfile[0] == 0))){
fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
return 1;
}
}else{
if((parameters->infile[0] == 0) ) {
fprintf(stderr, "Error: One of the options -i or -ImgDir must be specified\n");
fprintf(stderr, "usage: image_to_j2k -i *.j2k/jp2/j2c (+ options)\n");
return 1;
}
}
return 0;
}
/* -------------------------------------------------------------------------- */
/**
sample error callback expecting a FILE* client object
*/
void error_callback(const char *msg, void *client_data) {
FILE *stream = (FILE*)client_data;
fprintf(stream, "[ERROR] %s", msg);
}
/**
sample warning callback expecting a FILE* client object
*/
void warning_callback(const char *msg, void *client_data) {
FILE *stream = (FILE*)client_data;
fprintf(stream, "[WARNING] %s", msg);
}
/**
sample debug callback expecting no client object
*/
void info_callback(const char *msg, void *client_data) {
(void)client_data;
fprintf(stdout, "[INFO] %s", msg);
}
/* -------------------------------------------------------------------------- */
int main(int argc, char *argv[])
{
int ret;
opj_dparameters_t parameters; /* decompression parameters */
img_fol_t img_fol;
opj_image_t *image = NULL;
FILE *fsrc = NULL;
bool bResult;
int num_images;
int i,imageno;
dircnt_t *dirptr;
opj_codec_t* dinfo = NULL; /* handle to a decompressor */
opj_stream_t *cio = NULL;
opj_codestream_info_t cstr_info; /* Codestream information structure */
char indexfilename[OPJ_PATH_LEN]; /* index file name */
OPJ_INT32 l_tile_x0,l_tile_y0;
OPJ_UINT32 l_tile_width,l_tile_height,l_nb_tiles_x,l_nb_tiles_y;
/* configure the event callbacks (not required) */
/* set decoding parameters to default values */
opj_set_default_decoder_parameters(&parameters);
/* Initialize indexfilename and img_fol */
*indexfilename = 0;
memset(&img_fol,0,sizeof(img_fol_t));
/* parse input and get user encoding parameters */
if(parse_cmdline_decoder(argc, argv, &parameters,&img_fol, indexfilename) == 1) {
return EXIT_FAILURE;
}
/* Initialize reading of directory */
if(img_fol.set_imgdir==1){
num_images=get_num_images(img_fol.imgdirpath);
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
if(dirptr){
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); // Stores at max 10 image file names
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
if(!dirptr->filename_buf){
return EXIT_FAILURE;
}
for(i=0;i<num_images;i++){
dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
}
}
if(load_images(dirptr,img_fol.imgdirpath)==1){
return EXIT_FAILURE;
}
if (num_images==0){
fprintf(stdout,"Folder is empty\n");
return EXIT_FAILURE;
}
}else{
num_images=1;
}
/*Encoding image one by one*/
for(imageno = 0; imageno < num_images ; imageno++)
{
image = NULL;
fprintf(stderr,"\n");
if(img_fol.set_imgdir==1){
if (get_next_file(imageno, dirptr,&img_fol, &parameters)) {
fprintf(stderr,"skipping file...\n");
continue;
}
}
/* read the input file and put it in memory */
/* ---------------------------------------- */
fsrc = fopen(parameters.infile, "rb");
if (!fsrc) {
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
return EXIT_FAILURE;
}
cio = opj_stream_create_default_file_stream(fsrc,true);
/* decode the code-stream */
/* ---------------------- */
switch (parameters.decod_format)
{
case J2K_CFMT:
{
/* JPEG-2000 codestream */
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_J2K);
break;
}
case JP2_CFMT:
{
/* JPEG 2000 compressed image data */
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_JP2);
break;
}
case JPT_CFMT:
{
/* JPEG 2000, JPIP */
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_JPT);
break;
}
default:
fprintf(stderr, "skipping file..\n");
opj_stream_destroy(cio);
continue;
}
/* catch events using our callbacks and give a local context */
/* setup the decoder decoding parameters using user parameters */
opj_setup_decoder(dinfo, &parameters);
/* decode the stream and fill the image structure */
/* if (*indexfilename) // If need to extract codestream information
image = opj_decode_with_info(dinfo, cio, &cstr_info);
else
*/
bResult = opj_read_header(
dinfo,
&image,
&l_tile_x0,
&l_tile_y0,
&l_tile_width,
&l_tile_height,
&l_nb_tiles_x,
&l_nb_tiles_y,
cio);
//image = opj_decode(dinfo, cio);
//bResult = bResult && (image != 00);
//bResult = bResult && opj_end_decompress(dinfo,cio);
//if
// (!image)
//{
// fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
// opj_destroy_codec(dinfo);
// opj_stream_destroy(cio);
// fclose(fsrc);
// return EXIT_FAILURE;
//}
/* dump image */
if(!image)
{
fprintf(stderr, "ERROR -> j2k_to_image: failed to read header\n");
return EXIT_FAILURE;
}
j2k_dump_image(stdout, image);
/* dump cp */
//j2k_dump_cp(stdout, image, dinfo->m_codec);
/* close the byte stream */
opj_stream_destroy(cio);
fclose(fsrc);
/* Write the index to disk */
if (*indexfilename) {
char bSuccess;
bSuccess = write_index_file(&cstr_info, indexfilename);
if (bSuccess) {
fprintf(stderr, "Failed to output index file\n");
ret = EXIT_FAILURE;
}
}
/* free remaining structures */
if (dinfo) {
opj_destroy_codec(dinfo);
}
/* free codestream information structure */
if (*indexfilename)
opj_destroy_cstr_info(&cstr_info);
/* free image data structure */
opj_image_destroy(image);
}
return ret;
}
//end main

773
codec/j2k_to_image.c Normal file
View File

@ -0,0 +1,773 @@
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2006-2007, Parvatha Elangovan
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define USE_OPJ_DEPRECATED
#include "openjpeg.h"
#include "compat/getopt.h"
#include "convert.h"
#include "dirent.h"
#include "index.h"
#ifndef WIN32
#include <strings.h>
#define _stricmp strcasecmp
#define _strnicmp strncasecmp
#endif
/* ----------------------------------------------------------------------- */
#define J2K_CFMT 0
#define JP2_CFMT 1
#define JPT_CFMT 2
#define PXM_DFMT 10
#define PGX_DFMT 11
#define BMP_DFMT 12
#define YUV_DFMT 13
#define TIF_DFMT 14
#define RAW_DFMT 15
#define TGA_DFMT 16
#define PNG_DFMT 17
/* ----------------------------------------------------------------------- */
typedef struct dircnt{
/** Buffer for holding images read from Directory*/
char *filename_buf;
/** Pointer to the buffer*/
char **filename;
}dircnt_t;
typedef struct img_folder{
/** The directory path of the folder containing input images*/
char *imgdirpath;
/** Output format*/
const char *out_format;
/** Enable option*/
char set_imgdir;
/** Enable Cod Format for output*/
char set_out_format;
}img_fol_t;
void decode_help_display() {
fprintf(stdout,"HELP\n----\n\n");
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
/* UniPG>> */
fprintf(stdout,"List of parameters for the JPEG 2000 "
#ifdef USE_JPWL
"+ JPWL "
#endif /* USE_JPWL */
"decoder:\n");
/* <<UniPG */
fprintf(stdout,"\n");
fprintf(stdout,"\n");
fprintf(stdout," -ImgDir \n");
fprintf(stdout," Image file Directory path \n");
fprintf(stdout," -OutFor \n");
fprintf(stdout," REQUIRED only if -ImgDir is used\n");
fprintf(stdout," Need to specify only format without filename <BMP> \n");
fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA formats\n");
fprintf(stdout," -i <compressed file>\n");
fprintf(stdout," REQUIRED only if an Input image directory not specified\n");
fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
fprintf(stdout," is identified based on its suffix.\n");
fprintf(stdout," -o <decompressed file>\n");
fprintf(stdout," REQUIRED\n");
fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA files\n");
fprintf(stdout," Binary data is written to the file (not ascii). If a PGX\n");
fprintf(stdout," filename is given, there will be as many output files as there are\n");
fprintf(stdout," components: an indice starting from 0 will then be appended to the\n");
fprintf(stdout," output filename, just before the \"pgx\" extension. If a PGM filename\n");
fprintf(stdout," is given and there are more than one component, only the first component\n");
fprintf(stdout," will be written to the file.\n");
fprintf(stdout," -r <reduce factor>\n");
fprintf(stdout," Set the number of highest resolution levels to be discarded. The\n");
fprintf(stdout," image resolution is effectively divided by 2 to the power of the\n");
fprintf(stdout," number of discarded levels. The reduce factor is limited by the\n");
fprintf(stdout," smallest total number of decomposition levels among tiles.\n");
fprintf(stdout," -l <number of quality layers to decode>\n");
fprintf(stdout," Set the maximum number of quality layers to decode. If there are\n");
fprintf(stdout," less quality layers than the specified number, all the quality layers\n");
fprintf(stdout," are decoded.\n");
fprintf(stdout," -x \n");
fprintf(stdout," Create an index file *.Idx (-x index_name.Idx) \n");
fprintf(stdout,"\n");
/* UniPG>> */
#ifdef USE_JPWL
fprintf(stdout," -W <options>\n");
fprintf(stdout," Activates the JPWL correction capability, if the codestream complies.\n");
fprintf(stdout," Options can be a comma separated list of <param=val> tokens:\n");
fprintf(stdout," c, c=numcomps\n");
fprintf(stdout," numcomps is the number of expected components in the codestream\n");
fprintf(stdout," (search of first EPB rely upon this, default is %d)\n", JPWL_EXPECTED_COMPONENTS);
#endif /* USE_JPWL */
/* <<UniPG */
fprintf(stdout,"\n");
}
/* -------------------------------------------------------------------------- */
int get_num_images(char *imgdirpath){
DIR *dir;
struct dirent* content;
int num_images = 0;
/*Reading the input images from given input directory*/
dir= opendir(imgdirpath);
if(!dir){
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
return 0;
}
while((content=readdir(dir))!=NULL){
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
continue;
num_images++;
}
return num_images;
}
int load_images(dircnt_t *dirptr, char *imgdirpath){
DIR *dir;
struct dirent* content;
int i = 0;
/*Reading the input images from given input directory*/
dir= opendir(imgdirpath);
if(!dir){
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
return 1;
}else {
fprintf(stderr,"Folder opened successfully\n");
}
while((content=readdir(dir))!=NULL){
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
continue;
strcpy(dirptr->filename[i],content->d_name);
i++;
}
return 0;
}
int get_file_format(char *filename) {
unsigned int i;
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
char * ext = strrchr(filename, '.');
if (ext == NULL)
return -1;
ext++;
if(ext) {
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
if(_strnicmp(ext, extension[i], 3) == 0) {
return format[i];
}
}
}
return -1;
}
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
char *temp_p, temp1[OPJ_PATH_LEN]="";
strcpy(image_filename,dirptr->filename[imageno]);
fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
parameters->decod_format = get_file_format(image_filename);
if (parameters->decod_format == -1)
return 1;
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
strncpy(parameters->infile, infilename, sizeof(infilename));
//Set output file
strcpy(temp_ofname,strtok(image_filename,"."));
while((temp_p = strtok(NULL,".")) != NULL){
strcat(temp_ofname,temp1);
sprintf(temp1,".%s",temp_p);
}
if(img_fol->set_out_format==1){
sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
strncpy(parameters->outfile, outfilename, sizeof(outfilename));
}
return 0;
}
/* -------------------------------------------------------------------------- */
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
/* parse the command line */
int totlen;
option_t long_option[]={
{"ImgDir",REQ_ARG, NULL ,'y'},
{"OutFor",REQ_ARG, NULL ,'O'},
};
const char optlist[] = "i:o:r:l:hx:"
/* UniPG>> */
#ifdef USE_JPWL
"W:"
#endif /* USE_JPWL */
/* <<UniPG */
;
totlen=sizeof(long_option);
img_fol->set_out_format = 0;
while (1) {
int c = getopt_long(argc, argv,optlist,long_option,totlen);
if (c == -1)
break;
switch (c) {
case 'i': /* input file */
{
char *infile = optarg;
parameters->decod_format = get_file_format(infile);
switch(parameters->decod_format) {
case J2K_CFMT:
case JP2_CFMT:
case JPT_CFMT:
break;
default:
fprintf(stderr,
"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
infile);
return 1;
}
strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
}
break;
/* ----------------------------------------------------- */
case 'o': /* output file */
{
char *outfile = optarg;
parameters->cod_format = get_file_format(outfile);
switch(parameters->cod_format) {
case PGX_DFMT:
case PXM_DFMT:
case BMP_DFMT:
case TIF_DFMT:
case RAW_DFMT:
case TGA_DFMT:
case PNG_DFMT:
break;
default:
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outfile);
return 1;
}
strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
}
break;
/* ----------------------------------------------------- */
case 'O': /* output format */
{
char outformat[50];
char *of = optarg;
sprintf(outformat,".%s",of);
img_fol->set_out_format = 1;
parameters->cod_format = get_file_format(outformat);
switch(parameters->cod_format) {
case PGX_DFMT:
img_fol->out_format = "pgx";
break;
case PXM_DFMT:
img_fol->out_format = "ppm";
break;
case BMP_DFMT:
img_fol->out_format = "bmp";
break;
case TIF_DFMT:
img_fol->out_format = "tif";
break;
case RAW_DFMT:
img_fol->out_format = "raw";
break;
case TGA_DFMT:
img_fol->out_format = "raw";
break;
case PNG_DFMT:
img_fol->out_format = "png";
break;
default:
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outformat);
return 1;
break;
}
}
break;
/* ----------------------------------------------------- */
case 'r': /* reduce option */
{
sscanf(optarg, "%d", &parameters->cp_reduce);
}
break;
/* ----------------------------------------------------- */
case 'l': /* layering option */
{
sscanf(optarg, "%d", &parameters->cp_layer);
}
break;
/* ----------------------------------------------------- */
case 'h': /* display an help description */
decode_help_display();
return 1;
/* ------------------------------------------------------ */
case 'y': /* Image Directory path */
{
img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
strcpy(img_fol->imgdirpath,optarg);
img_fol->set_imgdir=1;
}
break;
/* ----------------------------------------------------- */
case 'x': /* Creation of index file */
{
char *index = optarg;
strncpy(indexfilename, index, OPJ_PATH_LEN);
}
break;
/* ----------------------------------------------------- */
/* UniPG>> */
#ifdef USE_JPWL
case 'W': /* activate JPWL correction */
{
char *token = NULL;
token = strtok(optarg, ",");
while(token != NULL) {
/* search expected number of components */
if (*token == 'c') {
static int compno;
compno = JPWL_EXPECTED_COMPONENTS; /* predefined no. of components */
if(sscanf(token, "c=%d", &compno) == 1) {
/* Specified */
if ((compno < 1) || (compno > 256)) {
fprintf(stderr, "ERROR -> invalid number of components c = %d\n", compno);
return 1;
}
parameters->jpwl_exp_comps = compno;
} else if (!strcmp(token, "c")) {
/* default */
parameters->jpwl_exp_comps = compno; /* auto for default size */
} else {
fprintf(stderr, "ERROR -> invalid components specified = %s\n", token);
return 1;
};
}
/* search maximum number of tiles */
if (*token == 't') {
static int tileno;
tileno = JPWL_MAXIMUM_TILES; /* maximum no. of tiles */
if(sscanf(token, "t=%d", &tileno) == 1) {
/* Specified */
if ((tileno < 1) || (tileno > JPWL_MAXIMUM_TILES)) {
fprintf(stderr, "ERROR -> invalid number of tiles t = %d\n", tileno);
return 1;
}
parameters->jpwl_max_tiles = tileno;
} else if (!strcmp(token, "t")) {
/* default */
parameters->jpwl_max_tiles = tileno; /* auto for default size */
} else {
fprintf(stderr, "ERROR -> invalid tiles specified = %s\n", token);
return 1;
};
}
/* next token or bust */
token = strtok(NULL, ",");
};
parameters->jpwl_correct = true;
fprintf(stdout, "JPWL correction capability activated\n");
fprintf(stdout, "- expecting %d components\n", parameters->jpwl_exp_comps);
}
break;
#endif /* USE_JPWL */
/* <<UniPG */
/* ----------------------------------------------------- */
default:
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
break;
}
}
/* check for possible errors */
if(img_fol->set_imgdir==1){
if(!(parameters->infile[0]==0)){
fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
return 1;
}
if(img_fol->set_out_format == 0){
fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
return 1;
}
if(!((parameters->outfile[0] == 0))){
fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
return 1;
}
}else{
if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
fprintf(stderr, "Error: One of the options -i or -ImgDir must be specified\n");
fprintf(stderr, "Error: When using -i, -o must be used\n");
fprintf(stderr, "usage: image_to_j2k -i *.j2k/jp2/j2c -o *.pgm/ppm/pnm/pgx/bmp/tif/raw/tga(+ options)\n");
return 1;
}
}
return 0;
}
/* -------------------------------------------------------------------------- */
/**
sample error callback expecting a FILE* client object
*/
void error_callback(const char *msg, void *client_data) {
FILE *stream = (FILE*)client_data;
fprintf(stream, "[ERROR] %s", msg);
}
/**
sample warning callback expecting a FILE* client object
*/
void warning_callback(const char *msg, void *client_data) {
FILE *stream = (FILE*)client_data;
fprintf(stream, "[WARNING] %s", msg);
}
/**
sample debug callback expecting no client object
*/
void info_callback(const char *msg, void *client_data) {
(void)client_data;
fprintf(stdout, "[INFO] %s", msg);
}
/* -------------------------------------------------------------------------- */
int main(int argc, char **argv)
{
int ret;
opj_dparameters_t parameters; /* decompression parameters */
img_fol_t img_fol;
opj_image_t *image = NULL;
FILE *fsrc = NULL;
bool bResult;
int num_images;
int i,imageno;
dircnt_t *dirptr;
opj_codec_t* dinfo = NULL; /* handle to a decompressor */
opj_stream_t *cio = NULL;
opj_codestream_info_t cstr_info; /* Codestream information structure */
char indexfilename[OPJ_PATH_LEN]; /* index file name */
OPJ_INT32 l_tile_x0,l_tile_y0;
OPJ_UINT32 l_tile_width,l_tile_height,l_nb_tiles_x,l_nb_tiles_y;
/* configure the event callbacks (not required) */
/* set decoding parameters to default values */
opj_set_default_decoder_parameters(&parameters);
/* Initialize indexfilename and img_fol */
*indexfilename = 0;
memset(&img_fol,0,sizeof(img_fol_t));
/* parse input and get user encoding parameters */
if(parse_cmdline_decoder(argc, argv, &parameters,&img_fol, indexfilename) == 1) {
return EXIT_FAILURE;
}
/* Initialize reading of directory */
if(img_fol.set_imgdir==1){
num_images=get_num_images(img_fol.imgdirpath);
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
if(dirptr){
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); // Stores at max 10 image file names
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
if(!dirptr->filename_buf){
return EXIT_FAILURE;
}
for(i=0;i<num_images;i++){
dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
}
}
if(load_images(dirptr,img_fol.imgdirpath)==1){
return EXIT_FAILURE;
}
if (num_images==0){
fprintf(stdout,"Folder is empty\n");
return EXIT_FAILURE;
}
}else{
num_images=1;
}
/*Encoding image one by one*/
for(imageno = 0; imageno < num_images ; imageno++)
{
image = NULL;
fprintf(stderr,"\n");
if(img_fol.set_imgdir==1){
if (get_next_file(imageno, dirptr,&img_fol, &parameters)) {
fprintf(stderr,"skipping file...\n");
continue;
}
}
/* read the input file and put it in memory */
/* ---------------------------------------- */
fsrc = fopen(parameters.infile, "rb");
if
(!fsrc)
{
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
return EXIT_FAILURE;
}
cio = opj_stream_create_default_file_stream(fsrc,true);
/* decode the code-stream */
/* ---------------------- */
switch
(parameters.decod_format)
{
case J2K_CFMT:
{
/* JPEG-2000 codestream */
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_J2K);
break;
}
case JP2_CFMT:
{
/* JPEG 2000 compressed image data */
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_JP2);
break;
}
case JPT_CFMT:
{
/* JPEG 2000, JPIP */
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_JPT);
break;
}
default:
fprintf(stderr, "skipping file..\n");
opj_stream_destroy(cio);
continue;
}
/* catch events using our callbacks and give a local context */
/* setup the decoder decoding parameters using user parameters */
opj_setup_decoder(dinfo, &parameters);
/* decode the stream and fill the image structure */
/* if (*indexfilename) // If need to extract codestream information
image = opj_decode_with_info(dinfo, cio, &cstr_info);
else
*/
bResult = opj_read_header(
dinfo,
&image,
&l_tile_x0,
&l_tile_y0,
&l_tile_width,
&l_tile_height,
&l_nb_tiles_x,
&l_nb_tiles_y,
cio);
image = opj_decode(dinfo, cio);
bResult = bResult && (image != 00);
bResult = bResult && opj_end_decompress(dinfo,cio);
if
(!image)
{
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
opj_destroy_codec(dinfo);
opj_stream_destroy(cio);
fclose(fsrc);
return EXIT_FAILURE;
}
/* close the byte stream */
opj_stream_destroy(cio);
fclose(fsrc);
/* Write the index to disk */
if (*indexfilename) {
char bSuccess;
bSuccess = write_index_file(&cstr_info, indexfilename);
if (bSuccess) {
fprintf(stderr, "Failed to output index file\n");
ret = EXIT_FAILURE;
}
}
/* create output image */
/* ------------------- */
switch (parameters.cod_format) {
case PXM_DFMT: /* PNM PGM PPM */
if (imagetopnm(image, parameters.outfile)) {
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
ret = EXIT_FAILURE;
}
else {
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
ret = EXIT_SUCCESS;
}
break;
case PGX_DFMT: /* PGX */
if(imagetopgx(image, parameters.outfile)){
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
ret = EXIT_FAILURE;
}
else {
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
ret = EXIT_SUCCESS;
}
break;
case BMP_DFMT: /* BMP */
if(imagetobmp(image, parameters.outfile)){
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
ret = EXIT_FAILURE;
}
else {
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
ret = EXIT_SUCCESS;
}
break;
case TIF_DFMT: /* TIFF */
if(imagetotif(image, parameters.outfile)){
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
ret = EXIT_FAILURE;
}
else {
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
ret = EXIT_SUCCESS;
}
break;
case RAW_DFMT: /* RAW */
if(imagetoraw(image, parameters.outfile)){
fprintf(stdout,"Error generating raw file. Outfile %s not generated\n",parameters.outfile);
ret = EXIT_FAILURE;
}
else {
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
ret = EXIT_SUCCESS;
}
break;
case TGA_DFMT: /* TGA */
if(imagetotga(image, parameters.outfile)){
fprintf(stdout,"Error generating tga file. Outfile %s not generated\n",parameters.outfile);
ret = EXIT_FAILURE;
}
else {
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
ret = EXIT_SUCCESS;
}
break;
case PNG_DFMT: /* PNG */
if(imagetopng(image, parameters.outfile)){
fprintf(stdout,"Error generating png file. Outfile %s not generated\n",parameters.outfile);
}
else {
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
}
break;
}
/* free remaining structures */
if
(dinfo)
{
opj_destroy_codec(dinfo);
}
/* free codestream information structure */
if (*indexfilename)
opj_destroy_cstr_info(&cstr_info);
/* free image data structure */
opj_image_destroy(image);
}
return ret;
}
//end main

View File

@ -1,52 +1,12 @@
# Generate target to build the html documentation through CMake tool
# After having configured the project with the BUILD_DOC option you can run make doc
# to generate the html documentation in the doc/html repository of the build folder.
FIND_PACKAGE(Doxygen REQUIRED)
# Try to find the doxygen tool
find_package(Doxygen)
if(DOXYGEN_FOUND)
# Configure the doxygen config file with variable from CMake and move it
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.dox.cmake.in
${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.in
${CMAKE_BINARY_DIR}/doc/mainpage.dox @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openjpip.dox.in
${CMAKE_BINARY_DIR}/doc/openjpip.dox @ONLY)
# copy png file to make local (binary tree) documentation valid:
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jpip_architect.png
${CMAKE_BINARY_DIR}/doc/html/jpip_architect.png COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jpip_protocol.png
${CMAKE_BINARY_DIR}/doc/html/jpip_protocol.png COPYONLY)
file(GLOB headers
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/*.h
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/*.c
${OPENJPEG_SOURCE_DIR}/src/lib/openjpip/*.h
${OPENJPEG_SOURCE_DIR}/src/lib/openjpip/*.c
)
# Generate new target to build the html documentation
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/index.html
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox
DEPENDS ${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox
${CMAKE_BINARY_DIR}/doc/mainpage.dox
${CMAKE_BINARY_DIR}/doc/openjpip.dox
${headers}
)
add_custom_target(doc ALL
DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html
COMMENT "Building doxygen documentation"
)
# install HTML documentation (install png files too):
install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/html
DESTINATION ${CMAKE_INSTALL_DOCDIR}
PATTERN ".svn" EXCLUDE
)
else()
message(STATUS "Doxygen not found, we cannot generate the documentation")
endif()
# The Doxyfile.dox is poorly defined and produce output
# in the source dir
ADD_CUSTOM_TARGET(doxygen
# By default doxygen target is added to the 'all' target. Project is small
# thus running doxygen is not too time consuming
ALL
${DOXYGEN}
${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.dox
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

View File

@ -1,14 +1,14 @@
# Doxyfile 1.7.1
# Doxyfile 1.4.2
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = OpenJPEG
PROJECT_NUMBER = @OPENJPEG_VERSION@
OUTPUT_DIRECTORY = @OPENJPEG_BINARY_DIR@/doc
PROJECT_NUMBER =
OUTPUT_DIRECTORY = ../
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = YES
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class" \
@ -26,27 +26,19 @@ ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH = C://
STRIP_FROM_INC_PATH =
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = YES
INHERIT_DOCS = YES
DISTRIBUTE_GROUP_DOC = NO
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
EXTENSION_MAPPING =
BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
IDL_PROPERTY_SUPPORT = YES
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
TYPEDEF_HIDES_STRUCT = NO
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
@ -55,7 +47,6 @@ EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
EXTRACT_ANON_NSPACES = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
@ -64,24 +55,19 @@ INTERNAL_DOCS = NO
CASE_SENSE_NAMES = NO
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
FORCE_LOCAL_INCLUDES = NO
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_MEMBERS_CTORS_1ST = NO
SORT_GROUP_NAMES = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_FILES = YES
SHOW_NAMESPACES = YES
FILE_VERSION_FILTER =
LAYOUT_FILE =
SHOW_DIRECTORIES = NO
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
@ -91,28 +77,24 @@ WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = @OPENJPEG_SOURCE_DIR@/src/lib/openjp2 \
@OPENJPEG_SOURCE_DIR@/src/lib/openjpip \
@OPENJPEG_BINARY_DIR@/doc
INPUT_ENCODING = UTF-8
INPUT = ../libopenjpeg \
../jpwl
FILE_PATTERNS = *.h \
*.c \
*.dox
RECURSIVE = YES
EXCLUDE =
*.c
RECURSIVE = NO
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = */.svn/*
EXCLUDE_SYMBOLS =
EXAMPLE_PATH =
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH = @OPENJPEG_SOURCE_DIR@/doc
INPUT_FILTER =
FILTER_PATTERNS =
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
@ -122,60 +104,33 @@ INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
REFERENCES_LINK_SOURCE = YES
USE_HTAGS = NO
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = ./html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_COLORSTYLE_HUE = 220
HTML_COLORSTYLE_SAT = 100
HTML_COLORSTYLE_GAMMA = 80
HTML_TIMESTAMP = NO
HTML_DYNAMIC_SECTIONS = NO
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_BUNDLE_ID = org.doxygen.Project
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
DOCSET_PUBLISHER_NAME = Publisher
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
CHM_INDEX_ENCODING =
BINARY_TOC = NO
TOC_EXPAND = NO
GENERATE_QHP = NO
QCH_FILE =
QHP_NAMESPACE = org.doxygen.Project
QHP_VIRTUAL_FOLDER = doc
QHP_CUST_FILTER_NAME =
QHP_CUST_FILTER_ATTRS =
QHP_SECT_FILTER_ATTRS =
QHG_LOCATION =
GENERATE_ECLIPSEHELP = NO
ECLIPSE_DOC_ID = org.doxygen.Project
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
EXT_LINKS_IN_WINDOW = NO
FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES
SEARCHENGINE = NO
SERVER_BASED_SEARCH = NO
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
@ -185,13 +140,12 @@ LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
LATEX_SOURCE_CODE = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
@ -199,8 +153,8 @@ GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
@ -213,6 +167,8 @@ MAN_LINKS = NO
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
@ -224,39 +180,34 @@ GENERATE_AUTOGEN_DEF = NO
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED = USE_JPWL \
USE_JPSEC
EXPAND_AS_DEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
MSCGEN_PATH =
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
DOT_NUM_THREADS = 0
DOT_FONTNAME = Helvetica
DOT_FONTSIZE = 10
DOT_FONTPATH =
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
@ -265,15 +216,19 @@ TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
DOT_GRAPH_MAX_NODES = 50
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

View File

@ -1,62 +0,0 @@
/*
* $Id$
*
* Copyright (c) 2002-2014, 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 project can be found at:
*
* http://www.openjpeg.org/
*
* The source code repository is available here:
*
* http://github.com/uclouvain/openjpeg
*
* The OpenJPEG mailing list is located here:
*
* http://groups.google.com/group/openjpeg
*
* The test files repository is available here:
*
* http://github.com/uclouvain/openjpeg-data
*
* \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
*
*/

View File

@ -1,222 +0,0 @@
'\" t
'\" The line above instructs most `man' programs to invoke tbl
'\"
'\" Separate paragraphs; not the same as PP which resets indent level.
.de SP
.if t .sp .5
.if n .sp
..
'\"
'\" Replacement em-dash for nroff (default is too short).
.ie n .ds m " -
.el .ds m \(em
'\"
'\" Placeholder macro for if longer nroff arrow is needed.
.ds RA \(->
'\"
'\" Decimal point set slightly raised
.if t .ds d \v'-.15m'.\v'+.15m'
.if n .ds d .
'\"
'\" Enclosure macro for examples
.de EX
.SP
.nf
.ft CW
..
.de EE
.ft R
.SP
.fi
..
.TH opj_compress 1 "Version 2.1.1" "opj_compress" "converts to jpeg2000 files"
.P
.SH NAME
opj_compress \-
This program reads in an image of a certain type and converts it to a
jpeg2000 file. It is part of the OpenJPEG library.
.SP
Valid input image extensions are
.B .bmp, .pgm, .pgx, .png, .pnm, .ppm, .raw, .tga, .tif \fR. For PNG resp. TIF it needs libpng resp. libtiff .
.SP
Valid output image extensions are
.B .j2k, .jp2
.SH SYNOPSIS
.P
.B opj_compress \-i \fRinfile.bmp \fB-o \fRoutfile.j2k
.P
.B opj_compress \-ImgDir \fRdirectory_name \fB-OutFor \fRjp2
.P
.B opj_compress \-h \fRPrint a help message and exit.
.P
See JPWL OPTIONS for special options
.SH OPTIONS
.TP
.B \-\^b " n,n"
(Size of code block (e.g. \-b 32,32). Default: 64 x 64)
.TP
.B \-\^c " n"
(Size of precinct (e.g. \-c 128,128). Default: 2^15 x 2^15)
.TP
.B \-\^cinema2K " fps"
Digital Cinema 2K profile compliant codestream. Valid \fBfps\fR values are 24 or 48.
.TP
.B \-\^cinema4K
Digital Cinema 4K profile compliant codestream. Does not need an fps: default is 24 fps.
.TP
.B \-\^d " X,Y"
(Offset of image origin (e.g. \-d 150,300))
.TP
.B \-\^h
Print a help message and exit.
.TP
.B \-\^i " name"
(input file name)
.TP
.B \-\^n " n"
(Number of resolutions. Default: 6)
.TP
.B \-\^o " name"
(output file name)
.TP
.B \-\^p " name"
Progression order. \fBname\fR can be one out of:LRCP, RLCP, RPCL, PCRL, CPRL. Default: LRCP.
.TP
.B \-\^q " n"
different psnr for successive layers
.br
.B Note: \fR(options \-r and \-q cannot be used together)
.TP
.B \-\^r " n"
different compression ratio(s) for successive layers. The rate specified for each quality level is the desired compression factor.
.br
.B Note: \fR(options \-r and \-q cannot be used together)
.TP
.B \-\^s " X,Y"
sub-sampling factor (e.g. \-s 2,2). Default: No sub-sampling in x or y direction.
.br
.B Remark: \fRsub-sampling bigger than 2 can produce errors.
.TP
.B \-\^t " W,H"
(Size of tile (e.g. \-t 512,512) )
.TP
.B \-\^x " name"
(Create index file and fill it. Default: no index file)
.TP
.B \-\^EPH
(Write EPH marker after each header packet. Default:no EPH)
.TP
.B \-\^F " rawWidth,rawHeight,rawComp,rawBitDepth,s_or_u"
characteristics of the raw input image
.TP
.B \-\^I
(Use the irreversible DWT 9-7. Default: Reversible DWT 5-3)
.TP
.B \-\^ImgDir " directory_name"
(directory containing input files)
.TP
.B \-\^M " n"
mode switch with values: 1, 2, 4, 8, 16, 32. Default:No mode switch activated.
.br
\fIMeaning:\fR
.br
BYPASS(1)
.br
RESET(2)
.br
RESTART(4)
.br
VSC(8)
.br
ERTERM(16)
.br
SEGMARK(32)
.br
Values can be added: RESTART(4) + RESET(2) + SEGMARK(32) = \-M 38
.TP
.B \-\^OutFor "ext"
(extension for output files)
.TP
.B \-\^POC "TtileNr=resolutionStart, componentStart, layerEnd, resolutionEnd, componentEnd, progressionOrder"
(see Examples)
.TP
.B \-\^ROI "c=n,U=n"
quantization indices upshifted for component c (0 or 1 or 2) with a value of U (>= 0 and <= 37)
.br
e.g. \fB-ROI c=0,U=25\fR
.TP
.B \-\^SOP
(Write SOP marker before each packet. Default: No SOP marker in the codestream.)
.TP
.B \-\^T "X,Y"
(Offset of the origin of the tiles (e.g. \-T 100,75) )
.TP
.B \-\^W
(see JPWL OPTIONS)
.P
.SH JPWL OPTIONS
Options usable only if the library has been compiled with \fB-DUSE_JPWL\fR
.P
.B \-W h<tilepart><=type>, s<tilepart><=method>, a=<addr>, z=<size>, g=<range>, p<tilepart:pack><=type>
.P
.B h\fR selects the header error protection (EPB): \fBtype\fR can be
[0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]
if \fBtilepart\fR is absent, it is for main and tile headers
if \fBtilepart\fR is present, it applies from that tile
onwards, up to the next h<> spec, or to the last tilepart
in the codestream (max. 16 specs)
.P
.B p \fRselects the packet error protection (EEP/UEP with EPBs)
to be applied to raw data: \fBtype\fR can be
[0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]
if \fBtilepart:pack\fR is absent, it is from tile 0, packet 0
if \fBtilepart:pack\fR is present, it applies from that tile
and that packet onwards, up to the next packet spec
or to the last packet in the last tilepart in the stream
(max. 16 specs)
.P
.B s \fRenables sensitivity data insertion (ESD): \fBmethod\fR can be
[\-1=NO ESD 0=RELATIVE ERROR 1=MSE 2=MSE REDUCTION 3=PSNR
4=PSNR INCREMENT 5=MAXERR 6=TSE 7=RESERVED]
if \fBtilepart\fR is absent, it is for main header only
if \fBtilepart\fR is present, it applies from that tile
onwards, up to the next s<> spec, or to the last tilepart
in the codestream (max. 16 specs)
.P
.B g \fRdetermines the addressing mode: \fBrange\fR can be
[0=PACKET 1=BYTE RANGE 2=PACKET RANGE]
.P
.B a \fRdetermines the size of data addressing: \fBaddr\fR can be
2/4 bytes (small/large codestreams). If not set, auto-mode
.P
.B z \fRdetermines the size of sensitivity values: \fBsize\fR can be
1/2 bytes, for the transformed pseudo-floating point value
.P
.SH EXAMPLES
.P
.B opj_compress \-i \fRfile.bmp \fB-o \fRfile.j2k \fB-r \fR20,10,1 (compress 20x, then 10x, then lossless).
.P
.B opj_compress \-i \fRfile.ppm \fB-o \fRfile.j2k \fB-q \fR30,40,50
.P
.B opj_compress \-i \fRfile.pgx \fB-o \fRfile.j2k \fB-POC \fRT1=0,0,1,5,3,CPRL
.P
.B opj_compress \-i \fRlena.raw \fB-o \fRlena.j2k \fB-F \fR512,512,3,8,u
.P
.SH AUTHORS
Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
.br
Copyright (c) 2002-2014, Professor Benoit Macq
.br
Copyright (c) 2001-2003, David Janssens
.br
Copyright (c) 2002-2003, Yannick Verschueren
.br
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
.br
Copyright (c) 2005, Herve Drolon, FreeImage Team
.br
Copyright (c) 2006-2007, Parvatha Elangovan
.P
.SH "SEE ALSO"
opj_decompress(1) opj_dump(1)

View File

@ -1,119 +0,0 @@
'\" t
'\" The line above instructs most `man' programs to invoke tbl
'\"
'\" Separate paragraphs; not the same as PP which resets indent level.
.de SP
.if t .sp .5
.if n .sp
..
'\"
'\" Replacement em-dash for nroff (default is too short).
.ie n .ds m " -
.el .ds m \(em
'\"
'\" Placeholder macro for if longer nroff arrow is needed.
.ds RA \(->
'\"
'\" Decimal point set slightly raised
.if t .ds d \v'-.15m'.\v'+.15m'
.if n .ds d .
'\"
'\" Enclosure macro for examples
.de EX
.SP
.nf
.ft CW
..
.de EE
.ft R
.SP
.fi
..
.TH opj_decompress 1 "Version 2.1.1" "opj_decompress" "converts jpeg2000 files"
.P
.SH NAME
opj_decompress \-
This program reads in a jpeg2000 image and converts it to another
image type. It is part of the OpenJPEG library.
.SP
Valid input image extensions are
.B .j2k, .jp2, .j2c, .jpt
.SP
Valid output image extensions are
.B .bmp, .pgm, .pgx, .png, .pnm, .ppm, .raw, .tga, .tif \fR. For PNG resp. TIF it needs libpng resp. libtiff .
.SH SYNOPSIS
.P
.B opj_decompress \-i \fRinfile.j2k \fB-o \fRoutfile.png
.P
.B opj_decompress \-ImgDir \fRimages/ \fB-OutFor \fRbmp
.P
.B opj_decompress \-h \fRPrint help message and exit
.P
See JPWL OPTIONS for special options
.SH OPTIONS
.TP
.B \-\^i "name"
(jpeg2000 input file name)
.TP
.B \-\^l "n"
n is the maximum number of quality layers to decode. See LAYERS below)
.TP
.B \-\^o "name"
(output file name with extension)
.TP
.B \-\^r "n"
(n is the highest resolution level to be discarded. See REDUCTION below)
.TP
.B \-\^x "name"
(use name as index file and fill it)
.TP
.B \-\^ImgDir "directory_name"
(directory containing input files)
.TP
.B \-\^OutFor "ext"
(extension for output files)
.P
.SH JPIP OPTIONS
Options usable only if the library has been compiled with
.B BUILD_JPIP
.TP
.B -jpip
Embed index table box into the output JP2 file (compulsory for JPIP)
.TP
.B -TP R
Partition a tile into tile parts of different resolution levels (compulsory for JPT-stream)
.P
.SH JPWL OPTIONS
Options usable only if the library has been compiled with
.B BUILD_JPWL
.TP
.B -W c\fR[=Nc] (Nc is the number of expected components in the codestream; default:3)
.TP
.B -W t\fR[=Nt] (Nt is the maximum number of tiles in the codestream; default:8192)
.TP
.B -W c\fR[=Nc]\fB, t\fR[=Nt] \fR(same as above)
.P
.SH REDUCTION
Set the number of highest resolution levels to be discarded.
The image resolution is effectively divided by 2 to the power of the number of discarded levels. The reduce factor is limited by the smallest total number of decomposition levels among tiles.
.SH TILES
Set the maximum number of quality layers to decode. If there are less quality layers than the specified number, all the quality layers are decoded.
.P
'\".SH BUGS
.SH AUTHORS
Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
.br
Copyright (c) 2002-2014, Professor Benoit Macq
.br
Copyright (c) 2001-2003, David Janssens
.br
Copyright (c) 2002-2003, Yannick Verschueren
.br
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
.br
Copyright (c) 2005, Herve Drolon, FreeImage Team
.br
Copyright (c) 2006-2007, Parvatha Elangovan
.P
.SH "SEE ALSO"
opj_compress(1) opj_dump(1)

View File

@ -1,62 +0,0 @@
'\" t
'\" The line above instructs most `man' programs to invoke tbl
'\"
'\" Separate paragraphs; not the same as PP which resets indent level.
.de SP
.if t .sp .5
.if n .sp
..
'\"
'\" Replacement em-dash for nroff (default is too short).
.ie n .ds m " -
.el .ds m \(em
'\"
'\" Placeholder macro for if longer nroff arrow is needed.
.ds RA \(->
'\"
'\" Decimal point set slightly raised
.if t .ds d \v'-.15m'.\v'+.15m'
.if n .ds d .
'\"
'\" Enclosure macro for examples
.de EX
.SP
.nf
.ft CW
..
.de EE
.ft R
.SP
.fi
..
.TH opj_dump 1 "Version 2.1.1" "opj_dump" "dumps jpeg2000 files"
.P
.SH NAME
opj_dump \-
This program reads in a jpeg2000 image and dumps the contents to stdout. It is part of the OpenJPEG library.
.SP
Valid input image extensions are
.B .j2k, .jp2, .jpt
.SP
.SH SYNOPSIS
.P
.B opj_dump \-i \fRinfile.j2k
.P
.B opj_dump \-ImgDir \fRimages/ \fRDump all files in images/
.P
.B opj_dump \-h \fRPrint help message and exit
.P
.SH OPTIONS
.TP
.B \-\^i "name"
(jpeg2000 input file name)
.TP
.B \-\^ImgDir "directory_name"
(directory containing jpeg2000 input files)
.P
'\".SH BUGS
.SH AUTHORS
Copyright (c) 2010, Mathieu Malaterre
.P
.SH "SEE ALSO"
opj_compress(1) opj_decompress(1)

View File

@ -1,337 +0,0 @@
'\" t
'\" The line above instructs most `man' programs to invoke tbl
'\"
'\" Separate paragraphs; not the same as PP which resets indent level.
.de SP
.if t .sp .5
.if n .sp
..
'\"
'\" Replacement em-dash for nroff (default is too short).
.ie n .ds m " -
.el .ds m \(em
'\"
'\" Placeholder macro for if longer nroff arrow is needed.
.ds RA \(->
'\"
'\" Decimal point set slightly raised
.if t .ds d \v'-.15m'.\v'+.15m'
.if n .ds d .
'\"
'\" Enclosure macro for examples
.de EX
.SP
.nf
.ft CW
..
.de EE
.ft R
.SP
.fi
..
.TH libopenjp2 3 "Oct 2010" "Version 1.4.0" "Oct 2010"
.P
.SH NAME
libopenjp2 -
a library for reading and writing JPEG2000 image files.
.SP
.SH SYNOPSIS
.P
.B #include <openjpeg.h>
.P
.SS CONVERSION FORMATS
.B PGX: imagetopgx() \fR/\fB pgxtoimage()
.P
.B PXM: imagetopnm() \fR/\fB pnmtoimage()
.P
.B BMP: imagetobmp() \fR/\fB bmptoimage()
.P
.B TIF: imagetotif() \fR/\fB tiftoimage()
.P
.B RAW: imagetoraw() \fR/\fB rawtoimage()
.P
.B TGA: imagetotga() \fR/\fB tgatoimage()
.P
.B PNG: imagetopng() \fR/\fB pngtoimage()
.P
.B YUV: imagetoyuv() \fR/\fB yuvtoimage() \fR(MJ2)
.P
.SS READ
.B opj_set_default_decoder_parameters(opj_dparameters_t *\fIparams\fB);
.P
.B opj_dinfo_t *opj_create_decompress(OPJ_CODEC_FORMAT \fIformat\fB);
.P
.B opj_event_mgr_t *opj_set_event_mgr(opj_common_ptr \fIinfo\fB, opj_event_mgr_t *\fIevent_mgr\fB, void *\fIcontext\fB);
.P
.B void opj_setup_decoder(opj_dinfo_t *\fIdinfo\fB, opj_dparameters_t * \fIparams\fB);
.P
.B opj_cio_t *opj_cio_open(opj_common_ptr \fIinfo\fB, unsigned char *\fIbuf\fB, int \fIbuf_len\fB);
.P
.B opj_image_t *opj_decode(opj_dinfo_t *\fIdinfo\fB, opj_cio_t *\fIcio\fB);
.P
.B void opj_cio_close(opj_cio_t *\fIcio\fB);
.P
.B void opj_destroy_decompress(opj_dinfo_t *\fIdinfo\fB);
.P
.B void opj_image_destroy(opj_image_t *\fIimage\fB);
.P
.SS WRITE
.B void opj_set_default_encoder_parameters(opj_cparameters_t *\fIparams\fB);
.P
/*
.B opj_image_t *FORMATtoimage(const char *\fIfname\fB, opj_cparameters_t *\fIparams\fB);
.P
*/
.br
.B opj_cinfo_t* opj_create_compress(OPJ_CODEC_FORMAT \fIformat\fB);
.P
.B opj_event_mgr_t *opj_set_event_mgr(opj_common_ptr \fIinfo\fB, opj_event_mgr_t *\fIevent_mgr\fB, void *\fIcontext\fB);
.P
.B void opj_setup_encoder(opj_cinfo_t *\fIcinfo\fB, opj_cparameters_t *\fIparams\fB, opj_image_t *\fIimage\fB);
.P
.B opj_cio_t *opj_cio_open(opj_common_ptr \fIcinfo\fB, \fINULL\fB, \fI0\fB);
.P
.B bool opj_encode(opj_cinfo_t *\fIcinfo\fB, opj_cio_t *\fIcio\fB, opj_image_t *\fIimage\fB, char *\fIindex\fB);
.P
.B void opj_cio_close(opj_cio_t *\fIcio\fB);
.P
.B void opj_destroy_compress(opj_cinfo_t *\fIcinfo\fB);
.P
.B void opj_image_destroy(opj_image_t *\fIimage\fB);
.P
.SS GENERAL
.P
.B void opj_image_create(int \fInumcmpts\fB, opj_image_cmptparm_t *\fIcmptparms\fB, OPJ_COLOR_SPACE \fIclrspc\fB);
.P
.B int cio_tell(opj_cio_t *\fIcio\fB);
.P
.B void cio_seek(opj_cio_t *\fIcio\fB, int \fIpos\fB);
.P
.B opj_image_t *opj_decode_with_info(opj_dinfo_t *\fIdinfo\fB, opj_cio_t *\fIcio\fB, opj_codestream_info_t *\fIcstr_info\fB);
.P
.B bool opj_encode_with_info(opj_cinfo_t *\fIcinfo\fB, opj_cio_t *\fIcio\fB, opj_image_t *\fIimage\fB, opj_codestream_info_t *\fIcstr_info\fB);
.P
.B void opj_destroy_cstr_info(opj_codestream_info_t *\fIcstr_info\fB);
.P
.B const char *opj_version(\fIvoid\fB);
.P
.SH OPJ_CODEC_FORMAT
.P
.B CODEC_J2K\fR or \fBCODEC_JPT\fR or \fBCODEC_JP2
.P
.SH OPJ_COLOR_SPACE
.P
.B CLRSPC_UNKNOWN\fR or \fBCLRSPC_UNSPECIFIED\fR or \fBCLRSPC_SRGB\fR or \fBCLRSPC_GRAY\fR or \fBCLRSPC_SYCC
.P
.SH DECOMPRESSION PARAMETERS
.p
typedef struct opj_dparameters
.br
{
/*
Set the number of highest resolution levels to be discarded.
The image resolution is effectively divided by 2 to the power
of the number of discarded levels.
The reduce factor is limited by the smallest total number of
decomposition levels among tiles.
if != 0, then original dimension divided by 2^(reduce);
if == 0 or not used, image is decoded to the full resolution
*/
\fBint\fR cp_reduce;
/*
Set the maximum number of quality layers to decode.
If there are less quality layers than the specified number,
all the quality layers are decoded.
if != 0, then only the first "layer" layers are decoded;
if == 0 or not used, all the quality layers are decoded
*/
\fBint\fR cp_layer;
/*command line encoder parameters (not used inside the library) */
/* input file name */
\fBchar\fR infile[OPJ_PATH_LEN];
/* output file name */
\fBchar\fR outfile[OPJ_PATH_LEN];
/* input file format: see OPJ_CODEC_FORMAT */
\fBint\fR decod_format;
/* output file format */
\fBint\fR cod_format;
/*JPWL decoding parameters */
/* activates the JPWL correction capabilities */
\fBbool\fR jpwl_correct;
/* expected number of components */
\fBint\fR jpwl_exp_comps;
/* maximum number of tiles */
\fBint\fR jpwl_max_tiles;
/*
Specify whether the decoding should be done on the entire
codestream, or be limited to the main header
Limiting the decoding to the main header makes it possible
to extract the characteristics of the codestream
if == NO_LIMITATION, the entire codestream is decoded;
if == LIMIT_TO_MAIN_HEADER, only the main header is decoded;
*/
\fBOPJ_LIMIT_DECODING\fR cp_limit_decoding;
.br
} opj_dparameters_t;
.SH COMPRESSION PARAMETERS
.P
typedef struct opj_cparameters
.br
{
/* size of tile: tile_size_on = false (not in argument)
or tile_size_on = true (in argument) */
\fBbool\fR tile_size_on;
/* XTOsiz */
\fBint\fR cp_tx0;
/* YTOsiz */
\fBint\fR cp_ty0;
/* XTsiz */
\fBint\fR cp_tdx;
/* YTsiz */
\fBint\fR cp_tdy;
/* allocation by rate/distortion */
\fBint\fR cp_disto_alloc;
/* allocation by fixed layer */
\fBint\fR cp_fixed_alloc;
/* add fixed_quality */
\fBint\fR cp_fixed_quality;
/* fixed layer */
\fBint *\fRcp_matrice;
/* comment for coding */
\fBchar *\fRcp_comment;
/* coding style */
\fBint\fR csty;
/* progression order:
PROG_UNKNOWN, LRCP(default), RLCP, RPCL, PCRL, CPRL */
\fBOPJ_PROG_ORDER\fR prog_order;
/* progression order changes */
\fBopj_poc_t\fR POC[32];
/* number of progression order changes (POC), default: 0 */
\fBint\fR numpocs;
/* number of layers */
\fBint\fR tcp_numlayers;
/* rates of layers */
\fBfloat\fR tcp_rates[100];
/* different psnr for successive layers */
\fBfloat\fR tcp_distoratio[100];
/* number of resolutions */
\fBint\fR numresolution;
/* initial code block width, default: 64 */
\fBint\fR cblockw_init;
/* initial code block height, default: 64 */
\fBint\fR cblockh_init;
/* mode switch (cblk_style) */
/* 1 : use the irreversible DWT 9-7,
0 : use lossless compression (default) */
\fBint\fR irreversible;
/* region of interest: affected component in [0..3],
-1 means no ROI */
\fBint\fR roi_compno;
/* region of interest: upshift value */
\fBint\fR roi_shift;
/* number of precinct size specifications */
\fBint\fR res_spec;
/* initial precinct width */
\fBint\fR prcw_init[J2K_MAXRLVLS];
/* initial precinct height */
\fBint\fR prch_init[J2K_MAXRLVLS];
/*command line encoder parameters (not used inside the library) */
/* input file name */
\fBchar\fR infile[OPJ_PATH_LEN];
/* output file name */
\fBchar\fR outfile[OPJ_PATH_LEN];
/* DEPRECATED. Index generation is now handeld with the
opj_encode_with_info() function. Set to NULL */
\fBint\fR index_on;
/* DEPRECATED. Index generation is now handeld with the
opj_encode_with_info() function. Set to NULL */
\fBchar\fR index[OPJ_PATH_LEN];
/* subimage encoding: origin image offset in x direction */
\fBint\fR image_offset_x0;
/* subimage encoding: origin image offset in y direction */
\fBint\fR image_offset_y0;
/* subsampling value for dx */
\fBint\fR subsampling_dx;
/* subsampling value for dy */
\fBint\fR subsampling_dy;
/* input file format */
\fBint\fR decod_format;
/* output file format: see OPJ_CODEC_FORMAT */
\fBint\fR cod_format;
/*JPWL encoding parameters */
/* enables writing of EPC in MH, thus activating JPWL */
\fBbool\fR jpwl_epc_on;
/* error protection method for MH (0,1,16,32,37-128) */
\fBint\fR jpwl_hprot_MH;
/* tile number of header protection specification (>=0) */
\fBint\fR jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
/* error protection methods for TPHs (0,1,16,32,37-128) */
\fBint\fR jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS];
/* tile number of packet protection specification (>=0) */
\fBint\fR jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS];
/* packet number of packet protection specification (>=0) */
\fBint\fR jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS];
/* error protection methods for packets (0,1,16,32,37-128) */
\fBint\fR jpwl_pprot[JPWL_MAX_NO_PACKSPECS];
/* enables writing of ESD, (0=no/1/2 bytes) */
\fBint\fR jpwl_sens_size;
/* sensitivity addressing size (0=auto/2/4 bytes) */
\fBint\fR jpwl_sens_addr;
/* sensitivity range (0-3) */
\fBint\fR jpwl_sens_range;
/* sensitivity method for MH (-1=no,0-7) */
\fBint\fR jpwl_sens_MH;
/* tile number of sensitivity specification (>=0) */
\fBint\fR jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
/* sensitivity methods for TPHs (-1=no,0-7) */
\fBint\fR jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS];
/* Digital Cinema compliance: OFF-not compliant,
CINEMA2K_24, CINEMA2K_48, CINEMA4K_24 */
\fBOPJ_CINEMA_MODE\fR cp_cinema;
/* Maximum rate for each component.
If == 0, component size limitation is not considered */
\fBint\fR max_comp_size;
/* Profile name*/
\fBOPJ_RSIZ_CAPABILITIES\fR cp_rsiz;
/* Tile part generation*/
\fBchar\fR tp_on;
/* Flag for Tile part generation*/
\fBchar\fR tp_flag;
/* MCT (multiple component transform) */
\fBchar\fR tcp_mct;
.br
} opj_cparameters_t;
'\".SH OPTIONS
'\".SH BUGS
.SH AUTHORS
Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
Copyright (c) 2002-2014, Professor Benoit Macq
Copyright (c) 2001-2003, David Janssens
Copyright (c) 2002-2003, Yannick Verschueren
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
Copyright (c) 2005, Herve Drolon, FreeImage Team
Copyright (c) 2006-2007, Parvatha Elangovan
.P
.SH "SEE ALSO"
\fBimage_to_j2k\fR(1) \fBj2k_to_image\fR(1) \fBj2k_dump\fR(1)
\fBJPWL_image_to_j2k\fR(1) \fBJPWL_j2k_to_image\fR(1)
\fBextract_j2k_from_mj2\fR(1) \fBwrap_j2k_in_mj2\fR(1)
\fBframes_to_mj2\fR(1) \fBmj2_to_frames\fR(1)

View File

@ -1,94 +0,0 @@
/*
* $Id$
*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2010-2011, Kaori Hagihara
* 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.
*/
/*! \page openjpippage OpenJPIP v@OPENJPEG_VERSION@ Documentation
*
* \section Introduction
* This manual documents the low-level OpenJPIP C API.\n
* OpenJPIP software is an implementation of JPEG 2000 Part9: Interactivity tools, APIs and protocols (JPIP).\n
* ( For more info about JPIP, check the website: http://www.jpeg.org/jpeg2000/j2kpart9.html)\n
*
* This whole documents covers the following six programs.\n
* - opj_server.c JPIP server supporting HTTP connection and JPT/JPP-stream
* - opj_dec_server.c Server to decode JPT/JPP-stream and communicate locally with JPIP client, which is coded in java
* - opj_jpip_addxml.c To Embed metadata into JP2 file
* - opj_jpip_transcode.c To Convert JPT/JPP-stream to JP2 or J2K
* - opj_jpip_test.c To test index code format of a JP2 file
*
* \section 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.
*
*
* \section reqlibs Required libraries
* - OpenJPEG library
* - FastCGI development kit (C libraries) at server (http://www.fastcgi.com)
* - libcURL library
*
* We tested this software with a virtual server running on the same Linux machine as the clients.
*
*
* \section compilenotes Compiling Notes
* When you are making opj_server, set anything (e.g. yes) to the parameter jpipserver to define itself in the Makefile, which enables to make it in server mode.\n
* Otherwise do not define (or do not set to) the parameter jpipserver.\n
* Be sure that any object files and library file libopenjpip.a are not reused to compile in the two different mode (server mode and non server mode).\n
* In other words, do make clean before making new targets which are in different modes as previous make.\n
*
*
* \section sysarchtect System Architecture
* JPIP protocol is implemented between the JPIP server program (opj_server) and the JPIP client java program (opj_viewer).\n
* Figure below represents the overview of our system architecture.\n
* The JPIP server parses JPIP query and sends corresponding JPT/JPP-stream.
* The JPIP client viewer is an image viewer with GUI to publish JPIP requests and receive JPT/JPP-stream.\n
* Particularly, our system has the image decoding module implemented on a server (opj_dec_server, Image decoding Server).
* Image decoding Server and JPIP client viewer communicate closely.
* This specific architecture enables sharing cache of image codestream data among all viewers connected to the same Image decoding Server not only locally but also remotely.
*
* \image html jpip_architect.png "OpenJPIP system architecture"
*
* JPIP server follows up the client cache during a session. \n
* Concretely, the JPIP server models cache in each session, to which Channel IDs are associated.
* A Channel ID identifies a JPIP client viewer.
* And, new viewers can belong to a session by referring to one of its channel ID.
* The Image decoding Server maintains the association between channel IDs and targets, and provides a reference channel ID to a Viewer on demand.\n
*
* Typical requests and replies among JPIP server, JPIP client, and Image decoding server is presented below.\n
* The JPIP server parses HTTP query and sends corresponding JPT/JPP-stream back to the JPIP client (Viewer).
* JPT/JPP-stream is unreadable by JPIP client, and it is directly passed to Image decoding Server, and which provides the image in raw format (PGM or PPM) to the JPIP client.
* The Image decoding Server handles the decoding and caching of JPT/JPP-stream.
* JPIP client can read PGM and PPM images natively.
* Before connecting to the JPIP server, every JPIP client checks local cache data of the requesting image with the image decoding server.
* If its cache exists, the image decoding server provides ChannelID (CID), which identifies the image and its cache model on the JPIP server, and the whole system can continue the session using the CID.
*
* \image html jpip_protocol.png "Message Sequence Chart of OpenJPIP implementation"
*
* \author Kaori Hagihara UCL/SST/ICTM/ELEN
*/

View File

@ -0,0 +1,80 @@
INCLUDE_REGULAR_EXPRESSION("^.*$")
# Defines the source code for the library
SET(OPENJPEG_SRCS
tcd.c
bio.c
cio.c
dwt.c
event.c
image.c
j2k.c
j2k_lib.c
jp2.c
jpt.c
mct.c
mqc.c
openjpeg.c
pi.c
raw.c
t1.c
tgt.c
profile.c
invert.c
function_list.c
t2.c
bio.h
cio.h
dwt.h
event.h
image.h
j2k.h
j2k_lib.h
jp2.h
jpt.h
mct.h
mqc.h
openjpeg.h
pi.h
int.h
raw.h
t1.h
t2.h
tcd.h
tgt.h
profile.h
invert.h
function_list.h
)
# Pass proper definition to preprocessor to generate shared lib
IF(WIN32)
IF(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DOPJ_EXPORTS)
ELSE(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DOPJ_STATIC)
ENDIF(BUILD_SHARED_LIBS)
ENDIF(WIN32)
IF(ENABLE_PROFILING)
ADD_DEFINITIONS(-D_PROFILE)
ENDIF(ENABLE_PROFILING)
# Create the library
ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS})
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME} PROPERTIES
${OPENJPEG_LIBRARY_PROPERTIES})
IF(UNIX)
TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME} m)
ENDIF(UNIX)
# Install library
INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}
EXPORT OpenJPEGTargets
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
)
# Install includes files
INSTALL(FILES openjpeg.h
DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers
)

189
libopenjpeg/bio.c Normal file
View File

@ -0,0 +1,189 @@
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#include "bio.h"
#include "opj_malloc.h"
/** @defgroup BIO BIO - Individual bit input-output stream */
/*@{*/
/** @name Local static functions */
/*@{*/
/**
Write a bit
@param bio BIO handle
@param b Bit to write (0 or 1)
*/
static void bio_putbit(opj_bio_t *bio, OPJ_UINT32 b);
/**
Read a bit
@param bio BIO handle
@return Returns the read bit
*/
static OPJ_UINT32 bio_getbit(opj_bio_t *bio);
/**
Write a byte
@param bio BIO handle
@return Returns 0 if successful, returns 1 otherwise
*/
static bool bio_byteout(opj_bio_t *bio);
/**
Read a byte
@param bio BIO handle
@return Returns 0 if successful, returns 1 otherwise
*/
static bool bio_bytein(opj_bio_t *bio);
/*@}*/
/*@}*/
/*
==========================================================
local functions
==========================================================
*/
static bool bio_byteout(opj_bio_t *bio) {
bio->buf = (bio->buf << 8) & 0xffff;
bio->ct = bio->buf == 0xff00 ? 7 : 8;
if (bio->bp >= bio->end) {
return true;
}
*bio->bp++ = bio->buf >> 8;
return false;
}
static bool bio_bytein(opj_bio_t *bio) {
bio->buf = (bio->buf << 8) & 0xffff;
bio->ct = bio->buf == 0xff00 ? 7 : 8;
if (bio->bp >= bio->end) {
return true;
}
bio->buf |= *bio->bp++;
return false;
}
static void bio_putbit(opj_bio_t *bio, OPJ_UINT32 b) {
if (bio->ct == 0) {
bio_byteout(bio);
}
bio->ct--;
bio->buf |= b << bio->ct;
}
static OPJ_UINT32 bio_getbit(opj_bio_t *bio) {
if (bio->ct == 0) {
bio_bytein(bio);
}
bio->ct--;
return (bio->buf >> bio->ct) & 1;
}
/*
==========================================================
Bit Input/Output interface
==========================================================
*/
opj_bio_t* bio_create(void) {
opj_bio_t *bio = (opj_bio_t*)opj_malloc(sizeof(opj_bio_t));
return bio;
}
void bio_destroy(opj_bio_t *bio) {
if(bio) {
opj_free(bio);
}
}
OPJ_UINT32 bio_numbytes(opj_bio_t *bio) {
return (bio->bp - bio->start);
}
void bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
bio->start = bp;
bio->end = bp + len;
bio->bp = bp;
bio->buf = 0;
bio->ct = 8;
}
void bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
bio->start = bp;
bio->end = bp + len;
bio->bp = bp;
bio->buf = 0;
bio->ct = 0;
}
void bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n) {
OPJ_UINT32 i;
for (i = n - 1; i != -1 ; --i) {
bio_putbit(bio, (v >> i) & 1);
}
}
OPJ_UINT32 bio_read(opj_bio_t *bio, OPJ_UINT32 n) {
OPJ_UINT32 i, v;
v = 0;
for (i = n - 1; i != -1 ; --i) {
v += bio_getbit(bio) << i;
}
return v;
}
bool bio_flush(opj_bio_t *bio) {
bio->ct = 0;
if (bio_byteout(bio)) {
return true;
}
if (bio->ct == 7) {
bio->ct = 0;
if (bio_byteout(bio)) {
return true;
}
}
return false;
}
bool bio_inalign(opj_bio_t *bio) {
bio->ct = 0;
if ((bio->buf & 0xff) == 0xff) {
if (bio_bytein(bio)) {
return true;
}
bio->ct = 0;
}
return false;
}

View File

@ -1,16 +1,11 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux
* Copyright (c) 2003-2014, Antonin Descampe
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -35,18 +30,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OPJ_BIO_H
#define OPJ_BIO_H
#include <stddef.h> /* ptrdiff_t */
/**
#ifndef __BIO_H
#define __BIO_H
/**
@file bio.h
@brief Implementation of an individual bit input-output (BIO)
The functions in BIO.C have for goal to realize an individual bit input - output.
*/
#include "openjpeg.h"
/** @defgroup BIO BIO - Individual bit input-output stream */
/*@{*/
@ -54,89 +46,81 @@ The functions in BIO.C have for goal to realize an individual bit input - output
Individual bit input-output stream (BIO)
*/
typedef struct opj_bio {
/** pointer to the start of the buffer */
OPJ_BYTE *start;
/** pointer to the end of the buffer */
OPJ_BYTE *end;
/** pointer to the present position in the buffer */
OPJ_BYTE *bp;
/** temporary place where each byte is read or written */
OPJ_UINT32 buf;
/** coder : number of bits free to write. decoder : number of bits read */
OPJ_UINT32 ct;
/** pointer to the start of the buffer */
OPJ_BYTE *start;
/** pointer to the end of the buffer */
OPJ_BYTE *end;
/** pointer to the present position in the buffer */
OPJ_BYTE *bp;
/** temporary place where each byte is read or written */
OPJ_UINT32 buf;
/** coder : number of bits free to write. decoder : number of bits read */
OPJ_UINT32 ct;
} opj_bio_t;
/** @name Exported functions */
/*@{*/
/* ----------------------------------------------------------------------- */
/**
Create a new BIO handle
Create a new BIO handle
@return Returns a new BIO handle if successful, returns NULL otherwise
*/
opj_bio_t* opj_bio_create(void);
opj_bio_t* bio_create(void);
/**
Destroy a previously created BIO handle
@param bio BIO handle to destroy
*/
void opj_bio_destroy(opj_bio_t *bio);
void bio_destroy(opj_bio_t *bio);
/**
Number of bytes written.
@param bio BIO handle
@return Returns the number of bytes written
*/
ptrdiff_t opj_bio_numbytes(opj_bio_t *bio);
OPJ_UINT32 bio_numbytes(opj_bio_t *bio);
/**
Init encoder
@param bio BIO handle
@param bp Output buffer
@param len Output buffer length
@param len Output buffer length
*/
void opj_bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len);
void bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len);
/**
Init decoder
@param bio BIO handle
@param bp Input buffer
@param len Input buffer length
@param len Input buffer length
*/
void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len);
void bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len);
/**
Write bits
@param bio BIO handle
@param v Value of bits
@param n Number of bits to write
*/
void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n);
/**
Write a bit
@param bio BIO handle
@param b Bit to write (0 or 1)
*/
void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b);
void bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n);
/**
Read bits
@param bio BIO handle
@param n Number of bits to read
@param n Number of bits to read
@return Returns the corresponding read number
*/
OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n);
OPJ_UINT32 bio_read(opj_bio_t *bio, OPJ_UINT32 n);
/**
Flush bits
@param bio BIO handle
@return Returns OPJ_TRUE if successful, returns OPJ_FALSE otherwise
@return Returns 1 if successful, returns 0 otherwise
*/
OPJ_BOOL opj_bio_flush(opj_bio_t *bio);
bool bio_flush(opj_bio_t *bio);
/**
Passes the ending bits (coming from flushing)
@param bio BIO handle
@return Returns OPJ_TRUE if successful, returns OPJ_FALSE otherwise
@return Returns 1 if successful, returns 0 otherwise
*/
OPJ_BOOL opj_bio_inalign(opj_bio_t *bio);
bool bio_inalign(opj_bio_t *bio);
/* ----------------------------------------------------------------------- */
/*@}*/
/*@}*/
#endif /* OPJ_BIO_H */
#endif /* __BIO_H */

828
libopenjpeg/cio.c Normal file
View File

@ -0,0 +1,828 @@
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#include "cio.h"
#include "opj_includes.h"
#include "opj_malloc.h"
#include "event.h"
/* ----------------------------------------------------------------------- */
/**
* Write some bytes to the given data buffer, this function is used in Big Endian cpus.
* @param p_buffer pointer the data buffer to write data to.
* @param p_value the value to write
* @param p_nb_bytes the number of bytes to write
*/
void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes)
{
const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + p_nb_bytes;
assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
memcpy(p_buffer,l_data_ptr,p_nb_bytes);
}
/**
* Write some bytes to the given data buffer, this function is used in Little Endian cpus.
* @param p_buffer pointer the data buffer to write data to.
* @param p_value the value to write
* @param p_nb_bytes the number of bytes to write
* @return the number of bytes written or -1 if an error occured
*/
void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes)
{
const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + p_nb_bytes - 1;
OPJ_UINT32 i;
assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
for
(i=0;i<p_nb_bytes;++i)
{
*(p_buffer++) = *(l_data_ptr--);
}
}
/**
* Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
* @param p_buffer pointer the data buffer to read data from.
* @param p_value pointer to the value that will store the data.
* @param p_nb_bytes the nb bytes to read.
* @return the number of bytes read or -1 if an error occured.
*/
void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes)
{
OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value);
assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
*p_value = 0;
memcpy(l_data_ptr+4-p_nb_bytes,p_buffer,p_nb_bytes);
}
/**
* Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
* @param p_buffer pointer the data buffer to read data from.
* @param p_value pointer to the value that will store the data.
* @param p_nb_bytes the nb bytes to read.
* @return the number of bytes read or -1 if an error occured.
*/
void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes)
{
OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value) + p_nb_bytes-1;
OPJ_UINT32 i;
assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
*p_value = 0;
for
(i=0;i<p_nb_bytes;++i)
{
*(l_data_ptr--) = *(p_buffer++);
}
}
/**
* Write some bytes to the given data buffer, this function is used in Big Endian cpus.
* @param p_buffer pointer the data buffer to write data to.
* @param p_value the value to write
* @return the number of bytes written or -1 if an error occured
*/
void opj_write_double_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value)
{
const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value);
memcpy(p_buffer,l_data_ptr,sizeof(OPJ_FLOAT64));
}
/**
* Write some bytes to the given data buffer, this function is used in Little Endian cpus.
* @param p_buffer pointer the data buffer to write data to.
* @param p_value the value to write
*/
void opj_write_double_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value)
{
const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + sizeof(OPJ_FLOAT64) - 1;
OPJ_UINT32 i;
for
(i=0;i<sizeof(OPJ_FLOAT64);++i)
{
*(p_buffer++) = *(l_data_ptr--);
}
}
/**
* Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
* @param p_buffer pointer the data buffer to read data from.
* @param p_value pointer to the value that will store the data.
*/
void opj_read_double_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value)
{
OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value);
memcpy(l_data_ptr,p_buffer,sizeof(OPJ_FLOAT64));
}
/**
* Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
* @param p_buffer pointer the data buffer to read data from.
* @param p_value pointer to the value that will store the data.
*/
void opj_read_double_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value)
{
OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value) + sizeof(OPJ_FLOAT64)-1;
OPJ_UINT32 i;
for
(i=0;i<sizeof(OPJ_FLOAT64);++i)
{
*(l_data_ptr--) = *(p_buffer++);
}
}
/**
* Write some bytes to the given data buffer, this function is used in Big Endian cpus.
* @param p_buffer pointer the data buffer to write data to.
* @param p_value the value to write
* @return the number of bytes written or -1 if an error occured
*/
void opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value)
{
const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value);
memcpy(p_buffer,l_data_ptr,sizeof(OPJ_FLOAT32));
}
/**
* Write some bytes to the given data buffer, this function is used in Little Endian cpus.
* @param p_buffer pointer the data buffer to write data to.
* @param p_value the value to write
*/
void opj_write_float_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value)
{
const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + sizeof(OPJ_FLOAT32) - 1;
OPJ_UINT32 i;
for
(i=0;i<sizeof(OPJ_FLOAT32);++i)
{
*(p_buffer++) = *(l_data_ptr--);
}
}
/**
* Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
* @param p_buffer pointer the data buffer to read data from.
* @param p_value pointer to the value that will store the data.
*/
void opj_read_float_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value)
{
OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value);
memcpy(l_data_ptr,p_buffer,sizeof(OPJ_FLOAT32));
}
/**
* Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
* @param p_buffer pointer the data buffer to read data from.
* @param p_value pointer to the value that will store the data.
*/
void opj_read_float_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value)
{
OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value) + sizeof(OPJ_FLOAT32)-1;
OPJ_UINT32 i;
for
(i=0;i<sizeof(OPJ_FLOAT32);++i)
{
*(l_data_ptr--) = *(p_buffer++);
}
}
/**
* Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream.
* @return a stream object.
*/
opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_UINT32 p_size,bool l_is_input)
{
opj_stream_private_t * l_stream = 00;
l_stream = (opj_stream_private_t*) opj_malloc(sizeof(opj_stream_private_t));
if
(! l_stream)
{
return 00;
}
memset(l_stream,0,sizeof(opj_stream_private_t));
l_stream->m_buffer_size = p_size;
l_stream->m_stored_data = (OPJ_BYTE *) opj_malloc(p_size);
if
(! l_stream->m_stored_data)
{
opj_free(l_stream);
return 00;
}
l_stream->m_current_data = l_stream->m_stored_data;
if
(l_is_input)
{
l_stream->m_status |= opj_stream_e_input;
l_stream->m_opj_skip = opj_stream_read_skip;
l_stream->m_opj_seek = opj_stream_read_seek;
}
else
{
l_stream->m_status |= opj_stream_e_output;
l_stream->m_opj_skip = opj_stream_write_skip;
l_stream->m_opj_seek = opj_stream_write_seek;
}
l_stream->m_read_fn = opj_stream_default_read;
l_stream->m_write_fn = opj_stream_default_write;
l_stream->m_skip_fn = opj_stream_default_skip;
l_stream->m_seek_fn = opj_stream_default_seek;
return (opj_stream_t *) l_stream;
}
/**
* Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream.
* @return a stream object.
*/
opj_stream_t* OPJ_CALLCONV opj_stream_default_create(bool l_is_input)
{
return opj_stream_create(J2K_STREAM_CHUNK_SIZE,l_is_input);
}
/**
* Destroys a stream created by opj_create_stream. This function does NOT close the abstract stream. If needed the user must
* close its own implementation of the stream.
*/
OPJ_API void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream)
{
opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
if
(l_stream)
{
opj_free(l_stream->m_stored_data);
l_stream->m_stored_data = 00;
opj_free(l_stream);
}
}
/**
* Sets the given function to be used as a read function.
* @param p_stream the stream to modify
* @param p_function the function to use a read function.
*/
OPJ_API void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream, opj_stream_read_fn p_function)
{
opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
if
((!l_stream) || (! (l_stream->m_status & opj_stream_e_input)))
{
return;
}
l_stream->m_read_fn = p_function;
}
OPJ_API void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream, opj_stream_seek_fn p_function)
{
opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
if
(!l_stream)
{
return;
}
l_stream->m_seek_fn = p_function;
}
/**
* Sets the given function to be used as a write function.
* @param p_stream the stream to modify
* @param p_function the function to use a write function.
*/
OPJ_API void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t* p_stream, opj_stream_write_fn p_function)
{
opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
if
((!l_stream )|| (! (l_stream->m_status & opj_stream_e_output)))
{
return;
}
l_stream->m_write_fn = p_function;
}
/**
* Sets the given function to be used as a skip function.
* @param p_stream the stream to modify
* @param p_function the function to use a skip function.
*/
OPJ_API void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream, opj_stream_skip_fn p_function)
{
opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
if
(! l_stream)
{
return;
}
l_stream->m_skip_fn = p_function;
}
/**
* Sets the given data to be used as a user data for the stream.
* @param p_stream the stream to modify
* @param p_data the data to set.
*/
OPJ_API void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t* p_stream, void * p_data)
{
opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
l_stream->m_user_data = p_data;
}
/**
* Reads some bytes from the stream.
* @param p_stream the stream to read data from.
* @param p_buffer pointer to the data buffer that will receive the data.
* @param p_size number of bytes to read.
* @param p_event_mgr the user event manager to be notified of special events.
* @return the number of bytes read, or -1 if an error occured or if the stream is at the end.
*/
OPJ_UINT32 opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_buffer, OPJ_UINT32 p_size, opj_event_mgr_t * p_event_mgr)
{
OPJ_UINT32 l_read_nb_bytes = 0;
if
(p_stream->m_bytes_in_buffer >= p_size)
{
memcpy(p_buffer,p_stream->m_current_data,p_size);
p_stream->m_current_data += p_size;
p_stream->m_bytes_in_buffer -= p_size;
l_read_nb_bytes += p_size;
p_stream->m_byte_offset += p_size;
return l_read_nb_bytes;
}
// we are now in the case when the remaining data if not sufficient
if
(p_stream->m_status & opj_stream_e_end)
{
l_read_nb_bytes += p_stream->m_bytes_in_buffer;
memcpy(p_buffer,p_stream->m_current_data,p_stream->m_bytes_in_buffer);
p_stream->m_current_data += p_stream->m_bytes_in_buffer;
p_stream->m_byte_offset += p_stream->m_bytes_in_buffer;
p_stream->m_bytes_in_buffer = 0;
return l_read_nb_bytes ? l_read_nb_bytes : -1;
}
// the flag is not set, we copy data and then do an actual read on the stream
if
(p_stream->m_bytes_in_buffer)
{
l_read_nb_bytes += p_stream->m_bytes_in_buffer;
memcpy(p_buffer,p_stream->m_current_data,p_stream->m_bytes_in_buffer);
p_stream->m_current_data = p_stream->m_stored_data;
p_buffer += p_stream->m_bytes_in_buffer;
p_size -= p_stream->m_bytes_in_buffer;
p_stream->m_byte_offset += p_stream->m_bytes_in_buffer;
p_stream->m_bytes_in_buffer = 0;
}
else
{
/* case where we are already at the end of the buffer
so reset the m_current_data to point to the start of the
stored buffer to get ready to read from disk*/
p_stream->m_current_data = p_stream->m_stored_data;
}
while
(true)
{
// we should read less than a chunk -> read a chunk
if
(p_size < p_stream->m_buffer_size)
{
// we should do an actual read on the media
p_stream->m_bytes_in_buffer = p_stream->m_read_fn(p_stream->m_stored_data,p_stream->m_buffer_size,p_stream->m_user_data);
if
(p_stream->m_bytes_in_buffer == -1)
{
// end of stream
opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n");
p_stream->m_bytes_in_buffer = 0;
p_stream->m_status |= opj_stream_e_end;
// end of stream
return l_read_nb_bytes ? l_read_nb_bytes : -1;
}
else if
(p_stream->m_bytes_in_buffer < p_size)
{
// not enough data
l_read_nb_bytes += p_stream->m_bytes_in_buffer;
memcpy(p_buffer,p_stream->m_current_data,p_stream->m_bytes_in_buffer);
p_stream->m_current_data = p_stream->m_stored_data;
p_buffer += p_stream->m_bytes_in_buffer;
p_size -= p_stream->m_bytes_in_buffer;
p_stream->m_byte_offset += p_stream->m_bytes_in_buffer;
p_stream->m_bytes_in_buffer = 0;
}
else
{
l_read_nb_bytes += p_size;
memcpy(p_buffer,p_stream->m_current_data,p_size);
p_stream->m_current_data += p_size;
p_stream->m_bytes_in_buffer -= p_size;
p_stream->m_byte_offset += p_size;
return l_read_nb_bytes;
}
}
else
{
// direct read on the dest buffer
p_stream->m_bytes_in_buffer = p_stream->m_read_fn(p_buffer,p_size,p_stream->m_user_data);
if
(p_stream->m_bytes_in_buffer == -1)
{
// end of stream
opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n");
p_stream->m_bytes_in_buffer = 0;
p_stream->m_status |= opj_stream_e_end;
// end of stream
return l_read_nb_bytes ? l_read_nb_bytes : -1;
}
else if
(p_stream->m_bytes_in_buffer < p_size)
{
// not enough data
l_read_nb_bytes += p_stream->m_bytes_in_buffer;
p_stream->m_current_data = p_stream->m_stored_data;
p_buffer += p_stream->m_bytes_in_buffer;
p_size -= p_stream->m_bytes_in_buffer;
p_stream->m_byte_offset += p_stream->m_bytes_in_buffer;
p_stream->m_bytes_in_buffer = 0;
}
else
{
// we have read the exact size
l_read_nb_bytes += p_stream->m_bytes_in_buffer;
p_stream->m_byte_offset += p_stream->m_bytes_in_buffer;
p_stream->m_current_data = p_stream->m_stored_data;
p_stream->m_bytes_in_buffer = 0;
return l_read_nb_bytes;
}
}
}
}
/**
* Writes some bytes from the stream.
* @param p_stream the stream to write data to.
* @param p_buffer pointer to the data buffer holds the data to be writtent.
* @param p_size number of bytes to write.
* @param p_event_mgr the user event manager to be notified of special events.
* @return the number of bytes writtent, or -1 if an error occured.
*/
OPJ_UINT32 opj_stream_write_data (opj_stream_private_t * p_stream,const OPJ_BYTE * p_buffer,OPJ_UINT32 p_size, opj_event_mgr_t * p_event_mgr)
{
OPJ_UINT32 l_remaining_bytes = 0;
OPJ_UINT32 l_write_nb_bytes = 0;
if
(p_stream->m_status & opj_stream_e_error)
{
return -1;
}
while
(true)
{
l_remaining_bytes = p_stream->m_buffer_size - p_stream->m_bytes_in_buffer;
// we have more memory than required
if
(l_remaining_bytes >= p_size)
{
memcpy(p_stream->m_current_data,p_buffer,p_size);
p_stream->m_current_data += p_size;
p_stream->m_bytes_in_buffer += p_size;
l_write_nb_bytes += p_size;
p_stream->m_byte_offset += p_size;
return l_write_nb_bytes;
}
// we copy data and then do an actual read on the stream
if
(l_remaining_bytes)
{
l_write_nb_bytes += l_remaining_bytes;
memcpy(p_stream->m_current_data,p_buffer,l_remaining_bytes);
p_stream->m_current_data = p_stream->m_stored_data;
p_buffer += l_remaining_bytes;
p_size -= l_remaining_bytes;
p_stream->m_bytes_in_buffer += l_remaining_bytes;
p_stream->m_byte_offset += l_remaining_bytes;
}
if
(! opj_stream_flush(p_stream, p_event_mgr))
{
return -1;
}
}
}
/**
* Writes the content of the stream buffer to the stream.
* @param p_stream the stream to write data to.
* @param p_event_mgr the user event manager to be notified of special events.
* @return the number of bytes written, or -1 if an error occured.
*/
bool opj_stream_flush (opj_stream_private_t * p_stream, opj_event_mgr_t * p_event_mgr)
{
// the number of bytes written on the media.
OPJ_UINT32 l_current_write_nb_bytes = 0;
p_stream->m_current_data = p_stream->m_stored_data;
while
(p_stream->m_bytes_in_buffer)
{
// we should do an actual write on the media
l_current_write_nb_bytes = p_stream->m_write_fn(p_stream->m_current_data,p_stream->m_bytes_in_buffer,p_stream->m_user_data);
if
(l_current_write_nb_bytes == -1)
{
p_stream->m_status |= opj_stream_e_error;
opj_event_msg(p_event_mgr, EVT_INFO, "Error on writting stream!\n");
return false;
}
p_stream->m_current_data += l_current_write_nb_bytes;
p_stream->m_bytes_in_buffer -= l_current_write_nb_bytes;
}
p_stream->m_current_data = p_stream->m_stored_data;
return true;
}
/**
* Skips a number of bytes from the stream.
* @param p_stream the stream to skip data from.
* @param p_size the number of bytes to skip.
* @param p_event_mgr the user event manager to be notified of special events.
* @return the number of bytes skipped, or -1 if an error occured.
*/
OPJ_SIZE_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, opj_event_mgr_t * p_event_mgr)
{
OPJ_SIZE_T l_skip_nb_bytes = 0;
OPJ_SIZE_T l_current_skip_nb_bytes = 0;
if
(p_stream->m_bytes_in_buffer >= p_size)
{
p_stream->m_current_data += p_size;
p_stream->m_bytes_in_buffer -= p_size;
l_skip_nb_bytes += p_size;
p_stream->m_byte_offset += l_skip_nb_bytes;
return l_skip_nb_bytes;
}
// we are now in the case when the remaining data if not sufficient
if
(p_stream->m_status & opj_stream_e_end)
{
l_skip_nb_bytes += p_stream->m_bytes_in_buffer;
p_stream->m_current_data += p_stream->m_bytes_in_buffer;
p_stream->m_bytes_in_buffer = 0;
p_stream->m_byte_offset += l_skip_nb_bytes;
return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_SIZE_T) -1;
}
// the flag is not set, we copy data and then do an actual skip on the stream
if
(p_stream->m_bytes_in_buffer)
{
l_skip_nb_bytes += p_stream->m_bytes_in_buffer;
p_stream->m_current_data = p_stream->m_stored_data;
p_size -= p_stream->m_bytes_in_buffer;
p_stream->m_bytes_in_buffer = 0;
}
while
(p_size > 0)
{
// we should do an actual skip on the media
l_current_skip_nb_bytes = p_stream->m_skip_fn(p_size, p_stream->m_user_data);
if
(l_current_skip_nb_bytes == (OPJ_SIZE_T) -1)
{
opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n");
p_stream->m_status |= opj_stream_e_end;
p_stream->m_byte_offset += l_skip_nb_bytes;
// end if stream
return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_SIZE_T) -1;
}
p_size -= l_current_skip_nb_bytes;
l_skip_nb_bytes += l_current_skip_nb_bytes;
}
p_stream->m_byte_offset += l_skip_nb_bytes;
return l_skip_nb_bytes;
}
/**
* Skips a number of bytes from the stream.
* @param p_stream the stream to skip data from.
* @param p_size the number of bytes to skip.
* @param p_event_mgr the user event manager to be notified of special events.
* @return the number of bytes skipped, or -1 if an error occured.
*/
OPJ_SIZE_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, opj_event_mgr_t * p_event_mgr)
{
bool l_is_written = 0;
OPJ_SIZE_T l_current_skip_nb_bytes = 0;
OPJ_SIZE_T l_skip_nb_bytes = 0;
if
(p_stream->m_status & opj_stream_e_error)
{
return (OPJ_SIZE_T) -1;
}
// we should flush data
l_is_written = opj_stream_flush (p_stream, p_event_mgr);
if
(! l_is_written)
{
p_stream->m_status |= opj_stream_e_error;
p_stream->m_bytes_in_buffer = 0;
p_stream->m_current_data = p_stream->m_current_data;
return (OPJ_SIZE_T) -1;
}
// then skip
while
(p_size > 0)
{
// we should do an actual skip on the media
l_current_skip_nb_bytes = p_stream->m_skip_fn(p_size, p_stream->m_user_data);
if
(l_current_skip_nb_bytes == (OPJ_SIZE_T)-1)
{
opj_event_msg(p_event_mgr, EVT_INFO, "Stream error!\n");
p_stream->m_status |= opj_stream_e_error;
p_stream->m_byte_offset += l_skip_nb_bytes;
// end if stream
return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_SIZE_T)-1;
}
p_size -= l_current_skip_nb_bytes;
l_skip_nb_bytes += l_current_skip_nb_bytes;
}
p_stream->m_byte_offset += l_skip_nb_bytes;
return l_skip_nb_bytes;
}
/**
* Tells the byte offset on the stream (similar to ftell).
*
* @param p_stream the stream to get the information from.
*
* @return the current position o fthe stream.
*/
OPJ_SIZE_T opj_stream_tell (const opj_stream_private_t * p_stream)
{
return p_stream->m_byte_offset;
}
/**
* Skips a number of bytes from the stream.
* @param p_stream the stream to skip data from.
* @param p_size the number of bytes to skip.
* @param p_event_mgr the user event manager to be notified of special events.
* @return the number of bytes skipped, or -1 if an error occured.
*/
OPJ_SIZE_T opj_stream_skip (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, opj_event_mgr_t * p_event_mgr)
{
return p_stream->m_opj_skip(p_stream,p_size,p_event_mgr);
}
/**
* Skips a number of bytes from the stream.
* @param p_stream the stream to skip data from.
* @param p_size the number of bytes to skip.
* @param p_event_mgr the user event manager to be notified of special events.
* @return the number of bytes skipped, or -1 if an error occured.
*/
bool opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, opj_event_mgr_t * p_event_mgr)
{
p_stream->m_current_data = p_stream->m_stored_data;
p_stream->m_bytes_in_buffer = 0;
if
(! p_stream->m_seek_fn(p_size,p_stream->m_user_data))
{
p_stream->m_status |= opj_stream_e_end;
return false;
}
else
{
// reset stream status
p_stream->m_status &= (~opj_stream_e_end);
p_stream->m_byte_offset = p_size;
}
return true;
}
/**
* Skips a number of bytes from the stream.
* @param p_stream the stream to skip data from.
* @param p_size the number of bytes to skip.
* @param p_event_mgr the user event manager to be notified of special events.
* @return the number of bytes skipped, or -1 if an error occured.
*/
bool opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, opj_event_mgr_t * p_event_mgr)
{
if
(! opj_stream_flush(p_stream,p_event_mgr))
{
p_stream->m_status |= opj_stream_e_error;
return false;
}
p_stream->m_current_data = p_stream->m_stored_data;
p_stream->m_bytes_in_buffer = 0;
if
(! p_stream->m_seek_fn(p_size,p_stream->m_user_data))
{
p_stream->m_status |= opj_stream_e_error;
return false;
}
else
{
p_stream->m_byte_offset = p_size;
}
return true;
}
/**
* Seeks a number of bytes from the stream.
* @param p_stream the stream to skip data from.
* @param p_size the number of bytes to skip.
* @param p_event_mgr the user event manager to be notified of special events.
* @return true if the stream is seekable.
*/
bool opj_stream_seek (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr)
{
return p_stream->m_opj_seek(p_stream,p_size,p_event_mgr);
}
/**
* Tells if the given stream is seekable.
*/
bool opj_stream_has_seek (const opj_stream_private_t * p_stream)
{
return p_stream->m_seek_fn != opj_stream_default_seek;
}
OPJ_UINT32 opj_stream_default_read (void * p_buffer, OPJ_UINT32 p_nb_bytes, void * p_user_data)
{
return (OPJ_UINT32) -1;
}
OPJ_UINT32 opj_stream_default_write (void * p_buffer, OPJ_UINT32 p_nb_bytes, void * p_user_data)
{
return (OPJ_UINT32) -1;
}
OPJ_SIZE_T opj_stream_default_skip (OPJ_SIZE_T p_nb_bytes, void * p_user_data)
{
return (OPJ_SIZE_T) -1;
}
bool opj_stream_default_seek (OPJ_SIZE_T p_nb_bytes, void * p_user_data)
{
return false;
}

359
libopenjpeg/cio.h Normal file
View File

@ -0,0 +1,359 @@
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#ifndef __CIO_H
#define __CIO_H
/**
@file cio.h
@brief Implementation of a byte input-output process (CIO)
The functions in CIO.C have for goal to realize a byte input / output process.
*/
/** @defgroup CIO CIO - byte input-output stream */
/*@{*/
#include "openjpeg.h"
#include "opj_configure.h"
struct opj_event_mgr;
/** @name Exported functions (see also openjpeg.h) */
/*@{*/
/* ----------------------------------------------------------------------- */
#if defined(OPJ_BIG_ENDIAN)
#if !defined(OPJ_LITTLE_ENDIAN)
#define opj_write_bytes opj_write_bytes_BE
#define opj_read_bytes opj_read_bytes_BE
#define opj_write_double opj_write_double_BE
#define opj_read_double opj_read_double_BE
#define opj_write_float opj_write_float_BE
#define opj_read_float opj_read_float_BE
#else
#error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not both."
#endif
#else
#if defined(OPJ_LITTLE_ENDIAN)
#define opj_write_bytes opj_write_bytes_LE
#define opj_read_bytes opj_read_bytes_LE
#define opj_write_double opj_write_double_LE
#define opj_read_double opj_read_double_LE
#define opj_write_float opj_write_float_LE
#define opj_read_float opj_read_float_LE
#else
#error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not none."
#endif
#endif
typedef enum
{
opj_stream_e_output = 0x1,
opj_stream_e_input = 0x2,
opj_stream_e_end = 0x4,
opj_stream_e_error = 0x8
}
opj_stream_flag ;
/**
Byte input-output stream.
*/
typedef struct opj_stream_private
{
/**
* User data, be it files, ... The actual data depends on the type of the stream.
*/
void * m_user_data;
/**
* Pointer to actual read function (NULL at the initialization of the cio.
*/
opj_stream_read_fn m_read_fn;
/**
* Pointer to actual write function (NULL at the initialization of the cio.
*/
opj_stream_write_fn m_write_fn;
/**
* Pointer to actual skip function (NULL at the initialization of the cio.
* There is no seek function to prevent from back and forth slow procedures.
*/
opj_stream_skip_fn m_skip_fn;
/**
* Pointer to actual seek function (if available).
*/
opj_stream_seek_fn m_seek_fn;
/**
* Actual data stored into the stream if readed from. Data is read by chunk of fixed size.
* you should never access this data directly.
*/
OPJ_BYTE * m_stored_data;
/**
* Pointer to the current read data.
*/
OPJ_BYTE * m_current_data;
OPJ_SIZE_T (* m_opj_skip)(struct opj_stream_private * ,OPJ_SIZE_T , struct opj_event_mgr *);
bool (* m_opj_seek) (struct opj_stream_private * , OPJ_SIZE_T , struct opj_event_mgr *);
/**
* number of bytes containing in the buffer.
*/
OPJ_UINT32 m_bytes_in_buffer;
/**
* The number of bytes read/written.
*/
OPJ_SIZE_T m_byte_offset;
/**
* The size of the buffer.
*/
OPJ_UINT32 m_buffer_size;
/**
* Flags to tell the status of the stream.
*/
OPJ_UINT32 m_status;
}
opj_stream_private_t;
/**
* Write some bytes to the given data buffer, this function is used in Big Endian cpus.
* @param p_buffer pointer the data buffer to write data to.
* @param p_value the value to write
* @param p_nb_bytes the number of bytes to write
*/
void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes);
/**
* Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
* @param p_buffer pointer the data buffer to read data from.
* @param p_value pointer to the value that will store the data.
* @param p_nb_bytes the nb bytes to read.
* @return the number of bytes read or -1 if an error occured.
*/
void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes);
/**
* Write some bytes to the given data buffer, this function is used in Little Endian cpus.
* @param p_buffer pointer the data buffer to write data to.
* @param p_value the value to write
* @param p_nb_bytes the number of bytes to write
* @return the number of bytes written or -1 if an error occured
*/
void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes);
/**
* Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
* @param p_buffer pointer the data buffer to read data from.
* @param p_value pointer to the value that will store the data.
* @param p_nb_bytes the nb bytes to read.
* @return the number of bytes read or -1 if an error occured.
*/
void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes);
/**
* Write some bytes to the given data buffer, this function is used in Little Endian cpus.
* @param p_buffer pointer the data buffer to write data to.
* @param p_value the value to write
*/
void opj_write_double_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value);
/***
* Write some bytes to the given data buffer, this function is used in Big Endian cpus.
* @param p_buffer pointer the data buffer to write data to.
* @param p_value the value to write
*/
void opj_write_double_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value);
/**
* Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
* @param p_buffer pointer the data buffer to read data from.
* @param p_value pointer to the value that will store the data.
*/
void opj_read_double_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value);
/**
* Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
* @param p_buffer pointer the data buffer to read data from.
* @param p_value pointer to the value that will store the data.
*/
void opj_read_double_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value);
/**
* Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
* @param p_buffer pointer the data buffer to read data from.
* @param p_value pointer to the value that will store the data.
*/
void opj_read_float_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value);
/**
* Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
* @param p_buffer pointer the data buffer to read data from.
* @param p_value pointer to the value that will store the data.
*/
void opj_read_float_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value);
/**
* Write some bytes to the given data buffer, this function is used in Little Endian cpus.
* @param p_buffer pointer the data buffer to write data to.
* @param p_value the value to write
*/
void opj_write_float_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
/***
* Write some bytes to the given data buffer, this function is used in Big Endian cpus.
* @param p_buffer pointer the data buffer to write data to.
* @param p_value the value to write
*/
void opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
/**
* Reads some bytes from the stream.
* @param p_stream the stream to read data from.
* @param p_buffer pointer to the data buffer that will receive the data.
* @param p_size number of bytes to read.
* @param p_event_mgr the user event manager to be notified of special events.
* @return the number of bytes read, or -1 if an error occured or if the stream is at the end.
*/
OPJ_UINT32 opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_buffer, OPJ_UINT32 p_size, struct opj_event_mgr * p_event_mgr);
/**
* Writes some bytes to the stream.
* @param p_stream the stream to write data to.
* @param p_buffer pointer to the data buffer holds the data to be writtent.
* @param p_size number of bytes to write.
* @param p_event_mgr the user event manager to be notified of special events.
* @return the number of bytes writtent, or -1 if an error occured.
*/
OPJ_UINT32 opj_stream_write_data (opj_stream_private_t * p_stream,const OPJ_BYTE * p_buffer, OPJ_UINT32 p_size, struct opj_event_mgr * p_event_mgr);
/**
* Writes the content of the stream buffer to the stream.
* @param p_stream the stream to write data to.
* @param p_event_mgr the user event manager to be notified of special events.
* @return true if the data could be flushed, false else.
*/
bool opj_stream_flush (opj_stream_private_t * p_stream, struct opj_event_mgr * p_event_mgr);
/**
* Skips a number of bytes from the stream.
* @param p_stream the stream to skip data from.
* @param p_size the number of bytes to skip.
* @param p_event_mgr the user event manager to be notified of special events.
* @return the number of bytes skipped, or -1 if an error occured.
*/
OPJ_SIZE_T opj_stream_skip (opj_stream_private_t * p_stream,OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
/**
* Tells the byte offset on the stream (similar to ftell).
*
* @param p_stream the stream to get the information from.
*
* @return the current position o fthe stream.
*/
OPJ_SIZE_T opj_stream_tell (const opj_stream_private_t * p_stream);
/**
* Skips a number of bytes from the stream.
* @param p_stream the stream to skip data from.
* @param p_size the number of bytes to skip.
* @param p_event_mgr the user event manager to be notified of special events.
* @return the number of bytes skipped, or -1 if an error occured.
*/
OPJ_SIZE_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
/**
* Skips a number of bytes from the stream.
* @param p_stream the stream to skip data from.
* @param p_size the number of bytes to skip.
* @param p_event_mgr the user event manager to be notified of special events.
* @return the number of bytes skipped, or -1 if an error occured.
*/
OPJ_SIZE_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
/**
* Skips a number of bytes from the stream.
* @param p_stream the stream to skip data from.
* @param p_size the number of bytes to skip.
* @param p_event_mgr the user event manager to be notified of special events.
* @return the number of bytes skipped, or -1 if an error occured.
*/
bool opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
/**
* Skips a number of bytes from the stream.
* @param p_stream the stream to skip data from.
* @param p_size the number of bytes to skip.
* @param p_event_mgr the user event manager to be notified of special events.
* @return the number of bytes skipped, or -1 if an error occured.
*/
bool opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
/**
* Seeks a number of bytes from the stream.
* @param p_stream the stream to skip data from.
* @param p_size the number of bytes to skip.
* @param p_event_mgr the user event manager to be notified of special events.
* @return true if the stream is seekable.
*/
bool opj_stream_seek (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
/**
* Tells if the given stream is seekable.
*/
bool opj_stream_has_seek (const opj_stream_private_t * p_stream);
OPJ_UINT32 opj_stream_default_read (void * p_buffer, OPJ_UINT32 p_nb_bytes, void * p_user_data);
OPJ_UINT32 opj_stream_default_write (void * p_buffer, OPJ_UINT32 p_nb_bytes, void * p_user_data);
OPJ_SIZE_T opj_stream_default_skip (OPJ_SIZE_T p_nb_bytes, void * p_user_data);
bool opj_stream_default_seek (OPJ_SIZE_T p_nb_bytes, void * p_user_data);
/* ----------------------------------------------------------------------- */
/*@}*/
/*@}*/
#endif /* __CIO_H */

874
libopenjpeg/dwt.c Normal file
View File

@ -0,0 +1,874 @@
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2007, Jonathan Ballard <dzonatas@dzonux.net>
* Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#ifdef __SSE__
#include <xmmintrin.h>
#endif
#include "dwt.h"
#include "j2k.h"
#include "tcd.h"
#include "fix.h"
#include "opj_malloc.h"
#include "int.h"
/** @defgroup DWT DWT - Implementation of a discrete wavelet transform */
/*@{*/
#define WS(i) v->mem[(i)*2]
#define WD(i) v->mem[(1+(i)*2)]
/** @name Local data structures */
/*@{*/
typedef struct dwt_local {
OPJ_INT32* mem;
OPJ_INT32 dn;
OPJ_INT32 sn;
OPJ_INT32 cas;
} dwt_t;
typedef union {
OPJ_FLOAT32 f[4];
} v4;
typedef struct v4dwt_local {
v4* wavelet ;
OPJ_INT32 dn ;
OPJ_INT32 sn ;
OPJ_INT32 cas ;
} v4dwt_t ;
static const OPJ_FLOAT32 dwt_alpha = 1.586134342f; // 12994
static const OPJ_FLOAT32 dwt_beta = 0.052980118f; // 434
static const OPJ_FLOAT32 dwt_gamma = -0.882911075f; // -7233
static const OPJ_FLOAT32 delta = -0.443506852f; // -3633
static const OPJ_FLOAT32 K = 1.230174105f; // 10078
/* FIXME: What is this constant? */
static const OPJ_FLOAT32 c13318 = 1.625732422f;
/*@}*/
/**
Virtual function type for wavelet transform in 1-D
*/
typedef void (*DWT1DFN)(dwt_t* v);
/** @name Local static functions */
/*@{*/
/**
Forward lazy transform (horizontal)
*/
static void dwt_deinterleave_h(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas);
/**
Forward lazy transform (vertical)
*/
static void dwt_deinterleave_v(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 x, OPJ_INT32 cas);
/**
Inverse lazy transform (horizontal)
*/
static void dwt_interleave_h(dwt_t* h, OPJ_INT32 *a);
/**
Inverse lazy transform (vertical)
*/
static void dwt_interleave_v(dwt_t* v, OPJ_INT32 *a, OPJ_INT32 x);
/**
Forward 5-3 wavelet transform in 1-D
*/
static void dwt_encode_1(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas);
/**
Inverse 5-3 wavelet transform in 1-D
*/
static void dwt_decode_1(dwt_t *v);
/**
Forward 9-7 wavelet transform in 1-D
*/
static void dwt_encode_1_real(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas);
/**
Explicit calculation of the Quantization Stepsizes
*/
static void dwt_encode_stepsize(OPJ_INT32 stepsize, OPJ_INT32 numbps, opj_stepsize_t *bandno_stepsize);
/**
Inverse wavelet transform in 2-D.
*/
static bool dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 i, DWT1DFN fn);
static OPJ_UINT32 dwt_max_resolution(opj_tcd_resolution_t* restrict r, OPJ_UINT32 i);
static bool dwt_encode_procedure(opj_tcd_tilecomp_t * tilec,void (*p_function)(OPJ_INT32 *, OPJ_INT32,OPJ_INT32,OPJ_INT32) );
/*@}*/
/*@}*/
#define S(i) a[(i)*2]
#define D(i) a[(1+(i)*2)]
#define S_(i) ((i)<0?S(0):((i)>=sn?S(sn-1):S(i)))
#define D_(i) ((i)<0?D(0):((i)>=dn?D(dn-1):D(i)))
/* new */
#define SS_(i) ((i)<0?S(0):((i)>=dn?S(dn-1):S(i)))
#define DD_(i) ((i)<0?D(0):((i)>=sn?D(sn-1):D(i)))
/* <summary> */
/* This table contains the norms of the 5-3 wavelets for different bands. */
/* </summary> */
static const OPJ_FLOAT64 dwt_norms[4][10] = {
{1.000, 1.500, 2.750, 5.375, 10.68, 21.34, 42.67, 85.33, 170.7, 341.3},
{1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
{1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
{.7186, .9218, 1.586, 3.043, 6.019, 12.01, 24.00, 47.97, 95.93}
};
/* <summary> */
/* This table contains the norms of the 9-7 wavelets for different bands. */
/* </summary> */
static const OPJ_FLOAT64 dwt_norms_real[4][10] = {
{1.000, 1.965, 4.177, 8.403, 16.90, 33.84, 67.69, 135.3, 270.6, 540.9},
{2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
{2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
{2.080, 3.865, 8.307, 17.18, 34.71, 69.59, 139.3, 278.6, 557.2}
};
/*
==========================================================
local functions
==========================================================
*/
/* <summary> */
/* Forward lazy transform (horizontal). */
/* </summary> */
static void dwt_deinterleave_h(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas) {
OPJ_INT32 i;
OPJ_INT32 * l_dest = b;
OPJ_INT32 * l_src = a+cas;
for
(i=0; i<sn; ++i)
{
*l_dest++ = *l_src;
l_src += 2;
}
l_dest = b + sn;
l_src = a + 1 - cas;
for
(i=0; i<dn; ++i)
{
*l_dest++=*l_src;
l_src += 2;
}
}
/* <summary> */
/* Forward lazy transform (vertical). */
/* </summary> */
static void dwt_deinterleave_v(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 x, OPJ_INT32 cas) {
OPJ_INT32 i = sn;
OPJ_INT32 * l_dest = b;
OPJ_INT32 * l_src = a+cas;
while
(i--)
{
*l_dest = *l_src;
l_dest += x;
l_src += 2;
/* b[i*x]=a[2*i+cas]; */
}
l_dest = b + sn * x;
l_src = a + 1 - cas;
i = dn;
while
(i--)
{
*l_dest = *l_src;
l_dest += x;
l_src += 2;
/*b[(sn+i)*x]=a[(2*i+1-cas)];*/
}
}
/* <summary> */
/* Inverse lazy transform (horizontal). */
/* </summary> */
static void dwt_interleave_h(dwt_t* h, OPJ_INT32 *a) {
OPJ_INT32 *ai = a;
OPJ_INT32 *bi = h->mem + h->cas;
OPJ_INT32 i = h->sn;
while
( i-- )
{
*bi = *(ai++);
bi += 2;
}
ai = a + h->sn;
bi = h->mem + 1 - h->cas;
i = h->dn ;
while
( i-- )
{
*bi = *(ai++);
bi += 2;
}
}
/* <summary> */
/* Inverse lazy transform (vertical). */
/* </summary> */
static void dwt_interleave_v(dwt_t* v, OPJ_INT32 *a, OPJ_INT32 x) {
OPJ_INT32 *ai = a;
OPJ_INT32 *bi = v->mem + v->cas;
OPJ_INT32 i = v->sn;
while( i-- ) {
*bi = *ai;
bi += 2;
ai += x;
}
ai = a + (v->sn * x);
bi = v->mem + 1 - v->cas;
i = v->dn ;
while( i-- ) {
*bi = *ai;
bi += 2;
ai += x;
}
}
/* <summary> */
/* Forward 5-3 wavelet transform in 1-D. */
/* </summary> */
static void dwt_encode_1(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas) {
OPJ_INT32 i;
if (!cas) {
if ((dn > 0) || (sn > 1)) { /* NEW : CASE ONE ELEMENT */
for (i = 0; i < dn; i++) D(i) -= (S_(i) + S_(i + 1)) >> 1;
for (i = 0; i < sn; i++) S(i) += (D_(i - 1) + D_(i) + 2) >> 2;
}
} else {
if (!sn && dn == 1) /* NEW : CASE ONE ELEMENT */
S(0) *= 2;
else {
for (i = 0; i < dn; i++) S(i) -= (DD_(i) + DD_(i - 1)) >> 1;
for (i = 0; i < sn; i++) D(i) += (SS_(i) + SS_(i + 1) + 2) >> 2;
}
}
}
/* <summary> */
/* Inverse 5-3 wavelet transform in 1-D. */
/* </summary> */
static void dwt_decode_1_(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas) {
OPJ_INT32 i;
if (!cas) {
if ((dn > 0) || (sn > 1)) { /* NEW : CASE ONE ELEMENT */
for (i = 0; i < sn; i++) S(i) -= (D_(i - 1) + D_(i) + 2) >> 2;
for (i = 0; i < dn; i++) D(i) += (S_(i) + S_(i + 1)) >> 1;
}
} else {
if (!sn && dn == 1) /* NEW : CASE ONE ELEMENT */
S(0) /= 2;
else {
for (i = 0; i < sn; i++) D(i) -= (SS_(i) + SS_(i + 1) + 2) >> 2;
for (i = 0; i < dn; i++) S(i) += (DD_(i) + DD_(i - 1)) >> 1;
}
}
}
/* <summary> */
/* Inverse 5-3 wavelet transform in 1-D. */
/* </summary> */
static void dwt_decode_1(dwt_t *v) {
dwt_decode_1_(v->mem, v->dn, v->sn, v->cas);
}
/* <summary> */
/* Forward 9-7 wavelet transform in 1-D. */
/* </summary> */
static void dwt_encode_1_real(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas) {
OPJ_INT32 i;
if (!cas) {
if ((dn > 0) || (sn > 1)) { /* NEW : CASE ONE ELEMENT */
for (i = 0; i < dn; i++)
D(i) -= fix_mul(S_(i) + S_(i + 1), 12993);
for (i = 0; i < sn; i++)
S(i) -= fix_mul(D_(i - 1) + D_(i), 434);
for (i = 0; i < dn; i++)
D(i) += fix_mul(S_(i) + S_(i + 1), 7233);
for (i = 0; i < sn; i++)
S(i) += fix_mul(D_(i - 1) + D_(i), 3633);
for (i = 0; i < dn; i++)
D(i) = fix_mul(D(i), 5038); /*5038 */
for (i = 0; i < sn; i++)
S(i) = fix_mul(S(i), 6659); /*6660 */
}
} else {
if ((sn > 0) || (dn > 1)) { /* NEW : CASE ONE ELEMENT */
for (i = 0; i < dn; i++)
S(i) -= fix_mul(DD_(i) + DD_(i - 1), 12993);
for (i = 0; i < sn; i++)
D(i) -= fix_mul(SS_(i) + SS_(i + 1), 434);
for (i = 0; i < dn; i++)
S(i) += fix_mul(DD_(i) + DD_(i - 1), 7233);
for (i = 0; i < sn; i++)
D(i) += fix_mul(SS_(i) + SS_(i + 1), 3633);
for (i = 0; i < dn; i++)
S(i) = fix_mul(S(i), 5038); /*5038 */
for (i = 0; i < sn; i++)
D(i) = fix_mul(D(i), 6659); /*6660 */
}
}
}
static void dwt_encode_stepsize(OPJ_INT32 stepsize, OPJ_INT32 numbps, opj_stepsize_t *bandno_stepsize) {
OPJ_INT32 p, n;
p = int_floorlog2(stepsize) - 13;
n = 11 - int_floorlog2(stepsize);
bandno_stepsize->mant = (n < 0 ? stepsize >> -n : stepsize << n) & 0x7ff;
bandno_stepsize->expn = numbps - p;
}
/*
==========================================================
DWT interface
==========================================================
*/
/* <summary> */
/* Forward 5-3 wavelet transform in 2-D. */
/* </summary> */
INLINE bool dwt_encode_procedure(opj_tcd_tilecomp_t * tilec,void (*p_function)(OPJ_INT32 *, OPJ_INT32,OPJ_INT32,OPJ_INT32) )
{
OPJ_INT32 i, j, k;
OPJ_INT32 *a = 00;
OPJ_INT32 *aj = 00;
OPJ_INT32 *bj = 00;
OPJ_INT32 w, l;
OPJ_INT32 rw; /* width of the resolution level computed */
OPJ_INT32 rh; /* height of the resolution level computed */
OPJ_INT32 l_data_size;
opj_tcd_resolution_t * l_cur_res = 0;
opj_tcd_resolution_t * l_last_res = 0;
w = tilec->x1-tilec->x0;
l = tilec->numresolutions-1;
a = tilec->data;
l_cur_res = tilec->resolutions + l;
l_last_res = l_cur_res - 1;
rw = l_cur_res->x1 - l_cur_res->x0;
rh = l_cur_res->y1 - l_cur_res->y0;
l_data_size = dwt_max_resolution( tilec->resolutions,tilec->numresolutions) * sizeof(OPJ_INT32);
bj = (OPJ_INT32*)opj_malloc(l_data_size);
if
(! bj)
{
return false;
}
i = l;
while
(i--)
{
OPJ_INT32 rw1; /* width of the resolution level once lower than computed one */
OPJ_INT32 rh1; /* height of the resolution level once lower than computed one */
OPJ_INT32 cas_col; /* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
OPJ_INT32 cas_row; /* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering */
OPJ_INT32 dn, sn;
rw = l_cur_res->x1 - l_cur_res->x0;
rh = l_cur_res->y1 - l_cur_res->y0;
rw1 = l_last_res->x1 - l_last_res->x0;
rh1 = l_last_res->y1 - l_last_res->y0;
cas_row = l_cur_res->x0 & 1;
cas_col = l_cur_res->y0 & 1;
sn = rh1;
dn = rh - rh1;
for
(j = 0; j < rw; ++j)
{
aj = a + j;
for
(k = 0; k < rh; ++k)
{
bj[k] = aj[k*w];
}
(*p_function) (bj, dn, sn, cas_col);
dwt_deinterleave_v(bj, aj, dn, sn, w, cas_col);
}
sn = rw1;
dn = rw - rw1;
for (j = 0; j < rh; j++)
{
aj = a + j * w;
for (k = 0; k < rw; k++) bj[k] = aj[k];
(*p_function) (bj, dn, sn, cas_row);
dwt_deinterleave_h(bj, aj, dn, sn, cas_row);
}
l_cur_res = l_last_res;
--l_last_res;
}
opj_free(bj);
return true;
}
/* Forward 5-3 wavelet transform in 2-D. */
/* </summary> */
bool dwt_encode(opj_tcd_tilecomp_t * tilec)
{
return dwt_encode_procedure(tilec,dwt_encode_1);
}
/* <summary> */
/* Inverse 5-3 wavelet transform in 2-D. */
/* </summary> */
bool dwt_decode(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres) {
return dwt_decode_tile(tilec, numres, &dwt_decode_1);
}
/* <summary> */
/* Get gain of 5-3 wavelet transform. */
/* </summary> */
OPJ_UINT32 dwt_getgain(OPJ_UINT32 orient) {
if (orient == 0)
return 0;
if (orient == 1 || orient == 2)
return 1;
return 2;
}
/* <summary> */
/* Get norm of 5-3 wavelet. */
/* </summary> */
OPJ_FLOAT64 dwt_getnorm(OPJ_UINT32 level, OPJ_UINT32 orient) {
return dwt_norms[orient][level];
}
/* <summary> */
/* Forward 9-7 wavelet transform in 2-D. */
/* </summary> */
bool dwt_encode_real(opj_tcd_tilecomp_t * tilec)
{
return dwt_encode_procedure(tilec,dwt_encode_1_real);
}
/* <summary> */
/* Get gain of 9-7 wavelet transform. */
/* </summary> */
OPJ_UINT32 dwt_getgain_real(OPJ_UINT32 orient) {
(void)orient;
return 0;
}
/* <summary> */
/* Get norm of 9-7 wavelet. */
/* </summary> */
OPJ_FLOAT64 dwt_getnorm_real(OPJ_UINT32 level, OPJ_UINT32 orient) {
return dwt_norms_real[orient][level];
}
void dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, OPJ_UINT32 prec) {
OPJ_UINT32 numbands, bandno;
numbands = 3 * tccp->numresolutions - 2;
for (bandno = 0; bandno < numbands; bandno++) {
OPJ_FLOAT64 stepsize;
OPJ_UINT32 resno, level, orient, gain;
resno = (bandno == 0) ? 0 : ((bandno - 1) / 3 + 1);
orient = (bandno == 0) ? 0 : ((bandno - 1) % 3 + 1);
level = tccp->numresolutions - 1 - resno;
gain = (tccp->qmfbid == 0) ? 0 : ((orient == 0) ? 0 : (((orient == 1) || (orient == 2)) ? 1 : 2));
if (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
stepsize = 1.0;
} else {
OPJ_FLOAT64 norm = dwt_norms_real[orient][level];
stepsize = (1 << (gain)) / norm;
}
dwt_encode_stepsize((OPJ_INT32) floor(stepsize * 8192.0), prec + gain, &tccp->stepsizes[bandno]);
}
}
/* <summary> */
/* Determine maximum computed resolution level for inverse wavelet transform */
/* </summary> */
static OPJ_UINT32 dwt_max_resolution(opj_tcd_resolution_t* restrict r, OPJ_UINT32 i) {
OPJ_UINT32 mr = 0;
OPJ_UINT32 w;
while( --i ) {
++r;
if( mr < ( w = r->x1 - r->x0 ) )
mr = w ;
if( mr < ( w = r->y1 - r->y0 ) )
mr = w ;
}
return mr ;
}
/* <summary> */
/* Inverse wavelet transform in 2-D. */
/* </summary> */
static bool dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres, DWT1DFN dwt_1D) {
dwt_t h;
dwt_t v;
opj_tcd_resolution_t* tr = tilec->resolutions;
OPJ_UINT32 rw = tr->x1 - tr->x0; /* width of the resolution level computed */
OPJ_UINT32 rh = tr->y1 - tr->y0; /* height of the resolution level computed */
OPJ_UINT32 w = tilec->x1 - tilec->x0;
h.mem = (OPJ_INT32*)
opj_aligned_malloc(dwt_max_resolution(tr, numres) * sizeof(OPJ_INT32));
if
(! h.mem)
{
return false;
}
v.mem = h.mem;
while( --numres) {
OPJ_INT32 * restrict tiledp = tilec->data;
OPJ_UINT32 j;
++tr;
h.sn = rw;
v.sn = rh;
rw = tr->x1 - tr->x0;
rh = tr->y1 - tr->y0;
h.dn = rw - h.sn;
h.cas = tr->x0 % 2;
for(j = 0; j < rh; ++j) {
dwt_interleave_h(&h, &tiledp[j*w]);
(dwt_1D)(&h);
memcpy(&tiledp[j*w], h.mem, rw * sizeof(OPJ_INT32));
}
v.dn = rh - v.sn;
v.cas = tr->y0 % 2;
for(j = 0; j < rw; ++j){
OPJ_UINT32 k;
dwt_interleave_v(&v, &tiledp[j], w);
(dwt_1D)(&v);
for(k = 0; k < rh; ++k) {
tiledp[k * w + j] = v.mem[k];
}
}
}
opj_aligned_free(h.mem);
return true;
}
static void v4dwt_interleave_h(v4dwt_t* restrict w, OPJ_FLOAT32* restrict a, OPJ_INT32 x, OPJ_INT32 size){
OPJ_FLOAT32* restrict bi = (OPJ_FLOAT32*) (w->wavelet + w->cas);
OPJ_INT32 count = w->sn;
OPJ_INT32 i, k;
for(k = 0; k < 2; ++k){
for(i = 0; i < count; ++i){
OPJ_INT32 j = i;
bi[i*8 ] = a[j];
j += x;
if(j >= size) continue;
bi[i*8 + 1] = a[j];
j += x;
if(j >= size) continue;
bi[i*8 + 2] = a[j];
j += x;
if(j >= size) continue;
bi[i*8 + 3] = a[j];
}
bi = (OPJ_FLOAT32*) (w->wavelet + 1 - w->cas);
a += w->sn;
size -= w->sn;
count = w->dn;
}
}
static void v4dwt_interleave_v(v4dwt_t* restrict v , OPJ_FLOAT32* restrict a , OPJ_INT32 x){
v4* restrict bi = v->wavelet + v->cas;
OPJ_INT32 i;
for(i = 0; i < v->sn; ++i){
memcpy(&bi[i*2], &a[i*x], 4 * sizeof(OPJ_FLOAT32));
}
a += v->sn * x;
bi = v->wavelet + 1 - v->cas;
for(i = 0; i < v->dn; ++i){
memcpy(&bi[i*2], &a[i*x], 4 * sizeof(OPJ_FLOAT32));
}
}
#ifdef __SSE__
static void v4dwt_decode_step1_sse(v4* w, OPJ_INT32 count, const __m128 c){
__m128* restrict vw = (__m128*) w;
OPJ_INT32 i;
for(i = 0; i < count; ++i){
__m128 tmp = vw[i*2];
vw[i*2] = tmp * c;
}
}
static void v4dwt_decode_step2_sse(v4* l, v4* w, OPJ_INT32 k, OPJ_INT32 m, __m128 c){
__m128* restrict vl = (__m128*) l;
__m128* restrict vw = (__m128*) w;
OPJ_INT32 i;
for(i = 0; i < m; ++i){
__m128 tmp1 = vl[ 0];
__m128 tmp2 = vw[-1];
__m128 tmp3 = vw[ 0];
vw[-1] = tmp2 + ((tmp1 + tmp3) * c);
vl = vw;
vw += 2;
}
if(m >= k){
return;
}
c += c;
c *= vl[0];
for(; m < k; ++m){
__m128 tmp = vw[-1];
vw[-1] = tmp + c;
vw += 2;
}
}
#else
static void v4dwt_decode_step1(v4* w, OPJ_INT32 count, const OPJ_FLOAT32 c){
OPJ_FLOAT32* restrict fw = (OPJ_FLOAT32*) w;
OPJ_INT32 i;
for(i = 0; i < count; ++i){
OPJ_FLOAT32 tmp1 = fw[i*8 ];
OPJ_FLOAT32 tmp2 = fw[i*8 + 1];
OPJ_FLOAT32 tmp3 = fw[i*8 + 2];
OPJ_FLOAT32 tmp4 = fw[i*8 + 3];
fw[i*8 ] = tmp1 * c;
fw[i*8 + 1] = tmp2 * c;
fw[i*8 + 2] = tmp3 * c;
fw[i*8 + 3] = tmp4 * c;
}
}
static void v4dwt_decode_step2(v4* l, v4* w, OPJ_INT32 k, OPJ_INT32 m, OPJ_FLOAT32 c){
OPJ_FLOAT32* restrict fl = (OPJ_FLOAT32*) l;
OPJ_FLOAT32* restrict fw = (OPJ_FLOAT32*) w;
OPJ_INT32 i;
for(i = 0; i < m; ++i){
OPJ_FLOAT32 tmp1_1 = fl[0];
OPJ_FLOAT32 tmp1_2 = fl[1];
OPJ_FLOAT32 tmp1_3 = fl[2];
OPJ_FLOAT32 tmp1_4 = fl[3];
OPJ_FLOAT32 tmp2_1 = fw[-4];
OPJ_FLOAT32 tmp2_2 = fw[-3];
OPJ_FLOAT32 tmp2_3 = fw[-2];
OPJ_FLOAT32 tmp2_4 = fw[-1];
OPJ_FLOAT32 tmp3_1 = fw[0];
OPJ_FLOAT32 tmp3_2 = fw[1];
OPJ_FLOAT32 tmp3_3 = fw[2];
OPJ_FLOAT32 tmp3_4 = fw[3];
fw[-4] = tmp2_1 + ((tmp1_1 + tmp3_1) * c);
fw[-3] = tmp2_2 + ((tmp1_2 + tmp3_2) * c);
fw[-2] = tmp2_3 + ((tmp1_3 + tmp3_3) * c);
fw[-1] = tmp2_4 + ((tmp1_4 + tmp3_4) * c);
fl = fw;
fw += 8;
}
if(m < k){
OPJ_FLOAT32 c1;
OPJ_FLOAT32 c2;
OPJ_FLOAT32 c3;
OPJ_FLOAT32 c4;
c += c;
c1 = fl[0] * c;
c2 = fl[1] * c;
c3 = fl[2] * c;
c4 = fl[3] * c;
for(; m < k; ++m){
OPJ_FLOAT32 tmp1 = fw[-4];
OPJ_FLOAT32 tmp2 = fw[-3];
OPJ_FLOAT32 tmp3 = fw[-2];
OPJ_FLOAT32 tmp4 = fw[-1];
fw[-4] = tmp1 + c1;
fw[-3] = tmp2 + c2;
fw[-2] = tmp3 + c3;
fw[-1] = tmp4 + c4;
fw += 8;
}
}
}
#endif
/* <summary> */
/* Inverse 9-7 wavelet transform in 1-D. */
/* </summary> */
static void v4dwt_decode(v4dwt_t* restrict dwt){
OPJ_INT32 a, b;
if(dwt->cas == 0) {
if(!((dwt->dn > 0) || (dwt->sn > 1))){
return;
}
a = 0;
b = 1;
}else{
if(!((dwt->sn > 0) || (dwt->dn > 1))) {
return;
}
a = 1;
b = 0;
}
#ifdef __SSE__
v4dwt_decode_step1_sse(dwt->wavelet+a, dwt->sn, _mm_set1_ps(K));
v4dwt_decode_step1_sse(dwt->wavelet+b, dwt->dn, _mm_set1_ps(c13318));
v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(delta));
v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(dwt_gamma));
v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(dwt_beta));
v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(dwt_alpha));
#else
v4dwt_decode_step1(dwt->wavelet+a, dwt->sn, K);
v4dwt_decode_step1(dwt->wavelet+b, dwt->dn, c13318);
v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), delta);
v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), dwt_gamma);
v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), dwt_beta);
v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), dwt_alpha);
#endif
}
/* <summary> */
/* Inverse 9-7 wavelet transform in 2-D. */
/* </summary> */
bool dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, OPJ_UINT32 numres){
v4dwt_t h;
v4dwt_t v;
opj_tcd_resolution_t* res = tilec->resolutions;
OPJ_UINT32 rw = res->x1 - res->x0; /* width of the resolution level computed */
OPJ_UINT32 rh = res->y1 - res->y0; /* height of the resolution level computed */
OPJ_UINT32 w = tilec->x1 - tilec->x0;
h.wavelet = (v4*) opj_aligned_malloc((dwt_max_resolution(res, numres)+5) * sizeof(v4));
v.wavelet = h.wavelet;
while( --numres) {
OPJ_FLOAT32 * restrict aj = (OPJ_FLOAT32*) tilec->data;
OPJ_UINT32 bufsize = (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0);
OPJ_INT32 j;
h.sn = rw;
v.sn = rh;
++res;
rw = res->x1 - res->x0; /* width of the resolution level computed */
rh = res->y1 - res->y0; /* height of the resolution level computed */
h.dn = rw - h.sn;
h.cas = res->x0 & 1;
for(j = rh; j > 0; j -= 4){
v4dwt_interleave_h(&h, aj, w, bufsize);
v4dwt_decode(&h);
if(j >= 4){
OPJ_INT32 k = rw;
while
(--k >= 0)
{
aj[k ] = h.wavelet[k].f[0];
aj[k+w ] = h.wavelet[k].f[1];
aj[k+w*2] = h.wavelet[k].f[2];
aj[k+w*3] = h.wavelet[k].f[3];
}
}else{
OPJ_INT32 k = rw;
while
(--k >= 0)
{
switch(j) {
case 3: aj[k+w*2] = h.wavelet[k].f[2];
case 2: aj[k+w ] = h.wavelet[k].f[1];
case 1: aj[k ] = h.wavelet[k].f[0];
}
}
}
aj += w*4;
bufsize -= w*4;
}
v.dn = rh - v.sn;
v.cas = res->y0 % 2;
aj = (OPJ_FLOAT32*) tilec->data;
for(j = rw; j > 0; j -= 4){
v4dwt_interleave_v(&v, aj, w);
v4dwt_decode(&v);
if(j >= 4){
OPJ_UINT32 k;
for(k = 0; k < rh; ++k){
memcpy(&aj[k*w], &v.wavelet[k], 4 * sizeof(OPJ_FLOAT32));
}
}else{
OPJ_UINT32 k;
for(k = 0; k < rh; ++k){
memcpy(&aj[k*w], &v.wavelet[k], j * sizeof(OPJ_FLOAT32));
}
}
aj += 4;
}
}
opj_aligned_free(h.wavelet);
return true;
}

View File

@ -1,16 +1,11 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux
* Copyright (c) 2003-2014, Antonin Descampe
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -35,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OPJ_DWT_H
#define OPJ_DWT_H
#ifndef __DWT_H
#define __DWT_H
/**
@file dwt.h
@brief Implementation of a discrete wavelet transform (DWT)
@ -45,6 +40,10 @@ The functions in DWT.C have for goal to realize forward and inverse discret wave
transform with filter 5-3 (reversible) and filter 9-7 (irreversible). The functions in
DWT.C are used by some function in TCD.C.
*/
#include "openjpeg.h"
struct opj_tcd_tilecomp;
struct opj_tccp;
/** @defgroup DWT DWT - Implementation of a discrete wavelet transform */
/*@{*/
@ -54,67 +53,66 @@ DWT.C are used by some function in TCD.C.
/*@{*/
/* ----------------------------------------------------------------------- */
/**
Forward 5-3 wavelet transform in 2-D.
Forward 5-3 wavelet tranform in 2-D.
Apply a reversible DWT transform to a component of an image.
@param p_tcd TCD handle
@param tilec Tile component information (current tile)
*/
OPJ_BOOL opj_dwt_encode(opj_tcd_t *p_tcd,
opj_tcd_tilecomp_t * tilec);
bool dwt_encode(struct opj_tcd_tilecomp * tilec);
/**
Inverse 5-3 wavelet transform in 2-D.
Inverse 5-3 wavelet tranform in 2-D.
Apply a reversible inverse DWT transform to a component of an image.
@param p_tcd TCD handle
@param tilec Tile component information (current tile)
@param numres Number of resolution levels to decode
*/
OPJ_BOOL opj_dwt_decode(opj_tcd_t *p_tcd,
opj_tcd_tilecomp_t* tilec,
OPJ_UINT32 numres);
bool dwt_decode(struct opj_tcd_tilecomp* tilec, OPJ_UINT32 numres);
/**
Get the gain of a subband for the reversible 5-3 DWT.
@param orient Number that identifies the subband (0->LL, 1->HL, 2->LH, 3->HH)
@return Returns 0 if orient = 0, returns 1 if orient = 1 or 2, returns 2 otherwise
*/
OPJ_UINT32 dwt_getgain(OPJ_UINT32 orient);
/**
Get the norm of a wavelet function of a subband at a specified level for the reversible 5-3 DWT.
@param level Level of the wavelet function
@param orient Band of the wavelet function
@return Returns the norm of the wavelet function
*/
OPJ_FLOAT64 opj_dwt_getnorm(OPJ_UINT32 level, OPJ_UINT32 orient);
OPJ_FLOAT64 dwt_getnorm(OPJ_UINT32 level, OPJ_UINT32 orient);
/**
Forward 9-7 wavelet transform in 2-D.
Forward 9-7 wavelet transform in 2-D.
Apply an irreversible DWT transform to a component of an image.
@param p_tcd TCD handle
@param tilec Tile component information (current tile)
*/
OPJ_BOOL opj_dwt_encode_real(opj_tcd_t *p_tcd,
opj_tcd_tilecomp_t * tilec);
bool dwt_encode_real(struct opj_tcd_tilecomp * tilec);
/**
Inverse 9-7 wavelet transform in 2-D.
Inverse 9-7 wavelet transform in 2-D.
Apply an irreversible inverse DWT transform to a component of an image.
@param p_tcd TCD handle
@param tilec Tile component information (current tile)
@param numres Number of resolution levels to decode
*/
OPJ_BOOL opj_dwt_decode_real(opj_tcd_t *p_tcd,
opj_tcd_tilecomp_t* OPJ_RESTRICT tilec,
OPJ_UINT32 numres);
bool dwt_decode_real(struct opj_tcd_tilecomp* tilec, OPJ_UINT32 numres);
/**
Get the gain of a subband for the irreversible 9-7 DWT.
@param orient Number that identifies the subband (0->LL, 1->HL, 2->LH, 3->HH)
@return Returns the gain of the 9-7 wavelet transform
*/
OPJ_UINT32 dwt_getgain_real(OPJ_UINT32 orient);
/**
Get the norm of a wavelet function of a subband at a specified level for the irreversible 9-7 DWT
@param level Level of the wavelet function
@param orient Band of the wavelet function
@return Returns the norm of the 9-7 wavelet
*/
OPJ_FLOAT64 opj_dwt_getnorm_real(OPJ_UINT32 level, OPJ_UINT32 orient);
OPJ_FLOAT64 dwt_getnorm_real(OPJ_UINT32 level, OPJ_UINT32 orient);
/**
Explicit calculation of the Quantization Stepsizes
Explicit calculation of the Quantization Stepsizes
@param tccp Tile-component coding parameters
@param prec Precint analyzed
*/
void opj_dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, OPJ_UINT32 prec);
void dwt_calc_explicit_stepsizes(struct opj_tccp * tccp, OPJ_UINT32 prec);
/* ----------------------------------------------------------------------- */
/*@}*/
/*@}*/
#endif /* OPJ_DWT_H */
#endif /* __DWT_H */

96
libopenjpeg/event.c Normal file
View File

@ -0,0 +1,96 @@
/*
* Copyright (c) 2005, Hervé Drolon, FreeImage Team
* 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.
*/
#include "event.h"
#include "openjpeg.h"
#include "opj_includes.h"
/* ==========================================================
Utility functions
==========================================================*/
#if !defined(_MSC_VER) && !defined(__MINGW32__)
static OPJ_CHAR*
i2a(OPJ_UINT32 i, OPJ_CHAR *a, OPJ_UINT32 r) {
if (i/r > 0) a = i2a(i/r,a,r);
*a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i%r];
return a+1;
}
#endif
/* ----------------------------------------------------------------------- */
bool opj_event_msg(opj_event_mgr_t * p_event_mgr, OPJ_INT32 event_type, const OPJ_CHAR *fmt, ...) {
#define MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */
opj_msg_callback msg_handler = 00;
void * l_data = 00;
if(p_event_mgr != 00) {
switch(event_type) {
case EVT_ERROR:
msg_handler = p_event_mgr->error_handler;
l_data = p_event_mgr->m_error_data;
break;
case EVT_WARNING:
msg_handler = p_event_mgr->warning_handler;
l_data = p_event_mgr->m_warning_data;
break;
case EVT_INFO:
msg_handler = p_event_mgr->info_handler;
l_data = p_event_mgr->m_info_data;
break;
default:
break;
}
if(msg_handler == 00) {
return false;
}
} else {
return false;
}
if ((fmt != 00) && (p_event_mgr != 00)) {
va_list arg;
OPJ_INT32 str_length/*, i, j*/; /* UniPG */
OPJ_CHAR message[MSG_SIZE];
memset(message, 0, MSG_SIZE);
/* initialize the optional parameter list */
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' */
vsprintf(message, fmt, arg); /* UniPG */
/* deinitialize the optional parameter list */
va_end(arg);
/* output the message to the user program */
msg_handler(message, l_data);
}
return true;
}

View File

@ -1,12 +1,6 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
* Copyright (c) 2012, CS Systemes d'Information, France
* Copyright (c) 2005, Hervé Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -30,8 +24,11 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OPJ_EVENT_H
#define OPJ_EVENT_H
#ifndef __EVENT_H
#define __EVENT_H
#include "openjpeg.h"
/**
@file event.h
@brief Implementation of a event callback system
@ -40,32 +37,32 @@ The functions in EVENT.C have for goal to send output messages (errors, warnings
*/
/**
Message handler object
used for
used for
<ul>
<li>Error messages
<li>Warning messages
<li>Debugging messages
</ul>
*/
typedef struct opj_event_mgr {
/** Data to call the event manager upon */
void * m_error_data;
/** Data to call the event manager upon */
void * m_warning_data;
/** Data to call the event manager upon */
void * m_info_data;
/** Error message callback if available, NULL otherwise */
opj_msg_callback error_handler;
/** Warning message callback if available, NULL otherwise */
opj_msg_callback warning_handler;
/** Debug message callback if available, NULL otherwise */
opj_msg_callback info_handler;
typedef struct opj_event_mgr
{
/** Data to call the event manager upon */
void * m_error_data;
/** Data to call the event manager upon */
void * m_warning_data;
/** Data to call the event manager upon */
void * m_info_data;
/** Error message callback if available, NULL otherwise */
opj_msg_callback error_handler;
/** Warning message callback if available, NULL otherwise */
opj_msg_callback warning_handler;
/** Debug message callback if available, NULL otherwise */
opj_msg_callback info_handler;
} opj_event_mgr_t;
#define EVT_ERROR 1 /**< Error event type */
#define EVT_WARNING 2 /**< Warning event type */
#define EVT_INFO 4 /**< Debug event type */
#define EVT_ERROR 1 /**< Error event type */
#define EVT_WARNING 2 /**< Warning event type */
#define EVT_INFO 4 /**< Debug event type */
/** @defgroup EVENT EVENT - Implementation of a event callback system */
/*@{*/
@ -73,36 +70,17 @@ typedef struct opj_event_mgr {
/** @name Exported functions (see also openjpeg.h) */
/*@{*/
/* ----------------------------------------------------------------------- */
/* ----------------------------------------------------------------------- */
/**
* Write formatted data to a string and send the string to a user callback.
*
* @param event_mgr Event handler
* @param event_type Event type or callback to use to send the message
* @param fmt Format-control string (plus optional arguments)
*
* Writes formatted data to a string and send the string to a user callback.
* @param p_event_mgr the event manager to display messages.
* @param event_type Event type of the message
* @param fmt Format-control string (plus optionnal arguments)
* @return Returns true if successful, returns false otherwise
*/
OPJ_BOOL opj_event_msg(opj_event_mgr_t* event_mgr, OPJ_INT32 event_type,
const char *fmt, ...);
/* ----------------------------------------------------------------------- */
/**
* Set the event manager with the default callback function for the 3 levels.
*/
void opj_set_default_event_handler(opj_event_mgr_t * p_manager);
/*
#ifdef __GNUC__
#pragma GCC poison printf fprintf
#endif
*/
bool opj_event_msg(struct opj_event_mgr * p_event_mgr, OPJ_INT32 event_type, const OPJ_CHAR *fmt, ...);
/* ----------------------------------------------------------------------- */
/*@}*/
/*@}*/
#endif /* OPJ_EVENT_H */
#endif /* __EVENT_H */

View File

@ -1,15 +1,9 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux
* Copyright (c) 2003-2014, Antonin Descampe
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved.
*
@ -34,14 +28,33 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __FIX_H
#define __FIX_H
#ifndef _OPJ_COLOR_H_
#define _OPJ_COLOR_H_
#include "openjpeg.h"
#include "opj_includes.h"
extern void color_sycc_to_rgb(opj_image_t *img);
extern void color_apply_icc_profile(opj_image_t *image);
extern void color_cielab_to_rgb(opj_image_t *image);
/**
@file fix.h
@brief Implementation of operations of specific multiplication (FIX)
extern void color_cmyk_to_rgb(opj_image_t *image);
extern void color_esycc_to_rgb(opj_image_t *image);
#endif /* _OPJ_COLOR_H_ */
The functions in FIX.H have for goal to realize specific multiplication.
*/
/** @defgroup FIX FIX - Implementation of operations of specific multiplication */
/*@{*/
/**
Multiply two fixed-precision rational numbers.
@param a
@param b
@return Returns a * b
*/
static INLINE int fix_mul(int a, int b) {
OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ;
temp += temp & 4096;
return (int) (temp >> 13) ;
}
/*@}*/
#endif /* __FIX_H */

149
libopenjpeg/function_list.c Normal file
View File

@ -0,0 +1,149 @@
/*
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#include "function_list.h"
#include "opj_includes.h"
#include "opj_malloc.h"
/**
* Default size of the validation list, if not sufficient, data will be reallocated with a double size.
*/
#define OPJ_VALIDATION_SIZE 10
/**
* Creates a validation list.
*
* @return the newly created validation list.
*/
opj_procedure_list_t * opj_procedure_list_create()
{
/* memory allocation */
opj_procedure_list_t * l_validation = (opj_procedure_list_t *) opj_malloc(sizeof(opj_procedure_list_t));
if
(! l_validation)
{
return 00;
}
/* initialization */
memset(l_validation,0,sizeof(opj_procedure_list_t));
l_validation->m_nb_max_procedures = OPJ_VALIDATION_SIZE;
l_validation->m_procedures = (void**)opj_malloc(
OPJ_VALIDATION_SIZE * sizeof(opj_procedure));
if
(! l_validation->m_procedures)
{
opj_free(l_validation);
return 00;
}
memset(l_validation->m_procedures,0,OPJ_VALIDATION_SIZE * sizeof(opj_procedure));
return l_validation;
}
/**
* Destroys a validation list.
*
* @param p_list the list to destroy.
*/
void opj_procedure_list_destroy(opj_procedure_list_t * p_list)
{
if
(! p_list)
{
return;
}
/* initialization */
if
(p_list->m_procedures)
{
opj_free(p_list->m_procedures);
}
opj_free(p_list);
}
/**
* Adds a new validation procedure.
*
* @param p_validation_list the list of procedure to modify.
* @param p_procedure the procedure to add.
*/
bool opj_procedure_list_add_procedure (opj_procedure_list_t * p_validation_list, opj_procedure p_procedure)
{
if
(p_validation_list->m_nb_max_procedures == p_validation_list->m_nb_procedures)
{
p_validation_list->m_nb_max_procedures += OPJ_VALIDATION_SIZE;
p_validation_list->m_procedures = (void**)opj_realloc(
p_validation_list->m_procedures,p_validation_list->m_nb_max_procedures * sizeof(opj_procedure));
if
(! p_validation_list->m_procedures)
{
p_validation_list->m_nb_max_procedures = 0;
p_validation_list->m_nb_procedures = 0;
return false;
}
}
p_validation_list->m_procedures[p_validation_list->m_nb_procedures] = p_procedure;
++p_validation_list->m_nb_procedures;
return true;
}
/**
* Gets the number of validation procedures.
*
* @param p_validation_list the list of procedure to modify.
*
* @return the number of validation procedures.
*/
OPJ_UINT32 opj_procedure_list_get_nb_procedures (opj_procedure_list_t * p_validation_list)
{
return p_validation_list->m_nb_procedures;
}
/**
* Gets the pointer on the first validation procedure. This function is similar to the C++
* iterator class to iterate through all the procedures inside the validation list.
* the caller does not take ownership of the pointer.
*
* @param p_validation_list the list of procedure to get the first procedure from.
*
* @return a pointer to the first procedure.
*/
opj_procedure* opj_procedure_list_get_first_procedure (opj_procedure_list_t * p_validation_list)
{
return p_validation_list->m_procedures;
}
/**
* Clears the list of validation procedures.
*
* @param p_validation_list the list of procedure to clear.
*
*/
void opj_procedure_list_clear (opj_procedure_list_t * p_validation_list)
{
p_validation_list->m_nb_procedures = 0;
}

View File

@ -1,9 +1,4 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
* All rights reserved.
*
@ -29,44 +24,50 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OPJ_FUNCTION_LIST_H
#define OPJ_FUNCTION_LIST_H
#ifndef __FUNCTION_LIST_H
#define __FUNCTION_LIST_H
/**
/**
* @file function_list.h
* @brief Implementation of a list of procedures.
* The functions in validation.c aims to have access to a list of procedures.
*/
/** @defgroup VAL VAL - validation procedure*/
/** @defgroup validation validation procedure*/
/*@{*/
#include "openjpeg.h"
/**************************************************************************************************
***************************************** FORWARD DECLARATION ************************************
**************************************************************************************************/
struct opj_jp2;
/**
* declare a function pointer
* ARGGGG, when will the template be added to the C language ???
* in order not to have to duplicate the code in a vast number of times, use void * and downcast
* it after => UGLY but faster and easier
* TODO : make the class template in C++, use STL vector or duplicate code for each procedure type.
*/
typedef void (*opj_procedure)(void);
typedef void * opj_procedure;
/**
* A list of procedures.
*/
typedef struct opj_procedure_list {
/**
* The number of validation procedures.
*/
OPJ_UINT32 m_nb_procedures;
/**
* The number of the array of validation procedures.
*/
OPJ_UINT32 m_nb_max_procedures;
/**
* The array of procedures.
*/
opj_procedure * m_procedures;
typedef struct opj_procedure_list
{
/**
* The number of validation procedures.
*/
OPJ_UINT32 m_nb_procedures;
/**
* The number of the array of validation procedures.
*/
OPJ_UINT32 m_nb_max_procedures;
/**
* The array of procedures.
*/
opj_procedure * m_procedures;
} opj_procedure_list_t;
@ -75,9 +76,9 @@ typedef struct opj_procedure_list {
/**
* Creates a validation list.
*
* @return the newly created validation list.
* @return the newly created validation list.
*/
opj_procedure_list_t * opj_procedure_list_create(void);
opj_procedure_list_t * opj_procedure_list_create();
/**
* Destroys a validation list.
@ -89,46 +90,42 @@ void opj_procedure_list_destroy(opj_procedure_list_t * p_list);
/**
* Adds a new validation procedure.
*
* @param p_validation_list the list of procedure to modify.
* @param p_procedure the procedure to add.
* @param p_manager the user event manager.
* @param p_validation_list the list of procedure to modify.
* @param p_procedure the procedure to add.
*
* @return OPJ_TRUE if the procedure could be added.
* @return true if the procedure could ne added.
*/
OPJ_BOOL opj_procedure_list_add_procedure(opj_procedure_list_t *
p_validation_list, opj_procedure p_procedure, opj_event_mgr_t* p_manager);
bool opj_procedure_list_add_procedure (opj_procedure_list_t * p_validation_list, opj_procedure p_procedure);
/**
* Gets the number of validation procedures.
*
* @param p_validation_list the list of procedure to modify.
* @param p_validation_list the list of procedure to modify.
*
* @return the number of validation procedures.
*/
OPJ_UINT32 opj_procedure_list_get_nb_procedures(opj_procedure_list_t *
p_validation_list);
OPJ_UINT32 opj_procedure_list_get_nb_procedures (opj_procedure_list_t * p_validation_list);
/**
* Gets the pointer on the first validation procedure. This function is similar to the C++
* iterator class to iterate through all the procedures inside the validation list.
* the caller does not take ownership of the pointer.
*
* @param p_validation_list the list of procedure to get the first procedure from.
* @param p_validation_list the list of procedure to get the first procedure from.
*
* @return a pointer to the first procedure.
* @return a pointer to the first procedure.
*/
opj_procedure* opj_procedure_list_get_first_procedure(opj_procedure_list_t *
p_validation_list);
opj_procedure* opj_procedure_list_get_first_procedure (opj_procedure_list_t * p_validation_list);
/**
* Clears the list of validation procedures.
*
* @param p_validation_list the list of procedure to clear.
* @param p_validation_list the list of procedure to clear.
*
*/
void opj_procedure_list_clear(opj_procedure_list_t * p_validation_list);
/*@}*/
void opj_procedure_list_clear (opj_procedure_list_t * p_validation_list);
#endif /* OPJ_FUNCTION_LIST_H */
#endif /* __FUNCTION_LIST_H */

175
libopenjpeg/image.c Normal file
View File

@ -0,0 +1,175 @@
/*
* Copyright (c) 2005, Hervé Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#include "image.h"
#include "openjpeg.h"
#include "opj_malloc.h"
#include "j2k.h"
#include "int.h"
opj_image_t* opj_image_create0(void) {
opj_image_t *image = (opj_image_t*)opj_malloc(sizeof(opj_image_t));
memset(image,0,sizeof(opj_image_t));
return image;
}
opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) {
OPJ_UINT32 compno;
opj_image_t *image = 00;
image = (opj_image_t*) opj_malloc(sizeof(opj_image_t));
if
(image)
{
memset(image,0,sizeof(opj_image_t));
image->color_space = clrspc;
image->numcomps = numcmpts;
/* allocate memory for the per-component information */
image->comps = (opj_image_comp_t*)opj_malloc(image->numcomps * sizeof(opj_image_comp_t));
if
(!image->comps)
{
opj_image_destroy(image);
return 00;
}
memset(image->comps,0,image->numcomps * sizeof(opj_image_comp_t));
/* create the individual image components */
for(compno = 0; compno < numcmpts; compno++) {
opj_image_comp_t *comp = &image->comps[compno];
comp->dx = cmptparms[compno].dx;
comp->dy = cmptparms[compno].dy;
comp->w = cmptparms[compno].w;
comp->h = cmptparms[compno].h;
comp->x0 = cmptparms[compno].x0;
comp->y0 = cmptparms[compno].y0;
comp->prec = cmptparms[compno].prec;
comp->sgnd = cmptparms[compno].sgnd;
comp->data = (OPJ_INT32*) opj_calloc(comp->w * comp->h, sizeof(OPJ_INT32));
if
(!comp->data)
{
opj_image_destroy(image);
return 00;
}
}
}
return image;
}
opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) {
OPJ_UINT32 compno;
opj_image_t *image = 00;
image = (opj_image_t*) opj_malloc(sizeof(opj_image_t));
if
(image)
{
memset(image,0,sizeof(opj_image_t));
image->color_space = clrspc;
image->numcomps = numcmpts;
/* allocate memory for the per-component information */
image->comps = (opj_image_comp_t*)opj_malloc(image->numcomps * sizeof(opj_image_comp_t));
if
(!image->comps)
{
opj_image_destroy(image);
return 00;
}
memset(image->comps,0,image->numcomps * sizeof(opj_image_comp_t));
/* create the individual image components */
for(compno = 0; compno < numcmpts; compno++) {
opj_image_comp_t *comp = &image->comps[compno];
comp->dx = cmptparms[compno].dx;
comp->dy = cmptparms[compno].dy;
comp->w = cmptparms[compno].w;
comp->h = cmptparms[compno].h;
comp->x0 = cmptparms[compno].x0;
comp->y0 = cmptparms[compno].y0;
comp->prec = cmptparms[compno].prec;
comp->sgnd = cmptparms[compno].sgnd;
comp->data = 0;
}
}
return image;
}
void OPJ_CALLCONV opj_image_destroy(opj_image_t *image) {
OPJ_UINT32 i;
if
(image)
{
if
(image->comps)
{
/* image components */
for(i = 0; i < image->numcomps; i++) {
opj_image_comp_t *image_comp = &image->comps[i];
if(image_comp->data) {
opj_free(image_comp->data);
}
}
opj_free(image->comps);
}
opj_free(image);
}
}
/**
* Updates the components of the image from the coding parameters.
*
* @param p_image the image to update.
* @param p_cp the coding parameters from which to update the image.
*/
void opj_image_comp_update(opj_image_t * p_image,const opj_cp_t * p_cp)
{
OPJ_UINT32 i, l_width, l_height;
OPJ_INT32 l_x0,l_y0,l_x1,l_y1;
OPJ_INT32 l_comp_x0,l_comp_y0,l_comp_x1,l_comp_y1;
opj_image_comp_t * l_img_comp = 00;
l_x0 = int_max(p_cp->tx0 , p_image->x0);
l_y0 = int_max(p_cp->ty0 , p_image->y0);
l_x1 = int_min(p_cp->tx0 + p_cp->tw * p_cp->tdx, p_image->x1);
l_y1 = int_min(p_cp->ty0 + p_cp->th * p_cp->tdy, p_image->y1);
l_img_comp = p_image->comps;
for
(i = 0; i < p_image->numcomps; ++i)
{
l_comp_x0 = int_ceildiv(l_x0, l_img_comp->dx);
l_comp_y0 = int_ceildiv(l_y0, l_img_comp->dy);
l_comp_x1 = int_ceildiv(l_x1, l_img_comp->dx);
l_comp_y1 = int_ceildiv(l_y1, l_img_comp->dy);
l_width = int_ceildivpow2(l_comp_x1 - l_comp_x0, l_img_comp->factor);
l_height = int_ceildivpow2(l_comp_y1 - l_comp_y0, l_img_comp->factor);
l_img_comp->w = l_width;
l_img_comp->h = l_height;
l_img_comp->x0 = l_x0;
l_img_comp->y0 = l_y0;
++l_img_comp;
}
}

View File

@ -1,10 +1,6 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2005, Hervé Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -28,43 +24,35 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OPJ_IMAGE_H
#define OPJ_IMAGE_H
#ifndef __IMAGE_H
#define __IMAGE_H
/**
@file image.h
@brief Implementation of operations on images (IMAGE)
The functions in IMAGE.C have for goal to realize operations on images.
*/
struct opj_image;
struct opj_cp;
/** @defgroup IMAGE IMAGE - Implementation of operations on images */
/*@{*/
/**
* Create an empty image
*
* @return returns an empty image if successful, returns NULL otherwise
*/
opj_image_t* opj_image_create0(void);
Create an empty image
@todo this function should be removed
@return returns an empty image if successful, returns NULL otherwise
*/
struct opj_image* opj_image_create0(void);
/**
* Updates the components characteristics of the image from the coding parameters.
*
* @param p_image_header the image header to update.
* @param p_cp the coding parameters from which to update the image.
* Updates the components of the image from the coding parameters.
*
* @param p_image the image to update.
* @param p_cp the coding parameters from which to update the image.
*/
void opj_image_comp_header_update(opj_image_t * p_image,
const struct opj_cp* p_cp);
void opj_copy_image_header(const opj_image_t* p_image_src,
opj_image_t* p_image_dest);
void opj_image_comp_update(struct opj_image * p_image,const struct opj_cp * p_cp);
/*@}*/
#endif /* OPJ_IMAGE_H */
#endif /* __IMAGE_H */

159
libopenjpeg/int.h Normal file
View File

@ -0,0 +1,159 @@
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#ifndef __INT_H
#define __INT_H
/**
@file int.h
@brief Implementation of operations on integers (INT)
The functions in INT.H have for goal to realize operations on integers.
*/
#include "openjpeg.h"
#include "opj_includes.h"
/** @defgroup INT INT - Implementation of operations on integers */
/*@{*/
/** @name Exported functions (see also openjpeg.h) */
/*@{*/
/* ----------------------------------------------------------------------- */
/**
Get the minimum of two integers
@return Returns a if a < b else b
*/
static INLINE OPJ_INT32 int_min(OPJ_INT32 a, OPJ_INT32 b) {
return a < b ? a : b;
}
/**
Get the minimum of two integers
@return Returns a if a < b else b
*/
static INLINE OPJ_UINT32 uint_min(OPJ_UINT32 a, OPJ_UINT32 b) {
return a < b ? a : b;
}
/**
Get the maximum of two integers
@return Returns a if a > b else b
*/
static INLINE OPJ_INT32 int_max(OPJ_INT32 a, OPJ_INT32 b) {
return (a > b) ? a : b;
}
/**
Get the maximum of two integers
@return Returns a if a > b else b
*/
static INLINE OPJ_UINT32 uint_max(OPJ_UINT32 a, OPJ_UINT32 b) {
return (a > b) ? a : b;
}
/**
Clamp an integer inside an interval
@return
<ul>
<li>Returns a if (min < a < max)
<li>Returns max if (a > max)
<li>Returns min if (a < min)
</ul>
*/
static INLINE OPJ_INT32 int_clamp(OPJ_INT32 a, OPJ_INT32 min, OPJ_INT32 max) {
if (a < min)
return min;
if (a > max)
return max;
return a;
}
/**
@return Get absolute value of integer
*/
static INLINE OPJ_INT32 int_abs(OPJ_INT32 a) {
return a < 0 ? -a : a;
}
/**
Divide an integer and round upwards
@return Returns a divided by b
*/
static INLINE OPJ_INT32 int_ceildiv(OPJ_INT32 a, OPJ_INT32 b) {
return (a + b - 1) / b;
}
/**
Divide an integer and round upwards
@return Returns a divided by b
*/
static INLINE OPJ_UINT32 uint_ceildiv(OPJ_UINT32 a, OPJ_UINT32 b) {
return (a + b - 1) / b;
}
/**
Divide an integer by a power of 2 and round upwards
@return Returns a divided by 2^b
*/
static INLINE OPJ_INT32 int_ceildivpow2(OPJ_INT32 a, OPJ_INT32 b) {
return (a + (1 << b) - 1) >> b;
}
/**
Divide an integer by a power of 2 and round downwards
@return Returns a divided by 2^b
*/
static INLINE OPJ_INT32 int_floordivpow2(OPJ_INT32 a, OPJ_INT32 b) {
return a >> b;
}
/**
Get logarithm of an integer and round downwards
@return Returns log2(a)
*/
static INLINE OPJ_INT32 int_floorlog2(OPJ_INT32 a) {
OPJ_INT32 l;
for (l = 0; a > 1; l++) {
a >>= 1;
}
return l;
}
/**
Get logarithm of an integer and round downwards
@return Returns log2(a)
*/
static INLINE OPJ_UINT32 uint_floorlog2(OPJ_UINT32 a) {
OPJ_UINT32 l;
for (l = 0; a > 1; ++l)
{
a >>= 1;
}
return l;
}
/* ----------------------------------------------------------------------- */
/*@}*/
/*@}*/
#endif

291
libopenjpeg/invert.c Normal file
View File

@ -0,0 +1,291 @@
/*
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#include "invert.h"
#include "opj_malloc.h"
bool opj_lupDecompose(OPJ_FLOAT32 * matrix,OPJ_UINT32 * permutations, OPJ_FLOAT32 * p_swap_area,OPJ_UINT32 n);
void opj_lupSolve(OPJ_FLOAT32 * pResult, OPJ_FLOAT32* pMatrix, OPJ_FLOAT32* pVector, OPJ_UINT32* pPermutations, OPJ_UINT32 n,OPJ_FLOAT32 * p_intermediate_data);
void opj_lupInvert (OPJ_FLOAT32 * pSrcMatrix,
OPJ_FLOAT32 * pDestMatrix,
OPJ_UINT32 n,
OPJ_UINT32 * pPermutations,
OPJ_FLOAT32 * p_src_temp,
OPJ_FLOAT32 * p_dest_temp,
OPJ_FLOAT32 * p_swap_area);
/**
* Matrix inversion.
*/
bool opj_matrix_inversion_f(OPJ_FLOAT32 * pSrcMatrix,OPJ_FLOAT32 * pDestMatrix, OPJ_UINT32 n)
{
OPJ_BYTE * l_data = 00;
OPJ_UINT32 l_permutation_size = n * sizeof(OPJ_UINT32);
OPJ_UINT32 l_swap_size = n * sizeof(OPJ_FLOAT32);
OPJ_UINT32 l_total_size = l_permutation_size + 3 * l_swap_size;
OPJ_UINT32 * lPermutations = 00;
OPJ_FLOAT32 * l_double_data = 00;
l_data = (OPJ_BYTE *) opj_malloc(l_total_size);
if
(l_data == 0)
{
return false;
}
lPermutations = (OPJ_UINT32 *) l_data;
l_double_data = (OPJ_FLOAT32 *) (l_data + l_permutation_size);
memset(lPermutations,0,l_permutation_size);
if
(! opj_lupDecompose(pSrcMatrix,lPermutations,l_double_data,n))
{
opj_free(l_data);
return false;
}
opj_lupInvert(pSrcMatrix,pDestMatrix,n,lPermutations,l_double_data,l_double_data + n,l_double_data + 2*n);
opj_free(l_data);
return true;
}
/**
* LUP decomposition
*/
bool opj_lupDecompose(OPJ_FLOAT32 * matrix,OPJ_UINT32 * permutations, OPJ_FLOAT32 * p_swap_area,OPJ_UINT32 n)
{
OPJ_UINT32 * tmpPermutations = permutations;
OPJ_UINT32 * dstPermutations;
OPJ_UINT32 k2=0,t;
OPJ_FLOAT32 temp;
OPJ_UINT32 i,j,k;
OPJ_FLOAT32 p;
OPJ_UINT32 lLastColum = n - 1;
OPJ_UINT32 lSwapSize = n * sizeof(OPJ_FLOAT32);
OPJ_FLOAT32 * lTmpMatrix = matrix;
OPJ_FLOAT32 * lColumnMatrix,* lDestMatrix;
OPJ_UINT32 offset = 1;
OPJ_UINT32 lStride = n-1;
//initialize permutations
for
(i = 0; i < n; ++i)
{
*tmpPermutations++ = i;
}
// now make a pivot with colum switch
tmpPermutations = permutations;
for
(k = 0; k < lLastColum; ++k)
{
p = 0.0;
// take the middle element
lColumnMatrix = lTmpMatrix + k;
// make permutation with the biggest value in the column
for
(i = k; i < n; ++i)
{
temp = ((*lColumnMatrix > 0) ? *lColumnMatrix : -(*lColumnMatrix));
if
(temp > p)
{
p = temp;
k2 = i;
}
// next line
lColumnMatrix += n;
}
// a whole rest of 0 -> non singular
if
(p == 0.0)
{
return false;
}
// should we permute ?
if
(k2 != k)
{
//exchange of line
// k2 > k
dstPermutations = tmpPermutations + k2 - k;
// swap indices
t = *tmpPermutations;
*tmpPermutations = *dstPermutations;
*dstPermutations = t;
// and swap entire line.
lColumnMatrix = lTmpMatrix + (k2 - k) * n;
memcpy(p_swap_area,lColumnMatrix,lSwapSize);
memcpy(lColumnMatrix,lTmpMatrix,lSwapSize);
memcpy(lTmpMatrix,p_swap_area,lSwapSize);
}
// now update data in the rest of the line and line after
lDestMatrix = lTmpMatrix + k;
lColumnMatrix = lDestMatrix + n;
// take the middle element
temp = *(lDestMatrix++);
// now compute up data (i.e. coeff up of the diagonal).
for (i = offset; i < n; ++i)
{
//lColumnMatrix;
// divide the lower column elements by the diagonal value
// matrix[i][k] /= matrix[k][k];
// p = matrix[i][k]
p = *lColumnMatrix / temp;
*(lColumnMatrix++) = p;
for
(j = /* k + 1 */ offset; j < n; ++j)
{
// matrix[i][j] -= matrix[i][k] * matrix[k][j];
*(lColumnMatrix++) -= p * (*(lDestMatrix++));
}
// come back to the k+1th element
lDestMatrix -= lStride;
// go to kth element of the next line
lColumnMatrix += k;
}
// offset is now k+2
++offset;
// 1 element less for stride
--lStride;
// next line
lTmpMatrix+=n;
// next permutation element
++tmpPermutations;
}
return true;
}
/**
* LUP solving
*/
void opj_lupSolve (OPJ_FLOAT32 * pResult, OPJ_FLOAT32 * pMatrix, OPJ_FLOAT32 * pVector, OPJ_UINT32* pPermutations, OPJ_UINT32 n,OPJ_FLOAT32 * p_intermediate_data)
{
OPJ_UINT32 i,j;
OPJ_FLOAT32 sum;
OPJ_FLOAT32 u;
OPJ_UINT32 lStride = n+1;
OPJ_FLOAT32 * lCurrentPtr;
OPJ_FLOAT32 * lIntermediatePtr;
OPJ_FLOAT32 * lDestPtr;
OPJ_FLOAT32 * lTmpMatrix;
OPJ_FLOAT32 * lLineMatrix = pMatrix;
OPJ_FLOAT32 * lBeginPtr = pResult + n - 1;
OPJ_FLOAT32 * lGeneratedData;
OPJ_UINT32 * lCurrentPermutationPtr = pPermutations;
lIntermediatePtr = p_intermediate_data;
lGeneratedData = p_intermediate_data + n - 1;
for
(i = 0; i < n; ++i)
{
sum = 0.0;
lCurrentPtr = p_intermediate_data;
lTmpMatrix = lLineMatrix;
for
(j = 1; j <= i; ++j)
{
// sum += matrix[i][j-1] * y[j-1];
sum += (*(lTmpMatrix++)) * (*(lCurrentPtr++));
}
//y[i] = pVector[pPermutations[i]] - sum;
*(lIntermediatePtr++) = pVector[*(lCurrentPermutationPtr++)] - sum;
lLineMatrix += n;
}
// we take the last point of the matrix
lLineMatrix = pMatrix + n*n - 1;
// and we take after the last point of the destination vector
lDestPtr = pResult + n;
for
(i = n - 1; i != -1 ; --i)
{
sum = 0.0;
lTmpMatrix = lLineMatrix;
u = *(lTmpMatrix++);
lCurrentPtr = lDestPtr--;
for
(j = i + 1; j < n; ++j)
{
// sum += matrix[i][j] * x[j]
sum += (*(lTmpMatrix++)) * (*(lCurrentPtr++));
}
//x[i] = (y[i] - sum) / u;
*(lBeginPtr--) = (*(lGeneratedData--) - sum) / u;
lLineMatrix -= lStride;
}
}
/** LUP inversion (call with the result of lupDecompose)
*/
void opj_lupInvert (
OPJ_FLOAT32 * pSrcMatrix,
OPJ_FLOAT32 * pDestMatrix,
OPJ_UINT32 n,
OPJ_UINT32 * pPermutations,
OPJ_FLOAT32 * p_src_temp,
OPJ_FLOAT32 * p_dest_temp,
OPJ_FLOAT32 * p_swap_area
)
{
OPJ_UINT32 j,i;
OPJ_FLOAT32 * lCurrentPtr;
OPJ_FLOAT32 * lLineMatrix = pDestMatrix;
OPJ_UINT32 lSwapSize = n * sizeof(OPJ_FLOAT32);
for
(j = 0; j < n; ++j)
{
lCurrentPtr = lLineMatrix++;
memset(p_src_temp,0,lSwapSize);
p_src_temp[j] = 1.0;
opj_lupSolve(p_dest_temp,pSrcMatrix,p_src_temp, pPermutations, n , p_swap_area);
for
(i = 0; i < n; ++i)
{
*(lCurrentPtr) = p_dest_temp[i];
lCurrentPtr+=n;
}
}
}

View File

@ -1,10 +1,5 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2012, Mathieu Malaterre <mathieu.malaterre@gmail.com>
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -28,21 +23,18 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OPJ_INTTYPES_H
#define OPJ_INTTYPES_H
#include "opj_config_private.h"
#ifdef OPJ_HAVE_INTTYPES_H
#include <inttypes.h>
#else
#if defined(_WIN32)
#define PRId64 "I64d"
#define PRIi64 "I64i"
#define PRIu64 "I64u"
#define PRIx64 "I64x"
#else
#error unsupported platform
#endif
#ifndef __INVERT_H
#define __INVERT_H
#include "openjpeg.h"
/**
* Calculates a n x n double matrix inversion with a LUP method. Data is aligned, rows after rows (or columns after columns).
* The function does not take ownership of any memory block, data must be fred by the user.
*
* @param pSrcMatrix the matrix to invert.
* @param pDestMatrix data to store the inverted matrix.
* @return 1 if the inversion is successful, 0 if the matrix is singular.
*/
bool opj_matrix_inversion_f(OPJ_FLOAT32 * pSrcMatrix,OPJ_FLOAT32 * pDestMatrix, OPJ_UINT32 n);
#endif
#endif /* OPJ_INTTYPES_H */

9398
libopenjpeg/j2k.c Normal file

File diff suppressed because it is too large Load Diff

737
libopenjpeg/j2k.h Normal file
View File

@ -0,0 +1,737 @@
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2006-2007, Parvatha Elangovan
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#ifndef __J2K_H
#define __J2K_H
/**
@file j2k.h
@brief The JPEG-2000 Codestream Reader/Writer (J2K)
The functions in J2K.C have for goal to read/write the several parts of the codestream: markers and data.
*/
#include "openjpeg.h"
struct opj_dparameters;
struct opj_stream_private;
struct opj_event_mgr;
/** @defgroup J2K J2K - JPEG-2000 codestream reader/writer */
/*@{*/
#define J2K_CP_CSTY_PRT 0x01
#define J2K_CP_CSTY_SOP 0x02
#define J2K_CP_CSTY_EPH 0x04
#define J2K_CCP_CSTY_PRT 0x01
#define J2K_CCP_CBLKSTY_LAZY 0x01
#define J2K_CCP_CBLKSTY_RESET 0x02
#define J2K_CCP_CBLKSTY_TERMALL 0x04
#define J2K_CCP_CBLKSTY_VSC 0x08
#define J2K_CCP_CBLKSTY_PTERM 0x10
#define J2K_CCP_CBLKSTY_SEGSYM 0x20
#define J2K_CCP_QNTSTY_NOQNT 0
#define J2K_CCP_QNTSTY_SIQNT 1
#define J2K_CCP_QNTSTY_SEQNT 2
/* ----------------------------------------------------------------------- */
#define J2K_MS_SOC 0xff4f /**< SOC marker value */
#define J2K_MS_SOT 0xff90 /**< SOT marker value */
#define J2K_MS_SOD 0xff93 /**< SOD marker value */
#define J2K_MS_EOC 0xffd9 /**< EOC marker value */
#define J2K_MS_SIZ 0xff51 /**< SIZ marker value */
#define J2K_MS_COD 0xff52 /**< COD marker value */
#define J2K_MS_COC 0xff53 /**< COC marker value */
#define J2K_MS_RGN 0xff5e /**< RGN marker value */
#define J2K_MS_QCD 0xff5c /**< QCD marker value */
#define J2K_MS_QCC 0xff5d /**< QCC marker value */
#define J2K_MS_POC 0xff5f /**< POC marker value */
#define J2K_MS_TLM 0xff55 /**< TLM marker value */
#define J2K_MS_PLM 0xff57 /**< PLM marker value */
#define J2K_MS_PLT 0xff58 /**< PLT marker value */
#define J2K_MS_PPM 0xff60 /**< PPM marker value */
#define J2K_MS_PPT 0xff61 /**< PPT marker value */
#define J2K_MS_SOP 0xff91 /**< SOP marker value */
#define J2K_MS_EPH 0xff92 /**< EPH marker value */
#define J2K_MS_CRG 0xff63 /**< CRG marker value */
#define J2K_MS_COM 0xff64 /**< COM marker value */
#define J2K_MS_CBD 0xff78 /**< CBD marker value */
#define J2K_MS_MCC 0xff75 /**< MCC marker value */
#define J2K_MS_MCT 0xff74 /**< MCT marker value */
#define J2K_MS_MCO 0xff77 /**< MCO marker value */
/* UniPG>> */
#ifdef USE_JPWL
#define J2K_MS_EPC 0xff68 /**< EPC marker value (Part 11: JPEG 2000 for Wireless) */
#define J2K_MS_EPB 0xff66 /**< EPB marker value (Part 11: JPEG 2000 for Wireless) */
#define J2K_MS_ESD 0xff67 /**< ESD marker value (Part 11: JPEG 2000 for Wireless) */
#define J2K_MS_RED 0xff69 /**< RED marker value (Part 11: JPEG 2000 for Wireless) */
#endif /* USE_JPWL */
#ifdef USE_JPSEC
#define J2K_MS_SEC 0xff65 /**< SEC marker value (Part 8: Secure JPEG 2000) */
#define J2K_MS_INSEC 0xff94 /**< INSEC marker value (Part 8: Secure JPEG 2000) */
#endif /* USE_JPSEC */
/* <<UniPG */
/* ----------------------------------------------------------------------- */
/**
Values that specify the status of the decoding process when decoding the main header.
These values may be combined with a | operator.
*/
typedef enum
{
J2K_DEC_STATE_NONE = 0x0000, /**< a SOC marker is expected */
J2K_DEC_STATE_MHSOC = 0x0001, /**< a SOC marker is expected */
J2K_DEC_STATE_MHSIZ = 0x0002, /**< a SIZ marker is expected */
J2K_DEC_STATE_MH = 0x0004, /**< the decoding process is in the main header */
J2K_DEC_STATE_TPHSOT = 0x0008, /**< the decoding process is in a tile part header and expects a SOT marker */
J2K_DEC_STATE_TPH = 0x0010, /**< the decoding process is in a tile part header */
J2K_DEC_STATE_MT = 0x0020, /**< the EOC marker has just been read */
J2K_DEC_STATE_NEOC = 0x0040, /**< the decoding process must not expect a EOC marker because the codestream is truncated */
J2K_DEC_STATE_DATA = 0x0080, /**< the decoding process must not expect a EOC marker because the codestream is truncated */
J2K_DEC_STATE_ERR = 0x8000, /**< the decoding process has encountered an error */
J2K_DEC_STATE_EOC = 0x0100
}
J2K_DECODING_STATUS;
/**
Values that specify the status of the decoding process when decoding the main header.
These values may be combined with a | operator.
*/
typedef enum
{
J2K_ENC_STATE_NONE = 0x0000, /**< a SOC marker is expected */
J2K_ENC_STATE_ENCODE = 0x0001, /**< a SOC marker is expected */
}
J2K_ENCODING_STATUS;
/**
* Type of data for storing the MCT data
*/
typedef enum MCT_ELEMENT_TYPE
{
MCT_TYPE_INT16 = 0, /** MCT data is stored as signed shorts*/
MCT_TYPE_INT32 = 1, /** MCT data is stored as signed integers*/
MCT_TYPE_FLOAT = 2, /** MCT data is stored as floats*/
MCT_TYPE_DOUBLE = 3 /** MCT data is stored as doubles*/
} J2K_MCT_ELEMENT_TYPE;
/**
* Type of data for storing the MCT data
*/
typedef enum MCT_ARRAY_TYPE
{
MCT_TYPE_DEPENDENCY = 0,
MCT_TYPE_DECORRELATION = 1,
MCT_TYPE_OFFSET = 2
} J2K_MCT_ARRAY_TYPE;
/* ----------------------------------------------------------------------- */
/**
Quantization stepsize
*/
typedef struct opj_stepsize
{
/** exponent */
OPJ_UINT32 expn;
/** mantissa */
OPJ_UINT32 mant;
}
opj_stepsize_t;
typedef struct opj_mct_data
{
J2K_MCT_ELEMENT_TYPE m_element_type;
J2K_MCT_ARRAY_TYPE m_array_type;
OPJ_UINT32 m_index;
OPJ_BYTE * m_data;
OPJ_UINT32 m_data_size;
}
opj_mct_data_t;
typedef struct opj_simple_mcc_decorrelation_data
{
OPJ_UINT32 m_index;
OPJ_UINT32 m_nb_comps;
opj_mct_data_t * m_decorrelation_array;
opj_mct_data_t * m_offset_array;
OPJ_UINT32 m_is_irreversible : 1;
}
opj_simple_mcc_decorrelation_data_t;
/**
Tile-component coding parameters
*/
typedef struct opj_tccp
{
/** coding style */
OPJ_UINT32 csty;
/** number of resolutions */
OPJ_UINT32 numresolutions;
/** code-blocks width */
OPJ_UINT32 cblkw;
/** code-blocks height */
OPJ_UINT32 cblkh;
/** code-block coding style */
OPJ_UINT32 cblksty;
/** discrete wavelet transform identifier */
OPJ_UINT32 qmfbid;
/** quantisation style */
OPJ_UINT32 qntsty;
/** stepsizes used for quantization */
opj_stepsize_t stepsizes[J2K_MAXBANDS];
/** number of guard bits */
OPJ_UINT32 numgbits;
/** Region Of Interest shift */
OPJ_INT32 roishift;
/** precinct width */
OPJ_UINT32 prcw[J2K_MAXRLVLS];
/** precinct height */
OPJ_UINT32 prch[J2K_MAXRLVLS];
/** the dc_level_shift **/
OPJ_INT32 m_dc_level_shift;
}
opj_tccp_t;
/**
Tile coding parameters :
this structure is used to store coding/decoding parameters common to all
tiles (information like COD, COC in main header)
*/
typedef struct opj_tcp
{
/** coding style */
OPJ_UINT32 csty;
/** progression order */
OPJ_PROG_ORDER prg;
/** number of layers */
OPJ_UINT32 numlayers;
OPJ_UINT32 num_layers_to_decode;
/** multi-component transform identifier */
OPJ_UINT32 mct;
/** rates of layers */
OPJ_FLOAT32 rates[100];
/** number of progression order changes */
OPJ_UINT32 numpocs;
/** progression order changes */
opj_poc_t pocs[32];
/** packet header store there for futur use in t2_decode_packet */
OPJ_BYTE *ppt_data;
/** used to keep a track of the allocated memory */
OPJ_BYTE *ppt_buffer;
/** Number of bytes stored inside ppt_data*/
OPJ_UINT32 ppt_data_size;
/** size of ppt_data*/
OPJ_UINT32 ppt_len;
/** add fixed_quality */
OPJ_FLOAT32 distoratio[100];
/** tile-component coding parameters */
opj_tccp_t *tccps;
/** number of tile parts for the tile. */
OPJ_UINT32 m_nb_tile_parts;
/** data for the tile */
OPJ_BYTE * m_data;
/** size of data */
OPJ_UINT32 m_data_size;
/** encoding norms */
OPJ_FLOAT64 * mct_norms;
/** the mct decoding matrix */
OPJ_FLOAT32 * m_mct_decoding_matrix;
/** the mct coding matrix */
OPJ_FLOAT32 * m_mct_coding_matrix;
/** mct records */
opj_mct_data_t * m_mct_records;
/** the number of mct records. */
OPJ_UINT32 m_nb_mct_records;
/** the max number of mct records. */
OPJ_UINT32 m_nb_max_mct_records;
/** mcc records */
opj_simple_mcc_decorrelation_data_t * m_mcc_records;
/** the number of mct records. */
OPJ_UINT32 m_nb_mcc_records;
/** the max number of mct records. */
OPJ_UINT32 m_nb_max_mcc_records;
/***** FLAGS *******/
/** If ppt == 1 --> there was a PPT marker for the present tile */
OPJ_UINT32 ppt : 1;
/** indicates if a POC marker has been used O:NO, 1:YES */
OPJ_UINT32 POC : 1;
} opj_tcp_t;
typedef struct opj_encoding_param
{
/** Digital cinema profile*/
OPJ_CINEMA_MODE m_cinema;
/** Maximum rate for each component. If == 0, component size limitation is not considered */
OPJ_UINT32 m_max_comp_size;
/** Position of tile part flag in progression order*/
OPJ_INT32 m_tp_pos;
/** fixed layer */
OPJ_INT32 *m_matrice;
/** Flag determining tile part generation*/
OPJ_BYTE m_tp_flag;
/** allocation by rate/distortion */
OPJ_UINT32 m_disto_alloc : 1;
/** allocation by fixed layer */
OPJ_UINT32 m_fixed_alloc : 1;
/** add fixed_quality */
OPJ_UINT32 m_fixed_quality : 1;
/** Enabling Tile part generation*/
OPJ_UINT32 m_tp_on : 1;
}
opj_encoding_param_t;
typedef struct opj_decoding_param
{
/** if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, image is decoded to the full resolution */
OPJ_UINT32 m_reduce;
/** if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */
OPJ_UINT32 m_layer;
}
opj_decoding_param_t;
/**
Coding parameters
*/
typedef struct opj_cp
{
/** Size of the image in bits*/
/*int img_size;*/
/** Rsiz*/
OPJ_RSIZ_CAPABILITIES rsiz;
/** XTOsiz */
OPJ_INT32 tx0;
/** YTOsiz */
OPJ_INT32 ty0;
/** XTsiz */
OPJ_UINT32 tdx;
/** YTsiz */
OPJ_UINT32 tdy;
/** comment */
OPJ_CHAR *comment;
/** number of tiles in width */
OPJ_UINT32 tw;
/** number of tiles in heigth */
OPJ_UINT32 th;
/** packet header storage original buffer */
OPJ_BYTE *ppm_buffer;
/** packet header store there for futur use in t2_decode_packet */
OPJ_BYTE *ppm_data;
/** size of the ppm_data*/
OPJ_UINT32 ppm_len;
/** Number of bytes actually stored inside the ppm_data */
OPJ_UINT32 ppm_data_size;
/** tile coding parameters */
opj_tcp_t *tcps;
union
{
opj_decoding_param_t m_dec;
opj_encoding_param_t m_enc;
}
m_specific_param;
/* UniPG>> */
#ifdef USE_JPWL
/** enables writing of EPC in MH, thus activating JPWL */
bool epc_on;
/** enables writing of EPB, in case of activated JPWL */
bool epb_on;
/** enables writing of ESD, in case of activated JPWL */
bool esd_on;
/** enables writing of informative techniques of ESD, in case of activated JPWL */
bool info_on;
/** enables writing of RED, in case of activated JPWL */
bool red_on;
/** error protection method for MH (0,1,16,32,37-128) */
int hprot_MH;
/** tile number of header protection specification (>=0) */
int hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
/** error protection methods for TPHs (0,1,16,32,37-128) */
int hprot_TPH[JPWL_MAX_NO_TILESPECS];
/** tile number of packet protection specification (>=0) */
int pprot_tileno[JPWL_MAX_NO_PACKSPECS];
/** packet number of packet protection specification (>=0) */
int pprot_packno[JPWL_MAX_NO_PACKSPECS];
/** error protection methods for packets (0,1,16,32,37-128) */
int pprot[JPWL_MAX_NO_PACKSPECS];
/** enables writing of ESD, (0/2/4 bytes) */
int sens_size;
/** sensitivity addressing size (0=auto/2/4 bytes) */
int sens_addr;
/** sensitivity range (0-3) */
int sens_range;
/** sensitivity method for MH (-1,0-7) */
int sens_MH;
/** tile number of sensitivity specification (>=0) */
int sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
/** sensitivity methods for TPHs (-1,0-7) */
int sens_TPH[JPWL_MAX_NO_TILESPECS];
/** enables JPWL correction at the decoder */
bool correct;
/** expected number of components at the decoder */
int exp_comps;
/** maximum number of tiles at the decoder */
int max_tiles;
#endif /* USE_JPWL */
/******** FLAGS *********/
/** if ppm == 1 --> there was a PPM marker*/
OPJ_UINT32 ppm : 1;
/** tells if the parameter is a coding or decoding one */
OPJ_UINT32 m_is_decoder : 1;
/* <<UniPG */
} opj_cp_t;
typedef struct opj_j2k_dec
{
/** locate in which part of the codestream the decoder is (main header, tile header, end) */
OPJ_UINT32 m_state;
/**
* store decoding parameters common to all tiles (information like COD, COC in main header)
*/
opj_tcp_t *m_default_tcp;
OPJ_BYTE *m_header_data;
OPJ_UINT32 m_header_data_size;
/** to tell the tile part length */
OPJ_UINT32 m_sot_length;
/** Only tiles index in the correct range will be decoded.*/
OPJ_UINT32 m_start_tile_x;
OPJ_UINT32 m_start_tile_y;
OPJ_UINT32 m_end_tile_x;
OPJ_UINT32 m_end_tile_y;
/** to tell that a tile can be decoded. */
OPJ_UINT32 m_can_decode : 1;
OPJ_UINT32 m_discard_tiles : 1;
OPJ_UINT32 m_skip_data : 1;
} opj_j2k_dec_t;
typedef struct opj_j2k_enc
{
/** Tile part number, regardless of poc, for each new poc, tp is reset to 1*/
OPJ_UINT32 m_current_poc_tile_part_number; // tp_num
/** Tile part number currently coding, taking into account POC. m_current_tile_part_number holds the total number of tile parts while encoding the last tile part.*/
OPJ_UINT32 m_current_tile_part_number; //cur_tp_num
/**
locate the start position of the TLM marker
after encoding the tilepart, a jump (in j2k_write_sod) is done to the TLM marker to store the value of its length.
*/
OPJ_SIZE_T m_tlm_start;
/**
* Stores the sizes of the tlm.
*/
OPJ_BYTE * m_tlm_sot_offsets_buffer;
/**
* The current offset of the tlm buffer.
*/
OPJ_BYTE * m_tlm_sot_offsets_current;
/** Total num of tile parts in whole image = num tiles* num tileparts in each tile*/
/** used in TLMmarker*/
OPJ_UINT32 m_total_tile_parts; // totnum_tp
/* encoded data for a tile */
OPJ_BYTE * m_encoded_tile_data;
/* size of the encoded_data */
OPJ_UINT32 m_encoded_tile_size;
/* encoded data for a tile */
OPJ_BYTE * m_header_tile_data;
/* size of the encoded_data */
OPJ_UINT32 m_header_tile_data_size;
} opj_j2k_enc_t;
/**
JPEG-2000 codestream reader/writer
*/
typedef struct opj_j2k
{
union
{
opj_j2k_dec_t m_decoder;
opj_j2k_enc_t m_encoder;
}
m_specific_param;
/** number of the tile curently concern by coding/decoding */
OPJ_UINT32 m_current_tile_number;
/** pointer to the encoded / decoded image */
opj_image_t *m_image;
/** Coding parameters */
opj_cp_t m_cp;
/** the list of procedures to exec **/
struct opj_procedure_list * m_procedure_list;
/** the list of validation procedures to follow to make sure the code is valid **/
struct opj_procedure_list * m_validation_list;
/** helper used to write the index file */
opj_codestream_info_t *cstr_info;
/** the current tile coder/decoder **/
struct opj_tcd * m_tcd;
OPJ_UINT32 m_is_decoder : 1;
}
opj_j2k_t;
/** @name Exported functions */
/*@{*/
/* ----------------------------------------------------------------------- */
/**
* Creates a J2K decompression structure.
*
* @return a handle to a J2K decompressor if successful, NULL otherwise.
*/
opj_j2k_t* j2k_create_decompress();
/**
* Destroys a jpeg2000 codec.
*
* @param p_j2k the jpeg20000 structure to destroy.
*/
void j2k_destroy (opj_j2k_t *p_j2k);
/**
* Starts a compression scheme, i.e. validates the codec parameters, writes the header.
*
* @param p_j2k the jpeg2000 codec.
* @param cio the stream object.
* @param p_manager the user event manager.
*
* @return true if the codec is valid.
*/
bool j2k_start_compress(
opj_j2k_t *p_j2k,
struct opj_stream_private *cio,
struct opj_image * p_image,
struct opj_event_mgr * p_manager
);
/**
* Ends the compression procedures and possibiliy add data to be read after the
* codestream.
*/
bool j2k_end_compress(opj_j2k_t *p_j2k, struct opj_stream_private *cio, struct opj_event_mgr * p_manager);
/**
* Sets up the decoder decoding parameters using user parameters.
* Decoding parameters are stored in j2k->cp.
*
* @param p_j2k J2K codec
* @param p_parameters decompression parameters
* @deprecated
*/
void j2k_setup_decoder(
opj_j2k_t *p_j2k,
struct opj_dparameters *p_parameters
);
/**
* Reads a jpeg2000 codestream header structure.
*
* @param cio the stream to read data from.
* @param p_j2k the jpeg2000 codec.
* @param p_manager the user event manager.
*
* @return true if the box is valid.
*/
bool j2k_read_header(
opj_j2k_t *p_j2k,
struct opj_image ** p_image,
OPJ_INT32 * p_tile_x0,
OPJ_INT32 * p_tile_y0,
OPJ_UINT32 * p_tile_width,
OPJ_UINT32 * p_tile_height,
OPJ_UINT32 * p_nb_tiles_x,
OPJ_UINT32 * p_nb_tiles_y,
struct opj_stream_private *cio,
struct opj_event_mgr * p_manager
);
/**
Decode an image from a JPEG-2000 codestream
@param j2k J2K decompressor handle
@param cio Input buffer stream
@param cstr_info Codestream information structure if required, NULL otherwise
@return Returns a decoded image if successful, returns NULL otherwise
*/
opj_image_t* j2k_decode(opj_j2k_t *j2k, struct opj_stream_private *cio, struct opj_event_mgr * p_manager);
/**
* Ends the decompression procedures and possibiliy add data to be read after the
* codestream.
*/
bool j2k_end_decompress(opj_j2k_t *j2k, struct opj_stream_private *cio, struct opj_event_mgr * p_manager);
/**
Decode an image form a JPT-stream (JPEG 2000, JPIP)
@param j2k J2K decompressor handle
@param cio Input buffer stream
@param cstr_info Codestream information structure if required, NULL otherwise
@return Returns a decoded image if successful, returns NULL otherwise
*/
opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, struct opj_stream_private *cio, struct opj_codestream_info *cstr_info);
/**
Creates a J2K compression structure
@param cinfo Codec context info
@return Returns a handle to a J2K compressor if successful, returns NULL otherwise
*/
opj_j2k_t* j2k_create_compress();
/**
Setup the encoder parameters using the current image and using user parameters.
Coding parameters are returned in j2k->cp.
@param j2k J2K compressor handle
@param parameters compression parameters
@param image input filled image
*/
void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_t *image, struct opj_event_mgr * p_manager);
/**
* Writes a tile.
* @param p_j2k the jpeg2000 codec.
* @param p_stream the stream to write data to.
* @param p_manager the user event manager.
*/
bool j2k_write_tile (
opj_j2k_t * p_j2k,
OPJ_UINT32 p_tile_index,
OPJ_BYTE * p_data,
OPJ_UINT32 p_data_size,
struct opj_stream_private *p_stream,
struct opj_event_mgr * p_manager
);
/**
* Converts an enum type progression order to string type.
*
* @param prg_order the progression order to get.
*
* @return the string representation of the gicen progression order.
*/
const char * j2k_convert_progression_order(OPJ_PROG_ORDER prg_order);
/**
* Encodes an image into a JPEG-2000 codestream
*/
bool j2k_encode(
opj_j2k_t * p_j2k,
struct opj_stream_private *cio,
struct opj_event_mgr * p_manager
);
bool j2k_setup_mct_encoding (opj_tcp_t * p_tcp,opj_image_t * p_image);
/**
* Decode tile data.
* @param p_j2k the jpeg2000 codec.
* @param p_stream the stream to write data to.
* @param p_manager the user event manager.
*/
bool j2k_decode_tile (
opj_j2k_t * p_j2k,
OPJ_UINT32 p_tile_index,
OPJ_BYTE * p_data,
OPJ_UINT32 p_data_size,
struct opj_stream_private *p_stream,
struct opj_event_mgr * p_manager
);
/**
* Reads a tile header.
* @param p_j2k the jpeg2000 codec.
* @param p_stream the stream to write data to.
* @param p_manager the user event manager.
*/
bool j2k_read_tile_header (
opj_j2k_t * p_j2k,
OPJ_UINT32 * p_tile_index,
OPJ_UINT32 * p_data_size,
OPJ_INT32 * p_tile_x0,
OPJ_INT32 * p_tile_y0,
OPJ_INT32 * p_tile_x1,
OPJ_INT32 * p_tile_y1,
OPJ_UINT32 * p_nb_comps,
bool * p_go_on,
struct opj_stream_private *p_stream,
struct opj_event_mgr * p_manager
);
/**
* Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
*
* @param p_j2k the jpeg2000 codec.
* @param p_start_x the left position of the rectangle to decode (in image coordinates).
* @param p_end_x the right position of the rectangle to decode (in image coordinates).
* @param p_start_y the up position of the rectangle to decode (in image coordinates).
* @param p_end_y the bottom position of the rectangle to decode (in image coordinates).
* @param p_manager the user event manager
*
* @return true if the area could be set.
*/
bool j2k_set_decode_area(
opj_j2k_t *p_j2k,
OPJ_INT32 p_start_x,
OPJ_INT32 p_start_y,
OPJ_INT32 p_end_x,
OPJ_INT32 p_end_y,
struct opj_event_mgr * p_manager
);
void j2k_dump_image(FILE *fd, opj_image_t * img);
/* ----------------------------------------------------------------------- */
/*@}*/
/*@}*/
#endif /* __J2K_H */

View File

@ -1,10 +1,5 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2005, Hervé Drolon, FreeImage Team
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -29,39 +24,42 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "opj_includes.h"
#ifdef _WIN32
#ifdef WIN32
#include <windows.h>
#else
#include <sys/time.h>
/*#include <sys/time.h>
#include <sys/resource.h>
#include <sys/times.h>
#endif /* _WIN32 */
*/
#endif /* WIN32 */
#include "j2k_lib.h"
OPJ_FLOAT64 opj_clock(void)
{
#ifdef _WIN32
/* _WIN32: use QueryPerformance (very accurate) */
LARGE_INTEGER freq, t ;
OPJ_FLOAT64 opj_clock(void) {
#if 0
#ifdef WIN32
/* WIN32: use QueryPerformance (very accurate) */
LARGE_INTEGER freq , t ;
/* freq is the clock speed of the CPU */
QueryPerformanceFrequency(&freq) ;
/* cout << "freq = " << ((double) freq.QuadPart) << endl; */
/* cout << "freq = " << ((double) freq.QuadPart) << endl; */
/* t is the high resolution performance counter (see MSDN) */
QueryPerformanceCounter(& t) ;
return ((OPJ_FLOAT64) t.QuadPart / (OPJ_FLOAT64) freq.QuadPart) ;
QueryPerformanceCounter ( & t ) ;
return ( t.QuadPart /(double) freq.QuadPart ) ;
#else
/* Unix or Linux: use resource usage */
/* Unix or Linux: use resource usage */
struct rusage t;
OPJ_FLOAT64 procTime;
double procTime;
/* (1) Get the rusage data structure at this moment (man getrusage) */
getrusage(0, &t);
getrusage(0,&t);
/* (2) What is the elapsed time ? - CPU time = User time + System time */
/* (2a) Get the seconds */
procTime = (OPJ_FLOAT64)(t.ru_utime.tv_sec + t.ru_stime.tv_sec);
/* (2a) Get the seconds */
procTime = t.ru_utime.tv_sec + t.ru_stime.tv_sec;
/* (2b) More precisely! Get the microseconds part ! */
return (procTime + (OPJ_FLOAT64)(t.ru_utime.tv_usec + t.ru_stime.tv_usec) *
1e-6) ;
return ( procTime + (t.ru_utime.tv_usec + t.ru_stime.tv_usec) * 1e-6 ) ;
#endif
#endif
return 0;
}

View File

@ -1,10 +1,5 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2005, Hervé Drolon, FreeImage Team
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -28,15 +23,15 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OPJ_CLOCK_H
#define OPJ_CLOCK_H
#ifndef __J2K_LIB_H
#define __J2K_LIB_H
/**
@file opj_clock.h
@brief Internal function for timing
@file j2k_lib.h
@brief Internal functions
The functions in OPJ_CLOCK.C are internal utilities mainly used for timing.
The functions in J2K_LIB.C are internal utilities mainly used for timing.
*/
#include "openjpeg.h"
/** @defgroup MISC MISC - Miscellaneous internal functions */
/*@{*/
@ -55,5 +50,5 @@ OPJ_FLOAT64 opj_clock(void);
/*@}*/
#endif /* OPJ_CLOCK_H */
#endif /* __J2K_LIB_H */

2237
libopenjpeg/jp2.c Normal file

File diff suppressed because it is too large Load Diff

342
libopenjpeg/jp2.h Normal file
View File

@ -0,0 +1,342 @@
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#ifndef __JP2_H
#define __JP2_H
/**
@file jp2.h
@brief The JPEG-2000 file format Reader/Writer (JP2)
*/
#include "openjpeg.h"
/**********************************************************************************
********************************* FORWARD DECLARATIONS ***************************
**********************************************************************************/
struct opj_j2k;
struct opj_procedure_list;
struct opj_event_mgr;
struct opj_stream_private;
struct opj_dparameters;
struct opj_cparameters;
/** @defgroup JP2 JP2 - JPEG-2000 file format reader/writer */
/*@{*/
#define JPIP_JPIP 0x6a706970
#define JP2_JP 0x6a502020 /**< JPEG 2000 signature box */
#define JP2_FTYP 0x66747970 /**< File type box */
#define JP2_JP2H 0x6a703268 /**< JP2 header box */
#define JP2_IHDR 0x69686472 /**< Image header box */
#define JP2_COLR 0x636f6c72 /**< Colour specification box */
#define JP2_JP2C 0x6a703263 /**< Contiguous codestream box */
#define JP2_URL 0x75726c20 /**< URL box */
#define JP2_DBTL 0x6474626c /**< ??? */
#define JP2_BPCC 0x62706363 /**< Bits per component box */
#define JP2_JP2 0x6a703220 /**< File type fields */
/* ----------------------------------------------------------------------- */
typedef enum
{
JP2_STATE_NONE = 0x0,
JP2_STATE_SIGNATURE = 0x1,
JP2_STATE_FILE_TYPE = 0x2,
JP2_STATE_HEADER = 0x4,
JP2_STATE_CODESTREAM = 0x8,
JP2_STATE_END_CODESTREAM = 0x10,
JP2_STATE_UNKNOWN = 0x80000000
}
JP2_STATE;
typedef enum
{
JP2_IMG_STATE_NONE = 0x0,
JP2_IMG_STATE_UNKNOWN = 0x80000000
}
JP2_IMG_STATE;
/**
JP2 component
*/
typedef struct opj_jp2_comps
{
unsigned int depth;
int sgnd;
unsigned int bpcc;
}
opj_jp2_comps_t;
/**
JPEG-2000 file format reader/writer
*/
typedef struct opj_jp2
{
/** handle to the J2K codec */
struct opj_j2k *j2k;
/** list of validation procedures */
struct opj_procedure_list * m_validation_list;
/** list of execution procedures */
struct opj_procedure_list * m_procedure_list;
/* width of image */
unsigned int w;
/* height of image */
unsigned int h;
/* number of components in the image */
unsigned int numcomps;
unsigned int bpc;
unsigned int C;
unsigned int UnkC;
unsigned int IPR;
unsigned int meth;
unsigned int approx;
unsigned int enumcs;
unsigned int precedence;
unsigned int brand;
unsigned int minversion;
unsigned int numcl;
unsigned int *cl;
opj_jp2_comps_t *comps;
unsigned int j2k_codestream_offset;
unsigned int jp2_state;
unsigned int jp2_img_state;
}
opj_jp2_t;
/**
JP2 Box
*/
typedef struct opj_jp2_box
{
unsigned int length;
unsigned int type;
}
opj_jp2_box_t;
typedef struct opj_jp2_header_handler
{
/* marker value */
int id;
/* action linked to the marker */
bool (*handler) (opj_jp2_t *jp2,unsigned char * p_header_data, unsigned int p_header_size,struct opj_event_mgr * p_manager);
}
opj_jp2_header_handler_t;
typedef struct opj_jp2_img_header_writer_handler
{
/* action to perform */
unsigned char* (*handler) (opj_jp2_t *jp2, unsigned int * p_data_size);
/* result of the action : data */
unsigned char * m_data;
/* size of data */
unsigned int m_size;
}
opj_jp2_img_header_writer_handler_t;
/** @name Exported functions */
/*@{*/
/* ----------------------------------------------------------------------- */
/**
* Creates a jpeg2000 file decompressor.
*
* @return an empty jpeg2000 file codec.
*/
opj_jp2_t* jp2_create (bool p_is_decoder);
/**
Destroy a JP2 decompressor handle
@param jp2 JP2 decompressor handle to destroy
*/
void jp2_destroy(opj_jp2_t *jp2);
/**
Setup the decoder decoding parameters using user parameters.
Decoding parameters are returned in jp2->j2k->cp.
@param jp2 JP2 decompressor handle
@param parameters decompression parameters
*/
void jp2_setup_decoder(opj_jp2_t *jp2, struct opj_dparameters *parameters);
/**
* Decode an image from a JPEG-2000 file stream
* @param jp2 JP2 decompressor handle
* @param cio Input buffer stream
* @param cstr_info Codestream information structure if required, NULL otherwise
* @return Returns a decoded image if successful, returns NULL otherwise
*/
struct opj_image* opj_jp2_decode(opj_jp2_t *jp2, struct opj_stream_private *cio, struct opj_event_mgr * p_manager);
/**
Setup the encoder parameters using the current image and using user parameters.
Coding parameters are returned in jp2->j2k->cp.
@param jp2 JP2 compressor handle
@param parameters compression parameters
@param image input filled image
*/
void jp2_setup_encoder(opj_jp2_t *jp2, struct opj_cparameters *parameters, struct opj_image *image,struct opj_event_mgr * p_manager);
/**
* Starts a compression scheme, i.e. validates the codec parameters, writes the header.
*
* @param jp2 the jpeg2000 file codec.
* @param cio the stream object.
*
* @return true if the codec is valid.
*/
bool jp2_start_compress(opj_jp2_t *jp2, struct opj_stream_private *cio,struct opj_image * p_image,struct opj_event_mgr * p_manager);
/**
* Ends the compression procedures and possibiliy add data to be read after the
* codestream.
*/
bool jp2_end_compress(opj_jp2_t *jp2, struct opj_stream_private *cio, struct opj_event_mgr * p_manager);
/**
Encode an image into a JPEG-2000 file stream
@param jp2 JP2 compressor handle
@param cio Output buffer stream
@param image Image to encode
@param cstr_info Codestream information structure if required, NULL otherwise
@return Returns true if successful, returns false otherwise
*/
bool opj_jp2_encode(opj_jp2_t *jp2, struct opj_stream_private *cio, struct opj_event_mgr * p_manager);
/**
* Reads a jpeg2000 file header structure.
*
* @param cio the stream to read data from.
* @param jp2 the jpeg2000 file header structure.
* @param p_manager the user event manager.
*
* @return true if the box is valid.
*/
bool jp2_read_header(
opj_jp2_t *jp2,
struct opj_image ** p_image,
OPJ_INT32 * p_tile_x0,
OPJ_INT32 * p_tile_y0,
OPJ_UINT32 * p_tile_width,
OPJ_UINT32 * p_tile_height,
OPJ_UINT32 * p_nb_tiles_x,
OPJ_UINT32 * p_nb_tiles_y,
struct opj_stream_private *cio,
struct opj_event_mgr * p_manager
);
/**
* Ends the decompression procedures and possibiliy add data to be read after the
* codestream.
*/
bool jp2_end_decompress(opj_jp2_t *jp2, struct opj_stream_private *cio, struct opj_event_mgr * p_manager);
/**
* Writes a tile.
* @param p_j2k the jpeg2000 codec.
* @param p_stream the stream to write data to.
* @param p_manager the user event manager.
*/
bool jp2_write_tile (
opj_jp2_t *p_jp2,
OPJ_UINT32 p_tile_index,
OPJ_BYTE * p_data,
OPJ_UINT32 p_data_size,
struct opj_stream_private *p_stream,
struct opj_event_mgr * p_manager
);
/**
* Decode tile data.
* @param p_j2k the jpeg2000 codec.
* @param p_stream the stream to write data to.
* @param p_manager the user event manager.
*/
bool opj_jp2_decode_tile (
opj_jp2_t * p_jp2,
OPJ_UINT32 p_tile_index,
OPJ_BYTE * p_data,
OPJ_UINT32 p_data_size,
struct opj_stream_private *p_stream,
struct opj_event_mgr * p_manager
);
/**
* Reads a tile header.
* @param p_j2k the jpeg2000 codec.
* @param p_stream the stream to write data to.
* @param p_manager the user event manager.
*/
bool jp2_read_tile_header (
opj_jp2_t * p_j2k,
OPJ_UINT32 * p_tile_index,
OPJ_UINT32 * p_data_size,
OPJ_INT32 * p_tile_x0,
OPJ_INT32 * p_tile_y0,
OPJ_INT32 * p_tile_x1,
OPJ_INT32 * p_tile_y1,
OPJ_UINT32 * p_nb_comps,
bool * p_go_on,
struct opj_stream_private *p_stream,
struct opj_event_mgr * p_manager
);
/**
* Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
*
* @param p_jp2 the jpeg2000 codec.
* @param p_end_x the right position of the rectangle to decode (in image coordinates).
* @param p_start_y the up position of the rectangle to decode (in image coordinates).
* @param p_end_y the bottom position of the rectangle to decode (in image coordinates).
* @param p_manager the user event manager
*
* @return true if the area could be set.
*/
bool jp2_set_decode_area(
opj_jp2_t *p_jp2,
OPJ_INT32 p_start_x,
OPJ_INT32 p_start_y,
OPJ_INT32 p_end_x,
OPJ_INT32 p_end_y,
struct opj_event_mgr * p_manager
);
/* ----------------------------------------------------------------------- */
/*@}*/
/*@}*/
#endif /* __JP2_H */

249
libopenjpeg/jpt.c Normal file
View File

@ -0,0 +1,249 @@
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#include "jpt.h"
#include "openjpeg.h"
#include "cio.h"
#include "event.h"
/*
* Read the information contains in VBAS [JPP/JPT stream message header]
* Store information (7 bits) in value
* @param p_cio the stream to read from.
* @param p_value the data to update
* @return the nb of bytes read or -1 if an io error occurred.
*/
bool jpt_read_VBAS_info(opj_stream_private_t * p_cio, OPJ_UINT32 * p_nb_bytes_read, OPJ_UINT32 * p_value, opj_event_mgr_t * p_manager)
{
OPJ_BYTE l_elmt;
OPJ_UINT32 l_nb_bytes_read = 0;
// read data till the MSB of the current byte is 1.
// concatenate 7 bits of data, last bit is finish flag
// read data from the stream
if
(opj_stream_read_data(p_cio,&l_elmt,1,p_manager) != 1)
{
opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data.\n");
return false;
}
++l_nb_bytes_read;
// is the MSB equal to 1 ?
while
(l_elmt & 0x80)
{
// concatenate 7 bits of data, last bit is finish flag
*p_value = (*p_value << 7) | (l_elmt & 0x7f);
if
(opj_stream_read_data(p_cio,&l_elmt,1,p_manager) != 1)
{
opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data.\n");
return false;
}
++l_nb_bytes_read;
}
// concatenate 7 bits of data, last bit is finish flag
*p_value = (*p_value << 7) | (l_elmt & 0x7f);
* p_nb_bytes_read = l_nb_bytes_read;
return true;
}
/*
* Initialize the value of the message header structure
*
*/
void jpt_init_msg_header(opj_jpt_msg_header_t * header)
{
header->Id = 0; /* In-class Identifier */
header->last_byte = 0; /* Last byte information */
header->Class_Id = 0; /* Class Identifier */
header->CSn_Id = 0; /* CSn : index identifier */
header->Msg_offset = 0; /* Message offset */
header->Msg_length = 0; /* Message length */
header->Layer_nb = 0; /* Auxiliary for JPP case */
}
/*
* Re-initialize the value of the message header structure
*
* Only parameters always present in message header
*
*/
void jpt_reinit_msg_header(opj_jpt_msg_header_t * header)
{
header->Id = 0; /* In-class Identifier */
header->last_byte = 0; /* Last byte information */
header->Msg_offset = 0; /* Message offset */
header->Msg_length = 0; /* Message length */
}
/*
* Read the message header for a JPP/JPT - stream
*
*/
bool jpt_read_msg_header(opj_stream_private_t *cio, opj_jpt_msg_header_t *header, OPJ_UINT32 * p_nb_bytes_read, opj_event_mgr_t * p_manager)
{
OPJ_BYTE elmt, Class = 0, CSn = 0;
OPJ_UINT32 l_nb_bytes_read = 0;
OPJ_UINT32 l_last_nb_bytes_read;
jpt_reinit_msg_header(header);
/* ------------- */
/* VBAS : Bin-ID */
/* ------------- */
if
(opj_stream_read_data(cio,&elmt,1,p_manager) != 1)
{
opj_event_msg(p_manager, EVT_ERROR, "Forbidden value encounter in message header !!\n");
return false;
}
++l_nb_bytes_read;
/* See for Class and CSn */
switch ((elmt >> 5) & 0x03)
{
case 0:
opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data!!!\n");
break;
case 1:
Class = 0;
CSn = 0;
break;
case 2:
Class = 1;
CSn = 0;
break;
case 3:
Class = 1;
CSn = 1;
break;
default:
break;
}
/* see information on bits 'c' [p 10 : A.2.1 general, ISO/IEC FCD 15444-9] */
if
(((elmt >> 4) & 0x01) == 1)
{
header->last_byte = 1;
}
/* In-class identifier */
header->Id |= (elmt & 0x0f);
if
((elmt >> 7) == 1)
{
l_last_nb_bytes_read = 0;
if
(! jpt_read_VBAS_info(cio, &l_last_nb_bytes_read, &(header->Id), p_manager))
{
opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data!!!\n");
return false;
}
l_nb_bytes_read += l_last_nb_bytes_read;
}
/* ------------ */
/* VBAS : Class */
/* ------------ */
if (Class == 1)
{
header->Class_Id = 0;
l_last_nb_bytes_read = 0;
if
(! jpt_read_VBAS_info(cio, &l_last_nb_bytes_read, &(header->Class_Id), p_manager))
{
opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data!!!\n");
return false;
}
l_nb_bytes_read += l_last_nb_bytes_read;
}
/* ---------- */
/* VBAS : CSn */
/* ---------- */
if (CSn == 1)
{
header->CSn_Id = 0;
l_last_nb_bytes_read = 0;
if
(! jpt_read_VBAS_info(cio, &l_last_nb_bytes_read, &(header->CSn_Id), p_manager))
{
opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data!!!\n");
return false;
}
l_nb_bytes_read += l_last_nb_bytes_read;
}
/* ----------------- */
/* VBAS : Msg_offset */
/* ----------------- */
l_last_nb_bytes_read = 0;
if
(! jpt_read_VBAS_info(cio, &l_last_nb_bytes_read, &(header->Msg_offset), p_manager))
{
opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data!!!\n");
return false;
}
l_nb_bytes_read += l_last_nb_bytes_read;
/* ----------------- */
/* VBAS : Msg_length */
/* ----------------- */
l_last_nb_bytes_read = 0;
if
(! jpt_read_VBAS_info(cio, &l_last_nb_bytes_read, &(header->Msg_length), p_manager))
{
opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data!!!\n");
return false;
}
l_nb_bytes_read += l_last_nb_bytes_read;
/* ---------- */
/* VBAS : Aux */
/* ---------- */
if ((header->Class_Id & 0x01) == 1)
{
header->Layer_nb = 0;
if
(! jpt_read_VBAS_info(cio, &l_last_nb_bytes_read, &(header->Layer_nb), p_manager))
{
opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data!!!\n");
return false;
}
l_nb_bytes_read += l_last_nb_bytes_read;
}
* p_nb_bytes_read = l_nb_bytes_read;
return true;
}

View File

@ -1,9 +1,8 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
* All rights reserved.
*
@ -29,36 +28,56 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OPJ_INVERT_H
#define OPJ_INVERT_H
#ifndef __JPT_H
#define __JPT_H
/**
@file invert.h
@brief Implementation of the matrix inversion
@file jpt.h
@brief JPT-stream reader (JPEG 2000, JPIP)
The function in INVERT.H compute a matrix inversion with a LUP method
JPT-stream functions are implemented in J2K.C.
*/
#include "openjpeg.h"
struct opj_stream_private;
struct opj_event_mgr;
/**
Message Header JPT stream structure
*/
typedef struct opj_jpt_msg_header
{
/** In-class Identifier */
OPJ_UINT32 Id;
/** Last byte information */
OPJ_UINT32 last_byte;
/** Class Identifier */
OPJ_UINT32 Class_Id;
/** CSn : index identifier */
OPJ_UINT32 CSn_Id;
/** Message offset */
OPJ_UINT32 Msg_offset;
/** Message length */
OPJ_UINT32 Msg_length;
/** Auxiliary for JPP case */
OPJ_UINT32 Layer_nb;
} opj_jpt_msg_header_t;
/** @defgroup INVERT INVERT - Implementation of a matrix inversion */
/*@{*/
/** @name Exported functions */
/*@{*/
/* ----------------------------------------------------------------------- */
/**
* Calculates a n x n double matrix inversion with a LUP method. Data is aligned, rows after rows (or columns after columns).
* The function does not take ownership of any memory block, data must be fred by the user.
*
* @param pSrcMatrix the matrix to invert.
* @param pDestMatrix data to store the inverted matrix.
* @param nb_compo size of the matrix
* @return OPJ_TRUE if the inversion is successful, OPJ_FALSE if the matrix is singular.
*/
OPJ_BOOL opj_matrix_inversion_f(OPJ_FLOAT32 * pSrcMatrix,
OPJ_FLOAT32 * pDestMatrix,
OPJ_UINT32 nb_compo);
/* ----------------------------------------------------------------------- */
/*@}*/
Initialize the value of the message header structure
@param header Message header structure
*/
void jpt_init_msg_header(opj_jpt_msg_header_t * header);
/*@}*/
/**
* Read the message header for a JPP/JPT - stream
* @param p_cio stream handle
* @param header JPT Message header structure
* @param p_manager user event manager to display nice messages.
*/
bool jpt_read_msg_header(
struct opj_stream_private * p_cio,
opj_jpt_msg_header_t * p_header,
OPJ_UINT32 * p_nb_bytes_read,
struct opj_event_mgr * p_manager);
#endif /* OPJ_INVERT_H */
#endif

304
libopenjpeg/mct.c Normal file
View File

@ -0,0 +1,304 @@
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#include "mct.h"
#include "fix.h"
#include "opj_malloc.h"
/* <summary> */
/* This table contains the norms of the basis function of the reversible MCT. */
/* </summary> */
static const OPJ_FLOAT64 mct_norms[3] = { 1.732, .8292, .8292 };
/* <summary> */
/* This table contains the norms of the basis function of the irreversible MCT. */
/* </summary> */
static const OPJ_FLOAT64 mct_norms_real[3] = { 1.732, 1.805, 1.573 };
const OPJ_FLOAT64 * get_mct_norms ()
{
return mct_norms;
}
const OPJ_FLOAT64 * get_mct_norms_real ()
{
return mct_norms_real;
}
/* <summary> */
/* Foward reversible MCT. */
/* </summary> */
void mct_encode(
OPJ_INT32* restrict c0,
OPJ_INT32* restrict c1,
OPJ_INT32* restrict c2,
OPJ_UINT32 n)
{
OPJ_UINT32 i;
for(i = 0; i < n; ++i) {
OPJ_INT32 r = c0[i];
OPJ_INT32 g = c1[i];
OPJ_INT32 b = c2[i];
OPJ_INT32 y = (r + (g * 2) + b) >> 2;
OPJ_INT32 u = b - g;
OPJ_INT32 v = r - g;
c0[i] = y;
c1[i] = u;
c2[i] = v;
}
}
/* <summary> */
/* Inverse reversible MCT. */
/* </summary> */
void mct_decode(
OPJ_INT32* restrict c0,
OPJ_INT32* restrict c1,
OPJ_INT32* restrict c2,
OPJ_UINT32 n)
{
OPJ_UINT32 i;
for (i = 0; i < n; ++i) {
OPJ_INT32 y = c0[i];
OPJ_INT32 u = c1[i];
OPJ_INT32 v = c2[i];
OPJ_INT32 g = y - ((u + v) >> 2);
OPJ_INT32 r = v + g;
OPJ_INT32 b = u + g;
c0[i] = r;
c1[i] = g;
c2[i] = b;
}
}
/* <summary> */
/* Get norm of basis function of reversible MCT. */
/* </summary> */
OPJ_FLOAT64 mct_getnorm(OPJ_UINT32 compno) {
return mct_norms[compno];
}
/* <summary> */
/* Foward irreversible MCT. */
/* </summary> */
void mct_encode_real(
OPJ_INT32* restrict c0,
OPJ_INT32* restrict c1,
OPJ_INT32* restrict c2,
OPJ_UINT32 n)
{
OPJ_UINT32 i;
for(i = 0; i < n; ++i) {
OPJ_INT32 r = c0[i];
OPJ_INT32 g = c1[i];
OPJ_INT32 b = c2[i];
OPJ_INT32 y = fix_mul(r, 2449) + fix_mul(g, 4809) + fix_mul(b, 934);
OPJ_INT32 u = -fix_mul(r, 1382) - fix_mul(g, 2714) + fix_mul(b, 4096);
OPJ_INT32 v = fix_mul(r, 4096) - fix_mul(g, 3430) - fix_mul(b, 666);
c0[i] = y;
c1[i] = u;
c2[i] = v;
}
}
/* <summary> */
/* Inverse irreversible MCT. */
/* </summary> */
void mct_decode_real(
OPJ_FLOAT32* restrict c0,
OPJ_FLOAT32* restrict c1,
OPJ_FLOAT32* restrict c2,
OPJ_UINT32 n)
{
OPJ_UINT32 i;
for(i = 0; i < n; ++i) {
OPJ_FLOAT32 y = c0[i];
OPJ_FLOAT32 u = c1[i];
OPJ_FLOAT32 v = c2[i];
OPJ_FLOAT32 r = y + (v * 1.402f);
OPJ_FLOAT32 g = y - (u * 0.34413f) - (v * (0.71414f));
OPJ_FLOAT32 b = y + (u * 1.772f);
c0[i] = r;
c1[i] = g;
c2[i] = b;
}
}
/* <summary> */
/* Get norm of basis function of irreversible MCT. */
/* </summary> */
OPJ_FLOAT64 mct_getnorm_real(OPJ_UINT32 compno) {
return mct_norms_real[compno];
}
bool mct_encode_custom(
// MCT data
OPJ_BYTE * pCodingdata,
// size of components
OPJ_UINT32 n,
// components
OPJ_BYTE ** pData,
// nb of components (i.e. size of pData)
OPJ_UINT32 pNbComp,
// tells if the data is signed
OPJ_UINT32 isSigned)
{
OPJ_FLOAT32 * lMct = (OPJ_FLOAT32 *) pCodingdata;
OPJ_UINT32 i;
OPJ_UINT32 j;
OPJ_UINT32 k;
OPJ_UINT32 lNbMatCoeff = pNbComp * pNbComp;
OPJ_INT32 * lCurrentData = 00;
OPJ_INT32 * lCurrentMatrix = 00;
OPJ_INT32 ** lData = (OPJ_INT32 **) pData;
OPJ_UINT32 lMultiplicator = 1 << 13;
OPJ_INT32 * lMctPtr;
lCurrentData = (OPJ_INT32 *) opj_malloc((pNbComp + lNbMatCoeff) * sizeof(OPJ_INT32));
if
(! lCurrentData)
{
return false;
}
lCurrentMatrix = lCurrentData + pNbComp;
for
(i =0;i<lNbMatCoeff;++i)
{
lCurrentMatrix[i] = (OPJ_INT32) (*(lMct++) * lMultiplicator);
}
for
(i = 0; i < n; ++i)
{
lMctPtr = lCurrentMatrix;
for
(j=0;j<pNbComp;++j)
{
lCurrentData[j] = (*(lData[j]));
}
for
(j=0;j<pNbComp;++j)
{
*(lData[j]) = 0;
for
(k=0;k<pNbComp;++k)
{
*(lData[j]) += fix_mul(*lMctPtr, lCurrentData[k]);
++lMctPtr;
}
++lData[j];
}
}
opj_free(lCurrentData);
return true;
}
bool mct_decode_custom(
// MCT data
OPJ_BYTE * pDecodingData,
// size of components
OPJ_UINT32 n,
// components
OPJ_BYTE ** pData,
// nb of components (i.e. size of pData)
OPJ_UINT32 pNbComp,
// tells if the data is signed
OPJ_UINT32 isSigned)
{
OPJ_FLOAT32 * lMct;
OPJ_UINT32 i;
OPJ_UINT32 j;
OPJ_UINT32 k;
OPJ_FLOAT32 * lCurrentData = 00;
OPJ_FLOAT32 * lCurrentResult = 00;
OPJ_FLOAT32 ** lData = (OPJ_FLOAT32 **) pData;
lCurrentData = (OPJ_FLOAT32 *) opj_malloc (2 * pNbComp * sizeof(OPJ_FLOAT32));
if
(! lCurrentData)
{
return false;
}
lCurrentResult = lCurrentData + pNbComp;
for
(i = 0; i < n; ++i)
{
lMct = (OPJ_FLOAT32 *) pDecodingData;
for
(j=0;j<pNbComp;++j)
{
lCurrentData[j] = (OPJ_FLOAT32) (*(lData[j]));
}
for
(j=0;j<pNbComp;++j)
{
lCurrentResult[j] = 0;
for
(k=0;k<pNbComp;++k)
{
lCurrentResult[j] += *(lMct++) * lCurrentData[k];
}
*(lData[j]++) = (OPJ_FLOAT32) (lCurrentResult[j]);
}
}
opj_free(lCurrentData);
return true;
}
void opj_calculate_norms(OPJ_FLOAT64 * pNorms,OPJ_UINT32 pNbComps,OPJ_FLOAT32 * pMatrix)
{
OPJ_UINT32 i,j,lIndex;
OPJ_FLOAT32 lCurrentValue;
OPJ_FLOAT64 * lNorms = (OPJ_FLOAT64 *) pNorms;
OPJ_FLOAT32 * lMatrix = (OPJ_FLOAT32 *) pMatrix;
for
(i=0;i<pNbComps;++i)
{
lNorms[i] = 0;
lIndex = i;
for
(j=0;j<pNbComps;++j)
{
lCurrentValue = lMatrix[lIndex];
lIndex += pNbComps;
lNorms[i] += lCurrentValue * lCurrentValue;
}
lNorms[i] = sqrt(lNorms[i]);
}
}

View File

@ -1,18 +1,11 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux
* Copyright (c) 2003-2014, Antonin Descampe
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
* Copyright (c) 2012, CS Systemes d'Information, France
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -37,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OPJ_MCT_H
#define OPJ_MCT_H
#ifndef __MCT_H
#define __MCT_H
/**
@file mct.h
@brief Implementation of a multi-component transforms (MCT)
@ -46,7 +39,7 @@
The functions in MCT.C have for goal to realize reversible and irreversible multicomponent
transform. The functions in MCT.C are used by some function in TCD.C.
*/
#include "openjpeg.h"
/** @defgroup MCT MCT - Implementation of a multi-component transform */
/*@{*/
@ -60,8 +53,7 @@ Apply a reversible multi-component transform to an image
@param c2 Samples blue component
@param n Number of samples for each component
*/
void opj_mct_encode(OPJ_INT32* OPJ_RESTRICT c0, OPJ_INT32* OPJ_RESTRICT c1,
OPJ_INT32* OPJ_RESTRICT c2, OPJ_SIZE_T n);
void mct_encode(OPJ_INT32 *c0, OPJ_INT32 *c1, OPJ_INT32 *c2, OPJ_UINT32 n);
/**
Apply a reversible multi-component inverse transform to an image
@param c0 Samples for luminance component
@ -69,14 +61,13 @@ Apply a reversible multi-component inverse transform to an image
@param c2 Samples for blue chrominance component
@param n Number of samples for each component
*/
void opj_mct_decode(OPJ_INT32* OPJ_RESTRICT c0, OPJ_INT32* OPJ_RESTRICT c1,
OPJ_INT32* OPJ_RESTRICT c2, OPJ_SIZE_T n);
void mct_decode(OPJ_INT32 *c0, OPJ_INT32 *c1, OPJ_INT32 *c2, OPJ_UINT32 n);
/**
Get norm of the basis function used for the reversible multi-component transform
@param compno Number of the component (0->Y, 1->U, 2->V)
@return
@return
*/
OPJ_FLOAT64 opj_mct_getnorm(OPJ_UINT32 compno);
OPJ_FLOAT64 mct_getnorm(OPJ_UINT32 compno);
/**
Apply an irreversible multi-component transform to an image
@ -85,9 +76,7 @@ Apply an irreversible multi-component transform to an image
@param c2 Samples blue component
@param n Number of samples for each component
*/
void opj_mct_encode_real(OPJ_FLOAT32* OPJ_RESTRICT c0,
OPJ_FLOAT32* OPJ_RESTRICT c1,
OPJ_FLOAT32* OPJ_RESTRICT c2, OPJ_SIZE_T n);
void mct_encode_real(OPJ_INT32 *c0, OPJ_INT32 *c1, OPJ_INT32 *c2, OPJ_UINT32 n);
/**
Apply an irreversible multi-component inverse transform to an image
@param c0 Samples for luminance component
@ -95,66 +84,47 @@ Apply an irreversible multi-component inverse transform to an image
@param c2 Samples for blue chrominance component
@param n Number of samples for each component
*/
void opj_mct_decode_real(OPJ_FLOAT32* OPJ_RESTRICT c0,
OPJ_FLOAT32* OPJ_RESTRICT c1, OPJ_FLOAT32* OPJ_RESTRICT c2, OPJ_SIZE_T n);
void mct_decode_real(OPJ_FLOAT32* c0, OPJ_FLOAT32* c1, OPJ_FLOAT32* c2, OPJ_UINT32 n);
/**
Get norm of the basis function used for the irreversible multi-component transform
@param compno Number of the component (0->Y, 1->U, 2->V)
@return
@return
*/
OPJ_FLOAT64 opj_mct_getnorm_real(OPJ_UINT32 compno);
OPJ_FLOAT64 mct_getnorm_real(OPJ_UINT32 compno);
bool mct_encode_custom(
// MCT data
OPJ_BYTE * p_coding_data,
// size of components
OPJ_UINT32 n,
// components
OPJ_BYTE ** p_data,
// nb of components (i.e. size of p_data)
OPJ_UINT32 p_nb_comp,
// tells if the data is signed
OPJ_UINT32 is_signed);
bool mct_decode_custom(
// MCT data
OPJ_BYTE * pDecodingData,
// size of components
OPJ_UINT32 n,
// components
OPJ_BYTE ** pData,
// nb of components (i.e. size of pData)
OPJ_UINT32 pNbComp,
// tells if the data is signed
OPJ_UINT32 isSigned);
void opj_calculate_norms(OPJ_FLOAT64 * pNorms,OPJ_UINT32 p_nb_comps,OPJ_FLOAT32 * pMatrix);
const OPJ_FLOAT64 * get_mct_norms ();
const OPJ_FLOAT64 * get_mct_norms_real ();
/**
FIXME DOC
@param p_coding_data MCT data
@param n size of components
@param p_data components
@param p_nb_comp nb of components (i.e. size of p_data)
@param is_signed tells if the data is signed
@return OPJ_FALSE if function encounter a problem, OPJ_TRUE otherwise
*/
OPJ_BOOL opj_mct_encode_custom(
OPJ_BYTE * p_coding_data,
OPJ_SIZE_T n,
OPJ_BYTE ** p_data,
OPJ_UINT32 p_nb_comp,
OPJ_UINT32 is_signed);
/**
FIXME DOC
@param pDecodingData MCT data
@param n size of components
@param pData components
@param pNbComp nb of components (i.e. size of p_data)
@param isSigned tells if the data is signed
@return OPJ_FALSE if function encounter a problem, OPJ_TRUE otherwise
*/
OPJ_BOOL opj_mct_decode_custom(
OPJ_BYTE * pDecodingData,
OPJ_SIZE_T n,
OPJ_BYTE ** pData,
OPJ_UINT32 pNbComp,
OPJ_UINT32 isSigned);
/**
FIXME DOC
@param pNorms MCT data
@param p_nb_comps size of components
@param pMatrix components
@return
*/
void opj_calculate_norms(OPJ_FLOAT64 * pNorms,
OPJ_UINT32 p_nb_comps,
OPJ_FLOAT32 * pMatrix);
/**
FIXME DOC
*/
const OPJ_FLOAT64 * opj_mct_get_mct_norms(void);
/**
FIXME DOC
*/
const OPJ_FLOAT64 * opj_mct_get_mct_norms_real(void);
/* ----------------------------------------------------------------------- */
/*@}*/
/*@}*/
#endif /* OPJ_MCT_H */
#endif /* __MCT_H */

544
libopenjpeg/mqc.c Normal file
View File

@ -0,0 +1,544 @@
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#include "mqc.h"
#include "t1.h"
#include "opj_malloc.h"
/** @defgroup MQC MQC - Implementation of an MQ-Coder */
/*@{*/
/** @name Local static functions */
/*@{*/
/**
Output a byte, doing bit-stuffing if necessary.
After a 0xff byte, the next byte must be smaller than 0x90.
@param mqc MQC handle
*/
static void mqc_byteout(opj_mqc_t *mqc);
/**
Renormalize mqc->a and mqc->c while encoding, so that mqc->a stays between 0x8000 and 0x10000
@param mqc MQC handle
*/
static void mqc_renorme(opj_mqc_t *mqc);
/**
Encode the most probable symbol
@param mqc MQC handle
*/
static void mqc_codemps(opj_mqc_t *mqc);
/**
Encode the most least symbol
@param mqc MQC handle
*/
static void mqc_codelps(opj_mqc_t *mqc);
/**
Fill mqc->c with 1's for flushing
@param mqc MQC handle
*/
static void mqc_setbits(opj_mqc_t *mqc);
/**
FIXME: documentation ???
@param mqc MQC handle
@return
*/
static OPJ_INT32 mqc_mpsexchange(opj_mqc_t *mqc);
/**
FIXME: documentation ???
@param mqc MQC handle
@return
*/
static OPJ_INT32 mqc_lpsexchange(opj_mqc_t *mqc);
/**
Input a byte
@param mqc MQC handle
*/
static void mqc_bytein(opj_mqc_t *mqc);
/**
Renormalize mqc->a and mqc->c while decoding
@param mqc MQC handle
*/
static void mqc_renormd(opj_mqc_t *mqc);
/*@}*/
/*@}*/
/* <summary> */
/* This array defines all the possible states for a context. */
/* </summary> */
static opj_mqc_state_t mqc_states[47 * 2] = {
{0x5601, 0, &mqc_states[2], &mqc_states[3]},
{0x5601, 1, &mqc_states[3], &mqc_states[2]},
{0x3401, 0, &mqc_states[4], &mqc_states[12]},
{0x3401, 1, &mqc_states[5], &mqc_states[13]},
{0x1801, 0, &mqc_states[6], &mqc_states[18]},
{0x1801, 1, &mqc_states[7], &mqc_states[19]},
{0x0ac1, 0, &mqc_states[8], &mqc_states[24]},
{0x0ac1, 1, &mqc_states[9], &mqc_states[25]},
{0x0521, 0, &mqc_states[10], &mqc_states[58]},
{0x0521, 1, &mqc_states[11], &mqc_states[59]},
{0x0221, 0, &mqc_states[76], &mqc_states[66]},
{0x0221, 1, &mqc_states[77], &mqc_states[67]},
{0x5601, 0, &mqc_states[14], &mqc_states[13]},
{0x5601, 1, &mqc_states[15], &mqc_states[12]},
{0x5401, 0, &mqc_states[16], &mqc_states[28]},
{0x5401, 1, &mqc_states[17], &mqc_states[29]},
{0x4801, 0, &mqc_states[18], &mqc_states[28]},
{0x4801, 1, &mqc_states[19], &mqc_states[29]},
{0x3801, 0, &mqc_states[20], &mqc_states[28]},
{0x3801, 1, &mqc_states[21], &mqc_states[29]},
{0x3001, 0, &mqc_states[22], &mqc_states[34]},
{0x3001, 1, &mqc_states[23], &mqc_states[35]},
{0x2401, 0, &mqc_states[24], &mqc_states[36]},
{0x2401, 1, &mqc_states[25], &mqc_states[37]},
{0x1c01, 0, &mqc_states[26], &mqc_states[40]},
{0x1c01, 1, &mqc_states[27], &mqc_states[41]},
{0x1601, 0, &mqc_states[58], &mqc_states[42]},
{0x1601, 1, &mqc_states[59], &mqc_states[43]},
{0x5601, 0, &mqc_states[30], &mqc_states[29]},
{0x5601, 1, &mqc_states[31], &mqc_states[28]},
{0x5401, 0, &mqc_states[32], &mqc_states[28]},
{0x5401, 1, &mqc_states[33], &mqc_states[29]},
{0x5101, 0, &mqc_states[34], &mqc_states[30]},
{0x5101, 1, &mqc_states[35], &mqc_states[31]},
{0x4801, 0, &mqc_states[36], &mqc_states[32]},
{0x4801, 1, &mqc_states[37], &mqc_states[33]},
{0x3801, 0, &mqc_states[38], &mqc_states[34]},
{0x3801, 1, &mqc_states[39], &mqc_states[35]},
{0x3401, 0, &mqc_states[40], &mqc_states[36]},
{0x3401, 1, &mqc_states[41], &mqc_states[37]},
{0x3001, 0, &mqc_states[42], &mqc_states[38]},
{0x3001, 1, &mqc_states[43], &mqc_states[39]},
{0x2801, 0, &mqc_states[44], &mqc_states[38]},
{0x2801, 1, &mqc_states[45], &mqc_states[39]},
{0x2401, 0, &mqc_states[46], &mqc_states[40]},
{0x2401, 1, &mqc_states[47], &mqc_states[41]},
{0x2201, 0, &mqc_states[48], &mqc_states[42]},
{0x2201, 1, &mqc_states[49], &mqc_states[43]},
{0x1c01, 0, &mqc_states[50], &mqc_states[44]},
{0x1c01, 1, &mqc_states[51], &mqc_states[45]},
{0x1801, 0, &mqc_states[52], &mqc_states[46]},
{0x1801, 1, &mqc_states[53], &mqc_states[47]},
{0x1601, 0, &mqc_states[54], &mqc_states[48]},
{0x1601, 1, &mqc_states[55], &mqc_states[49]},
{0x1401, 0, &mqc_states[56], &mqc_states[50]},
{0x1401, 1, &mqc_states[57], &mqc_states[51]},
{0x1201, 0, &mqc_states[58], &mqc_states[52]},
{0x1201, 1, &mqc_states[59], &mqc_states[53]},
{0x1101, 0, &mqc_states[60], &mqc_states[54]},
{0x1101, 1, &mqc_states[61], &mqc_states[55]},
{0x0ac1, 0, &mqc_states[62], &mqc_states[56]},
{0x0ac1, 1, &mqc_states[63], &mqc_states[57]},
{0x09c1, 0, &mqc_states[64], &mqc_states[58]},
{0x09c1, 1, &mqc_states[65], &mqc_states[59]},
{0x08a1, 0, &mqc_states[66], &mqc_states[60]},
{0x08a1, 1, &mqc_states[67], &mqc_states[61]},
{0x0521, 0, &mqc_states[68], &mqc_states[62]},
{0x0521, 1, &mqc_states[69], &mqc_states[63]},
{0x0441, 0, &mqc_states[70], &mqc_states[64]},
{0x0441, 1, &mqc_states[71], &mqc_states[65]},
{0x02a1, 0, &mqc_states[72], &mqc_states[66]},
{0x02a1, 1, &mqc_states[73], &mqc_states[67]},
{0x0221, 0, &mqc_states[74], &mqc_states[68]},
{0x0221, 1, &mqc_states[75], &mqc_states[69]},
{0x0141, 0, &mqc_states[76], &mqc_states[70]},
{0x0141, 1, &mqc_states[77], &mqc_states[71]},
{0x0111, 0, &mqc_states[78], &mqc_states[72]},
{0x0111, 1, &mqc_states[79], &mqc_states[73]},
{0x0085, 0, &mqc_states[80], &mqc_states[74]},
{0x0085, 1, &mqc_states[81], &mqc_states[75]},
{0x0049, 0, &mqc_states[82], &mqc_states[76]},
{0x0049, 1, &mqc_states[83], &mqc_states[77]},
{0x0025, 0, &mqc_states[84], &mqc_states[78]},
{0x0025, 1, &mqc_states[85], &mqc_states[79]},
{0x0015, 0, &mqc_states[86], &mqc_states[80]},
{0x0015, 1, &mqc_states[87], &mqc_states[81]},
{0x0009, 0, &mqc_states[88], &mqc_states[82]},
{0x0009, 1, &mqc_states[89], &mqc_states[83]},
{0x0005, 0, &mqc_states[90], &mqc_states[84]},
{0x0005, 1, &mqc_states[91], &mqc_states[85]},
{0x0001, 0, &mqc_states[90], &mqc_states[86]},
{0x0001, 1, &mqc_states[91], &mqc_states[87]},
{0x5601, 0, &mqc_states[92], &mqc_states[92]},
{0x5601, 1, &mqc_states[93], &mqc_states[93]},
};
/*
==========================================================
local functions
==========================================================
*/
static void mqc_byteout(opj_mqc_t *mqc) {
if (*mqc->bp == 0xff) {
mqc->bp++;
*mqc->bp = mqc->c >> 20;
mqc->c &= 0xfffff;
mqc->ct = 7;
} else {
if ((mqc->c & 0x8000000) == 0) { /* ((mqc->c&0x8000000)==0) CHANGE */
mqc->bp++;
*mqc->bp = mqc->c >> 19;
mqc->c &= 0x7ffff;
mqc->ct = 8;
} else {
(*mqc->bp)++;
if (*mqc->bp == 0xff) {
mqc->c &= 0x7ffffff;
mqc->bp++;
*mqc->bp = mqc->c >> 20;
mqc->c &= 0xfffff;
mqc->ct = 7;
} else {
mqc->bp++;
*mqc->bp = mqc->c >> 19;
mqc->c &= 0x7ffff;
mqc->ct = 8;
}
}
}
}
static void mqc_renorme(opj_mqc_t *mqc) {
do {
mqc->a <<= 1;
mqc->c <<= 1;
mqc->ct--;
if (mqc->ct == 0) {
mqc_byteout(mqc);
}
} while ((mqc->a & 0x8000) == 0);
}
static void mqc_codemps(opj_mqc_t *mqc) {
mqc->a -= (*mqc->curctx)->qeval;
if ((mqc->a & 0x8000) == 0) {
if (mqc->a < (*mqc->curctx)->qeval) {
mqc->a = (*mqc->curctx)->qeval;
} else {
mqc->c += (*mqc->curctx)->qeval;
}
*mqc->curctx = (*mqc->curctx)->nmps;
mqc_renorme(mqc);
} else {
mqc->c += (*mqc->curctx)->qeval;
}
}
static void mqc_codelps(opj_mqc_t *mqc) {
mqc->a -= (*mqc->curctx)->qeval;
if (mqc->a < (*mqc->curctx)->qeval) {
mqc->c += (*mqc->curctx)->qeval;
} else {
mqc->a = (*mqc->curctx)->qeval;
}
*mqc->curctx = (*mqc->curctx)->nlps;
mqc_renorme(mqc);
}
static void mqc_setbits(opj_mqc_t *mqc) {
OPJ_UINT32 tempc = mqc->c + mqc->a;
mqc->c |= 0xffff;
if (mqc->c >= tempc) {
mqc->c -= 0x8000;
}
}
static OPJ_INT32 mqc_mpsexchange(opj_mqc_t *mqc) {
OPJ_INT32 d;
if (mqc->a < (*mqc->curctx)->qeval) {
d = 1 - (*mqc->curctx)->mps;
*mqc->curctx = (*mqc->curctx)->nlps;
} else {
d = (*mqc->curctx)->mps;
*mqc->curctx = (*mqc->curctx)->nmps;
}
return d;
}
static OPJ_INT32 mqc_lpsexchange(opj_mqc_t *mqc) {
OPJ_INT32 d;
if (mqc->a < (*mqc->curctx)->qeval) {
mqc->a = (*mqc->curctx)->qeval;
d = (*mqc->curctx)->mps;
*mqc->curctx = (*mqc->curctx)->nmps;
} else {
mqc->a = (*mqc->curctx)->qeval;
d = 1 - (*mqc->curctx)->mps;
*mqc->curctx = (*mqc->curctx)->nlps;
}
return d;
}
static void mqc_bytein(opj_mqc_t *mqc) {
if (mqc->bp != mqc->end) {
OPJ_UINT32 c;
if (mqc->bp + 1 != mqc->end) {
c = *(mqc->bp + 1);
} else {
c = 0xff;
}
if (*mqc->bp == 0xff) {
if (c > 0x8f) {
mqc->c += 0xff00;
mqc->ct = 8;
} else {
mqc->bp++;
mqc->c += c << 9;
mqc->ct = 7;
}
} else {
mqc->bp++;
mqc->c += c << 8;
mqc->ct = 8;
}
} else {
mqc->c += 0xff00;
mqc->ct = 8;
}
}
static void mqc_renormd(opj_mqc_t *mqc) {
do {
if (mqc->ct == 0) {
mqc_bytein(mqc);
}
mqc->a <<= 1;
mqc->c <<= 1;
mqc->ct--;
} while (mqc->a < 0x8000);
}
/*
==========================================================
MQ-Coder interface
==========================================================
*/
opj_mqc_t* mqc_create(void) {
opj_mqc_t *mqc = (opj_mqc_t*)opj_malloc(sizeof(opj_mqc_t));
return mqc;
}
void mqc_destroy(opj_mqc_t *mqc) {
if
(mqc)
{
opj_free(mqc);
}
}
OPJ_UINT32 mqc_numbytes(opj_mqc_t *mqc) {
return mqc->bp - mqc->start;
}
void mqc_init_enc(opj_mqc_t *mqc, OPJ_BYTE *bp) {
mqc_setcurctx(mqc, 0);
mqc->a = 0x8000;
mqc->c = 0;
mqc->bp = bp - 1;
*(mqc->bp) = 0;
mqc->ct = 12;
/*if (*mqc->bp == 0xff) {
mqc->ct = 13;
}*/
mqc->start = bp;
}
void mqc_encode(opj_mqc_t *mqc, OPJ_UINT32 d) {
if ((*mqc->curctx)->mps == d) {
mqc_codemps(mqc);
} else {
mqc_codelps(mqc);
}
}
void mqc_flush(opj_mqc_t *mqc) {
mqc_setbits(mqc);
mqc->c <<= mqc->ct;
mqc_byteout(mqc);
mqc->c <<= mqc->ct;
mqc_byteout(mqc);
if (*mqc->bp != 0xff) {
mqc->bp++;
}
}
void mqc_bypass_init_enc(opj_mqc_t *mqc) {
mqc->c = 0;
mqc->ct = 8;
/*if (*mqc->bp == 0xff) {
mqc->ct = 7;
} */
}
void mqc_bypass_enc(opj_mqc_t *mqc, OPJ_UINT32 d) {
mqc->ct--;
mqc->c = mqc->c + (d << mqc->ct);
if (mqc->ct == 0) {
mqc->bp++;
*mqc->bp = mqc->c;
mqc->ct = 8;
if (*mqc->bp == 0xff) {
mqc->ct = 7;
}
mqc->c = 0;
}
}
OPJ_UINT32 mqc_bypass_flush_enc(opj_mqc_t *mqc) {
OPJ_BYTE bit_padding;
bit_padding = 0;
if (mqc->ct != 0) {
while (mqc->ct > 0) {
mqc->ct--;
mqc->c += bit_padding << mqc->ct;
bit_padding = (bit_padding + 1) & 0x01;
}
mqc->bp++;
*mqc->bp = mqc->c;
mqc->ct = 8;
mqc->c = 0;
}
return 1;
}
void mqc_reset_enc(opj_mqc_t *mqc) {
mqc_resetstates(mqc);
mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
}
OPJ_UINT32 mqc_restart_enc(opj_mqc_t *mqc) {
OPJ_UINT32 correction = 1;
/* <flush part> */
OPJ_INT32 n = 27 - 15 - mqc->ct;
mqc->c <<= mqc->ct;
while (n > 0) {
mqc_byteout(mqc);
n -= mqc->ct;
mqc->c <<= mqc->ct;
}
mqc_byteout(mqc);
return correction;
}
void mqc_restart_init_enc(opj_mqc_t *mqc) {
/* <Re-init part> */
mqc_setcurctx(mqc, 0);
mqc->a = 0x8000;
mqc->c = 0;
mqc->ct = 12;
mqc->bp--;
if (*mqc->bp == 0xff) {
mqc->ct = 13;
}
}
void mqc_erterm_enc(opj_mqc_t *mqc) {
OPJ_INT32 k = 11 - mqc->ct + 1;
while (k > 0) {
mqc->c <<= mqc->ct;
mqc->ct = 0;
mqc_byteout(mqc);
k -= mqc->ct;
}
if (*mqc->bp != 0xff) {
mqc_byteout(mqc);
}
}
void mqc_segmark_enc(opj_mqc_t *mqc) {
OPJ_UINT32 i;
mqc_setcurctx(mqc, 18);
for (i = 1; i < 5; i++) {
mqc_encode(mqc, i % 2);
}
}
void mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len) {
mqc_setcurctx(mqc, 0);
mqc->start = bp;
mqc->end = bp + len;
mqc->bp = bp;
if (len==0) mqc->c = 0xff << 16;
else mqc->c = *mqc->bp << 16;
mqc_bytein(mqc);
mqc->c <<= 7;
mqc->ct -= 7;
mqc->a = 0x8000;
}
OPJ_UINT32 mqc_decode(opj_mqc_t *mqc) {
OPJ_INT32 d;
mqc->a -= (*mqc->curctx)->qeval;
if ((mqc->c >> 16) < (*mqc->curctx)->qeval) {
d = mqc_lpsexchange(mqc);
mqc_renormd(mqc);
} else {
mqc->c -= (*mqc->curctx)->qeval << 16;
if ((mqc->a & 0x8000) == 0) {
d = mqc_mpsexchange(mqc);
mqc_renormd(mqc);
} else {
d = (*mqc->curctx)->mps;
}
}
return (OPJ_UINT32)d;
}
void mqc_resetstates(opj_mqc_t *mqc) {
OPJ_UINT32 i;
for (i = 0; i < MQC_NUMCTXS; i++) {
mqc->ctxs[i] = mqc_states;
}
}
void mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb, OPJ_INT32 prob) {
mqc->ctxs[ctxno] = &mqc_states[msb + (prob << 1)];
}

198
libopenjpeg/mqc.h Normal file
View File

@ -0,0 +1,198 @@
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#ifndef __MQC_H
#define __MQC_H
/**
@file mqc.h
@brief Implementation of an MQ-Coder (MQC)
The functions in MQC.C have for goal to realize the MQ-coder operations. The functions
in MQC.C are used by some function in T1.C.
*/
#include "openjpeg.h"
/** @defgroup MQC MQC - Implementation of an MQ-Coder */
/*@{*/
/**
This struct defines the state of a context.
*/
typedef struct opj_mqc_state {
/** the probability of the Least Probable Symbol (0.75->0x8000, 1.5->0xffff) */
OPJ_UINT32 qeval;
/** the Most Probable Symbol (0 or 1) */
OPJ_INT32 mps;
/** next state if the next encoded symbol is the MPS */
struct opj_mqc_state *nmps;
/** next state if the next encoded symbol is the LPS */
struct opj_mqc_state *nlps;
} opj_mqc_state_t;
#define MQC_NUMCTXS 32
/**
MQ coder
*/
typedef struct opj_mqc {
OPJ_UINT32 c;
OPJ_UINT32 a;
OPJ_UINT32 ct;
OPJ_BYTE *bp;
OPJ_BYTE *start;
OPJ_BYTE *end;
opj_mqc_state_t *ctxs[MQC_NUMCTXS];
opj_mqc_state_t **curctx;
} opj_mqc_t;
/** @name Exported functions */
/*@{*/
/* ----------------------------------------------------------------------- */
/**
Create a new MQC handle
@return Returns a new MQC handle if successful, returns NULL otherwise
*/
opj_mqc_t* mqc_create(void);
/**
Destroy a previously created MQC handle
@param mqc MQC handle to destroy
*/
void mqc_destroy(opj_mqc_t *mqc);
/**
Return the number of bytes written/read since initialisation
@param mqc MQC handle
@return Returns the number of bytes already encoded
*/
OPJ_UINT32 mqc_numbytes(opj_mqc_t *mqc);
/**
Reset the states of all the context of the coder/decoder
(each context is set to a state where 0 and 1 are more or less equiprobable)
@param mqc MQC handle
*/
void mqc_resetstates(opj_mqc_t *mqc);
/**
Set the state of a particular context
@param mqc MQC handle
@param ctxno Number that identifies the context
@param msb The MSB of the new state of the context
@param prob Number that identifies the probability of the symbols for the new state of the context
*/
void mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb, OPJ_INT32 prob);
/**
Initialize the encoder
@param mqc MQC handle
@param bp Pointer to the start of the buffer where the bytes will be written
*/
void mqc_init_enc(opj_mqc_t *mqc, OPJ_BYTE *bp);
/**
Set the current context used for coding/decoding
@param mqc MQC handle
@param ctxno Number that identifies the context
*/
#define mqc_setcurctx(mqc, ctxno) (mqc)->curctx = &(mqc)->ctxs[(OPJ_UINT32)(ctxno)]
/**
Encode a symbol using the MQ-coder
@param mqc MQC handle
@param d The symbol to be encoded (0 or 1)
*/
void mqc_encode(opj_mqc_t *mqc, OPJ_UINT32 d);
/**
Flush the encoder, so that all remaining data is written
@param mqc MQC handle
*/
void mqc_flush(opj_mqc_t *mqc);
/**
BYPASS mode switch, initialization operation.
JPEG 2000 p 505.
<h2>Not fully implemented and tested !!</h2>
@param mqc MQC handle
*/
void mqc_bypass_init_enc(opj_mqc_t *mqc);
/**
BYPASS mode switch, coding operation.
JPEG 2000 p 505.
<h2>Not fully implemented and tested !!</h2>
@param mqc MQC handle
@param d The symbol to be encoded (0 or 1)
*/
void mqc_bypass_enc(opj_mqc_t *mqc, OPJ_UINT32 d);
/**
BYPASS mode switch, flush operation
<h2>Not fully implemented and tested !!</h2>
@param mqc MQC handle
@return Returns 1 (always)
*/
OPJ_UINT32 mqc_bypass_flush_enc(opj_mqc_t *mqc);
/**
RESET mode switch
@param mqc MQC handle
*/
void mqc_reset_enc(opj_mqc_t *mqc);
/**
RESTART mode switch (TERMALL)
@param mqc MQC handle
@return Returns 1 (always)
*/
OPJ_UINT32 mqc_restart_enc(opj_mqc_t *mqc);
/**
RESTART mode switch (TERMALL) reinitialisation
@param mqc MQC handle
*/
void mqc_restart_init_enc(opj_mqc_t *mqc);
/**
ERTERM mode switch (PTERM)
@param mqc MQC handle
*/
void mqc_erterm_enc(opj_mqc_t *mqc);
/**
SEGMARK mode switch (SEGSYM)
@param mqc MQC handle
*/
void mqc_segmark_enc(opj_mqc_t *mqc);
/**
Initialize the decoder
@param mqc MQC handle
@param bp Pointer to the start of the buffer from which the bytes will be read
@param len Length of the input buffer
*/
void mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len);
/**
Decode a symbol
@param mqc MQC handle
@return Returns the decoded symbol (0 or 1)
*/
OPJ_UINT32 mqc_decode(opj_mqc_t *mqc);
/* ----------------------------------------------------------------------- */
/*@}*/
/*@}*/
#endif /* __MQC_H */

908
libopenjpeg/openjpeg.c Normal file
View File

@ -0,0 +1,908 @@
/*
* Copyright (c) 2005, Hervé Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#ifdef WIN32
#include <windows.h>
#endif /* WIN32 */
#include "openjpeg.h"
#include "opj_malloc.h"
#include "j2k.h"
#include "jp2.h"
#include "event.h"
#include "cio.h"
typedef struct opj_decompression
{
bool (* opj_read_header) (
void *p_codec,
opj_image_t **,
OPJ_INT32 * p_tile_x0,
OPJ_INT32 * p_tile_y0,
OPJ_UINT32 * p_tile_width,
OPJ_UINT32 * p_tile_height,
OPJ_UINT32 * p_nb_tiles_x,
OPJ_UINT32 * p_nb_tiles_y,
struct opj_stream_private *cio,
struct opj_event_mgr * p_manager);
opj_image_t* (* opj_decode) (void * p_codec, struct opj_stream_private *p_cio, struct opj_event_mgr * p_manager);
bool (*opj_read_tile_header)(
void * p_codec,
OPJ_UINT32 * p_tile_index,
OPJ_UINT32* p_data_size,
OPJ_INT32 * p_tile_x0,
OPJ_INT32 * p_tile_y0,
OPJ_INT32 * p_tile_x1,
OPJ_INT32 * p_tile_y1,
OPJ_UINT32 * p_nb_comps,
bool * p_should_go_on,
struct opj_stream_private *p_cio,
struct opj_event_mgr * p_manager);
bool (*opj_decode_tile_data)(void * p_codec,OPJ_UINT32 p_tile_index,OPJ_BYTE * p_data,OPJ_UINT32 p_data_size,struct opj_stream_private *p_cio,struct opj_event_mgr * p_manager);
bool (* opj_end_decompress) (void *p_codec,struct opj_stream_private *cio,struct opj_event_mgr * p_manager);
void (* opj_destroy) (void * p_codec);
void (*opj_setup_decoder) (void * p_codec,opj_dparameters_t * p_param);
bool (*opj_set_decode_area) (void * p_codec,OPJ_INT32 p_start_x,OPJ_INT32 p_end_x,OPJ_INT32 p_start_y,OPJ_INT32 p_end_y,struct opj_event_mgr * p_manager);
}opj_decompression_t;
typedef struct opj_compression
{
bool (* opj_start_compress) (void *p_codec,struct opj_stream_private *cio,struct opj_image * p_image, struct opj_event_mgr * p_manager);
bool (* opj_encode) (void * p_codec, struct opj_stream_private *p_cio, struct opj_event_mgr * p_manager);
bool (* opj_write_tile) (void * p_codec,OPJ_UINT32 p_tile_index,OPJ_BYTE * p_data,OPJ_UINT32 p_data_size,struct opj_stream_private * p_cio,struct opj_event_mgr * p_manager);
bool (* opj_end_compress) (void * p_codec, struct opj_stream_private *p_cio, struct opj_event_mgr * p_manager);
void (* opj_destroy) (void * p_codec);
void (*opj_setup_encoder) (void * p_codec,opj_cparameters_t * p_param,struct opj_image * p_image, struct opj_event_mgr * p_manager);
}opj_compression_t;
typedef struct opj_codec_private
{
union
{ /* code-blocks informations */
opj_decompression_t m_decompression;
opj_compression_t m_compression;
} m_codec_data;
void * m_codec;
opj_event_mgr_t m_event_mgr;
unsigned is_decompressor : 1;
}
opj_codec_private_t;
/**
* Default callback function.
* Do nothing.
*/
void opj_default_callback (const char *msg, void *client_data)
{
}
void set_default_event_handler(opj_event_mgr_t * p_manager)
{
p_manager->m_error_data = 00;
p_manager->m_warning_data = 00;
p_manager->m_info_data = 00;
p_manager->error_handler = opj_default_callback;
p_manager->info_handler = opj_default_callback;
p_manager->warning_handler = opj_default_callback;
}
OPJ_UINT32 opj_read_from_file (void * p_buffer, OPJ_UINT32 p_nb_bytes, FILE * p_file)
{
OPJ_UINT32 l_nb_read = fread(p_buffer,1,p_nb_bytes,p_file);
return l_nb_read ? l_nb_read : -1;
}
OPJ_UINT32 opj_write_from_file (void * p_buffer, OPJ_UINT32 p_nb_bytes, FILE * p_file)
{
return fwrite(p_buffer,1,p_nb_bytes,p_file);
}
OPJ_SIZE_T opj_skip_from_file (OPJ_SIZE_T p_nb_bytes, FILE * p_user_data)
{
if
(fseek(p_user_data,p_nb_bytes,SEEK_CUR))
{
return -1;
}
return p_nb_bytes;
}
bool opj_seek_from_file (OPJ_SIZE_T p_nb_bytes, FILE * p_user_data)
{
if
(fseek(p_user_data,p_nb_bytes,SEEK_SET))
{
return false;
}
return true;
}
/* ---------------------------------------------------------------------- */
#ifdef WIN32
#ifndef OPJ_STATIC
BOOL APIENTRY
DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH :
break;
case DLL_PROCESS_DETACH :
break;
case DLL_THREAD_ATTACH :
case DLL_THREAD_DETACH :
break;
}
return TRUE;
}
#endif /* OPJ_STATIC */
#endif /* WIN32 */
/* ---------------------------------------------------------------------- */
const char* OPJ_CALLCONV opj_version(void) {
return OPENJPEG_VERSION;
}
opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
{
opj_codec_private_t *l_info = 00;
l_info = (opj_codec_private_t*) opj_calloc(1, sizeof(opj_codec_private_t));
if
(!l_info)
{
return 00;
}
memset(l_info, 0, sizeof(opj_codec_private_t));
l_info->is_decompressor = 1;
switch
(p_format)
{
case CODEC_J2K:
l_info->m_codec_data.m_decompression.opj_decode = (opj_image_t* (*) (void *, struct opj_stream_private *, struct opj_event_mgr * ))j2k_decode;
l_info->m_codec_data.m_decompression.opj_end_decompress = (bool (*) (void *,struct opj_stream_private *,struct opj_event_mgr *))j2k_end_decompress;
l_info->m_codec_data.m_decompression.opj_read_header = (bool (*) (
void *,
opj_image_t **,
OPJ_INT32 * ,
OPJ_INT32 * ,
OPJ_UINT32 * ,
OPJ_UINT32 * ,
OPJ_UINT32 * ,
OPJ_UINT32 * ,
struct opj_stream_private *,
struct opj_event_mgr * )) j2k_read_header;
l_info->m_codec_data.m_decompression.opj_destroy = (void (*) (void *))j2k_destroy;
l_info->m_codec_data.m_decompression.opj_setup_decoder = (void (*) (void * ,opj_dparameters_t * )) j2k_setup_decoder;
l_info->m_codec_data.m_decompression.opj_read_tile_header = (bool (*) (
void *,
OPJ_UINT32*,
OPJ_UINT32*,
OPJ_INT32 * ,
OPJ_INT32 * ,
OPJ_INT32 * ,
OPJ_INT32 * ,
OPJ_UINT32 * ,
bool *,
struct opj_stream_private *,
struct opj_event_mgr * )) j2k_read_tile_header;
l_info->m_codec_data.m_decompression.opj_decode_tile_data = (bool (*) (void *,OPJ_UINT32,OPJ_BYTE*,OPJ_UINT32,struct opj_stream_private *, struct opj_event_mgr * )) j2k_decode_tile;
l_info->m_codec_data.m_decompression.opj_set_decode_area = (bool (*) (void *,OPJ_INT32,OPJ_INT32,OPJ_INT32,OPJ_INT32, struct opj_event_mgr * )) j2k_set_decode_area;
l_info->m_codec = j2k_create_decompress();
if
(! l_info->m_codec)
{
opj_free(l_info);
return 00;
}
break;
case CODEC_JP2:
/* get a JP2 decoder handle */
l_info->m_codec_data.m_decompression.opj_decode = (opj_image_t* (*) (void *, struct opj_stream_private *, struct opj_event_mgr * ))opj_jp2_decode;
l_info->m_codec_data.m_decompression.opj_end_decompress = (bool (*) (void *,struct opj_stream_private *,struct opj_event_mgr *)) jp2_end_decompress;
l_info->m_codec_data.m_decompression.opj_read_header = (bool (*) (
void *,
opj_image_t **,
OPJ_INT32 * ,
OPJ_INT32 * ,
OPJ_UINT32 * ,
OPJ_UINT32 * ,
OPJ_UINT32 * ,
OPJ_UINT32 * ,
struct opj_stream_private *,
struct opj_event_mgr * )) jp2_read_header;
l_info->m_codec_data.m_decompression.opj_read_tile_header = (
bool (*) (
void *,
OPJ_UINT32*,
OPJ_UINT32*,
OPJ_INT32*,
OPJ_INT32*,
OPJ_INT32 * ,
OPJ_INT32 * ,
OPJ_UINT32 * ,
bool *,
struct opj_stream_private *,
struct opj_event_mgr * )) jp2_read_tile_header;
l_info->m_codec_data.m_decompression.opj_decode_tile_data = (bool (*) (void *,OPJ_UINT32,OPJ_BYTE*,OPJ_UINT32,struct opj_stream_private *, struct opj_event_mgr * )) opj_jp2_decode_tile;
l_info->m_codec_data.m_decompression.opj_destroy = (void (*) (void *))jp2_destroy;
l_info->m_codec_data.m_decompression.opj_setup_decoder = (void (*) (void * ,opj_dparameters_t * )) jp2_setup_decoder;
l_info->m_codec_data.m_decompression.opj_set_decode_area = (bool (*) (void *,OPJ_INT32,OPJ_INT32,OPJ_INT32,OPJ_INT32, struct opj_event_mgr * )) jp2_set_decode_area;
l_info->m_codec = jp2_create(true);
if
(! l_info->m_codec)
{
opj_free(l_info);
return 00;
}
break;
case CODEC_UNKNOWN:
case CODEC_JPT:
default:
opj_free(l_info);
return 00;
}
set_default_event_handler(&(l_info->m_event_mgr));
return (opj_codec_t*) l_info;
}
void OPJ_CALLCONV opj_destroy_codec(opj_codec_t *p_info)
{
if
(p_info)
{
opj_codec_private_t * l_info = (opj_codec_private_t *) p_info;
if
(l_info->is_decompressor)
{
l_info->m_codec_data.m_decompression.opj_destroy(l_info->m_codec);
}
else
{
l_info->m_codec_data.m_compression.opj_destroy(l_info->m_codec);
}
l_info->m_codec = 00;
opj_free(l_info);
}
}
void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters) {
if(parameters) {
memset(parameters, 0, sizeof(opj_dparameters_t));
/* default decoding parameters */
parameters->cp_layer = 0;
parameters->cp_reduce = 0;
parameters->decod_format = -1;
parameters->cod_format = -1;
/* UniPG>> */
#ifdef USE_JPWL
parameters->jpwl_correct = false;
parameters->jpwl_exp_comps = JPWL_EXPECTED_COMPONENTS;
parameters->jpwl_max_tiles = JPWL_MAXIMUM_TILES;
#endif /* USE_JPWL */
/* <<UniPG */
}
}
bool OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_info, opj_dparameters_t *parameters) {
if
(p_info && parameters)
{
opj_codec_private_t * l_info = (opj_codec_private_t *) p_info;
if
(! l_info->is_decompressor)
{
return false;
}
l_info->m_codec_data.m_decompression.opj_setup_decoder(l_info->m_codec,parameters);
return true;
}
return false;
}
opj_image_t* OPJ_CALLCONV opj_decode(opj_codec_t *p_info, opj_stream_t *cio)
{
if
(p_info && cio)
{
opj_codec_private_t * l_info = (opj_codec_private_t *) p_info;
opj_stream_private_t * l_cio = (opj_stream_private_t *) cio;
if
(! l_info->is_decompressor)
{
return 00;
}
return l_info->m_codec_data.m_decompression.opj_decode(l_info->m_codec,l_cio,&(l_info->m_event_mgr));
}
return 00;
}
/**
* Writes a tile with the given data.
*
* @param p_compressor the jpeg2000 codec.
* @param p_tile_index the index of the tile to write. At the moment, the tiles must be written from 0 to n-1 in sequence.
* @param p_data pointer to the data to write. Data is arranged in sequence, data_comp0, then data_comp1, then ... NO INTERLEAVING should be set.
* @param p_data_size this value os used to make sure the data being written is correct. The size must be equal to the sum for each component of tile_width * tile_height * component_size. component_size can be 1,2 or 4 bytes,
* depending on the precision of the given component.
* @param p_stream the stream to write data to.
*/
bool OPJ_CALLCONV opj_write_tile (
opj_codec_t *p_codec,
OPJ_UINT32 p_tile_index,
OPJ_BYTE * p_data,
OPJ_UINT32 p_data_size,
opj_stream_t *p_stream
)
{
if
(p_codec && p_stream && p_data)
{
opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec;
opj_stream_private_t * l_cio = (opj_stream_private_t *) p_stream;
if
(l_info->is_decompressor)
{
return false;
}
return l_info->m_codec_data.m_compression.opj_write_tile(l_info->m_codec,p_tile_index,p_data,p_data_size,l_cio,&(l_info->m_event_mgr));
}
return false;
}
/**
* Reads a tile header. This function is compulsory and allows one to know the size of the tile thta will be decoded.
* The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.
*
* @param p_codec the jpeg2000 codec.
* @param p_tile_index pointer to a value that will hold the index of the tile being decoded, in case of success.
* @param p_data_size pointer to a value that will hold the maximum size of the decoded data, in case of success. In case
* of truncated codestreams, the actual number of bytes decoded may be lower. The computation of the size is the same
* as depicted in opj_write_tile.
* @param p_tile_x0 pointer to a value that will hold the x0 pos of the tile (in the image).
* @param p_tile_y0 pointer to a value that will hold the y0 pos of the tile (in the image).
* @param p_tile_x1 pointer to a value that will hold the x1 pos of the tile (in the image).
* @param p_tile_y1 pointer to a value that will hold the y1 pos of the tile (in the image).
* @param p_nb_comps pointer to a value that will hold the number of components in the tile.
* @param p_should_go_on pointer to a boolean that will hold the fact that the decoding should go on. In case the
* codestream is over at the time of the call, the value will be set to false. The user should then stop
* the decoding.
* @param p_stream the stream to decode.
* @return true if the tile header could be decoded. In case the decoding should end, the returned value is still true.
* returning false may be the result of a shortage of memory or an internal error.
*/
bool OPJ_CALLCONV opj_read_tile_header(
opj_codec_t *p_codec,
OPJ_UINT32 * p_tile_index,
OPJ_UINT32 * p_data_size,
OPJ_INT32 * p_tile_x0,
OPJ_INT32 * p_tile_y0,
OPJ_INT32 * p_tile_x1,
OPJ_INT32 * p_tile_y1,
OPJ_UINT32 * p_nb_comps,
bool * p_should_go_on,
opj_stream_t * p_stream)
{
if
(p_codec && p_stream && p_data_size && p_tile_index)
{
opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec;
opj_stream_private_t * l_cio = (opj_stream_private_t *) p_stream;
if
(! l_info->is_decompressor)
{
return false;
}
return l_info->m_codec_data.m_decompression.opj_read_tile_header(
l_info->m_codec,
p_tile_index,
p_data_size,
p_tile_x0,
p_tile_y0,
p_tile_x1,
p_tile_y1,
p_nb_comps,
p_should_go_on,
l_cio,&(l_info->m_event_mgr));
}
return false;
}
/**
* Reads a tile data. This function is compulsory and allows one to decode tile data. opj_read_tile_header should be called before.
* The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.
*
* @param p_codec the jpeg2000 codec.
* @param p_tile_index the index of the tile being decoded, this should be the value set by opj_read_tile_header.
* @param p_data pointer to a memory block that will hold the decoded data.
* @param p_data_size size of p_data. p_data_size should be bigger or equal to the value set by opj_read_tile_header.
* @param p_stream the stream to decode.
*
* @return true if the data could be decoded.
*/
bool OPJ_CALLCONV opj_decode_tile_data(
opj_codec_t *p_codec,
OPJ_UINT32 p_tile_index,
OPJ_BYTE * p_data,
OPJ_UINT32 p_data_size,
opj_stream_t *p_stream
)
{
if
(p_codec && p_data && p_stream)
{
opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec;
opj_stream_private_t * l_cio = (opj_stream_private_t *) p_stream;
if
(! l_info->is_decompressor)
{
return false;
}
return l_info->m_codec_data.m_decompression.opj_decode_tile_data(l_info->m_codec,p_tile_index,p_data,p_data_size,l_cio,&(l_info->m_event_mgr));
}
return false;
}
bool OPJ_CALLCONV opj_read_header (
opj_codec_t *p_codec,
opj_image_t ** p_image,
OPJ_INT32 * p_tile_x0,
OPJ_INT32 * p_tile_y0,
OPJ_UINT32 * p_tile_width,
OPJ_UINT32 * p_tile_height,
OPJ_UINT32 * p_nb_tiles_x,
OPJ_UINT32 * p_nb_tiles_y,
opj_stream_t *p_cio)
{
if
(p_codec && p_cio)
{
opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec;
opj_stream_private_t * l_cio = (opj_stream_private_t *) p_cio;
if
(! l_info->is_decompressor)
{
return false;
}
return l_info->m_codec_data.m_decompression.opj_read_header(
l_info->m_codec,
p_image,
p_tile_x0,
p_tile_y0,
p_tile_width,
p_tile_height,
p_nb_tiles_x,
p_nb_tiles_y,
l_cio,
&(l_info->m_event_mgr));
}
return false;
}
/**
* Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
*
* @param p_codec the jpeg2000 codec.
* @param p_start_x the left position of the rectangle to decode (in image coordinates).
* @param p_end_x the right position of the rectangle to decode (in image coordinates).
* @param p_start_y the up position of the rectangle to decode (in image coordinates).
* @param p_end_y the bottom position of the rectangle to decode (in image coordinates).
*
* @return true if the area could be set.
*/
bool OPJ_CALLCONV opj_set_decode_area(
opj_codec_t *p_codec,
OPJ_INT32 p_start_x,
OPJ_INT32 p_start_y,
OPJ_INT32 p_end_x,
OPJ_INT32 p_end_y
)
{
if
(p_codec)
{
opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec;
if
(! l_info->is_decompressor)
{
return false;
}
return l_info->m_codec_data.m_decompression.opj_set_decode_area(
l_info->m_codec,
p_start_x,
p_start_y,
p_end_x,
p_end_y,
&(l_info->m_event_mgr));
}
return false;
}
bool OPJ_CALLCONV opj_end_decompress (opj_codec_t *p_codec,opj_stream_t *p_cio)
{
if
(p_codec && p_cio)
{
opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec;
opj_stream_private_t * l_cio = (opj_stream_private_t *) p_cio;
if
(! l_info->is_decompressor)
{
return false;
}
return l_info->m_codec_data.m_decompression.opj_end_decompress(l_info->m_codec,l_cio,&(l_info->m_event_mgr));
}
return false;
}
opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
{
opj_codec_private_t *l_info = 00;
l_info = (opj_codec_private_t*)opj_calloc(1, sizeof(opj_codec_private_t));
if
(!l_info)
{
return 00;
}
memset(l_info, 0, sizeof(opj_codec_private_t));
l_info->is_decompressor = 0;
switch
(p_format)
{
case CODEC_J2K:
l_info->m_codec_data.m_compression.opj_encode = (bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr * )) j2k_encode;
l_info->m_codec_data.m_compression.opj_end_compress = (bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr *)) j2k_end_compress;
l_info->m_codec_data.m_compression.opj_start_compress = (bool (*) (void *,struct opj_stream_private *,struct opj_image * , struct opj_event_mgr *)) j2k_start_compress;
l_info->m_codec_data.m_compression.opj_write_tile = (bool (*) (void *,OPJ_UINT32,OPJ_BYTE*,OPJ_UINT32,struct opj_stream_private *, struct opj_event_mgr *)) j2k_write_tile;
l_info->m_codec_data.m_compression.opj_destroy = (void (*) (void *)) j2k_destroy;
l_info->m_codec_data.m_compression.opj_setup_encoder = (void (*) (void *,opj_cparameters_t *,struct opj_image *, struct opj_event_mgr * )) j2k_setup_encoder;
l_info->m_codec = j2k_create_compress();
if
(! l_info->m_codec)
{
opj_free(l_info);
return 00;
}
break;
case CODEC_JP2:
/* get a JP2 decoder handle */
l_info->m_codec_data.m_compression.opj_encode = (bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr * )) opj_jp2_encode;
l_info->m_codec_data.m_compression.opj_end_compress = (bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr *)) jp2_end_compress;
l_info->m_codec_data.m_compression.opj_start_compress = (bool (*) (void *,struct opj_stream_private *,struct opj_image * , struct opj_event_mgr *)) jp2_start_compress;
l_info->m_codec_data.m_compression.opj_write_tile = (bool (*) (void *,OPJ_UINT32,OPJ_BYTE*,OPJ_UINT32,struct opj_stream_private *, struct opj_event_mgr *)) jp2_write_tile;
l_info->m_codec_data.m_compression.opj_destroy = (void (*) (void *)) jp2_destroy;
l_info->m_codec_data.m_compression.opj_setup_encoder = (void (*) (void *,opj_cparameters_t *,struct opj_image *, struct opj_event_mgr * )) jp2_setup_encoder;
l_info->m_codec = jp2_create(false);
if
(! l_info->m_codec)
{
opj_free(l_info);
return 00;
}
break;
case CODEC_UNKNOWN:
case CODEC_JPT:
default:
opj_free(l_info);
return 00;
}
set_default_event_handler(&(l_info->m_event_mgr));
return (opj_codec_t*) l_info;
}
void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters) {
if(parameters) {
memset(parameters, 0, sizeof(opj_cparameters_t));
/* default coding parameters */
parameters->cp_cinema = OFF;
parameters->max_comp_size = 0;
parameters->numresolution = 6;
parameters->cp_rsiz = STD_RSIZ;
parameters->cblockw_init = 64;
parameters->cblockh_init = 64;
parameters->prog_order = LRCP;
parameters->roi_compno = -1; /* no ROI */
parameters->subsampling_dx = 1;
parameters->subsampling_dy = 1;
parameters->tp_on = 0;
parameters->decod_format = -1;
parameters->cod_format = -1;
parameters->tcp_rates[0] = 0;
parameters->tcp_numlayers = 0;
parameters->cp_disto_alloc = 0;
parameters->cp_fixed_alloc = 0;
parameters->cp_fixed_quality = 0;
/* UniPG>> */
#ifdef USE_JPWL
parameters->jpwl_epc_on = false;
parameters->jpwl_hprot_MH = -1; /* -1 means unassigned */
{
int i;
for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
parameters->jpwl_hprot_TPH_tileno[i] = -1; /* unassigned */
parameters->jpwl_hprot_TPH[i] = 0; /* absent */
}
};
{
int i;
for (i = 0; i < JPWL_MAX_NO_PACKSPECS; i++) {
parameters->jpwl_pprot_tileno[i] = -1; /* unassigned */
parameters->jpwl_pprot_packno[i] = -1; /* unassigned */
parameters->jpwl_pprot[i] = 0; /* absent */
}
};
parameters->jpwl_sens_size = 0; /* 0 means no ESD */
parameters->jpwl_sens_addr = 0; /* 0 means auto */
parameters->jpwl_sens_range = 0; /* 0 means packet */
parameters->jpwl_sens_MH = -1; /* -1 means unassigned */
{
int i;
for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
parameters->jpwl_sens_TPH_tileno[i] = -1; /* unassigned */
parameters->jpwl_sens_TPH[i] = -1; /* absent */
}
};
#endif /* USE_JPWL */
/* <<UniPG */
}
}
/**
* Helper function.
* Sets the stream to be a file stream. The FILE must have been open previously.
* @param p_stream the stream to modify
* @param p_file handler to an already open file.
*/
opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (FILE * p_file,bool p_is_read_stream)
{
return opj_stream_create_file_stream(p_file,J2K_STREAM_CHUNK_SIZE,p_is_read_stream);
}
opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (FILE * p_file,OPJ_UINT32 p_size,bool p_is_read_stream)
{
opj_stream_t* l_stream = 00;
if
(! p_file)
{
return 00;
}
l_stream = opj_stream_create(p_size,p_is_read_stream);
if
(! l_stream)
{
return 00;
}
opj_stream_set_user_data(l_stream,p_file);
opj_stream_set_read_function(l_stream,(opj_stream_read_fn) opj_read_from_file);
opj_stream_set_write_function(l_stream, (opj_stream_write_fn) opj_write_from_file);
opj_stream_set_skip_function(l_stream, (opj_stream_skip_fn) opj_skip_from_file);
opj_stream_set_seek_function(l_stream, (opj_stream_seek_fn) opj_seek_from_file);
return l_stream;
}
bool OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_info, opj_cparameters_t *parameters, opj_image_t *image)
{
if
(p_info && parameters && image)
{
opj_codec_private_t * l_codec = ((opj_codec_private_t *) p_info);
if
(! l_codec->is_decompressor)
{
l_codec->m_codec_data.m_compression.opj_setup_encoder(l_codec->m_codec,parameters,image,&(l_codec->m_event_mgr));
return true;
}
}
return false;
}
bool OPJ_CALLCONV opj_encode(opj_codec_t *p_info, opj_stream_t *cio)
{
if
(p_info && cio)
{
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_info;
opj_stream_private_t * l_cio = (opj_stream_private_t *) cio;
if
(! l_codec->is_decompressor)
{
l_codec->m_codec_data.m_compression.opj_encode(l_codec->m_codec,l_cio,&(l_codec->m_event_mgr));
return true;
}
}
return false;
}
bool OPJ_CALLCONV opj_start_compress (opj_codec_t *p_codec,opj_image_t * p_image,opj_stream_t *p_cio)
{
if
(p_codec && p_cio)
{
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
opj_stream_private_t * l_cio = (opj_stream_private_t *) p_cio;
if
(! l_codec->is_decompressor)
{
return l_codec->m_codec_data.m_compression.opj_start_compress(l_codec->m_codec,l_cio,p_image,&(l_codec->m_event_mgr));
}
}
return false;
}
bool OPJ_CALLCONV opj_end_compress (opj_codec_t *p_codec,opj_stream_t *p_cio)
{
if
(p_codec && p_cio)
{
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
opj_stream_private_t * l_cio = (opj_stream_private_t *) p_cio;
if
(! l_codec->is_decompressor)
{
return l_codec->m_codec_data.m_compression.opj_end_compress(l_codec->m_codec,l_cio,&(l_codec->m_event_mgr));
}
}
return false;
}
bool OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec, opj_msg_callback p_callback,void * p_user_data)
{
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
if
(! l_codec)
{
return false;
}
l_codec->m_event_mgr.info_handler = p_callback;
l_codec->m_event_mgr.m_info_data = p_user_data;
return true;
}
bool OPJ_CALLCONV opj_set_warning_handler(opj_codec_t * p_codec, opj_msg_callback p_callback,void * p_user_data)
{
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
if
(! l_codec)
{
return false;
}
l_codec->m_event_mgr.warning_handler = p_callback;
l_codec->m_event_mgr.m_warning_data = p_user_data;
return true;
}
bool OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec, opj_msg_callback p_callback,void * p_user_data)
{
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
if
(! l_codec)
{
return false;
}
l_codec->m_event_mgr.error_handler = p_callback;
l_codec->m_event_mgr.m_error_data = p_user_data;
return true;
}
/*bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_stream_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
if(cinfo && cio && image) {
switch(cinfo->codec_format) {
case CODEC_J2K:
return j2k_encode((opj_j2k_t*)cinfo->j2k_handle, (opj_stream_private_t *) cio, image, cstr_info);
case CODEC_JP2:
return opj_jp2_encode((opj_jp2_t*)cinfo->jp2_handle, (opj_stream_private_t *) cio, image, cstr_info);
case CODEC_JPT:
case CODEC_UNKNOWN:
default:
break;
}
}
return false;
}*/
void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) {
if
(cstr_info)
{
int tileno;
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
opj_tile_info_t *tile_info = &cstr_info->tile[tileno];
opj_free(tile_info->thresh);
opj_free(tile_info->packet);
opj_free(tile_info->tp);
}
opj_free(cstr_info->tile);
opj_free(cstr_info->marker);
}
}
bool OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters,OPJ_FLOAT32 * pEncodingMatrix,OPJ_INT32 * p_dc_shift,OPJ_UINT32 pNbComp)
{
OPJ_UINT32 l_matrix_size = pNbComp * pNbComp * sizeof(OPJ_FLOAT32);
OPJ_UINT32 l_dc_shift_size = pNbComp * sizeof(OPJ_INT32);
OPJ_UINT32 l_mct_total_size = l_matrix_size + l_dc_shift_size;
// add MCT capability
int rsiz = (int)parameters->cp_rsiz | (int)MCT;
parameters->cp_rsiz = (OPJ_RSIZ_CAPABILITIES)rsiz;
parameters->irreversible = 1;
// use array based MCT
parameters->tcp_mct = 2;
parameters->mct_data = opj_malloc(l_mct_total_size);
if
(! parameters->mct_data)
{
return false;
}
memcpy(parameters->mct_data,pEncodingMatrix,l_matrix_size);
memcpy(((OPJ_BYTE *) parameters->mct_data) + l_matrix_size,p_dc_shift,l_dc_shift_size);
return true;
}
/**
* Restricts the decoding to the given image area.
*
* @param parameters the parameters to update.
* @param p_start_x the starting x position of the area to decode.
* @param p_start_y the starting y position of the area to decode.
* @param p_end_x the x end position of the area to decode.
* @param p_end_x the y end position of the area to decode.
*/
OPJ_API bool OPJ_CALLCONV opj_restrict_decoding (opj_dparameters_t *parameters,OPJ_INT32 p_start_x,OPJ_INT32 p_start_y,OPJ_INT32 p_end_x,OPJ_INT32 p_end_y)
{
parameters->m_use_restrict_decode = 1;
parameters->m_decode_start_x = p_start_x;
parameters->m_decode_start_y = p_start_y;
parameters->m_decode_end_x = p_end_x;
parameters->m_decode_end_y = p_end_y;
return true;
}

1080
libopenjpeg/openjpeg.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,16 @@
/*
* here is where system comupted values get stored these values should only
* change when the target compile platform changes
*/
/* what byte order */
#ifndef __OPJ_CONFIGURE_H
#define __OPJ_CONFIGURE_H
/* #undef CMAKE_WORDS_BIGENDIAN */
#ifdef CMAKE_WORDS_BIGENDIAN
#define OPJ_BIG_ENDIAN
#else
#define OPJ_LITTLE_ENDIAN
#endif
#endif /* __OPJ_CONFIGURE_H */

124
libopenjpeg/opj_includes.h Normal file
View File

@ -0,0 +1,124 @@
/*
* Copyright (c) 2005, Hervé Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#ifndef OPJ_INCLUDES_H
#define OPJ_INCLUDES_H
/*
==========================================================
Standard includes used by the library
==========================================================
*/
#include <memory.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include <time.h>
#include <stdio.h>
#include <stdarg.h>
#include <ctype.h>
#include <assert.h>
/*
==========================================================
OpenJPEG interface
==========================================================
*/
/*
==========================================================
OpenJPEG modules
==========================================================
*/
/* Ignore GCC attributes if this is not GCC */
#ifndef __GNUC__
#define __attribute__(x) /* __attribute__(x) */
#endif
/*
The inline keyword is supported by C99 but not by C90.
Most compilers implement their own version of this keyword ...
*/
#ifndef INLINE
#if defined(_MSC_VER)
#define INLINE __inline
#elif defined(__GNUC__)
#define INLINE __inline__
#elif defined(__MWERKS__)
#define INLINE inline
#else
/* add other compilers here ... */
#define INLINE
#endif /* defined(<Compiler>) */
#endif /* INLINE */
/* Are restricted pointers available? (C99) */
#if (__STDC_VERSION__ != 199901L)
/* Not a C99 compiler */
#ifdef __GNUC__
#define restrict __restrict__
#else
#define restrict /* restrict */
#endif
#endif
/* MSVC and Borland C do not have lrintf */
#if defined(_MSC_VER) || defined(__BORLANDC__)
/* MSVC 64bits doesn't support _asm */
#if !defined(_WIN64)
static INLINE long lrintf(float f){
int i;
_asm{
fld f
fistp i
};
return i;
}
#else
static INLINE long lrintf(float x){
long r;
if (x>=0.f)
{
x+=0.5f;
}
else
{
x-=0.5f;
}
r = (long)(x);
if ( x != (float)(r) ) return r;
return 2*(r/2);
}
#endif
#endif
#endif /* OPJ_INCLUDES_H */

View File

@ -1,11 +1,7 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2005, Hervé Drolon, FreeImage Team
* Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -29,17 +25,16 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OPJ_MALLOC_H
#define OPJ_MALLOC_H
#include <stddef.h>
#ifndef __OPJ_MALLOC_H
#define __OPJ_MALLOC_H
/**
@file opj_malloc.h
@brief Internal functions
The functions in opj_malloc.h are internal utilities used for memory management.
*/
#include "openjpeg.h"
#include "opj_includes.h"
/** @defgroup MISC MISC - Miscellaneous internal functions */
/*@{*/
@ -52,48 +47,92 @@ Allocate an uninitialized memory block
@param size Bytes to allocate
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
*/
void * opj_malloc(size_t size);
#define opj_malloc(size) malloc(size)
#define my_opj_malloc(size) malloc(size)
/**
Allocate a memory block with elements initialized to 0
@param numOfElements Blocks to allocate
@param sizeOfElements Bytes per block to allocate
@param num Blocks to allocate
@param size Bytes per block to allocate
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
*/
void * opj_calloc(size_t numOfElements, size_t sizeOfElements);
#define opj_calloc(num, size) calloc(num, size)
/**
Allocate memory aligned to a 16 byte boundary
Allocate memory aligned to a 16 byte boundry
@param size Bytes to allocate
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
*/
void * opj_aligned_malloc(size_t size);
void * opj_aligned_realloc(void *ptr, size_t size);
void opj_aligned_free(void* ptr);
/* FIXME: These should be set with cmake tests, but we're currently not requiring use of cmake */
#ifdef WIN32
/* Someone should tell the mingw people that their malloc.h ought to provide _mm_malloc() */
#ifdef __GNUC__
#include <mm_malloc.h>
#define HAVE_MM_MALLOC
#else /* MSVC, Intel C++ */
#include <malloc.h>
#ifdef _mm_malloc
#define HAVE_MM_MALLOC
#endif
#endif
#else /* Not WIN32 */
#if defined(__sun)
#define HAVE_MEMALIGN
/* Linux x86_64 and OSX always align allocations to 16 bytes */
#elif !defined(__amd64__) && !defined(__APPLE__)
/* FIXME: Yes, this is a big assumption */
#define HAVE_POSIX_MEMALIGN
#endif
#endif
/**
Allocate memory aligned to a 32 byte boundary
@param size Bytes to allocate
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
*/
void * opj_aligned_32_malloc(size_t size);
void * opj_aligned_32_realloc(void *ptr, size_t size);
#define opj_aligned_malloc(size) malloc(size)
#define opj_aligned_free(m) free(m)
#ifdef HAVE_MM_MALLOC
#undef opj_aligned_malloc
#define opj_aligned_malloc(size) _mm_malloc(size, 16)
#undef opj_aligned_free
#define opj_aligned_free(m) _mm_free(m)
#endif
#ifdef HAVE_MEMALIGN
extern void* memalign(size_t, size_t);
#undef opj_aligned_malloc
#define opj_aligned_malloc(size) memalign(16, (size))
#undef opj_aligned_free
#define opj_aligned_free(m) free(m)
#endif
#ifdef HAVE_POSIX_MEMALIGN
#undef opj_aligned_malloc
extern int posix_memalign(void**, size_t, size_t);
static INLINE void* __attribute__ ((malloc)) opj_aligned_malloc(size_t size){
void* mem = NULL;
posix_memalign(&mem, 16, size);
return mem;
}
#undef opj_aligned_free
#define opj_aligned_free(m) free(m)
#endif
/**
Reallocate memory blocks.
@param m Pointer to previously allocated memory block
@param s New size in bytes
@param memblock Pointer to previously allocated memory block
@param size New size in bytes
@return Returns a void pointer to the reallocated (and possibly moved) memory block
*/
void * opj_realloc(void * m, size_t s);
#define opj_realloc(m, s) realloc(m, s)
#define my_opj_realloc(m,s) realloc(m,s)
/**
Deallocates or frees a memory block.
@param m Previously allocated memory block to be freed
@param memblock Previously allocated memory block to be freed
*/
void opj_free(void * m);
#define opj_free(m) free(m)
#if defined(__GNUC__) && !defined(OPJ_SKIP_POISON)
#ifdef __GNUC__
#pragma GCC poison malloc calloc realloc free
#endif
@ -102,5 +141,5 @@ void opj_free(void * m);
/*@}*/
#endif /* OPJ_MALLOC_H */
#endif /* __OPJ_MALLOC_H */

2003
libopenjpeg/pi.c Normal file

File diff suppressed because it is too large Load Diff

181
libopenjpeg/pi.h Normal file
View File

@ -0,0 +1,181 @@
/*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@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.
*/
#ifndef __PI_H
#define __PI_H
/**
@file pi.h
@brief Implementation of a packet iterator (PI)
The functions in PI.C have for goal to realize a packet iterator that permits to get the next
packet following the progression order and change of it. The functions in PI.C are used
by some function in T2.C.
*/
#include "openjpeg.h"
#include "t2.h"
/** @defgroup PI PI - Implementation of a packet iterator */
/*@{*/
struct opj_poc;
struct opj_image;
struct opj_cp;
/**
FIXME: documentation
*/
typedef struct opj_pi_resolution {
OPJ_UINT32 pdx, pdy;
OPJ_UINT32 pw, ph;
} opj_pi_resolution_t;
/**
FIXME: documentation
*/
typedef struct opj_pi_comp {
OPJ_UINT32 dx, dy;
/** number of resolution levels */
OPJ_UINT32 numresolutions;
opj_pi_resolution_t *resolutions;
} opj_pi_comp_t;
/**
Packet iterator
*/
typedef struct opj_pi_iterator {
/** Enabling Tile part generation*/
OPJ_BYTE tp_on;
/** precise if the packet has been already used (usefull for progression order change) */
OPJ_INT16 *include;
/** layer step used to localize the packet in the include vector */
OPJ_UINT32 step_l;
/** resolution step used to localize the packet in the include vector */
OPJ_UINT32 step_r;
/** component step used to localize the packet in the include vector */
OPJ_UINT32 step_c;
/** precinct step used to localize the packet in the include vector */
OPJ_UINT32 step_p;
/** component that identify the packet */
OPJ_UINT32 compno;
/** resolution that identify the packet */
OPJ_UINT32 resno;
/** precinct that identify the packet */
OPJ_UINT32 precno;
/** layer that identify the packet */
OPJ_UINT32 layno;
/** progression order change information */
struct opj_poc poc;
/** number of components in the image */
OPJ_UINT32 numcomps;
/** Components*/
opj_pi_comp_t *comps;
OPJ_INT32 tx0, ty0, tx1, ty1;
OPJ_INT32 x, y;
OPJ_UINT32 dx, dy;
/** 0 if the first packet */
OPJ_UINT32 first : 1;
} opj_pi_iterator_t;
/** @name Exported functions */
/*@{*/
/* ----------------------------------------------------------------------- */
/**
* Creates a packet iterator for encoding.
*
* @param p_image the image being encoded.
* @param p_cp the coding parameters.
* @param p_tile_no index of the tile being encoded.
* @param p_t2_mode the type of pass for generating the packet iterator
* @return a list of packet iterator that points to the first packet of the tile (not true).
*/
opj_pi_iterator_t *pi_initialise_encode(const struct opj_image *image,struct opj_cp *cp, OPJ_UINT32 tileno,J2K_T2_MODE t2_mode);
/**
* Updates the encoding parameters of the codec.
*
* @param p_image the image being encoded.
* @param p_cp the coding parameters.
* @param p_tile_no index of the tile being encoded.
*/
void pi_update_encoding_parameters(
const struct opj_image *p_image,
struct opj_cp *p_cp,
OPJ_UINT32 p_tile_no
);
/**
Modify the packet iterator for enabling tile part generation
@param pi Handle to the packet iterator generated in pi_initialise_encode
@param cp Coding parameters
@param tileno Number that identifies the tile for which to list the packets
@param tpnum Tile part number of the current tile
@param tppos The position of the tile part flag in the progression order
*/
void pi_create_encode( opj_pi_iterator_t *pi, struct opj_cp *cp,OPJ_UINT32 tileno, OPJ_UINT32 pino,OPJ_UINT32 tpnum, OPJ_INT32 tppos, J2K_T2_MODE t2_mode);
/**
Create a packet iterator for Decoder
@param image Raw image for which the packets will be listed
@param cp Coding parameters
@param tileno Number that identifies the tile for which to list the packets
@return Returns a packet iterator that points to the first packet of the tile
@see pi_destroy
*/
opj_pi_iterator_t *pi_create_decode(struct opj_image * image, struct opj_cp * cp, OPJ_UINT32 tileno);
/**
* Destroys a packet iterator array.
*
* @param p_pi the packet iterator array to destroy.
* @param p_nb_elements the number of elements in the array.
*/
void pi_destroy(
opj_pi_iterator_t *p_pi,
OPJ_UINT32 p_nb_elements);
/**
Modify the packet iterator to point to the next packet
@param pi Packet iterator to modify
@return Returns false if pi pointed to the last packet or else returns true
*/
bool pi_next(opj_pi_iterator_t * pi);
/* ----------------------------------------------------------------------- */
/*@}*/
/*@}*/
#endif /* __PI_H */

Some files were not shown because too many files have changed in this diff Show More