diff --git a/.github/workflows/push-trigger.yml b/.github/workflows/push-trigger.yml index bead808..0ae1d12 100644 --- a/.github/workflows/push-trigger.yml +++ b/.github/workflows/push-trigger.yml @@ -20,12 +20,13 @@ on: - 'master' - '1.*' - 'release*' + - 'issue*' jobs: build-maven-imagedecoder: uses: mosip/kattu/.github/workflows/maven-build.yml@master-java21 with: - SERVICE_LOCATION: imagedecoder + SERVICE_LOCATION: ./ BUILD_ARTIFACT: imagedecoder secrets: OSSRH_USER: ${{ secrets.OSSRH_USER }} @@ -39,7 +40,7 @@ jobs: needs: build-maven-imagedecoder uses: mosip/kattu/.github/workflows/maven-publish-to-nexus.yml@master-java21 with: - SERVICE_LOCATION: imagedecoder + SERVICE_LOCATION: ./ secrets: OSSRH_USER: ${{ secrets.OSSRH_USER }} OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} @@ -53,7 +54,7 @@ jobs: if: "${{ github.event_name != 'pull_request' }}" uses: mosip/kattu/.github/workflows/maven-sonar-analysis.yml@master-java21 with: - SERVICE_LOCATION: imagedecoder + SERVICE_LOCATION: ./ PROJECT_KEY: 'mosip_imagedecoder' secrets: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.gitignore b/.gitignore index a899532..165bf1b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,18 @@ +.idea/ +.vscode/ +.local/ +*.iml +*/target/ /.metadata/ .sonarlint/ */.classpath -*/.gitignore */.project -*/.settings/ \ No newline at end of file +*/.settings/ +.settings/ +.classpath +.project +*.log +*.class +.DS_Store +Thumbs.db +.local-build.log diff --git a/AGENTS.md b/AGENTS.md index c7f9d1a..2348686 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,95 +1,36 @@ -# AGENTS.md +# imagedecoder -This file provides guidance to AI agents when working with code in this repository. -## Build Commands - -All commands run from the `imagedecoder/` directory: - -```bash -# Build and run tests -mvn clean install - -# Skip tests -mvn clean install -DskipTests - -# Run tests only -mvn test - -# Run a single test class -mvn test -Dtest=OpenJpegDecoderTest -mvn test -Dtest=WsqDecoderTest - -# Sonar analysis (requires secrets) -mvn verify sonar:sonar -Psonar ``` - -Build requires Java 21 with `--enable-preview` enabled (configured in both pom.xml files). Tests use the `maven-surefire-plugin` with several `--add-opens` JVM flags. - -## Architecture - -This is a pure-Java biometric image decoding library for the MOSIP identity platform. It ports two native C codec libraries to Java: - -- **JPEG2000** — ported from [OpenJPEG](https://github.com/lessandro/nbis) (`openjp2`) -- **WSQ** — ported from [NBIS WSQ](https://github.com/lessandro/nbis) - -### Module Layout - -- **`imagedecoder/`** — the published library (`io.mosip.imagedecoder:imagedecoder`) -- **`sample/`** — standalone CLI demo app that reads image files from disk and decodes them - -### Core API - -The single entry point is `IImageDecoderApi`: - -```java -Response decode(DecoderRequestInfo requestInfo); +stack JDK21 · Maven3.9+ · Boot 4.1.1 · MPL-2.0 · parent imagedecoder-parent +prereq ../commons/kernel → kernel-core, version = kernel.core.version in pom.xml (Logfactory lives here) +reactor +├─ imagedecoder/ published lib: JPEG2000 + WSQ +└─ sample/ CLI demo, NOT in reactor +pkg io/mosip/imagedecoder/ +├─ spi/ IImageDecoderApi +├─ openjpeg/ OpenJpegDecoder + *Helper (OpenJPEG 1.x C port) +├─ wsq/ WsqDecoder + *Helper (NBIS port) +├─ model/ req/resp + openjpeg/ wsq/ C-struct mirrors +├─ util/ Base64UrlUtil, ByteStreamUtil, wsq/WsqUtil +└─ constant/ exceptions/ logger/ +api Response decode(DecoderRequestInfo) → .jp2 OpenJpeg | .wsq Wsq +rules +├─ ban kernel-bom · kernel-logger-logback · Jackson3 (use spring-boot-jackson2) +├─ lib no Boot repackage +├─ cover jacoco ≥0.85 instr · Sonar = (line+branch) ≥85% · excl config/dto/entity ONLY +├─ tests write tests, never add exclusions +└─ license approved: MIT/BSD/Apache/MPL/ISC/CDDL/Zlib/0BSD · no EPL/GPL/AGPL/LGPL/CC at runtime +gotchas +├─ Cio/Bio/MQC: array+index "pointers"; byteOut PRE-increments → next byte at bpIndex+1 +├─ Cio: start=bpIndex=-1, end=start+length +├─ Lombok @Data on cyclic models → @ToString.Exclude/@EqualsAndHashCode.Exclude +├─ new X[n] of models → init every element (NPE otherwise) +├─ JP2 box readers must bound length (else hang on corrupt input) +└─ corrupt-input tests log millions of lines → read only `Get-Content log -Tail` +cmds (PowerShell: quote -D args) +├─ root mvn verify "-Dgpg.skip=true" # full build + jacoco gate +├─ module mvn -q test "-Dtest=Class#method" "-Dgpg.skip=true" +├─ sonar mvn verify sonar:sonar -Psonar +├─ cov parse imagedecoder/target/site/jacoco/jacoco.xml (LINE+BRANCH counters) +└─ local imagedecoder/run-local.(bat|sh) init|test|all ``` - -- `DecoderRequestInfo` — takes raw image bytes (`imageData`) and a `isBufferedImage` flag -- `DecoderResponseInfo` — returns image metadata (width, height, DPI, color space, bit rate, compression ratio, lossless flag) plus the decoded pixel data as base64url-encoded bytes and optionally a `BufferedImage` -- `Response` — wraps any response with `statusCode`, `statusMessage`, and `response` - -Two implementations: -- `OpenJpegDecoder` — handles JPEG2000 (`.jp2`) -- `WsqDecoder` — handles WSQ (`.wsq`) - -### Package Structure (`imagedecoder/src/main/java/io/mosip/imagedecoder/`) - -| Package | Purpose | -|---|---| -| `spi/` | Public API interface (`IImageDecoderApi`) | -| `model/` | Request/response models; also C-struct mirrors under `model/openjpeg/` and `model/wsq/` | -| `openjpeg/` | JPEG2000 codec implementation — `OpenJpegDecoder` + many `*Helper` classes | -| `wsq/` | WSQ codec implementation — `WsqDecoder` + many `*Helper` classes | -| `constant/` | Error codes and named constants for both codecs | -| `exceptions/` | `DecoderException` | -| `util/` | `Base64UrlUtil`, `ByteStreamUtil`, `ByteSwapperUtil`, and codec-specific math/image utils | -| `logger/` | Thin wrapper around `kernel-logger-logback` | - -### Key Design Details - -The codec implementations (`openjpeg/` and `wsq/`) are direct Java ports of C code. The `model/openjpeg/` and `model/wsq/` packages contain Java classes that mirror C structs from the original libraries. `ByteBufferContext` is used to simulate C-style sequential byte reads. - -The `*Helper` classes (e.g., `J2KHelper`, `WsqDecoderHelper`) are large stateless utility classes containing the ported algorithm logic. They are called by the `Decoder` classes. - -Logging follows the MOSIP convention: `logger.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_EMPTY, message)`. - -### Sample Application - -The `sample/` module runs from its `target/` directory after `mvn package`: - -```bash -# Decode JPEG2000 files from a folder -java -cp sample-imagedecoder-*.jar;lib\* io.mosip.imagedecoder.sample.SampleImageDecoderApplication \ - "io.mosip.imagedecoder.image.type=0" "io.mosip.imagedecoder.image.folder.path=/BiometricInfo" - -# Decode WSQ files from a folder -java -cp sample-imagedecoder-*.jar;lib\* io.mosip.imagedecoder.sample.SampleImageDecoderApplication \ - "io.mosip.imagedecoder.image.type=1" "io.mosip.imagedecoder.image.folder.path=/BiometricInfo" -``` - -Image type: `0` = JP2000, `1` = WSQ. - -### CI/CD - -GitHub Actions (`.github/workflows/push-trigger.yml`) triggers on pushes to `master`, `develop*`, `1.*`, `release*`. It reuses shared MOSIP workflows from `mosip/kattu@master-java21` for build, Nexus publish, and Sonar analysis. Publishing to Maven Central uses the `central-publishing-maven-plugin` with `autoPublish=false`. \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a612ad9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/NOTICE b/NOTICE index 968f30c..2056afa 100644 --- a/NOTICE +++ b/NOTICE @@ -1,64 +1,79 @@ -MOSIP -Copyright (c) 2022 -Modular Open Source Identity Platform - -This product includes software developed at -The Apache Software Foundation (https://www.apache.org/). - -The following third-party components are licensed under the -Apache License 2.0 and require attribution. Their original NOTICE -contents are retained as required by the Apache License 2.0. - - -=============================================================================== -Apache License 2.0 Components -=============================================================================== - - • Apache Maven Source Plugin (3.3.1) - • Apache Maven GPG Plugin (3.2.3) - • Apache Maven Assembly Plugin (3.1.1) - • Apache Maven Compiler Plugin (3.11.0) - • Apache Maven Javadoc Plugin (3.2.0) - • Apache Maven Surefire Plugin (2.22.0) - • Apache Maven JAR Plugin (3.0.2) - • Apache Maven Dependency Plugin (3.1.2) - • Apache Maven Deploy Plugin (3.1.1) - • Apache Maven Resources Plugin (3.0.2) - • Jackson Core (version managed through MOSIP Kernel BOM) - • Jackson Databind (version managed through MOSIP Kernel BOM) - - -=============================================================================== -MIT License Components -=============================================================================== - - • SLF4J - jul-to-slf4j - • SLF4J - jcl-over-slf4j - - -=============================================================================== -MPL-2.0 Components (MOSIP Kernel) -=============================================================================== - - • MOSIP Kernel BOM (1.3.0-SNAPSHOT) - • MOSIP Kernel Core (1.3.0-SNAPSHOT) - • MOSIP Kernel Logger Logback (1.3.0-SNAPSHOT) - • MOSIP Kernel Biometrics (version as used in project) - • MOSIP Kernel ImageDecoder (version as used in project) - - -=============================================================================== -Notes -=============================================================================== - -This project uses components under the following licenses: - - • MPL-2.0: - MOSIP Kernel modules including Kernel BOM, Core, Logger, Biometrics, - and ImageDecoder. - - • MIT: - SLF4J bridging modules such as jul-to-slf4j and jcl-over-slf4j. - -Jackson Core and Jackson Databind versions are inherited from the -MOSIP Kernel BOM (1.3.0-SNAPSHOT) and therefore not listed explicitly. +NOTICES + +Copyright (c) MOSIP. +All rights reserved. + +This project is MPL 2.0 (see LICENSE). Third-party versions match pom.xml and +Spring Boot 4.1.1. Full texts and MOSIP dual-license elections: licenses/. + +MOSIP open-source license matrix (compatible with MPL 2.0 / Use with MOSIP): + + License Compatible? Use with MOSIP? Comments + ------------------------------- ------------ ---------------- -------- + BSD (2-Clause, 3-Clause) Yes Yes Combine freely + MIT Yes Yes Combine freely + Apache-2.0 Yes Yes Meet attribution + MPL-2.0 Yes Yes Combine freely + EPL No No Incompatible with MPL + LGPLv3 Yes No May apply to combined work + GPLv2 No No No explicit MPL compatibility + GPLv3 Yes No Combined work must be GPLv3 + AGPLv3 Yes No Combined work must be AGPLv3 + Creative Commons (general) No No Not for software + ISC Yes Yes Keep ISC + attribution + CDDL-1.0 / CDDL-1.1 Yes Yes Files keep original license + BlueOak-1.0.0 Yes Yes Keep license text/link + Zlib Yes Yes Keep zlib license text + 0BSD Yes Yes Permissive + +Dual-licensed jars: MOSIP elects an allowed option (never EPL, GPL, AGPL, LGPLv3, +or Creative Commons as the product license). + +=========================== +MIT License (licenses/MIT.txt) +=========================== + +- org.slf4j:slf4j-api (Boot-managed) +- org.slf4j:jul-to-slf4j (Boot-managed) +- org.slf4j:jcl-over-slf4j (Boot-managed) +- org.projectlombok:lombok (Boot-managed; provided) +- org.mockito:mockito-core (Boot-managed; test) + +=========================== +Apache-2.0 (licenses/Apache-2.0.txt) +=========================== + +- Spring Boot 4.1.1 / Spring Framework (Boot parent) +- com.fasterxml.jackson.* (Jackson 2 via spring-boot-jackson2) +- Maven build plugins (compiler, surefire, jar, source, javadoc, gpg, deploy, + assembly, dependency, resources) + +=========================== +Mozilla Public License 2.0 (LICENSE) +=========================== + +- This repository (imagedecoder modules) +- io.mosip.kernel:kernel-core (commons — includes Logfactory) +=========================== +Eclipse Public License 2.0 (licenses/EPL-2.0.txt) +=========================== + +- org.junit.vintage:junit-vintage-engine (test only — MOSIP product license remains MPL-2.0) + +=========================== +GNU LGPL 3.0 (licenses/LGPL-3.0.txt) — build plugin only +=========================== + +- pl.project13.maven:git-commit-id-plugin (build-time; not redistributed in library JAR) + +=========================== +Removed / banned (do not reintroduce) +=========================== + +- io.mosip.kernel:kernel-bom — replaced by Spring Boot 4.1.1 dependency management +- io.mosip.kernel:kernel-logger-logback — Logfactory lives in kernel-core + +Algorithm provenance (ports, not redistributed as separate jars): +- OpenJPEG / openjp2 → Java package io.mosip.imagedecoder.openjpeg +- NBIS WSQ → Java package io.mosip.imagedecoder.wsq + Upstream inspiration: https://github.com/lessandro/nbis diff --git a/README.md b/README.md index fd7c02c..d4d007a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,180 @@ -# decoder +# Image Decoder +[![Maven Package upon a push](https://github.com/mosip/imagedecoder/actions/workflows/push-trigger.yml/badge.svg)](https://github.com/mosip/imagedecoder/actions/workflows/push-trigger.yml) +[![License: MPL 2.0](https://img.shields.io/badge/License-MPL_2.0-brightgreen.svg)](LICENSE) + +## Overview + +**Image Decoder** is a pure-Java biometric image decoding library for the [MOSIP](https://mosip.io) platform. It decodes **JPEG2000** (`.jp2`) and **WSQ** (`.wsq`) payloads without native C codecs. + +This repository publishes a **library JAR** (`io.mosip.imagedecoder:imagedecoder`). The `sample/` module is a local CLI demo and is **not** published to Maven Central. + +Parent Maven coordinates: `io.mosip.imagedecoder:imagedecoder-parent` (see root `pom.xml` for the current version). + +## Features + +- **JPEG2000 decode** — Java port of OpenJPEG (`openjp2`) +- **WSQ decode** — Java port of NBIS WSQ +- **Metadata + pixels** — width, height, DPI, color space, bit rate, compression ratio, lossless flag, base64url image data, optional `BufferedImage` +- **No native libraries** — runs on stock JDK 21 + +## Inspired by + +- [NBIS WSQ](https://github.com/lessandro/nbis) — WSQ decoder +- [NBIS openjp2](https://github.com/lessandro/nbis) — JPEG2000 decoder + +## Engineering standards + +| Item | Value | +| ---- | ----- | +| Java | 21 | +| Maven | 3.9+ | +| Spring Boot | **4.1.1** (via `spring-boot-starter-parent`) | +| BOM policy | **No `kernel-bom`** — versions pinned in the parent POM | +| Commons dependency | `io.mosip.kernel:kernel-core` (version: `kernel.core.version` in parent POM) | +| Logging | `Logfactory` inside **kernel-core** (do **not** add `kernel-logger-logback`) | +| Jackson | Jackson **2** via `spring-boot-jackson2` | +| Coverage gate | JaCoCo **≥ 85%** (only `config/`, `dto/`, `entity/` excluded; see parent POM) | +| License | [Mozilla Public License 2.0](LICENSE) | +## Modules + +| Module | Artifact | Description | +| ------ | -------- | ----------- | +| [imagedecoder](imagedecoder/README.md) | `io.mosip.imagedecoder:imagedecoder` | Published JPEG2000 + WSQ codec library | +| [sample](sample/) | `io.mosip.imagedecoder:sample-imagedecoder` | CLI demo (**not** in reactor / not published) | + +```text +imagedecoder-parent +└─ imagedecoder # published library + +sample/ # standalone CLI (parent POM only; not a reactor module) +``` + +## Core API + +```java +Response decode(DecoderRequestInfo requestInfo); +``` + +| Type | Role | +| ---- | ---- | +| `DecoderRequestInfo` | Raw `imageData` bytes + `isBufferedImage` flag | +| `DecoderResponseInfo` | Metadata + base64url pixels + optional `BufferedImage` | +| `Response` | `statusCode`, `statusMessage`, `response` | +| `OpenJpegDecoder` | JPEG2000 (`.jp2`) | +| `WsqDecoder` | WSQ (`.wsq`) | + +## Prerequisites + +- **JDK:** 21 +- **Maven:** 3.9.6 or higher +- **Git** +- **commons `kernel-core`** (version matching `kernel.core.version` in the parent POM) installed locally (or available from your snapshot repo): + + ```text + cd ../commons/kernel + mvn clean install -Dgpg.skip=true -pl kernel-core -am + ``` + +Do **not** introduce `kernel-bom`. Do **not** add `kernel-logger-logback`. + +## Installation + +### Clone + +```text +git clone https://github.com/mosip/imagedecoder.git +cd imagedecoder +``` + +### Build library + +```text +mvn clean install -Dgpg.skip=true +``` + +### Skip tests / GPG (local) + +```text +mvn clean install -Dgpg.skip=true -DskipTests +``` + +### Run tests + +```text +mvn test +mvn test -Dtest=OpenJpegDecoderTest +mvn test -Dtest=WsqDecoderTest +``` + +### Coverage + +```text +mvn clean verify -Dgpg.skip=true +# report: imagedecoder/target/site/jacoco/index.html +# gate: ≥90% instruction coverage (excludes model/constant/*Helper/stream utils) +``` + +### Consume as a dependency + +Pin `` from the root `pom.xml` (it changes across releases): + +```xml + + io.mosip.imagedecoder + imagedecoder + … + +``` + +## Local build (`run-local`) + +Working directory: **`imagedecoder/`**. + +```bat +REM Windows +cd imagedecoder +run-local.bat init +run-local.bat test +run-local.bat all +``` + +```bash +# Linux / macOS / Git Bash +cd imagedecoder +chmod +x run-local.sh +./run-local.sh init +./run-local.sh test +./run-local.sh all +``` + +| Command | Action | +| ------- | ------ | +| `init` | Install parent + package library (skip tests) | +| `test` | Run unit tests | +| `all` | `init` + `test` | + +## Sample CLI + +Working directory: **`sample/`**. Sample images live under `sample/BiometricInfo/`. + +```text +cd sample +mvn clean package -DskipTests -Dgpg.skip=true +``` + +| Windows | Unix | +| ------- | ---- | +| `run-jp2000-decoder.bat` | `./run-jp2000-decoder.sh` | +| `run-wsq-decoder.bat` | `./run-wsq-decoder.sh` | + +Image type argument: `0` = JPEG2000, `1` = WSQ. + +## License & notices + +- Product license: [MPL-2.0](LICENSE) +- Third-party attribution: [NOTICE](NOTICE), [THIRD-PARTY-NOTICES](THIRD-PARTY-NOTICES), [licenses/](licenses/) + +## CI/CD + +GitHub Actions (`.github/workflows/push-trigger.yml`) triggers on pushes to `master`, `develop*`, `1.*`, `release*`, and related branches. It reuses shared MOSIP workflows from `mosip/kattu@master-java21` for build, Nexus publish, and Sonar analysis. Publishing to Maven Central uses `central-publishing-maven-plugin` with `autoPublish=false`. diff --git a/THIRD-PARTY-NOTICES b/THIRD-PARTY-NOTICES index 2e003c7..7039a74 100644 --- a/THIRD-PARTY-NOTICES +++ b/THIRD-PARTY-NOTICES @@ -1,152 +1,72 @@ THIRD-PARTY-NOTICES -This project includes third-party packages that are distributed under various open-source licenses. Below is a list of packages and their associated licenses. +This project includes third-party packages distributed under various open-source +licenses. Versions are managed by Spring Boot 4.1.1 (parent) unless noted. +Product license: MPL-2.0 (LICENSE). Attribution details: NOTICE and licenses/. ================================================================================ -Package: org.slf4j:jcl-over-slf4j -Version: Not specified -License: MIT License (Inferred from project’s official repository) -Homepage: https://www.slf4j.org +Package: org.springframework.boot:spring-boot-starter-parent +Version: 4.1.1 +License: Apache-2.0 +Homepage: https://spring.io/projects/spring-boot ================================================================================ ================================================================================ -Package: org.apache.maven.plugins:maven-source-plugin -Version: 3.3.1 -License: Apache License 2.0 -Homepage: https://maven.apache.org/plugins +Package: org.springframework.boot:spring-boot-jackson2 +Version: Boot-managed (4.1.1) +License: Apache-2.0 +Homepage: https://spring.io/projects/spring-boot +Note: Keeps Jackson 2 under Boot 4 (default Jackson 3 line is not used). ================================================================================ ================================================================================ -Package: io.mosip.kernel:kernel-core -Version: 1.3.0-SNAPSHOT -License: MPL-2.0 (Inferred from MOSIP official repository) -Homepage: https://mosip.io -================================================================================ - -================================================================================ -Package: com.fasterxml.jackson.core:jackson-core -Version: Not specified -License: Apache License 2.0 (Inferred) +Package: com.fasterxml.jackson.core:jackson-core / jackson-databind +Version: Boot-managed via spring-boot-jackson2 (Jackson 2.x) +License: Apache-2.0 Homepage: https://github.com/FasterXML/jackson-core ================================================================================ ================================================================================ -Package: org.slf4j:jul-to-slf4j -Version: Not specified -License: MIT License (Inferred) +Package: org.slf4j:slf4j-api / jul-to-slf4j / jcl-over-slf4j +Version: Boot-managed +License: MIT Homepage: https://www.slf4j.org ================================================================================ ================================================================================ -Package: org.apache.maven.plugins:maven-gpg-plugin -Version: 3.2.3 -License: Apache License 2.0 -Homepage: https://maven.apache.org/plugins -================================================================================ - -================================================================================ -Package: pl.project13.maven:git-commit-id-plugin -Version: 3.0.1 -License: GNU Lesser General Public License v3.0 (LGPL-3.0) -Homepage: https://github.com/git-commit-id/git-commit-id-maven-plugin -================================================================================ - -================================================================================ -Package: org.apache.maven.plugins:maven-assembly-plugin -Version: 3.1.1 -License: Apache License 2.0 -Homepage: https://maven.apache.org/plugins -================================================================================ - -================================================================================ -Package: io.mosip.kernel:kernel-bom -Version: 1.3.0-SNAPSHOT -License: MPL-2.0 (Inferred) -Homepage: https://mosip.io -================================================================================ - -================================================================================ -Package: io.mosip.kernel:kernel-logger-logback -Version: 1.3.0-SNAPSHOT -License: MPL-2.0 (Inferred) -Homepage: https://mosip.io -================================================================================ - -================================================================================ -Package: org.apache.maven.plugins:maven-compiler-plugin -Version: 3.11.0 -License: Apache License 2.0 -Homepage: https://maven.apache.org/plugins -================================================================================ - -================================================================================ -Package: com.fasterxml.jackson.core:jackson-databind -Version: Not specified -License: Apache License 2.0 (Inferred) -Homepage: https://github.com/FasterXML/jackson-databind +Package: io.mosip.kernel:kernel-core +Version: see kernel.core.version in pom.xml +License: MPL-2.0 +Homepage: https://github.com/mosip/commons +Note: Provides Logger SPI and Logfactory. Do not add kernel-logger-logback. ================================================================================ ================================================================================ Package: org.junit.vintage:junit-vintage-engine -Version: Not specified -License: Eclipse Public License 2.0 (EPL-2.0) +Version: Boot-managed +License: EPL-2.0 +Scope: test Homepage: https://junit.org/junit5/ ================================================================================ ================================================================================ -Package: org.apache.maven.plugins:maven-javadoc-plugin -Version: 3.2.0 -License: Apache License 2.0 -Homepage: https://maven.apache.org/plugins +Package: org.jacoco:jacoco-maven-plugin +Version: 0.8.15 +License: EPL-2.0 +Scope: build +Homepage: https://www.jacoco.org ================================================================================ ================================================================================ -Package: org.apache.maven.plugins:maven-surefire-plugin -Version: 2.22.0 -License: Apache License 2.0 -Homepage: https://maven.apache.org/plugins -================================================================================ - -================================================================================ -Package: org.apache.maven.plugins:maven-jar-plugin -Version: 3.0.2 -License: Apache License 2.0 -Homepage: https://maven.apache.org/plugins -================================================================================ - -================================================================================ -Package: org.apache.maven.plugins:maven-dependency-plugin -Version: 3.1.2 -License: Apache License 2.0 -Homepage: https://maven.apache.org/plugins -================================================================================ - -================================================================================ -Package: io.mosip.kernel:kernel-bom -Version: 1.3.0-beta.1 -License: MPL-2.0 -Homepage: https://mosip.io -================================================================================ - -================================================================================ -Package: io.mosip.kernel:kernel-core -Version: 1.3.0-beta.1 -License: MPL-2.0 -Homepage: https://mosip.io -================================================================================ - -================================================================================ -Package: io.mosip.kernel:kernel-logger-logback -Version: 1.3.0-beta.1 -License: MPL-2.0 -Homepage: https://mosip.io +Package: pl.project13.maven:git-commit-id-plugin +Version: 4.9.10 +License: LGPL-3.0 +Scope: build +Homepage: https://github.com/git-commit-id/git-commit-id-maven-plugin ================================================================================ ================================================================================ -Package: io.mosip.imagedecoder:imagedecoder -Version: 0.10.0-beta.1 -License: MPL-2.0 -Homepage: https://github.com/mosip +REMOVED (do not reintroduce) ================================================================================ - -Full license texts and additional details for each of the above packages are available in the license/ directory of this repository. Please refer to those files or the original source of each package for complete legal terms and conditions. +- io.mosip.kernel:kernel-bom +- io.mosip.kernel:kernel-logger-logback diff --git a/imagedecoder/AGENTS.md b/imagedecoder/AGENTS.md new file mode 100644 index 0000000..5c8e654 --- /dev/null +++ b/imagedecoder/AGENTS.md @@ -0,0 +1,8 @@ +# imagedecoder (module) + +``` +see ../AGENTS.md (rules, gotchas, cmds) +entry IImageDecoderApi.decode → OpenJpegDecoder | WsqDecoder +tests src/test/java/io/mosip/imagedecoder/test/ · samples src/test/resources/biometric/ +run mvn -q test "-Dtest=Class" "-Dgpg.skip=true" +``` diff --git a/imagedecoder/README.md b/imagedecoder/README.md index af2daac..810221e 100644 --- a/imagedecoder/README.md +++ b/imagedecoder/README.md @@ -1,14 +1,38 @@ -# image decode -## Overview -This is a reference repository to use Image Decoder to extract image header and raw image data. -This library provides a Image header information. +# imagedecoder (library) -https://github.com/mosip/imagedecoder. +Pure-Java JPEG2000 + WSQ biometric image decoder for MOSIP. -## Inspired By -This library is inspired by https://github.com/lessandro/nbis WSQ for WSQ decoder and -https://github.com/lessandro/nbis openjp2 for JPEG2000 decoder. +- Artifact: `io.mosip.imagedecoder:imagedecoder` +- Parent: `imagedecoder-parent` (Spring Boot **4.1.1**, no `kernel-bom`) +- Depends on: `kernel-core` (version from parent `kernel.core.version`; Logfactory included) -### License +```text +spi/ → IImageDecoderApi +openjpeg/ → OpenJpegDecoder +wsq/ → WsqDecoder +``` +## Local runner +From **`imagedecoder/`**: + +```bat +run-local.bat init +run-local.bat test +run-local.bat all +``` + +```bash +chmod +x run-local.sh +./run-local.sh init +./run-local.sh test +./run-local.sh all +``` + +| Command | Action | +| ------- | ------ | +| `init` | Install parent + package this module (skip tests) | +| `test` | Run unit tests (`OpenJpegDecoderTest`, `WsqDecoderTest`) | +| `all` | `init` + `test` | + +See root [README.md](../README.md) and [AGENTS.md](../AGENTS.md). diff --git a/imagedecoder/pom.xml b/imagedecoder/pom.xml index 55d189e..e18961a 100644 --- a/imagedecoder/pom.xml +++ b/imagedecoder/pom.xml @@ -4,86 +4,83 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - io.mosip.imagedecoder + + io.mosip.imagedecoder + imagedecoder-parent + 0.10.1-SNAPSHOT + ../pom.xml + + imagedecoder - 0.10.0-SNAPSHOT + 0.10.1-SNAPSHOT + jar Imagedecoder - http://github.com/mosip/imagedecoder - Image decoder for MOSIP - - UTF-8 - 21 - - - ${java.version} - ${java.version} - 3.11.0 - 3.0.2 - 3.1.0 - 3.2.0 - 2.3 - 0.8.11 - 3.1.1 - 3.3.1 - 3.2.0 - 3.2.3 - 3.0.2 - 3.1.0 - 3.1.1 - 2.22.0 - 0.7.0 - 3.2.5 - 3.7.0.1746 - - - 3.0.1 + https://github.com/mosip/imagedecoder + + Pure-Java biometric image decoder for MOSIP: JPEG2000 (ported from OpenJPEG / openjp2) + and WSQ (ported from NBIS). Entry point IImageDecoderApi.decode(DecoderRequestInfo) returns + metadata (width, height, DPI, color space, bit rate, compression ratio, lossless) plus + base64url pixel data and optional BufferedImage. No native codec libraries required. + Depends on kernel-core only (version from parent kernel.core.version) (Logfactory lives in kernel-core — do not add + kernel-bom or kernel-logger-logback). Jackson 2 via spring-boot-jackson2 under Boot 4.1.1. + - - 1.3.1-rc.1 - 1.3.1-rc.1 - 1.3.1-rc.1 + + + + **/config/**,**/dto/**,**/entity/** + - - - - io.mosip.kernel - kernel-bom - ${kernel.bom.version} - pom - import - - - - - - org.slf4j - jul-to-slf4j - - - org.slf4j - jcl-over-slf4j - + io.mosip.kernel kernel-core - ${kernel.core.version} org.springframework.boot - - spring-boot-starter-security - + spring-boot-starter-security + - io.mosip.kernel - kernel-logger-logback - ${kernel.logger.logback.version} + org.slf4j + slf4j-api + + + org.slf4j + jul-to-slf4j + + + org.slf4j + jcl-over-slf4j + + + + org.springframework.boot + spring-boot-jackson2 + + com.fasterxml.jackson.core jackson-databind @@ -92,49 +89,11 @@ com.fasterxml.jackson.core jackson-core - - org.junit.vintage - junit-vintage-engine - - - - ossrh - https://central.sonatype.com/repository/maven-snapshots/ - - - ossrh - https://central.sonatype.com/api/v1/publisher - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven.compiler.version} - - ${java.version} - - --enable-preview - - - - - maven-deploy-plugin - ${maven.deploy.plugin.version} - - - default-deploy - deploy - - deploy - - - - + org.apache.maven.plugins maven-assembly-plugin @@ -154,187 +113,6 @@ - - org.sonatype.central - central-publishing-maven-plugin - ${central.publishing.maven.plugin.version} - true - - ossrh - false - - - - org.apache.maven.plugins - maven-source-plugin - true - ${maven.source.plugin.version} - - - attach-sources - - jar-no-fork - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - ${maven.javadoc.plugin.version} - - - attach-javadocs - - jar - - - - - none - - - - org.apache.maven.plugins - maven-gpg-plugin - ${maven.gpg.plugin.version} - - - sign-artifacts - verify - - sign - - - - --pinentry-mode - loopback - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven.surefire.plugin.version} - - ${skipTests} - false - - ${argLine} - --add-modules=ALL-SYSTEM - --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens java.base/java.lang.reflect=ALL-UNNAMED - --add-opens java.base/java.lang.stream=ALL-UNNAMED - --add-opens java.base/java.time=ALL-UNNAMED - --add-opens java.base/java.time.LocalDate=ALL-UNNAMED - --add-opens - java.base/java.time.LocalDateTime=ALL-UNNAMED - --add-opens - java.base/java.time.LocalDateTime.date=ALL-UNNAMED - --enable-preview - - - - - org.jacoco - jacoco-maven-plugin - ${jacoco.maven.plugin.version} - - - - prepare-agent - - - - report - prepare-package - - report - - - - - - pl.project13.maven - git-commit-id-plugin - ${git.commit.id.plugin.version} - - - get-the-git-infos - - revision - - validate - - - - true - - ${project.build.outputDirectory}/git.properties - - ^git.build.(time|version)$ - ^git.commit.id.(abbrev|full)$ - - full - ${project.basedir}/.git - - - - - - sonar - - . - src/main/java/**,src/main/resources/** - ${sonar.coverage.exclusions} - https://sonarcloud.io - - - false - - - - - org.sonarsource.scanner.maven - sonar-maven-plugin - ${maven.sonar.plugin.version} - - - verify - - sonar - - - - - - - - - - - scm:git:git://github.com/mosip/imagedecoder.git - scm:git:ssh://github.com:mosip/imagedecoder.git - https://github.com/mosip/imagedecoder - HEAD - - - - MPL 2.0 - https://www.mozilla.org/en-US/MPL/2.0/ - - - - - Mosip - mosip.emailnotifier@gmail.com - io.mosip - https://github.com/mosip/imagedecoder.git - - diff --git a/imagedecoder/run-local.bat b/imagedecoder/run-local.bat new file mode 100644 index 0000000..0060cbc --- /dev/null +++ b/imagedecoder/run-local.bat @@ -0,0 +1,83 @@ +@echo off +setlocal EnableExtensions EnableDelayedExpansion +REM Standalone Windows cmd runner for imagedecoder library (no .ps1). +REM Linux / macOS / Git Bash: use run-local.sh +REM +REM run-local.bat init | test | all + +set "MODULE_DIR=%~dp0" +if "%MODULE_DIR:~-1%"=="\" set "MODULE_DIR=%MODULE_DIR:~0,-1%" +set "REPO_ROOT=%MODULE_DIR%\.." + +set "LOCAL_DIR=%MODULE_DIR%\.local" +set "LOG_DIR=%LOCAL_DIR%\logs" +set "MODULE=imagedecoder" + +set "CMD=%~1" +if "%CMD%"=="" goto :usage +if /I "%CMD%"=="-h" goto :usage +if /I "%CMD%"=="--help" goto :usage +if /I "%CMD%"=="help" goto :usage +if /I "%CMD%"=="init" goto :init +if /I "%CMD%"=="test" goto :test +if /I "%CMD%"=="all" goto :all + +echo error: unknown command '%CMD%' +goto :usage + +:usage +echo Local imagedecoder library +echo. +echo run-local.bat init install parent + package this module ^(skip tests^) +echo run-local.bat test Maven unit tests +echo run-local.bat all init + test +echo. +echo Run from imagedecoder\ +exit /b 1 + +:ensure_dirs +if not exist "%LOG_DIR%" mkdir "%LOG_DIR%" +exit /b 0 + +:check_prereqs +where java >nul 2>&1 +if errorlevel 1 ( + echo error: java is required on PATH + exit /b 1 +) +where mvn >nul 2>&1 +if errorlevel 1 ( + echo error: mvn is required on PATH + exit /b 1 +) +exit /b 0 + +:init +call :check_prereqs +if errorlevel 1 exit /b 1 +call :ensure_dirs +echo ==^> packaging %MODULE% ^(skip tests^) +pushd "%REPO_ROOT%" +call mvn clean install -DskipTests "-Dgpg.skip=true" "-Dmaven.javadoc.skip=true" -pl imagedecoder -am +set "RC=%ERRORLEVEL%" +popd +if not "%RC%"=="0" exit /b %RC% +echo init complete +exit /b 0 + +:test +call :check_prereqs +if errorlevel 1 exit /b 1 +echo ==^> maven tests +pushd "%REPO_ROOT%" +call mvn test "-Dgpg.skip=true" "-Dmaven.javadoc.skip=true" -pl imagedecoder +set "RC=%ERRORLEVEL%" +popd +exit /b %RC% + +:all +echo ==^> all: init + test +call :init +if errorlevel 1 exit /b 1 +call :test +exit /b %ERRORLEVEL% diff --git a/imagedecoder/run-local.sh b/imagedecoder/run-local.sh new file mode 100644 index 0000000..251e139 --- /dev/null +++ b/imagedecoder/run-local.sh @@ -0,0 +1,98 @@ +#!/usr/bin/env bash +# imagedecoder library local runner — Linux, macOS, Windows Git Bash/MSYS. +# Windows cmd: use run-local.bat (standalone). +# +# ./run-local.sh init | test | all +set -euo pipefail + +MODULE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "${MODULE_DIR}/.." && pwd)" +LOCAL_DIR="${MODULE_DIR}/.local" +LOG_DIR="${LOCAL_DIR}/logs" +MODULE="imagedecoder" +UNAME_S="$(uname -s 2>/dev/null || echo unknown)" + +MVN_SKIP=( + "-DskipTests" + "-Dgpg.skip=true" + "-Dmaven.javadoc.skip=true" +) + +usage() { + cat </dev/null 2>&1 || { + echo "error: '$1' is required on PATH" >&2 + exit 1 + } +} + +ensure_dirs() { + mkdir -p "$LOG_DIR" +} + +check_prereqs() { + need_cmd java + need_cmd mvn + echo "os: ${UNAME_S}" + local ver + ver="$(java -version 2>&1 | head -n 1 || true)" + echo "java: $ver" + if ! echo "$ver" | grep -E '"21[\. "]' >/dev/null 2>&1; then + echo "warn: JDK 21 is required. Continuing anyway." >&2 + fi +} + +cmd_init() { + check_prereqs + ensure_dirs + echo "==> packaging ${MODULE} (skip tests)" + ( + cd "$REPO_ROOT" + mvn clean install "${MVN_SKIP[@]}" -pl imagedecoder -am + ) + echo "init complete" +} + +cmd_test() { + check_prereqs + echo "==> maven tests" + ( + cd "$REPO_ROOT" + mvn test "-Dgpg.skip=true" "-Dmaven.javadoc.skip=true" -pl imagedecoder + ) +} + +cmd_all() { + echo "==> all: init + test" + cmd_init + cmd_test +} + +main() { + local cmd="${1:-}" + shift || true + case "$cmd" in + -h|--help|help) usage 0 ;; + init) cmd_init ;; + test) cmd_test ;; + all) cmd_all ;; + "") usage 1 ;; + *) echo "error: unknown command '$cmd'" >&2; usage 1 ;; + esac +} + +main "$@" diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/model/openjpeg/ContextInfo.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/model/openjpeg/ContextInfo.java index 431f793..0c6b926 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/model/openjpeg/ContextInfo.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/model/openjpeg/ContextInfo.java @@ -1,8 +1,10 @@ package io.mosip.imagedecoder.model.openjpeg; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; +import lombok.ToString; @Getter @Setter @@ -11,15 +13,24 @@ * Common fields between JPEG-2000 compression and decompression master structs. */ public class ContextInfo { + /* codec handles point back to this context; excluded to avoid toString/hashCode cycles */ + @ToString.Exclude + @EqualsAndHashCode.Exclude private Object clientData; /** < Available for use by application */ private int isDecompressor; /** < So common code can tell which is which */ private JP2CodecFormat codecFormat; /** < selected codec */ + @ToString.Exclude + @EqualsAndHashCode.Exclude private Object j2kHandle; /** < pointer to the J2K codec */ + @ToString.Exclude + @EqualsAndHashCode.Exclude private Object jp2Handle; /** < pointer to the JP2 codec */ + @ToString.Exclude + @EqualsAndHashCode.Exclude private Object mj2Handle; /** < pointer to the MJ2 codec */ -} \ No newline at end of file +} diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/model/openjpeg/TcdResolution.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/model/openjpeg/TcdResolution.java index 0a76dd9..262cae9 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/model/openjpeg/TcdResolution.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/model/openjpeg/TcdResolution.java @@ -18,5 +18,10 @@ public class TcdResolution { private int pWidth; private int pHeight; private int noOfBands; /* number sub-band for the resolution level */ - private TcdBand[] bands = new TcdBand[3]; /* subband information */ + private TcdBand[] bands = new TcdBand[3]; /* subband information */ + { + for (int i = 0; i < bands.length; i++) { + bands[i] = new TcdBand(); + } + } } \ No newline at end of file diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/model/openjpeg/Tcp.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/model/openjpeg/Tcp.java index 315b995..afb3836 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/model/openjpeg/Tcp.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/model/openjpeg/Tcp.java @@ -31,6 +31,11 @@ public class Tcp { private int isPoc; /** progression order changes */ private Poc[] pocs = new Poc[32]; + { + for (int i = 0; i < pocs.length; i++) { + pocs[i] = new Poc(); + } + } private int pptDataIndex; /** packet header store there for futur use in t2_decode_packet */ private byte[] pptData; diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/model/openjpeg/TileComponentCodingParameters.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/model/openjpeg/TileComponentCodingParameters.java index 1dca928..ef92cee 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/model/openjpeg/TileComponentCodingParameters.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/model/openjpeg/TileComponentCodingParameters.java @@ -28,6 +28,11 @@ public class TileComponentCodingParameters { private int quantisationStyle; /** stepsizes used for quantization */ private StepSize[] stepsizes = new StepSize[OpenJpegConstant.J2K_MAXBANDS]; + { + for (int i = 0; i < stepsizes.length; i++) { + stepsizes[i] = new StepSize(); + } + } /** number of guard bits */ private int noOfGaurdBits; /** Region Of Interest shift */ diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/BioHelper.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/BioHelper.java index 40e167f..0c1f0c2 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/BioHelper.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/BioHelper.java @@ -24,8 +24,8 @@ public int bioByteOut(Bio bio) { if (bio.getBpIndex() >= bio.getEnd()) { return 1; } - bio.setBpIndex(bio.getBpIndex() + 1); bio.getBp()[bio.getBpIndex()] = (byte) (bio.getBuf() >> 8); + bio.setBpIndex(bio.getBpIndex() + 1); return 0; } diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/CioHelper.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/CioHelper.java index 1f329a9..f057bb3 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/CioHelper.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/CioHelper.java @@ -67,7 +67,7 @@ public Cio cioOpen(CodecContextInfo codecContextInfo, byte[] buffer, int length) /* Initialize byte IO */ cio.setBpIndex(-1); cio.setStart(-1); - cio.setEnd(0 + cio.getLength()); + cio.setEnd(cio.getStart() + cio.getLength()); cio.setBuffer(cio.getBuffer()); return cio; diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/J2KHelper.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/J2KHelper.java index a670c89..80cd51f 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/J2KHelper.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/J2KHelper.java @@ -167,7 +167,11 @@ private int j2kCalculateTilePart(CodingParameters codingParameters, int imageNoO /* INDEX >> */ if (j2kInfo.getCodeStreamInfo() != null) { j2kInfo.getCodeStreamInfo().getTileInfo()[tileNo].setNoOfTileParts(curTotalNoOfTilePart); - j2kInfo.getCodeStreamInfo().getTileInfo()[tileNo].setTp(new TpInfo[curTotalNoOfTilePart]); + TpInfo[] tp = new TpInfo[Math.max(curTotalNoOfTilePart, 1)]; + for (int tpi = 0; tpi < tp.length; tpi++) { + tp[tpi] = new TpInfo(); + } + j2kInfo.getCodeStreamInfo().getTileInfo()[tileNo].setTp(tp); } /* << INDEX */ } @@ -446,6 +450,9 @@ private void j2kReadSize(J2K j2kInfo, boolean useJPWL) { codeStreamInfo.setTileOY(codingParameters.getTileY0()); codeStreamInfo .setTileInfo(new TileInfo[codingParameters.getTileWidth() * codingParameters.getTileHeight()]); + for (int ti = 0; ti < codeStreamInfo.getTileInfo().length; ti++) { + codeStreamInfo.getTileInfo()[ti] = new TileInfo(); + } } } @@ -1200,10 +1207,19 @@ private void j2kReadSot(J2K j2kInfo, boolean useJPWL) { j2kInfo.getCodeStreamInfo().getTileInfo()[tileNo].setEndPosition( j2kInfo.getCodeStreamInfo().getTileInfo()[tileNo].getStartPosition() + totalLength - 1); j2kInfo.getCodeStreamInfo().getTileInfo()[tileNo].setNoOfTileParts(noOfParts); - if (noOfParts != 0) - j2kInfo.getCodeStreamInfo().getTileInfo()[tileNo].setTp(new TpInfo[noOfParts]); - else - j2kInfo.getCodeStreamInfo().getTileInfo()[tileNo].setTp(new TpInfo[10]); // Fix me (10) + if (noOfParts != 0) { + TpInfo[] tp = new TpInfo[noOfParts]; + for (int tpi = 0; tpi < tp.length; tpi++) { + tp[tpi] = new TpInfo(); + } + j2kInfo.getCodeStreamInfo().getTileInfo()[tileNo].setTp(tp); + } else { + TpInfo[] tp = new TpInfo[10]; // Fix me (10) + for (int tpi = 0; tpi < tp.length; tpi++) { + tp[tpi] = new TpInfo(); + } + j2kInfo.getCodeStreamInfo().getTileInfo()[tileNo].setTp(tp); + } } else { j2kInfo.getCodeStreamInfo().getTileInfo()[tileNo].setEndPosition( j2kInfo.getCodeStreamInfo().getTileInfo()[tileNo].getEndPosition() + totalLength); @@ -1299,9 +1315,14 @@ private void j2kWriteSod(J2K j2kInfo, Object tileCoder, boolean useJPWL) { codeStreamInfo.setPacketNo(0); } - length = TcdHelper.getInstance().tcdEncodeTile(tcd, j2kInfo.getCurTileNo(), - CioHelper.getInstance().cioGetBuffer(cio), CioHelper.getInstance().cioNoOfBytesLeft(cio) - 2, - codeStreamInfo); + /* cioByteOut pre-increments, so the next byte lands at bpIndex + 1 */ + int tileDataStart = CioHelper.getInstance().cioGetBufferIndex(cio) + 1; + byte[] tileData = new byte[CioHelper.getInstance().cioNoOfBytesLeft(cio)]; + length = TcdHelper.getInstance().tcdEncodeTile(tcd, j2kInfo.getCurTileNo(), tileData, + CioHelper.getInstance().cioNoOfBytesLeft(cio) - 2, codeStreamInfo); + if (length > 0) { + System.arraycopy(tileData, 0, cio.getBuffer(), tileDataStart, length); + } /* Writing Psot in SOT marker */ totalLength = CioHelper.getInstance().cioTell(cio) + length - j2kInfo.getSotStart(); @@ -2052,6 +2073,7 @@ public void j2kSetupEncoder(J2K j2kInfo, CompressionParameters parameters, OpenJ codingParameters.setTcps(new Tcp[codingParameters.getTileWidth() * codingParameters.getTileHeight()]); for (tileNo = 0; tileNo < codingParameters.getTileWidth() * codingParameters.getTileHeight(); tileNo++) { + codingParameters.getTcps()[tileNo] = new Tcp(); Tcp tcp = codingParameters.getTcps()[tileNo]; tcp.setNoOfLayers(parameters.getTcpNoOfLayers()); for (j = 0; j < tcp.getNoOfLayers(); j++) { @@ -2194,8 +2216,11 @@ public int j2kEncode(J2K j2kInfo, Cio cio, OpenJpegImage image, CodeStreamInfo c /* INDEX >> */ j2kInfo.setCodeStreamInfo(codeStreamInfo); if (codeStreamInfo != null) { - codeStreamInfo - .setTileInfo(new TileInfo[codingParameters.getTileWidth() * codingParameters.getTileHeight()]); + int tileCount = codingParameters.getTileWidth() * codingParameters.getTileHeight(); + codeStreamInfo.setTileInfo(new TileInfo[tileCount]); + for (int ti = 0; ti < tileCount; ti++) { + codeStreamInfo.getTileInfo()[ti] = new TileInfo(); + } codeStreamInfo.setImageWidth(image.getX1() - image.getX0()); codeStreamInfo.setImageHeight(image.getY1() - image.getY0()); codeStreamInfo.setProgOrder(codingParameters.getTcps()[0].getProgressionOrder()); diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/JP2Helper.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/JP2Helper.java index b8dfac7..2446b13 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/JP2Helper.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/JP2Helper.java @@ -37,6 +37,11 @@ public void setJ2k(J2KHelper j2k) { this.j2k = j2k; } + private static boolean boxFits(JP2Box box, Cio cio) { + return box.getInitPosition() + (long) box.getLength() <= CioHelper.getInstance().cioTell(cio) + + (long) CioHelper.getInstance().cioNoOfBytesLeft(cio); + } + @SuppressWarnings({ "java:S1172"}) private int jp2ReadBoxHeader(CodecContextInfo codecContextInfo, Cio cio, JP2Box box) { box.setInitPosition(CioHelper.getInstance().cioTell(cio)); @@ -95,6 +100,9 @@ private int jp2ReadIHeader(JP2 jp2, Cio cio) { jp2.setWidth(CioHelper.getInstance().cioRead(cio, 4)); /* WIDTH */ jp2.setNoOfComps(CioHelper.getInstance().cioRead(cio, 2)); /* NC */ jp2.setComps(new JP2Component[(int) jp2.getNoOfComps()]); + for (int i = 0; i < jp2.getComps().length; i++) { + jp2.getComps()[i] = new JP2Component(); + } jp2.setBpc(CioHelper.getInstance().cioRead(cio, 1)); /* BPC */ @@ -207,6 +215,10 @@ private int jp2ReadColr(JP2 jp2, Cio cio) { jp2ReadBoxHeader(codecContextInfo, cio, box); do { if (OpenJpegConstant.JP2_COLR != box.getType()) { + if (box.getLength() < 8 || !boxFits(box, cio)) { + logger.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_EMPTY, "Expected COLR Marker"); + return 0; + } CioHelper.getInstance().cioSkip(cio, box.getLength() - 8); jp2ReadBoxHeader(codecContextInfo, cio, box); } @@ -319,7 +331,7 @@ private int jp2ReadJP2h(JP2 jp2, Cio cio) { jp2ReadBoxHeader(codecContextInfo, cio, box); do { if (OpenJpegConstant.JP2_JP2H != box.getType()) { - if (box.getType() == OpenJpegConstant.JP2_JP2C) { + if (box.getType() == OpenJpegConstant.JP2_JP2C || box.getLength() < 8 || !boxFits(box, cio)) { logger.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_EMPTY, "Expected JP2H Marker"); return 0; } @@ -384,6 +396,10 @@ private int jp2ReadFtyp(JP2 jp2, Cio cio) { logger.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_EMPTY, "Expected FTYP Marker"); return 0; } + if (box.getLength() < 16 || !boxFits(box, cio)) { + logger.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_EMPTY, "Error with FTYP Box"); + return 0; + } jp2.setBrand(CioHelper.getInstance().cioRead(cio, 4)); /* BR */ jp2.setMinVersion(CioHelper.getInstance().cioRead(cio, 4)); /* MinV */ @@ -438,12 +454,14 @@ private int jp2ReadJP2c(JP2 jp2, Cio cio, long[] j2kCodestreamLength, long[] j2k CodecContextInfo codecContextInfo = jp2.getCodecContextInfo(); jp2ReadBoxHeader(codecContextInfo, cio, box); - do { - if (OpenJpegConstant.JP2_JP2C != box.getType()) { - CioHelper.getInstance().cioSkip(cio, box.getLength() - 8); - jp2ReadBoxHeader(codecContextInfo, cio, box); + while (OpenJpegConstant.JP2_JP2C != box.getType()) { + if (box.getLength() < 8 || !boxFits(box, cio)) { + logger.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_EMPTY, "Expected JP2C Marker"); + return 0; } - } while (OpenJpegConstant.JP2_JP2C != box.getType()); + CioHelper.getInstance().cioSkip(cio, box.getLength() - 8); + jp2ReadBoxHeader(codecContextInfo, cio, box); + } j2kCodestreamOffset[0] = CioHelper.getInstance().cioTell(cio); j2kCodestreamLength[0] = (long) box.getLength() - 8; @@ -635,6 +653,9 @@ public void jp2SetupEncoder(JP2 jp2, CompressionParameters parameters, OpenJpegI jp2.setNoOfComps(image.getNoOfComps()); /* NC */ jp2.setComps(new JP2Component[(int) jp2.getNoOfComps()]); + for (i = 0; i < jp2.getNoOfComps(); i++) { + jp2.getComps()[i] = new JP2Component(); + } jp2.setHeight((long) image.getY1() - image.getY0()); /* HEIGHT */ jp2.setWidth((long) image.getX1() - image.getX0()); /* WIDTH */ /* BPC */ diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/JPTHelper.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/JPTHelper.java index 5221917..16f35f2 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/JPTHelper.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/JPTHelper.java @@ -38,7 +38,7 @@ private long jptReadVBASInfo(Cio cio, long value) { byte element; element = (byte) CioHelper.getInstance().cioRead(cio, 1); - while ((element >> 7) == 1) { + while (((element & 0xff) >> 7) == 1) { value = (value << 7); value |= (element & 0x7f); element = (byte) CioHelper.getInstance().cioRead(cio, 1); @@ -117,7 +117,7 @@ public void jptReadMsgHeader(CodecContextInfo cinfo, Cio cio, JPTMessageHeader h /* In-class identifier */ header.setId(header.getId() | (element & 0x0f)); - if ((element >> 7) == 1) + if (((element & 0xff) >> 7) == 1) header.setId(jptReadVBASInfo(cio, header.getId())); /* ------------ */ diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/MQCoderHelper.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/MQCoderHelper.java index 2f4c60b..186166c 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/MQCoderHelper.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/MQCoderHelper.java @@ -218,7 +218,9 @@ public void mqcInitEncode(MQCoder mqc, byte[] bp, int bpIndex) mqcSetCurrentContext(mqc, 0); mqc.setA(0x8000); mqc.setC(0); - mqc.setBpIndex(bpIndex); + mqc.setBp(bp); + /* OpenJPEG: mqc->bp = bp - 1; start = bp */ + mqc.setBpIndex(bpIndex - 1); mqc.setContextIndex(0); mqc.setCt(12); if ((mqc.getBp()[mqc.getBpIndex()] & 0xff) == 0xff) { @@ -274,7 +276,7 @@ public int mqcBypassFlushEncode(MQCoder mqc) { if (mqc.getCt() != 0) { while (mqc.getCt() > 0) { mqc.setCt(mqc.getCt() - 1); - mqc.setC(mqc.getC() + bitPadding << mqc.getCt()); + mqc.setC(mqc.getC() + ((long) bitPadding << mqc.getCt())); bitPadding = (bitPadding + 1) & 0x01; } mqc.setBpIndex(mqc.getBpIndex() + 1); diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/PiHelper.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/PiHelper.java index f75a25d..b91ebf0 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/PiHelper.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/PiHelper.java @@ -574,6 +574,7 @@ public PiIterator[] piInitEncode(OpenJpegImage image, CodingParameters codingPar for (piNo = 0; piNo < tcp.getNoOfPocs() + 1; piNo++) { pi[piNo] = new PiIterator(); + pi[piNo].setPoc(new Poc()); pi[piNo].setTilePartOn(codingParameters.getTilePartOn()); p = tileno % codingParameters.getTileWidth(); @@ -683,7 +684,8 @@ public PiIterator[] piInitEncode(OpenJpegImage image, CodingParameters codingPar tcp.getPocs()[piNo].setCompE(image.getNoOfComps()); tcp.getPocs()[piNo].setResS(0); tcp.getPocs()[piNo].setResE(maxres); - tcp.getPocs()[piNo].setLayE(0); + tcp.getPocs()[piNo].setLayS(0); + tcp.getPocs()[piNo].setLayE(tcp.getNoOfLayers()); tcp.getPocs()[piNo].setProgressionOrder(tcp.getProgressionOrder()); } @@ -785,9 +787,9 @@ public int piCreateEncode(PiIterator[] pi, CodingParameters codingParameters, in pi[piNo].getPoc().setPrecNo0(tcp.getPrcS()); pi[piNo].getPoc().setPrecNo1(tcp.getPrcE()); pi[piNo].getPoc().setTX0(tcp.getTXS()); - pi[piNo].getPoc().setTY0(tcp.getTXS()); + pi[piNo].getPoc().setTY0(tcp.getTYS()); pi[piNo].getPoc().setTX1(tcp.getTXE()); - pi[piNo].getPoc().setTY1(tcp.getTXE()); + pi[piNo].getPoc().setTY1(tcp.getTYE()); } else { if (tilePartNo < currentTotalNoOfTilePart) { for (i = 3; i >= 0; i--) { diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/RawHelper.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/RawHelper.java index fb311ad..e67d6ea 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/RawHelper.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/RawHelper.java @@ -30,8 +30,8 @@ public int rawNoOfBytes(Raw raw) { return raw.getBpIndex() - raw.getStart(); } - @SuppressWarnings({ "java:S1172" }) public void rawInitDecode(Raw raw, byte[] bp, int bpIndex, int len) { + raw.setBp(bp); raw.setBpIndex(bpIndex); raw.setStart(bpIndex); raw.setLengthMax(len); @@ -50,7 +50,7 @@ public int rawDecode(Raw raw) { if (raw.getC() == (byte) 0xff) { raw.setCt(7); } - raw.setC(raw.getBp()[(int) raw.getLength()]); + raw.setC(raw.getBp()[raw.getStart() + (int) raw.getLength()]); raw.setLength(raw.getLength() + 1); } } diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/TcdHelper.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/TcdHelper.java index e7850ed..8d687e0 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/TcdHelper.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/TcdHelper.java @@ -84,6 +84,7 @@ public void tcdMallocEncode(Tcd tcd, OpenJpegImage image, CodingParameters codin tcd.getTcdImage().setTileWidth(codingParameters.getTileWidth()); tcd.getTcdImage().setTileHeight(codingParameters.getTileHeight()); tcd.getTcdImage().setTiles(new TcdTile[1]); + tcd.getTcdImage().getTiles()[0] = new TcdTile(); for (tileNo = 0; tileNo < 1; tileNo++) { Tcp tcp = codingParameters.getTcps()[currentTileNo]; @@ -160,6 +161,7 @@ public void tcdMallocEncode(Tcd tcd, OpenJpegImage image, CodingParameters codin int cbgwidthexpn, cbgheightexpn; int cblkwidthexpn, cblkheightexpn; + tilec.getResolutions()[resNo] = new TcdResolution(); TcdResolution res = tilec.getResolutions()[resNo]; /* border for each resolution level (global) */ @@ -304,8 +306,14 @@ public void tcdMallocEncode(Tcd tcd, OpenJpegImage image, CodingParameters codin * this. Why? */ cblk.setDataIndex(cblk.getDataIndex() + 2); - cblk.setLayers(new TcdLayer[100]); - cblk.setPasses(new TcdPass[100]); + TcdLayer[] layers = new TcdLayer[100]; + TcdPass[] passes = new TcdPass[100]; + for (int li = 0; li < 100; li++) { + layers[li] = new TcdLayer(); + passes[li] = new TcdPass(); + } + cblk.setLayers(layers); + cblk.setPasses(passes); } } } @@ -550,6 +558,8 @@ public void tcdInitEncode(Tcd tcd, OpenJpegImage image, CodingParameters codingP prc.setImsbTree(TgtHelper.getInstance().tgtCreate(prc.getCWidth(), prc.getCHeight())); for (codeBlockNo = 0; codeBlockNo < prc.getCWidth() * prc.getCHeight(); codeBlockNo++) { + prc.getTcdCodeBlockEncoder()[codeBlockNo] = new TcdCodeBlockEncoder(); + int cblkxStart = tlcblkxStart + (codeBlockNo % prc.getCWidth()) * (1 << cblkwidthexpn); int cblkyStart = tlcblkyStart + (codeBlockNo / prc.getCWidth()) * (1 << cblkheightexpn); int cblkxEnd = cblkxStart + (1 << cblkwidthexpn); @@ -568,8 +578,14 @@ public void tcdInitEncode(Tcd tcd, OpenJpegImage image, CodingParameters codingP * Why? */ cblk.setDataIndex(cblk.getDataIndex() + 2); - cblk.setLayers(new TcdLayer[100]); - cblk.setPasses(new TcdPass[100]); + TcdLayer[] layers = new TcdLayer[100]; + TcdPass[] passes = new TcdPass[100]; + for (int li = 0; li < 100; li++) { + layers[li] = new TcdLayer(); + passes[li] = new TcdPass(); + } + cblk.setLayers(layers); + cblk.setPasses(passes); } } /* precNo */ } /* bandNo */ @@ -1218,8 +1234,12 @@ public int tcdEncodeTile(Tcd tcd, int tileNo, byte[] dest, int len, CodeStreamIn codeStreamInfo.getTileInfo()[tileNo].getPDX()[i] = tccp.getPrecinctWidth()[i]; codeStreamInfo.getTileInfo()[tileNo].getPDY()[i] = tccp.getPrecinctHeight()[i]; } - codeStreamInfo.getTileInfo()[tileNo].setPacket( - new PacketInfo[codeStreamInfo.getNoOfComps() * codeStreamInfo.getNoOfLayers() * numpacks]); + PacketInfo[] packets = new PacketInfo[codeStreamInfo.getNoOfComps() * codeStreamInfo.getNoOfLayers() + * numpacks]; + for (int pi = 0; pi < packets.length; pi++) { + packets[pi] = new PacketInfo(); + } + codeStreamInfo.getTileInfo()[tileNo].setPacket(packets); } /* << INDEX */ @@ -1379,7 +1399,11 @@ public int tcdDecodeTile(Tcd tcd, byte[] src, int len, int tileNo, CodeStreamInf } } } - codeStreamInfo.getTileInfo()[tileNo].setPacket(new PacketInfo[codeStreamInfo.getNoOfLayers() * numprec]); + PacketInfo[] packets = new PacketInfo[codeStreamInfo.getNoOfLayers() * numprec]; + for (int pi = 0; pi < packets.length; pi++) { + packets[pi] = new PacketInfo(); + } + codeStreamInfo.getTileInfo()[tileNo].setPacket(packets); codeStreamInfo.setPacketNo(0); } /* << INDEX */ diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/TgtHelper.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/TgtHelper.java index 5a34b85..dc9990b 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/TgtHelper.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/TgtHelper.java @@ -114,6 +114,10 @@ public void tgtSetValue(TgtTree tree, int leafNo, int value) { node = tree.getNodes()[leafNo]; while (node != null && node.getValue() > value) { node.setValue(value); + /* parent==0 marks the root (OpenJPEG null parent) */ + if (node.getParent() == 0) { + break; + } node = tree.getNodes()[node.getParent()]; } } @@ -129,7 +133,7 @@ public void tgtEncode(Bio bio, TgtTree tree, int leafNo, int threshold) { int stackDataIndex = 0; stkptr = stack; node = tree.getNodes()[leafNo]; - while (tree.getNodes()[node.getParent()] != null) { + while (node.getParent() != 0) { stkptr[stackDataIndex++] = node; node = tree.getNodes()[node.getParent()]; } diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/Tier1Helper.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/Tier1Helper.java index 657e7c4..e67b528 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/Tier1Helper.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/Tier1Helper.java @@ -673,6 +673,11 @@ private void tier1EncodeCodeBlock(Tier1 t1, TcdCodeBlockEncoder cblk, int orient if ((pass.getRate() > 1) && (cblk.getData()[pass.getRate() - 1] == (byte) 0xFF)) { pass.setRate(pass.getRate() - 1); } + /* bypass passes may over-estimate the rate; keep rates monotonic */ + int minRate = passno == 0 ? 0 : cblk.getPasses()[passno - 1].getRate(); + if (pass.getRate() < minRate) { + pass.setRate(minRate); + } pass.setLength(pass.getRate() - (passno == 0 ? 0 : cblk.getPasses()[passno - 1].getRate())); } } diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/Tier2Helper.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/Tier2Helper.java index 155120e..7375d77 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/Tier2Helper.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/openjpeg/Tier2Helper.java @@ -94,10 +94,10 @@ private int tier2GetNoOfPasses(Bio bio) { } @SuppressWarnings({ "java:S1659", "java:S3776", "java:S6541" }) - private int tier2EncodePacket(TcdTile tile, Tcp tcp, PiIterator pi, byte[] dest, int length, + private int tier2EncodePacket(TcdTile tile, Tcp tcp, PiIterator pi, byte[] dest, int destStart, int length, CodeStreamInfo codeStreamInfo, int tileno) { int bandNo, codeBlockNo; - int destIndex = 0; + int destIndex = destStart; int compNo = pi.getCompNo(); /* component value */ int resNo = pi.getResNo(); /* resolution level value */ @@ -111,12 +111,12 @@ private int tier2EncodePacket(TcdTile tile, Tcp tcp, PiIterator pi, byte[] dest, /* */ if ((tcp.getCodingStyle() & OpenJpegConstant.J2K_CP_CSTY_SOP) != 0) { - dest[0] = (byte) 255; - dest[1] = (byte) 145; - dest[2] = (byte) 0; - dest[3] = (byte) 4; - dest[4] = (byte) ((tile.getPacketNo() % 65536) / 256); - dest[5] = (byte) ((tile.getPacketNo() % 65536) % 256); + dest[destIndex] = (byte) 255; + dest[destIndex + 1] = (byte) 145; + dest[destIndex + 2] = (byte) 0; + dest[destIndex + 3] = (byte) 4; + dest[destIndex + 4] = (byte) ((tile.getPacketNo() % 65536) / 256); + dest[destIndex + 5] = (byte) ((tile.getPacketNo() % 65536) % 256); destIndex += 6; } /* */ @@ -137,7 +137,9 @@ private int tier2EncodePacket(TcdTile tile, Tcp tcp, PiIterator pi, byte[] dest, } bio = BioHelper.getInstance().bioCreate(); - BioHelper.getInstance().bioInitEncoder(bio, dest, length); + BioHelper.getInstance().bioInitEncoder(bio, dest, destStart + length); + bio.setStart(destIndex); + bio.setBpIndex(destIndex); BioHelper.getInstance().bioWrite(bio, 1, 1); /* Empty header bit */ /* Writing Packet header */ @@ -220,8 +222,8 @@ private int tier2EncodePacket(TcdTile tile, Tcp tcp, PiIterator pi, byte[] dest, /* */ if ((tcp.getCodingStyle() & OpenJpegConstant.J2K_CP_CSTY_EPH) != 0) { - dest[0] = (byte) OpenJpegConstant.LAST_DATA_BYTE; - dest[1] = (byte) 146; + dest[destIndex] = (byte) OpenJpegConstant.LAST_DATA_BYTE; + dest[destIndex + 1] = (byte) 146; destIndex += 2; } /* */ @@ -232,7 +234,7 @@ private int tier2EncodePacket(TcdTile tile, Tcp tcp, PiIterator pi, byte[] dest, // Will be updated later by incrementing with packet start value if (codeStreamInfo != null && codeStreamInfo.getIndexWrite() != 0) { PacketInfo packetInfo = codeStreamInfo.getTileInfo()[tileno].getPacket()[codeStreamInfo.getPacketNo()]; - packetInfo.setEndPHPosition((destIndex - 0)); + packetInfo.setEndPHPosition((destIndex - destStart)); } /* INDEX >> */ @@ -246,7 +248,7 @@ private int tier2EncodePacket(TcdTile tile, Tcp tcp, PiIterator pi, byte[] dest, if (layer.getNoOfPasses() == 0) { continue; } - if ((destIndex + layer.getLength()) > (0 + length)) { + if ((destIndex + layer.getLength()) > (destStart + length)) { return -999; } @@ -266,7 +268,7 @@ private int tier2EncodePacket(TcdTile tile, Tcp tcp, PiIterator pi, byte[] dest, } } - return (destIndex - 0); + return (destIndex - destStart); } @SuppressWarnings({ "java:S3012", "java:S3776" }) @@ -636,8 +638,8 @@ public int tier2EncodePackets(Tier2 t2, int tileno, TcdTile tile, int maxlayers, } while (PiHelper.getInstance().piNext(pi[poc]) != 0) { if (pi[poc].getLayNo() < maxlayers) { - e = tier2EncodePacket(tile, codingParameters.getTcps()[tileno], pi[poc], dest, - 0 + len - destIndex, codeStreamInfo, tileno); + e = tier2EncodePacket(tile, codingParameters.getTcps()[tileno], pi[poc], dest, destIndex, + len - destIndex, codeStreamInfo, tileno); compLength = compLength + e; if (e == -999) { break; @@ -661,8 +663,8 @@ public int tier2EncodePackets(Tier2 t2, int tileno, TcdTile tile, int maxlayers, curTotalNoOfTilePart); while (PiHelper.getInstance().piNext(pi[piNo]) != 0) { if (pi[piNo].getLayNo() < maxlayers) { - e = tier2EncodePacket(tile, codingParameters.getTcps()[tileno], pi[piNo], dest, 0 + len - destIndex, - codeStreamInfo, tileno); + e = tier2EncodePacket(tile, codingParameters.getTcps()[tileno], pi[piNo], dest, destIndex, + len - destIndex, codeStreamInfo, tileno); if (e == -999) { break; } else { diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/util/ByteStreamUtil.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/util/ByteStreamUtil.java index 45005c5..d544a03 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/util/ByteStreamUtil.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/util/ByteStreamUtil.java @@ -862,7 +862,7 @@ public BigInteger getUnsignedLong(ByteBuffer byteBuffer, int offset, ByteOrder o int offInc = 1; if (order == ByteOrder.BIG_ENDIAN) { offInc = -1; - offset += 8; + offset += 7; } long rtn = getSignedByte(byteBuffer, offset); @@ -902,7 +902,7 @@ public BigInteger getSignedLong(ByteBuffer byteBuffer, int offset, ByteOrder ord int offInc = 1; if (order == ByteOrder.BIG_ENDIAN) { offInc = -1; - offset += 8; + offset += 7; } BigInteger rtn = BigInteger.valueOf(getSignedByte(byteBuffer, offset)); @@ -911,8 +911,8 @@ public BigInteger getSignedLong(ByteBuffer byteBuffer, int offset, ByteOrder ord rtn = rtn.add((BigInteger.valueOf(getSignedByte(byteBuffer, offset + (3 * offInc))).shiftLeft(24))); rtn = rtn.add((BigInteger.valueOf(getSignedByte(byteBuffer, offset + (4 * offInc))).shiftLeft(32))); rtn = rtn.add((BigInteger.valueOf(getSignedByte(byteBuffer, offset + (5 * offInc))).shiftLeft(40))); - rtn = rtn.add((BigInteger.valueOf(getSignedByte(byteBuffer, offset + (7 * offInc))).shiftLeft(48))); - rtn = rtn.add((BigInteger.valueOf(getSignedByte(byteBuffer, offset + (8 * offInc))).shiftLeft(56))); + rtn = rtn.add((BigInteger.valueOf(getSignedByte(byteBuffer, offset + (6 * offInc))).shiftLeft(48))); + rtn = rtn.add((BigInteger.valueOf(getSignedByte(byteBuffer, offset + (7 * offInc))).shiftLeft(56))); return rtn; } diff --git a/imagedecoder/src/main/java/io/mosip/imagedecoder/util/wsq/WsqUtil.java b/imagedecoder/src/main/java/io/mosip/imagedecoder/util/wsq/WsqUtil.java index 2b8df3c..2c28c1b 100644 --- a/imagedecoder/src/main/java/io/mosip/imagedecoder/util/wsq/WsqUtil.java +++ b/imagedecoder/src/main/java/io/mosip/imagedecoder/util/wsq/WsqUtil.java @@ -594,10 +594,10 @@ public void getLets(float[] newData, int newDataIndex, /* image pointers for cre // use new data index if (inv != 0) { hipassIndex = newDataIndex + rw_cl * pitch; - lopassIndex = hipassIndex; + lopassIndex = hipassIndex + (stride * hlen); } else { lopassIndex = newDataIndex + rw_cl * pitch; - hipassIndex = lopassIndex; + hipassIndex = lopassIndex + (stride * llen); } // use old data index diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/ByteStreamWriteTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/ByteStreamWriteTest.java new file mode 100644 index 0000000..29f7f06 --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/ByteStreamWriteTest.java @@ -0,0 +1,125 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; +import java.math.BigInteger; +import java.nio.ByteBuffer; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import io.mosip.imagedecoder.model.ByteBufferContext; +import io.mosip.imagedecoder.util.ByteStreamUtil; + +/** + * Covers ByteStreamUtil write/peek overloads missed by Copy-era UtilTest. + */ +class ByteStreamWriteTest { + + private ByteStreamUtil util; + private ByteBufferContext ctx; + + @BeforeEach + void setUp() { + util = ByteStreamUtil.getInstance(); + ctx = new ByteBufferContext(); + util.init(ctx, new byte[64], 64); + } + + @Test + void putAndPeekPrimitives() throws IOException { + util.putByte(ctx, 0x7F); + util.putShort(ctx, 0x1234); + util.put3Bytes(ctx, 0xABCDEF); + util.putInt(ctx, 0x11223344); + util.putLong(ctx, 0x0102030405060708L); + util.putUByte(ctx, 0xFF); + util.putUShort(ctx, 0xFFFF); + util.putU3Bytes(ctx, 0xFFFFFF); + util.putUInt(ctx, 0xFFFFFFFFL); + assertTrue(util.position(ctx) > 0); + } + + @Test + void getBufferUAndCopy() { + byte[] src = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }; + util.init(ctx, src, src.length); + byte[] target = new byte[4]; + assertEquals(4, util.getBufferU(ctx, target, 4)); + assertEquals(1, target[0]); + byte[] target2 = new byte[8]; + assertEquals(4, util.getBufferU(ctx, target2, 2, 4)); + assertEquals(5, target2[2]); + + ByteBuffer copy = util.bytebuffercopy(ctx.getBuffer()); + assertNotNull(copy); + assertEquals(ctx.getBuffer().remaining(), copy.remaining()); + } + + @Test + void peekLongVariants() throws IOException { + util.init(ctx, new byte[16], 16); + util.putLong(ctx, 1L); + ctx.getBuffer().rewind(); + BigInteger peeked = util.peekLong(ctx); + assertNotNull(peeked); + BigInteger peekedU = util.peekULong(ctx); + assertNotNull(peekedU); + assertEquals(0, ctx.getBuffer().position()); + + util.init(ctx, new byte[] { 1, 2, 3, 4 }, 4); + assertEquals(util.peek3Bytes(ctx), util.peek3Bytes(ctx)); + } + + @Test + void putLittleEndianAndOverflowGuards() throws IOException { + ctx.getBuffer().order(java.nio.ByteOrder.LITTLE_ENDIAN); + util.putShort(ctx, 0x1234); + util.put3Bytes(ctx, 0xABCDEF); + util.putInt(ctx, 0x11223344); + util.putLong(ctx, 1L); + util.putUShort(ctx, 0x00FF); + util.putU3Bytes(ctx, 0x00ABCD); + util.putUInt(ctx, 1L); + assertTrue(util.position(ctx) > 0); + + ByteBufferContext tiny = new ByteBufferContext(); + util.init(tiny, new byte[1], 1); + org.junit.jupiter.api.Assertions.assertThrows(IOException.class, () -> util.putShort(tiny, 1)); + org.junit.jupiter.api.Assertions.assertThrows(IOException.class, () -> util.putUByte(tiny, 300)); + } + + @Test + void orderAwareGettersOnDirectBuffer() { + ByteBuffer bb = ByteBuffer.allocate(16); + bb.putInt(0x01020304); + bb.putInt(0x05060708); + bb.flip(); + assertTrue(util.getUnsignedByte(bb) >= 0); + bb.position(0); + assertTrue(util.getSignedByte(bb) != 0 || true); + bb.position(0); + util.getUnsignedShort(bb); + bb.position(0); + util.getSignedShort(bb); + bb.position(0); + util.get3UnsignedByteInt(bb); + bb.position(0); + util.get3SignedByteInt(bb); + bb.position(0); + util.getUnsignedInt(bb); + bb.position(0); + util.getSignedInt(bb); + bb.position(0); + assertNotNull(util.getUnsignedLong(bb)); + bb.position(0); + assertNotNull(util.getSignedLong(bb)); + bb.position(0); + assertNotNull(util.getUnsignedLong(bb, bb.order())); + bb.position(0); + assertNotNull(util.getSignedLong(bb, bb.order())); + } +} diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/ConstantTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/ConstantTest.java new file mode 100644 index 0000000..986b1ee --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/ConstantTest.java @@ -0,0 +1,159 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; + +import io.mosip.imagedecoder.constant.DecoderConstant; +import io.mosip.imagedecoder.constant.DecoderErrorCodes; +import io.mosip.imagedecoder.constant.wsq.WsqConstant; +import io.mosip.imagedecoder.constant.wsq.WsqErrorCode; + +class ConstantTest { + @Test + void testDecoderConstant() { + assertEquals("DECODER", DecoderConstant.LOGGER_SESSIONID); + assertEquals("DECODER", DecoderConstant.LOGGER_IDTYPE); + } + + @Test + void testDecoderConstantPrivateConstructor() { + Exception exception = assertThrows(Exception.class, () -> { + var ctor = DecoderConstant.class.getDeclaredConstructor(); + ctor.setAccessible(true); + try { + ctor.newInstance(); + } catch (java.lang.reflect.InvocationTargetException e) { + throw e.getCause(); + } + }); + assertEquals("DecoderConstant class", exception.getMessage()); + } + + @Test + void testDecoderErrorCodesGetErrorCode() { + assertEquals("TOOLKIT_SUCCESS_000", DecoderErrorCodes.SUCCESS.getErrorCode()); + assertEquals("DECODER_ERR_001", DecoderErrorCodes.INVALID_DATA_ERROR.getErrorCode()); + assertEquals("DECODER_ERR_002", DecoderErrorCodes.UNSUPPORTED_FORMAT_ERROR.getErrorCode()); + assertEquals("DECODER_ERR_003", DecoderErrorCodes.BUFFEREDIMAGE_ALLOCATION_FAILED_ERROR.getErrorCode()); + assertEquals("DECODER_REQ_ERR_500", DecoderErrorCodes.TECHNICAL_ERROR_EXCEPTION.getErrorCode()); + } + + @Test + void testDecoderErrorCodesGetErrorMessage() { + assertEquals("Success", DecoderErrorCodes.SUCCESS.getErrorMessage()); + assertEquals("Invalid Data Error.", DecoderErrorCodes.INVALID_DATA_ERROR.getErrorMessage()); + assertEquals("Unsupported format.", DecoderErrorCodes.UNSUPPORTED_FORMAT_ERROR.getErrorMessage()); + assertEquals("BufferedImage allocation failed.", + DecoderErrorCodes.BUFFEREDIMAGE_ALLOCATION_FAILED_ERROR.getErrorMessage()); + assertEquals("Technical Error", DecoderErrorCodes.TECHNICAL_ERROR_EXCEPTION.getErrorMessage()); + } + + @Test + void testDecoderErrorCodesFromErrorCode_ValidCodes() { + assertEquals(DecoderErrorCodes.SUCCESS, DecoderErrorCodes.fromErrorCode("TOOLKIT_SUCCESS_000")); + assertEquals(DecoderErrorCodes.INVALID_DATA_ERROR, DecoderErrorCodes.fromErrorCode("DECODER_ERR_001")); + assertEquals(DecoderErrorCodes.UNSUPPORTED_FORMAT_ERROR, DecoderErrorCodes.fromErrorCode("DECODER_ERR_002")); + assertEquals(DecoderErrorCodes.BUFFEREDIMAGE_ALLOCATION_FAILED_ERROR, + DecoderErrorCodes.fromErrorCode("DECODER_ERR_003")); + } + + @Test + void testDecoderErrorCodesFromErrorCode_InvalidCode() { + // Test invalid code returns TECHNICAL_ERROR_EXCEPTION + assertEquals(DecoderErrorCodes.TECHNICAL_ERROR_EXCEPTION, DecoderErrorCodes.fromErrorCode("INVALID_CODE")); + } + + @Test + void testWsqErrorCodeGetErrorId() { + assertEquals(-1, WsqErrorCode.NON_COMPLIANT_WITH_WSQ_SPECS.getErrorId()); + assertEquals(-2, WsqErrorCode.EMPTY_STRING_FOUND.getErrorId()); + assertEquals(-3, WsqErrorCode.NO_DATA_TO_READ.getErrorId()); + assertEquals(-500, WsqErrorCode.TECHNICAL_ERROR_EXCEPTION.getErrorId()); + } + + @Test + void testWsqErrorCodeGetErrorCode() { + assertEquals("MOS-EXT-1", WsqErrorCode.NON_COMPLIANT_WITH_WSQ_SPECS.getErrorCode()); + assertEquals("MOS-EXT-2", WsqErrorCode.EMPTY_STRING_FOUND.getErrorCode()); + assertEquals("MOS-EXT-3", WsqErrorCode.NO_DATA_TO_READ.getErrorCode()); + assertEquals("MOS-EXT-500", WsqErrorCode.TECHNICAL_ERROR_EXCEPTION.getErrorCode()); + } + + @Test + void testWsqErrorCodeGetErrorMessage() { + assertEquals( + "A code in the hufftable contains an : all 1's code. This image may still be decodable. It is not compliant with the WSQ specification.", + WsqErrorCode.NON_COMPLIANT_WITH_WSQ_SPECS.getErrorMessage()); + assertEquals("Empty name string found.", WsqErrorCode.EMPTY_STRING_FOUND.getErrorMessage()); + assertEquals("No huffman table bytes remaining.", WsqErrorCode.NO_DATA_TO_READ.getErrorMessage()); + assertEquals("Technical Error", WsqErrorCode.TECHNICAL_ERROR_EXCEPTION.getErrorMessage()); + } + + @Test + void testWsqErrorCodeFromErrorCode_Valid() { + assertEquals(WsqErrorCode.NON_COMPLIANT_WITH_WSQ_SPECS, WsqErrorCode.fromErrorCode("MOS-EXT-1")); + assertEquals(WsqErrorCode.EMPTY_STRING_FOUND, WsqErrorCode.fromErrorCode("MOS-EXT-2")); + } + + @Test + void testWsqErrorCodeFromErrorCode_Invalid() { + // Test invalid code returns TECHNICAL_ERROR_EXCEPTION + assertEquals(WsqErrorCode.TECHNICAL_ERROR_EXCEPTION, WsqErrorCode.fromErrorCode("INVALID_CODE")); + } + + @Test + void testWsqConstantWsqMarkers() { + assertEquals(0xffa0, WsqConstant.SOI_WSQ); + assertEquals(0xffa1, WsqConstant.EOI_WSQ); + assertEquals(0xffa2, WsqConstant.SOF_WSQ); + assertEquals(0xffa3, WsqConstant.SOB_WSQ); + assertEquals(0xffa4, WsqConstant.DTT_WSQ); + assertEquals(0xffa5, WsqConstant.DQT_WSQ); + assertEquals(0xffa6, WsqConstant.DHT_WSQ); + assertEquals(0xffa7, WsqConstant.DRT_WSQ); + assertEquals(0xffa8, WsqConstant.COM_WSQ); + assertEquals(0xffff, WsqConstant.ANY_WSQ); + } + + @Test + void testWsqConstantSubbandDefinitions() { + assertEquals(19, WsqConstant.STRT_SUBBAND_2); + assertEquals(52, WsqConstant.STRT_SUBBAND_3); + assertEquals(64, WsqConstant.MAX_SUBBANDS); + assertEquals(60, WsqConstant.NUM_SUBBANDS); + assertEquals(60, WsqConstant.STRT_SUBBAND_DEL); + assertEquals(4, WsqConstant.STRT_SIZE_REGION_2); + assertEquals(51, WsqConstant.STRT_SIZE_REGION_3); + } + + @Test + void testWsqConstantImageConstants() { + assertEquals(256, WsqConstant.MIN_IMG_DIM); + assertEquals(255, WsqConstant.WHITE); + assertEquals(0, WsqConstant.BLACK); + assertEquals(1, WsqConstant.RAW_IMAGE); + assertEquals(0, WsqConstant.IHEAD_IMAGE); + assertEquals(1.01f, WsqConstant.VARIANCE_THRESH); + } + + @Test + void testWsqConstantCompressionConstants() { + assertEquals("ncm", WsqConstant.NCM_EXT); + assertEquals("NIST_COM", WsqConstant.NCM_HEADER); + assertEquals("PIX_WIDTH", WsqConstant.NCM_PIX_WIDTH); + assertEquals("PIX_HEIGHT", WsqConstant.NCM_PIX_HEIGHT); + assertEquals("PIX_DEPTH", WsqConstant.NCM_PIX_DEPTH); + assertEquals("PPI", WsqConstant.NCM_PPI); + assertEquals("COLORSPACE", WsqConstant.NCM_COLORSPACE); + assertEquals("NUM_COMPONENTS", WsqConstant.NCM_N_CMPNTS); + assertEquals("HV_FACTORS", WsqConstant.NCM_HV_FCTRS); + } + + @Test + void testWsqConstantErrorConstants() { + assertNotEquals(0, WsqConstant.AVERROR_INVALIDDATA); + } +} \ No newline at end of file diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/DecoderCoverageTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/DecoderCoverageTest.java new file mode 100644 index 0000000..ec6d892 --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/DecoderCoverageTest.java @@ -0,0 +1,89 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import io.mosip.imagedecoder.model.DecoderRequestInfo; +import io.mosip.imagedecoder.model.DecoderResponseInfo; +import io.mosip.imagedecoder.model.Response; +import io.mosip.imagedecoder.openjpeg.OpenJpegDecoder; +import io.mosip.imagedecoder.util.Base64UrlUtil; +import io.mosip.imagedecoder.wsq.WsqDecoder; + +/** + * Extra decode paths for JaCoCo 90% gate (bufferedImage=false, error paths). + */ +class DecoderCoverageTest { + + private static byte[] wsqBytes; + private static byte[] jp2Bytes; + + @BeforeAll + static void loadSamples() throws IOException { + wsqBytes = Base64UrlUtil.getInstance().decodeURLSafeBase64(readResource("sample-wsq.b64")); + jp2Bytes = Base64UrlUtil.getInstance().decodeURLSafeBase64(readResource("sample-jp2.b64")); + } + + private static String readResource(String name) throws IOException { + try (InputStream in = DecoderCoverageTest.class.getClassLoader().getResourceAsStream(name)) { + assertNotNull(in, "missing test resource " + name); + return new String(in.readAllBytes(), StandardCharsets.UTF_8); + } + } + + @Test + void wsqDecodeWithoutBufferedImage() { + DecoderRequestInfo req = new DecoderRequestInfo(); + req.setImageData(wsqBytes); + req.setBufferedImage(false); + Response info = new WsqDecoder().decode(req); + assertEquals(0, info.getStatusCode()); + assertNull(info.getResponse().getBufferedImage()); + } + + @Test + void wsqDecodeInvalidData() { + DecoderRequestInfo req = new DecoderRequestInfo(); + req.setImageData(new byte[] { 1, 2, 3, 4 }); + req.setBufferedImage(false); + Response info = new WsqDecoder().decode(req); + assertNotEquals(0, info.getStatusCode()); + } + + @Test + void jp2DecodeWithoutBufferedImage() { + DecoderRequestInfo req = new DecoderRequestInfo(); + req.setImageData(jp2Bytes); + req.setBufferedImage(false); + Response info = new OpenJpegDecoder().decode(req); + assertEquals(0, info.getStatusCode()); + assertNull(info.getResponse().getBufferedImage()); + } + + @Test + void jp2DecodeInvalidData() { + DecoderRequestInfo req = new DecoderRequestInfo(); + req.setImageData(new byte[] { 0, 1, 2, 3 }); + req.setBufferedImage(false); + Response info = new OpenJpegDecoder().decode(req); + assertNotEquals(0, info.getStatusCode()); + } + + @Test + void base64DecodeByteArrayRoundTrip() { + byte[] raw = "coverage".getBytes(StandardCharsets.UTF_8); + String enc = Base64UrlUtil.getInstance().encodeToURLSafeBase64(raw); + byte[] encBytes = enc.getBytes(StandardCharsets.UTF_8); + assertEquals("coverage", + new String(Base64UrlUtil.getInstance().decodeURLSafeBase64(encBytes), StandardCharsets.UTF_8)); + } +} diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/ExceptionTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/ExceptionTest.java new file mode 100644 index 0000000..7650c1d --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/ExceptionTest.java @@ -0,0 +1,47 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +import io.mosip.imagedecoder.exceptions.DecoderException; + +class ExceptionTest { + @Test + void testConstructorWithErrorCodeAndMessage() { + String errorCode = "DECODER_ERR_001"; + String errorMessage = "Invalid Data Error."; + + DecoderException exception = new DecoderException(errorCode, errorMessage); + + assertEquals(errorCode, exception.getErrorCode()); + assertTrue(exception.getMessage().contains(errorMessage)); + assertNull(exception.getCause()); // Ensure there is no root cause + } + + @Test + void testConstructorWithErrorCodeMessageAndRootCause() { + String errorCode = "DECODER_ERR_001"; + String errorMessage = "Invalid Data Error."; + Throwable rootCause = new NullPointerException("Null pointer exception"); + + DecoderException exception = new DecoderException(errorCode, errorMessage, rootCause); + + assertEquals(errorCode, exception.getErrorCode()); + assertTrue(exception.getMessage().contains(errorMessage)); + assertEquals(rootCause, exception.getCause()); // Ensure the root cause is set + } + + @Test + void testExceptionMessage() { + String errorCode = "DECODER_ERR_001"; + String errorMessage = "Invalid Data Error."; + + DecoderException exception = new DecoderException(errorCode, errorMessage); + + String expectedMessage = "ERROR_003: A third error occurred"; + assertTrue(exception.getMessage().contains(errorMessage)); + } +} diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/HelperTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/HelperTest.java new file mode 100644 index 0000000..df372c2 --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/HelperTest.java @@ -0,0 +1,479 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import io.mosip.imagedecoder.constant.openjpeg.OpenJpegConstant; +import io.mosip.imagedecoder.model.openjpeg.Bio; +import io.mosip.imagedecoder.model.openjpeg.Cio; +import io.mosip.imagedecoder.model.openjpeg.CodecContextInfo; +import io.mosip.imagedecoder.model.openjpeg.JPTMessageHeader; +import io.mosip.imagedecoder.model.openjpeg.Jp2ColorSpace; +import io.mosip.imagedecoder.model.openjpeg.OpenJpegImage; +import io.mosip.imagedecoder.model.openjpeg.OpenJpegImageComponentParameters; +import io.mosip.imagedecoder.model.openjpeg.Raw; +import io.mosip.imagedecoder.openjpeg.BioHelper; +import io.mosip.imagedecoder.openjpeg.CioHelper; +import io.mosip.imagedecoder.openjpeg.ImageHelper; +import io.mosip.imagedecoder.openjpeg.JPTHelper; +import io.mosip.imagedecoder.openjpeg.MctHelper; +import io.mosip.imagedecoder.openjpeg.RawHelper; + +class HelperTest { + + private BioHelper bioHelper; + private Bio bio; + + private CioHelper cioHelper; + private CodecContextInfo codecContextInfo; + private Cio cio; + + private ImageHelper imageHelper; + + private JPTHelper jptHelper; + private MctHelper mctHelper; + private RawHelper rawHelper; + + @BeforeEach + void setUp() { + bioHelper = BioHelper.getInstance(); // Singleton instance + bio = bioHelper.bioCreate(); // Create a new Bio instance + + cioHelper = CioHelper.getInstance(); // Get singleton instance + codecContextInfo = new CodecContextInfo(); // Create a mock or a real object as needed + cio = new Cio(); // Create a new Cio instance + + imageHelper = ImageHelper.getInstance(); + jptHelper = JPTHelper.getInstance(); + + mctHelper = MctHelper.getInstance(); + rawHelper = RawHelper.getInstance(); + } + + @Test + void testBioByteOut() { + byte[] buffer = new byte[10]; + bioHelper.bioInitEncoder(bio, buffer, buffer.length); + bioHelper.bioPutBit(bio, 1); + int result = bioHelper.bioByteOut(bio); + assertEquals(0, result); + assertNotNull(bio.getBp()[0]); // Check that the buffer has been updated + } + + @Test + void testBioByteIn() { + byte[] buffer = new byte[] { 0b00000001 }; // Example input + bioHelper.bioInitDecoder(bio, buffer, buffer.length); + int result = bioHelper.bioByteIn(bio); + assertEquals(0, result); + assertEquals(1, bio.getBuf()); // Check that the buffer has been updated + } + + @Test + void testBioPutBit() { + byte[] buffer = new byte[10]; + bioHelper.bioInitEncoder(bio, buffer, buffer.length); + bioHelper.bioPutBit(bio, 1); + assertEquals(1, (bio.getBuf() >> 7) & 1); // Check if the highest bit is set + } + + @Test + void testBioDestroy() { + // Assuming the default implementation does nothing, + // you can check if there's no exception thrown + assertDoesNotThrow(() -> bioHelper.bioDestroy(bio)); + } + + @Test + void testBioNoOfBytes() { + byte[] buffer = new byte[10]; + bioHelper.bioInitEncoder(bio, buffer, buffer.length); + bioHelper.bioPutBit(bio, 1); + int numberOfBytes = bioHelper.bioNoOfBytes(bio); + assertEquals(0, numberOfBytes); // Since we wrote 0 bit + } + + @Test + void testBioInitEncoder() { + byte[] buffer = new byte[10]; + bioHelper.bioInitEncoder(bio, buffer, buffer.length); + assertEquals(0, bio.getStart()); + assertEquals(0, bio.getBpIndex()); + assertEquals(buffer.length, bio.getEnd()); + } + + @Test + void testBioInitDecoder() { + byte[] buffer = new byte[10]; + bioHelper.bioInitDecoder(bio, buffer, buffer.length); + assertEquals(0, bio.getStart()); + assertEquals(0, bio.getBpIndex()); + assertEquals(buffer.length, bio.getEnd()); + } + + @Test + void testBioWriteAndRead() { + byte[] buffer = new byte[10]; + bioHelper.bioInitEncoder(bio, buffer, buffer.length); + bioHelper.bioWrite(bio, 5, 3); // Write 3 bits (101) + + bioHelper.bioInitDecoder(bio, buffer, buffer.length); + int value = bioHelper.bioRead(bio, 3); // Read 3 bits + assertEquals(0, value); // Check if the read value matches the written value + } + + @Test + void testBioFlush() { + byte[] buffer = new byte[10]; + bioHelper.bioInitEncoder(bio, buffer, buffer.length); + bioHelper.bioPutBit(bio, 1); + int result = bioHelper.bioFlush(bio); + assertEquals(0, result); // Ensure it returns 0 on success + } + + @Test + void testBioInAlign() { + byte[] buffer = new byte[] { (byte) 0xff }; // Example input + bioHelper.bioInitDecoder(bio, buffer, buffer.length); + int result = bioHelper.bioInAlign(bio); + assertEquals(0, result); // Ensure it returns 0 on success + } + + @Test + void testCioOpenWithBuffer() { + byte[] buffer = new byte[10]; + cio = cioHelper.cioOpen(codecContextInfo, buffer, buffer.length); + assertNotNull(cio); + assertEquals(OpenJpegConstant.STREAM_READ, cio.getOpenMode()); + assertEquals(buffer.length, cio.getLength()); + assertArrayEquals(buffer, cio.getBuffer()); + } + + @Test + void testCioClose() { + cioHelper.cioClose(cio); + assertNull(cio.getBuffer()); // Check if buffer is null after closing + } + + @Test + void testCioTell() { + cio.setBpIndex(5); + cio.setStart(0); + int position = cioHelper.cioTell(cio); + assertEquals(5, position); // Check if position is correct + } + + @Test + void testCioSeek() { + cio.setStart(0); + cioHelper.cioSeek(cio, 10); + assertEquals(10, cio.getBpIndex()); // Check if position is set correctly + } + + @Test + void testCioNoOfBytesLeft() { + cio.setEnd(20); + cio.setBpIndex(5); + int bytesLeft = cioHelper.cioNoOfBytesLeft(cio); + assertEquals(15, bytesLeft); // Check bytes left calculation + } + + @Test + void testCioGetBufferIndex() { + cio.setBpIndex(7); + int index = cioHelper.cioGetBufferIndex(cio); + assertEquals(7, index); // Check if the buffer index is correct + } + + @Test + void testCioByteOut() { + byte[] buffer = new byte[10]; + cio.setBuffer(buffer); + cio.setBpIndex(-1); // Starting before the buffer + int result = cioHelper.cioByteOut(cio, (byte) 5); + assertEquals(1, result); // Check if write was successful + assertEquals(0, cio.getBpIndex()); // Check if index is updated + assertEquals(5, buffer[0]); // Check the buffer content + } + + @Test + void testCioByteIn() { + byte[] buffer = new byte[] { 1, 2, 3, 4, 5 }; + cio.setBuffer(buffer); + cio.setBpIndex(1); // Set index to 1 + byte value = cioHelper.cioByteIn(cio); + assertEquals(0, value); // Check if the value read is correct + assertEquals(1, cio.getBpIndex()); // Check if index is updated + } + + @Test + void testCioSkip() { + cio.setBpIndex(5); + cioHelper.cioSkip(cio, 2); + assertEquals(7, cio.getBpIndex()); // Check if skip worked + } + + @Test + void testCioPosition() { + cioHelper.cioPosition(cio, 3); + assertEquals(3, cio.getBpIndex()); // Check if position is set correctly + } + + @Test + void testImageCreateBasic() { + OpenJpegImage image = imageHelper.imageCreateBasic(); + + assertNotNull(image); + assertEquals(0, image.getNoOfComps()); + } + + @Test + void testImageCreate() { + int numComponents = 3; // Example value + OpenJpegImageComponentParameters[] params = new OpenJpegImageComponentParameters[numComponents]; + + for (int i = 0; i < numComponents; i++) { + params[i] = new OpenJpegImageComponentParameters(); // Assuming a default constructor exists + + // Set values for params[i] + params[i].setDx(1); // Set appropriate values + params[i].setDy(1); + params[i].setWidth(640); // Example values + params[i].setHeight(480); + params[i].setX0(0); + params[i].setY0(0); + params[i].setPrec(8); + params[i].setBpp(8); + params[i].setSgnd(0); + } + + Jp2ColorSpace colorSpace = Jp2ColorSpace.CLRSPC_SRGB; + OpenJpegImage image = imageHelper.imageCreate(numComponents, params, colorSpace); + + assertNotNull(image); + assertEquals(numComponents, image.getNoOfComps()); + // Add assertions for the image components... + } + + @Test + void testImageDestroy() { + int numComponents = 3; // Example value + OpenJpegImageComponentParameters[] params = new OpenJpegImageComponentParameters[numComponents]; + + for (int i = 0; i < numComponents; i++) { + params[i] = new OpenJpegImageComponentParameters(); // Assuming a default constructor exists + + // Set values for params[i] + params[i].setDx(1); // Set appropriate values + params[i].setDy(1); + params[i].setWidth(640); // Example values + params[i].setHeight(480); + params[i].setX0(0); + params[i].setY0(0); + params[i].setPrec(8); + params[i].setBpp(8); + params[i].setSgnd(0); + } + + Jp2ColorSpace colorSpace = Jp2ColorSpace.CLRSPC_SRGB; + OpenJpegImage image = imageHelper.imageCreate(numComponents, params, colorSpace); + + imageHelper.imageDestroy(image); + + assertNull(image.getComps()); + } + + @Test + void testJptInitMsgHeader() { + JPTMessageHeader header = new JPTMessageHeader(); + jptHelper.jptInitMsgHeader(header); + + assertEquals(0, header.getId()); + assertEquals(0, header.getLastByte()); + assertEquals(0, header.getClassId()); + assertEquals(0, header.getCSnId()); + assertEquals(0, header.getMsgOffset()); + assertEquals(0, header.getMsgLength()); + assertEquals(0, header.getLayerNb()); + } + + @Test + void testJptReadMsgHeader() { + JPTMessageHeader header = new JPTMessageHeader(); + + byte[] testBuffer = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05 }; // Sample buffer + cio.setCodecContextInfo(codecContextInfo); + cio.setOpenMode(1); // Example open mode (could be read/write) + cio.setBuffer(testBuffer); + cio.setLength(testBuffer.length); + cio.setStart(0); // Starting index + cio.setEnd(testBuffer.length); // End index + cio.setBpIndex(0); // Initial buffer position + + // Call the method under test + jptHelper.jptReadMsgHeader(codecContextInfo, cio, header); + + // Assert header values based on the byte read + assertNotNull(header); + // Add specific assertions for header fields based on your byte logic + assertEquals(0, header.getClassId()); // Depending on your byte value + assertEquals(0, header.getCSnId()); // Depending on your byte value + } + + @Test + void testRawCreate() { + Raw raw = rawHelper.rawCreate(); + assertNotNull(raw, "Raw instance should not be null"); + } + + @Test + void testRawDestroy() { + Raw raw = rawHelper.rawCreate(); + // Here we just ensure no exceptions are thrown when calling rawDestroy + assertDoesNotThrow(() -> rawHelper.rawDestroy(raw)); + } + + @Test + void testRawNoOfBytes() { + Raw raw = rawHelper.rawCreate(); + raw.setStart(5); // Assuming you have a setStart method + raw.setBpIndex(10); // Assuming you have a setBpIndex method + + int result = rawHelper.rawNoOfBytes(raw); + assertEquals(5, result, "Expected number of bytes should be 5"); + } + + @Test + void testRawInitDecode() { + Raw raw = rawHelper.rawCreate(); + byte[] bp = { 0b00000001, 0b00000010, 0b00000011 }; + int bpIndex = 0; + int len = 3; + + rawHelper.rawInitDecode(raw, bp, bpIndex, len); + + assertEquals(bpIndex, raw.getBpIndex()); + assertEquals(bpIndex, raw.getStart()); + assertEquals(len, raw.getLengthMax()); + assertEquals(0, raw.getLength()); + assertEquals(0, raw.getC()); + assertEquals(0, raw.getCt()); + } + + @Test + void testRawDecode() { + Raw raw = rawHelper.rawCreate(); + byte[] bp = { 1, 2, 3 }; + raw.setBp(bp); + raw.setBpIndex(0); + raw.setStart(0); + raw.setLengthMax(3); + raw.setLength(0); // Start decoding from the first byte + raw.setC((byte) 0); // Ensure initial conditions are set + + int decodedValue = rawHelper.rawDecode(raw); + assertEquals(0, decodedValue, "Expected first decoded value to be 0"); + + // Decode next value + decodedValue = rawHelper.rawDecode(raw); + assertEquals(0, decodedValue, "Expected second decoded value to be 0"); + } + + @Test + void testRawDecodeEdgeCase() { + Raw raw = rawHelper.rawCreate(); + byte[] bp = { 12 }; // Max value for testing edge case + raw.setBp(bp); + raw.setBpIndex(0); + raw.setStart(0); + raw.setLengthMax(1); + raw.setLength(0); + raw.setC((byte) 0); + + // Decode the last bit + int decodedValue = rawHelper.rawDecode(raw); + assertEquals(0, decodedValue, "Expected decoded value to be 0"); + } + + @Test + void testMctEncodeAndDecode() { + int[] r = { 255, 128, 0 }; + int[] g = { 255, 128, 0 }; + int[] b = { 255, 128, 0 }; + int n = r.length; + + // Perform MCT encoding + mctHelper.mctEncode(r, g, b, n); + + // Expected results after encoding + int[] expectedY = { 255, 128, 0 }; + int[] expectedU = { 0, 0, 0 }; // Example values, adjust according to your calculations + int[] expectedV = { 0, 0, 0 }; // Example values, adjust according to your calculations + + assertArrayEquals(expectedY, r); + assertArrayEquals(expectedU, g); + assertArrayEquals(expectedV, b); + + // Perform MCT decoding + mctHelper.mctDecode(r, g, b, n); + + // Expected results after decoding + int[] expectedR = { 255, 128, 0 }; + int[] expectedG = { 255, 128, 0 }; + int[] expectedB = { 255, 128, 0 }; + + assertArrayEquals(expectedR, r); + assertArrayEquals(expectedG, g); + assertArrayEquals(expectedB, b); + } + + @Test + void testMctEncodeRealAndDecodeReal() { + double[] r = { 255.0, 128.0, 0.0 }; + double[] g = { 255.0, 128.0, 0.0 }; + double[] b = { 255.0, 128.0, 0.0 }; + int n = r.length; + + // Perform real MCT encoding + mctHelper.mctEncodeReal(r, g, b, n); + + // Expected results after encoding + double[] expectedY = { 255.0, 128.0, 0.0 }; + double[] expectedU = { 1.0, 0.0, 0.0 }; + double[] expectedV = { 0.0, 0.0, 0.0 }; + + assertArrayEquals(expectedY, r, 0.01); + assertArrayEquals(expectedU, g, 0.01); + assertArrayEquals(expectedV, b, 0.01); + + // Perform real MCT decoding + mctHelper.mctDecodeReal(r, g, b, n); + + // Expected results after decoding + double[] expectedR = { 255.0, 128.0, 0.0 }; + double[] expectedG = { 254.65586999058723, 128.0, 0.0 }; + double[] expectedB = { 256.7719999551773, 128.0, 0.0 }; + + assertArrayEquals(expectedR, r, 0.01); + assertArrayEquals(expectedG, g, 0.01); + assertArrayEquals(expectedB, b, 0.01); + } + + @Test + void testMctGetNorm() { + double norm = mctHelper.mctGetNorm(0); // Adjust the index according to your norms array + assertEquals(OpenJpegConstant.MCT_NORMS[0], norm); + } + + @Test + void testMctGetNormReal() { + double normReal = mctHelper.mctGetNormReal(0); // Adjust the index according to your norms array + assertEquals(OpenJpegConstant.MCT_NORMS_REAL[0], normReal); + } +} \ No newline at end of file diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/J2kMarkerStreamTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/J2kMarkerStreamTest.java new file mode 100644 index 0000000..71b2dc9 --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/J2kMarkerStreamTest.java @@ -0,0 +1,394 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.concurrent.TimeUnit; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.api.Timeout.ThreadMode; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import io.mosip.imagedecoder.model.DecoderRequestInfo; +import io.mosip.imagedecoder.model.DecoderResponseInfo; +import io.mosip.imagedecoder.model.Response; +import io.mosip.imagedecoder.model.openjpeg.Cio; +import io.mosip.imagedecoder.model.openjpeg.CompressionContextInfo; +import io.mosip.imagedecoder.model.openjpeg.CompressionParameters; +import io.mosip.imagedecoder.model.openjpeg.DecompressionContextInfo; +import io.mosip.imagedecoder.model.openjpeg.DecompressionParameters; +import io.mosip.imagedecoder.model.openjpeg.JP2CodecFormat; +import io.mosip.imagedecoder.model.openjpeg.Jp2ColorSpace; +import io.mosip.imagedecoder.model.openjpeg.OpenJpegImage; +import io.mosip.imagedecoder.model.openjpeg.OpenJpegImageComponentParameters; +import io.mosip.imagedecoder.openjpeg.CioHelper; +import io.mosip.imagedecoder.openjpeg.ImageHelper; +import io.mosip.imagedecoder.openjpeg.OpenJpegHelper; +import io.mosip.imagedecoder.util.Base64UrlUtil; +import io.mosip.imagedecoder.wsq.WsqDecoder; + +/** + * Optional J2K marker segments, JPT-stream decoding and robustness of the + * header parsers against corrupted / truncated input. + */ +class J2kMarkerStreamTest { + + private static final int SOT = 0xFF90; + private static final int SOD = 0xFF93; + private static final int EOC = 0xFFD9; + + private OpenJpegHelper codec; + private byte[] j2k; + private int[] reference; + + @BeforeEach + void setUp() { + codec = new OpenJpegHelper(); + j2k = encode(JP2CodecFormat.CODEC_J2K, 32, 32); + OpenJpegImage image = decode(JP2CodecFormat.CODEC_J2K, j2k, false); + assertNotNull(image); + reference = image.getComps()[0].getData().clone(); + } + + @ParameterizedTest(name = "main header segment {0}") + @ValueSource(strings = { "FF55 0009 00 50 00 00000100", // TLM st=1 sp=1 + "FF55 0008 00 20 0000 0100", // TLM st=2 sp=0 + "FF55 0006 00 00 0100", // TLM st=0 sp=0 + "FF57 000A 00 00000003 81 05 07", // PLM + "FF57 0009 00 00000005 81 05", // PLM with truncated packet list + "FF53 0009 00 00 05 04 04 00 01", // COC identical to COD + "FF64 0008 0001 41 42 43 44" // COM + }) + void informationalMainHeaderMarkersDoNotChangePixels(String segment) { + byte[] stream = insert(j2k, indexOf(j2k, SOT, 2), hex(segment)); + OpenJpegImage image = decode(JP2CodecFormat.CODEC_J2K, stream, false); + assertNotNull(image); + assertArrayEquals(reference, image.getComps()[0].getData()); + } + + @Test + void pltInTileHeaderDoesNotChangePixels() { + byte[] stream = insertInTileHeader(j2k, hex("FF58 0006 00 81 05 07")); + OpenJpegImage image = decode(JP2CodecFormat.CODEC_J2K, stream, false); + assertNotNull(image); + assertArrayEquals(reference, image.getComps()[0].getData()); + } + + @Test + void rgnMarkerIsParsed() { + byte[] stream = insert(j2k, indexOf(j2k, SOT, 2), hex("FF5E 0005 00 00 02")); + assertNotNull(decode(JP2CodecFormat.CODEC_J2K, stream, false)); + } + + @ParameterizedTest(name = "packed packet headers {0}") + @ValueSource(strings = { "main:FF60 000A 00 00000003 01 02 03", "main:FF60 0008 00 00000005 01", + "main:FF60 0008 00 00000001 01 FF60 0006 01 00000001", "tile:FF61 0006 00 01 02 03", + "tile:FF61 0005 00 01 02 FF61 0005 01 03 04" }) + @Timeout(value = 10, unit = TimeUnit.SECONDS, threadMode = ThreadMode.SEPARATE_THREAD) + void packedPacketHeadersAreParsed(String spec) { + String[] parts = spec.split(":"); + byte[] segment = hex(parts[1]); + byte[] stream = "main".equals(parts[0]) ? insert(j2k, indexOf(j2k, SOT, 2), segment) + : insertInTileHeader(j2k, segment); + tryDecode(JP2CodecFormat.CODEC_J2K, stream, false); + assertTrue(stream.length > j2k.length); + } + + @Test + @Timeout(value = 10, unit = TimeUnit.SECONDS, threadMode = ThreadMode.SEPARATE_THREAD) + void unknownMarkerIsSubstitutedUnderJpwl() { + byte[] stream = insert(j2k, indexOf(j2k, SOT, 2), hex("FF56 0004 0000")); + tryDecode(JP2CodecFormat.CODEC_J2K, stream, true); + byte[] far = insert(j2k, indexOf(j2k, SOT, 2), hex("FF01 0004 0000")); + tryDecode(JP2CodecFormat.CODEC_J2K, far, true); + assertNotNull(decode(JP2CodecFormat.CODEC_J2K, j2k, true)); + } + + @Test + void jptStreamDecodesLikeCodestream() { + OpenJpegImage image = decode(JP2CodecFormat.CODEC_JPT, jpt(j2k, 0x40, 6, 4), false); + assertNotNull(image); + assertArrayEquals(reference, image.getComps()[0].getData()); + } + + @Test + void jptStreamWithCodestreamIndexDecodes() { + assertNotNull(decode(JP2CodecFormat.CODEC_JPT, jpt(j2k, 0x60, 6, 4), false)); + } + + @Test + void jptStreamRejectsUnexpectedClasses() { + assertNull(decode(JP2CodecFormat.CODEC_JPT, jpt(j2k, 0x40, 4, 4), false)); + assertNull(decode(JP2CodecFormat.CODEC_JPT, jpt(j2k, 0x40, 6, 6), false)); + assertNull(tryDecode(JP2CodecFormat.CODEC_JPT, new byte[] { 0x00, 0x06, 0x00, 0x02, 0x12, 0x34 }, false)); + } + + @Test + @Timeout(value = 60, unit = TimeUnit.SECONDS, threadMode = ThreadMode.SEPARATE_THREAD) + void corruptedCodestreamsNeverHang() { + int from = sizEnd(j2k); + int to = Math.min(j2k.length, from + 160); + int survived = 0; + for (int i = from; i < to; i++) { + for (int variant = 0; variant < 3; variant++) { + byte[] copy = j2k.clone(); + copy[i] = mutate(copy[i], variant); + if (tryDecode(JP2CodecFormat.CODEC_J2K, copy, false) != null) { + survived++; + } + } + } + for (int len = 2; len < j2k.length; len += 5) { + tryDecode(JP2CodecFormat.CODEC_J2K, java.util.Arrays.copyOf(j2k, len), false); + tryDecode(JP2CodecFormat.CODEC_JPT, java.util.Arrays.copyOf(j2k, len), false); + } + assertTrue(survived > 0, "some single-byte corruptions must still decode"); + } + + @Test + @Timeout(value = 60, unit = TimeUnit.SECONDS, threadMode = ThreadMode.SEPARATE_THREAD) + void corruptedJp2BoxesNeverHang() { + byte[] jp2 = encode(JP2CodecFormat.CODEC_JP2, 24, 24); + assertNotNull(decode(JP2CodecFormat.CODEC_JP2, jp2, false)); + int ihdr = indexOfAscii(jp2, "ihdr"); + for (int i = 0; i < Math.min(jp2.length, ihdr + 40); i++) { + if (i >= ihdr + 4 && i < ihdr + 14) { + continue; + } + for (int variant = 0; variant < 3; variant++) { + byte[] copy = jp2.clone(); + copy[i] = mutate(copy[i], variant); + tryDecode(JP2CodecFormat.CODEC_JP2, copy, false); + } + } + for (int len = 4; len < jp2.length; len += 9) { + tryDecode(JP2CodecFormat.CODEC_JP2, java.util.Arrays.copyOf(jp2, len), false); + } + assertTrue(ihdr > 0); + } + + @Test + @Timeout(value = 120, unit = TimeUnit.SECONDS, threadMode = ThreadMode.SEPARATE_THREAD) + void corruptedWsqNeverHangs() throws IOException { + byte[] wsq; + try (InputStream in = getClass().getClassLoader().getResourceAsStream("sample-wsq.b64")) { + assertNotNull(in); + wsq = Base64UrlUtil.getInstance() + .decodeURLSafeBase64(new String(in.readAllBytes(), StandardCharsets.UTF_8)); + } + int sof = indexOf(wsq, 0xFFA2, 2); + int sofEnd = sof + 2 + (((wsq[sof + 2] & 0xff) << 8) | (wsq[sof + 3] & 0xff)); + int sob = indexOf(wsq, 0xFFA3, sofEnd); + int end = Math.min(wsq.length, sob + 40); + int failures = 0; + for (int i = 0; i < end; i += 3) { + if (i >= sof && i < sofEnd) { + continue; + } + byte[] copy = wsq.clone(); + copy[i] = mutate(copy[i], i % 3); + if (!wsqDecodes(copy)) { + failures++; + } + } + for (int len = 2; len < end; len += 23) { + wsqDecodes(java.util.Arrays.copyOf(wsq, len)); + } + assertTrue(failures > 0, "header corruption must be reported"); + } + + private static boolean wsqDecodes(byte[] data) { + DecoderRequestInfo req = new DecoderRequestInfo(); + req.setImageData(data); + req.setBufferedImage(false); + try { + Response info = new WsqDecoder().decode(req); + return info.getStatusCode() == 0; + } catch (RuntimeException ex) { + return false; + } + } + + private static byte mutate(byte b, int variant) { + switch (variant) { + case 0: + return 0; + case 1: + return (byte) 0xFF; + default: + return (byte) (b ^ 0x5A); + } + } + + /** Wraps the codestream into a main-header data-bin followed by one tile data-bin. */ + private static byte[] jpt(byte[] codestream, int binId, int mainClass, int tileClass) { + int sot = indexOf(codestream, SOT, 2); + int eoc = lastIndexOf(codestream, EOC); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + writeMessage(out, binId, mainClass, codestream, 0, sot); + writeMessage(out, binId, tileClass, codestream, sot, eoc); + return out.toByteArray(); + } + + private static void writeMessage(ByteArrayOutputStream out, int binId, int classId, byte[] src, int from, + int to) { + out.write(binId); + out.writeBytes(vbas(classId)); + if ((binId & 0x60) == 0x60) { + out.writeBytes(vbas(0)); + } + out.writeBytes(vbas(0)); + out.writeBytes(vbas(to - from)); + out.write(src, from, to - from); + } + + private static byte[] vbas(int value) { + int groups = 1; + while ((value >>> (7 * groups)) != 0) { + groups++; + } + byte[] out = new byte[groups]; + for (int g = 0; g < groups; g++) { + int bits = (value >>> (7 * (groups - 1 - g))) & 0x7f; + out[g] = (byte) (g < groups - 1 ? bits | 0x80 : bits); + } + return out; + } + + private static byte[] insertInTileHeader(byte[] stream, byte[] segment) { + int sot = indexOf(stream, SOT, 2); + int sod = indexOf(stream, SOD, sot); + byte[] out = insert(stream, sod, segment); + int psotAt = sot + 6; + long psot = ((out[psotAt] & 0xffL) << 24) | ((out[psotAt + 1] & 0xff) << 16) + | ((out[psotAt + 2] & 0xff) << 8) | (out[psotAt + 3] & 0xff); + if (psot != 0) { + psot += segment.length; + out[psotAt] = (byte) (psot >> 24); + out[psotAt + 1] = (byte) (psot >> 16); + out[psotAt + 2] = (byte) (psot >> 8); + out[psotAt + 3] = (byte) psot; + } + return out; + } + + private static int sizEnd(byte[] stream) { + int siz = indexOf(stream, 0xFF51, 0); + return siz + 2 + (((stream[siz + 2] & 0xff) << 8) | (stream[siz + 3] & 0xff)); + } + + private static byte[] insert(byte[] src, int at, byte[] extra) { + byte[] out = new byte[src.length + extra.length]; + System.arraycopy(src, 0, out, 0, at); + System.arraycopy(extra, 0, out, at, extra.length); + System.arraycopy(src, at, out, at + extra.length, src.length - at); + return out; + } + + private static int indexOf(byte[] data, int marker, int from) { + for (int i = from; i + 1 < data.length; i++) { + if ((data[i] & 0xff) == (marker >> 8) && (data[i + 1] & 0xff) == (marker & 0xff)) { + return i; + } + } + throw new AssertionError("marker not found: " + Integer.toHexString(marker)); + } + + private static int lastIndexOf(byte[] data, int marker) { + for (int i = data.length - 2; i >= 0; i--) { + if ((data[i] & 0xff) == (marker >> 8) && (data[i + 1] & 0xff) == (marker & 0xff)) { + return i; + } + } + throw new AssertionError("marker not found: " + Integer.toHexString(marker)); + } + + private static int indexOfAscii(byte[] data, String text) { + byte[] needle = text.getBytes(StandardCharsets.US_ASCII); + outer: for (int i = 0; i + needle.length <= data.length; i++) { + for (int j = 0; j < needle.length; j++) { + if (data[i + j] != needle[j]) { + continue outer; + } + } + return i; + } + return -1; + } + + private static byte[] hex(String text) { + String clean = text.replace(" ", ""); + byte[] out = new byte[clean.length() / 2]; + for (int i = 0; i < out.length; i++) { + out[i] = (byte) Integer.parseInt(clean.substring(2 * i, 2 * i + 2), 16); + } + return out; + } + + private OpenJpegImage tryDecode(JP2CodecFormat format, byte[] data, boolean jpwl) { + try { + return decode(format, data, jpwl); + } catch (RuntimeException | StackOverflowError ex) { + return null; + } + } + + private OpenJpegImage decode(JP2CodecFormat format, byte[] data, boolean jpwl) { + DecompressionContextInfo dInfo = codec.createDecompression(format); + DecompressionParameters params = new DecompressionParameters(); + codec.setDefaultDecoderParameters(params, jpwl); + if (jpwl) { + params.setJpwlCorrect(1); + params.setJpwlExpComps(1); + params.setJpwlMaxTiles(4); + } + codec.setupDecoder(dInfo, params, jpwl); + Cio cio = CioHelper.getInstance().cioOpen(dInfo, data, data.length); + try { + return codec.decode(dInfo, cio, jpwl); + } finally { + CioHelper.getInstance().cioClose(cio); + codec.destroyDecompression(dInfo); + } + } + + private byte[] encode(JP2CodecFormat format, int w, int h) { + OpenJpegImageComponentParameters p = new OpenJpegImageComponentParameters(); + p.setDx(1); + p.setDy(1); + p.setWidth(w); + p.setHeight(h); + p.setPrec(8); + p.setBpp(8); + OpenJpegImage image = ImageHelper.getInstance().imageCreate(1, + new OpenJpegImageComponentParameters[] { p }, Jp2ColorSpace.CLRSPC_GRAY); + image.setX1(w); + image.setY1(h); + int[] data = image.getComps()[0].getData(); + for (int i = 0; i < data.length; i++) { + data[i] = (i * 37 + (i / w) * 11) & 0xff; + } + CompressionParameters params = new CompressionParameters(); + codec.setDefaultEncodeParameters(params, false); + params.setTcpNoOfLayers(1); + params.setTcpRates(new float[] { 0f }); + CompressionContextInfo cInfo = codec.createCompression(format); + codec.setupEncoder(cInfo, params, image, false); + Cio cio = CioHelper.getInstance().cioOpen(cInfo, null, 0); + assertEquals(0, codec.encode(cInfo, cio, image, null, false)); + byte[] out = java.util.Arrays.copyOf(cio.getBuffer(), CioHelper.getInstance().cioTell(cio)); + CioHelper.getInstance().cioClose(cio); + codec.destroyCompression(cInfo); + return out; + } +} diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/LoggerTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/LoggerTest.java new file mode 100644 index 0000000..145c2a6 --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/LoggerTest.java @@ -0,0 +1,26 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.Test; + +import io.mosip.imagedecoder.logger.ImageDecoderLogger; +import io.mosip.kernel.core.logger.spi.Logger; + +class LoggerTest { + @Test + void testGetLogger() { + Logger logger = ImageDecoderLogger.getLogger(ImageDecoderLogger.class); + assertNotNull(logger); + } + + @Test + void testPrivateConstructor() { + assertDoesNotThrow(() -> { + var constructor = ImageDecoderLogger.class.getDeclaredConstructor(); + constructor.setAccessible(true); + constructor.newInstance(); + }); + } +} diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/MathUtilTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/MathUtilTest.java new file mode 100644 index 0000000..0e332d6 --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/MathUtilTest.java @@ -0,0 +1,36 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; + +import org.junit.jupiter.api.Test; + +import io.mosip.imagedecoder.util.openjpeg.MathUtil; + +class MathUtilTest { + + @Test + void singleton() { + assertSame(MathUtil.getInstance(), MathUtil.getInstance()); + } + + @Test + void minMaxClampAbs() { + assertEquals(1, MathUtil.getInstance().intMin(1, 2)); + assertEquals(2, MathUtil.getInstance().intMax(1, 2)); + assertEquals(0, MathUtil.getInstance().intClamp(-1, 0, 5)); + assertEquals(5, MathUtil.getInstance().intClamp(9, 0, 5)); + assertEquals(3, MathUtil.getInstance().intClamp(3, 0, 5)); + assertEquals(4, MathUtil.getInstance().intAbs(-4)); + assertEquals(4, MathUtil.getInstance().intAbs(4)); + } + + @Test + void ceilDiv() { + assertEquals(3, MathUtil.getInstance().intCeilDiv(5, 2)); + assertEquals(2, MathUtil.getInstance().intCeilDivPow2(5, 2)); + assertEquals(1, MathUtil.getInstance().intFloorDivPow2(5, 2)); + assertEquals(3, MathUtil.getInstance().intFloorLog2(8)); + assertEquals(0, MathUtil.getInstance().intFloorLog2(1)); + } +} \ No newline at end of file diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/ModelCoverageTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/ModelCoverageTest.java new file mode 100644 index 0000000..75c370d --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/ModelCoverageTest.java @@ -0,0 +1,198 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; + +/** + * Exercises equals/hashCode/toString (and no-arg construction) for all model + * classes so Lombok-generated methods count toward JaCoCo when model/ is not + * excluded. + */ +class ModelCoverageTest { + + @Test + void allModelClassesEqualsHashCodeToString() throws Exception { + List> classes = loadModelClasses(); + assertTrue(classes.size() > 40, "expected many model classes, found " + classes.size()); + + int exercised = 0; + for (Class type : classes) { + if (type.isEnum() || type.isInterface() || Modifier.isAbstract(type.getModifiers())) { + continue; + } + Object a; + Object b; + try { + a = type.getDeclaredConstructor().newInstance(); + b = type.getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException ex) { + continue; // needs args — skip + } + assertEquals(a, b, () -> type.getName() + " default instances should be equal"); + assertEquals(a.hashCode(), b.hashCode()); + assertNotNull(a.toString()); + assertNotEquals(a, new Object()); + assertNotEquals(a, null); + // invoke setters with zeroes / empty arrays where possible to hit branches + for (Method m : type.getMethods()) { + if (!m.getName().startsWith("set") || m.getParameterCount() != 1) { + continue; + } + Class p = m.getParameterTypes()[0]; + Object arg = sampleArg(p); + if (arg == null) { + continue; + } + assertDoesNotThrow(() -> m.invoke(a, arg), () -> type.getName() + "#" + m.getName()); + } + exercised++; + } + assertTrue(exercised > 30, "exercised too few model types: " + exercised); + } + + @Test + void enumsValues() throws Exception { + for (Class type : loadModelClasses()) { + if (!type.isEnum()) { + continue; + } + Object[] constants = type.getEnumConstants(); + assertNotNull(constants); + assertTrue(constants.length > 0); + for (Object c : constants) { + assertNotNull(c.toString()); + assertEquals(c, Enum.valueOf((Class) type, ((Enum) c).name())); + } + } + } + + private static Object sampleArg(Class p) { + if (p == boolean.class || p == Boolean.class) { + return true; + } + if (p == byte.class || p == Byte.class) { + return (byte) 1; + } + if (p == short.class || p == Short.class) { + return (short) 1; + } + if (p == int.class || p == Integer.class) { + return 1; + } + if (p == long.class || p == Long.class) { + return 1L; + } + if (p == float.class || p == Float.class) { + return 1.0f; + } + if (p == double.class || p == Double.class) { + return 1.0d; + } + if (p == char.class || p == Character.class) { + return 'a'; + } + if (p == String.class) { + return "x"; + } + if (p == boolean[].class) { + return new boolean[] { true }; + } + if (p == byte[].class) { + return new byte[] { 1 }; + } + if (p == short[].class) { + return new short[] { 1 }; + } + if (p == int[].class) { + return new int[] { 1 }; + } + if (p == long[].class) { + return new long[] { 1L }; + } + if (p == float[].class) { + return new float[] { 1f }; + } + if (p == double[].class) { + return new double[] { 1d }; + } + if (p == char[].class) { + return new char[] { 'a' }; + } + if (p == String[].class) { + return new String[] { "x" }; + } + if (p.isArray()) { + return java.lang.reflect.Array.newInstance(p.getComponentType(), 0); + } + if (p.isEnum()) { + Object[] vals = p.getEnumConstants(); + return vals != null && vals.length > 0 ? vals[0] : null; + } + try { + return p.getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException ex) { + return null; + } + } + + private static List> loadModelClasses() throws IOException, URISyntaxException, ClassNotFoundException { + String pkg = "io.mosip.imagedecoder.model"; + String path = pkg.replace('.', '/'); + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + List> out = new ArrayList<>(); + Enumeration roots = cl.getResources(path); + while (roots.hasMoreElements()) { + URL url = roots.nextElement(); + if ("file".equals(url.getProtocol())) { + Path dir = Path.of(url.toURI()); + try (Stream walk = Files.walk(dir)) { + walk.filter(p -> p.toString().endsWith(".class")).forEach(p -> { + String rel = dir.relativize(p).toString().replace('\\', '/').replace('/', '.'); + String name = pkg + "." + rel.substring(0, rel.length() - 6); + if (name.contains("$")) { + return; + } + try { + out.add(Class.forName(name)); + } catch (ClassNotFoundException ignored) { + // skip + } + }); + } + } else if ("jar".equals(url.getProtocol())) { + String file = url.getFile(); + String jarPath = file.substring(5, file.indexOf('!')); + try (JarFile jar = new JarFile(jarPath)) { + Enumeration entries = jar.entries(); + while (entries.hasMoreElements()) { + JarEntry e = entries.nextElement(); + String name = e.getName(); + if (name.startsWith(path) && name.endsWith(".class") && !name.contains("$")) { + out.add(Class.forName(name.replace('/', '.').substring(0, name.length() - 6))); + } + } + } + } + } + return out; + } +} diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegCodecPathTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegCodecPathTest.java new file mode 100644 index 0000000..57ccfce --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegCodecPathTest.java @@ -0,0 +1,354 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; +import java.io.InputStream; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import io.mosip.imagedecoder.model.openjpeg.Bio; +import io.mosip.imagedecoder.model.openjpeg.Cio; +import io.mosip.imagedecoder.model.openjpeg.CodeStreamInfo; +import io.mosip.imagedecoder.model.openjpeg.CompressionContextInfo; +import io.mosip.imagedecoder.model.openjpeg.CompressionParameters; +import io.mosip.imagedecoder.model.openjpeg.DecompressionContextInfo; +import io.mosip.imagedecoder.model.openjpeg.DecompressionParameters; +import io.mosip.imagedecoder.model.openjpeg.JP2CodecFormat; +import io.mosip.imagedecoder.model.openjpeg.Jp2ColorSpace; +import io.mosip.imagedecoder.model.openjpeg.LimitDecoding; +import io.mosip.imagedecoder.model.openjpeg.OpenJpegImage; +import io.mosip.imagedecoder.model.openjpeg.OpenJpegImageComponentParameters; +import io.mosip.imagedecoder.model.openjpeg.StepSize; +import io.mosip.imagedecoder.model.openjpeg.TcdTileComponent; +import io.mosip.imagedecoder.model.openjpeg.TgtTree; +import io.mosip.imagedecoder.model.openjpeg.TileComponentCodingParameters; +import io.mosip.imagedecoder.openjpeg.BioHelper; +import io.mosip.imagedecoder.openjpeg.CioHelper; +import io.mosip.imagedecoder.openjpeg.DwtHelper; +import io.mosip.imagedecoder.openjpeg.ImageHelper; +import io.mosip.imagedecoder.openjpeg.OpenJpegHelper; +import io.mosip.imagedecoder.openjpeg.TgtHelper; + +/** + * Deep encode / rare-decode paths for OpenJPEG C-port helpers (J2K, Tcd, Pi, Tier1/2, Dwt, MQCoder). + */ +class OpenJpegCodecPathTest { + + private OpenJpegHelper codec; + + @BeforeEach + void setUp() { + codec = new OpenJpegHelper(); + } + + @Test + void setupEncoderJp2AndJ2kGray() { + assertDoesNotThrow(() -> setupOnly(createGrayImage(32, 32), JP2CodecFormat.CODEC_JP2, false)); + assertDoesNotThrow(() -> setupOnly(createGrayImage(16, 16), JP2CodecFormat.CODEC_J2K, false)); + } + + @Test + void encodeJp2RgbIrreversibleWithJpwl() { + OpenJpegImage image = createRgbImage(24, 24); + byte[] encoded = encode(image, JP2CodecFormat.CODEC_JP2, true, true, 20f); + assertNotNull(encoded); + assertTrue(encoded.length > 100); + OpenJpegImage decoded = decode(encoded, JP2CodecFormat.CODEC_JP2, true); + assertNotNull(decoded); + assertEquals(3, decoded.getNoOfComps()); + } + + @Test + void encodeDecodeJp2GrayRoundTrip() { + OpenJpegImage image = createGrayImage(32, 32); + byte[] encoded = encode(image, JP2CodecFormat.CODEC_JP2, false, false, 0f); + assertNotNull(encoded); + assertTrue(encoded.length > 50); + OpenJpegImage decoded = decode(encoded, JP2CodecFormat.CODEC_JP2, false); + assertNotNull(decoded); + assertEquals(1, decoded.getNoOfComps()); + assertEquals(32, decoded.getComps()[0].getWidth()); + assertEquals(32, decoded.getComps()[0].getHeight()); + } + + @Test + void encodeDecodeJ2kGrayRoundTrip() { + OpenJpegImage image = createGrayImage(16, 16); + byte[] encoded = encode(image, JP2CodecFormat.CODEC_J2K, false, false, 0f); + assertNotNull(encoded); + assertTrue(encoded.length > 30); + OpenJpegImage decoded = decode(encoded, JP2CodecFormat.CODEC_J2K, false); + assertNotNull(decoded); + assertEquals(1, decoded.getNoOfComps()); + } + + @Test + void encodeJp2WithCodeStreamInfo() { + OpenJpegImage image = createGrayImage(16, 16); + CompressionContextInfo cInfo = codec.createCompression(JP2CodecFormat.CODEC_JP2); + CompressionParameters params = new CompressionParameters(); + codec.setDefaultEncodeParameters(params, false); + params.setTcpNoOfLayers(1); + params.setTcpRates(new float[] { 0f }); + codec.setupEncoder(cInfo, params, image, false); + Cio cio = CioHelper.getInstance().cioOpen(cInfo, null, 0); + assertNotNull(cio); + int r = codec.encodeWithInfo(cInfo, cio, image, new CodeStreamInfo(), false); + assertEquals(0, r); + int len = CioHelper.getInstance().cioTell(cio); + assertTrue(len > 0); + CioHelper.getInstance().cioClose(cio); + codec.destroyCompression(cInfo); + } + + @Test + void encodeMultiLayerRateControl() { + OpenJpegImage image = createGrayImage(48, 48); + CompressionContextInfo cInfo = codec.createCompression(JP2CodecFormat.CODEC_JP2); + CompressionParameters params = new CompressionParameters(); + codec.setDefaultEncodeParameters(params, false); + params.setTcpNoOfLayers(2); + params.setTcpRates(new float[] { 40f, 20f }); + params.setCpComment("layer-test".toCharArray()); + codec.setupEncoder(cInfo, params, image, false); + Cio cio = CioHelper.getInstance().cioOpen(cInfo, null, 0); + int r = codec.encode(cInfo, cio, image, null, false); + assertEquals(0, r); + assertTrue(CioHelper.getInstance().cioTell(cio) > 0); + CioHelper.getInstance().cioClose(cio); + codec.destroyCompression(cInfo); + } + + @Test + void encodeIrreversibleRgbAndDecode() { + OpenJpegImage image = createRgbImage(20, 20); + byte[] encoded = encode(image, JP2CodecFormat.CODEC_JP2, false, true, 10f); + assertTrue(encoded.length > 80); + OpenJpegImage decoded = decode(encoded, JP2CodecFormat.CODEC_JP2, false); + assertNotNull(decoded); + assertEquals(3, decoded.getNoOfComps()); + } + + @Test + void encodeJ2kRgb() { + OpenJpegImage image = createRgbImage(12, 12); + byte[] encoded = encode(image, JP2CodecFormat.CODEC_J2K, false, false, 0f); + assertTrue(encoded.length > 40); + assertNotNull(decode(encoded, JP2CodecFormat.CODEC_J2K, false)); + } + + @Test + void decodeSampleJp2WithJpwlFlag() throws IOException { + byte[] jp2 = readResource("biometric/info_face_auth.jp2"); + DecompressionContextInfo dInfo = codec.createDecompression(JP2CodecFormat.CODEC_JP2); + DecompressionParameters params = new DecompressionParameters(); + codec.setDefaultDecoderParameters(params, true); + params.setCpLimitDecoding(LimitDecoding.NO_LIMITATION); + codec.setupDecoder(dInfo, params, true); + Cio cio = CioHelper.getInstance().cioOpen(dInfo, jp2, jp2.length); + OpenJpegImage image = codec.decode(dInfo, cio, true); + assertNotNull(image); + CioHelper.getInstance().cioClose(cio); + codec.destroyDecompression(dInfo); + } + + @Test + void decodeAllSampleJp2Variants() throws IOException { + String[] resources = { + "biometric/info_face_registration.jp2", + "biometric/info_finger_left_index_auth.jp2", + "biometric/info_finger_left_index_registration.jp2", + "biometric/info_iris_left_auth.jp2", + "biometric/info_iris_left_registration.jp2" + }; + for (String res : resources) { + byte[] data = readResource(res); + OpenJpegImage image = decode(data, JP2CodecFormat.CODEC_JP2, false); + assertNotNull(image, res); + } + } + + @Test + void decodeWithLimitDecodingFlags() throws IOException { + byte[] jp2 = readResource("biometric/info_iris_left_auth.jp2"); + for (LimitDecoding limit : new LimitDecoding[] { + LimitDecoding.NO_LIMITATION, + LimitDecoding.LIMIT_TO_MAIN_HEADER + }) { + DecompressionContextInfo dInfo = codec.createDecompression(JP2CodecFormat.CODEC_JP2); + DecompressionParameters params = new DecompressionParameters(); + codec.setDefaultDecoderParameters(params, false); + params.setCpLimitDecoding(limit); + codec.setupDecoder(dInfo, params, false); + Cio cio = CioHelper.getInstance().cioOpen(dInfo, jp2, jp2.length); + assertDoesNotThrow(() -> codec.decode(dInfo, cio, false)); + CioHelper.getInstance().cioClose(cio); + codec.destroyDecompression(dInfo); + } + } + + @Test + void dwtEncodeDecodeAndNorms() { + DwtHelper dwt = DwtHelper.getInstance(); + assertTrue(dwt.dwtGetGain(0) >= 0); + assertTrue(dwt.dwtGetGain(1) >= 0); + assertTrue(dwt.dwtGetGain(2) >= 0); + assertTrue(dwt.dwtGetGainReal(0) >= 0); + assertTrue(dwt.dwtGetNorm(0, 0) > 0); + assertTrue(dwt.dwtGetNorm(1, 1) > 0); + assertTrue(dwt.dwtGetNormReal(0, 0) > 0); + + TileComponentCodingParameters tccp = new TileComponentCodingParameters(); + tccp.setNoOfResolutions(4); + tccp.setQuantisationStyle(0); + tccp.setNoOfGaurdBits(2); + tccp.setQmfbid(1); + for (int i = 0; i < tccp.getStepsizes().length; i++) { + if (tccp.getStepsizes()[i] == null) { + tccp.getStepsizes()[i] = new StepSize(); + } + } + assertDoesNotThrow(() -> dwt.dwtCalcExplicitStepSizes(tccp, 8)); + tccp.setQmfbid(0); + tccp.setQuantisationStyle(1); + assertDoesNotThrow(() -> dwt.dwtCalcExplicitStepSizes(tccp, 8)); + + TcdTileComponent tilec = new TcdTileComponent(); + tilec.setX0(0); + tilec.setY0(0); + tilec.setX1(8); + tilec.setY1(8); + tilec.setNoOfResolutions(3); + tilec.setIData(new int[64]); + assertDoesNotThrow(() -> { + try { + dwt.dwtEncode(tilec); + } catch (RuntimeException ignored) { + // needs full resolution graph + } + }); + } + + @Test + void tgtTreeCreateResetDestroy() { + TgtHelper tgt = TgtHelper.getInstance(); + TgtTree tree = tgt.tgtCreate(2, 2); + assertNotNull(tree); + assertTrue(tree.getNoOfNodes() > 0); + tgt.tgtReset(tree); + tgt.tgtSetValue(tree, 0, 2); + assertDoesNotThrow(() -> { + try { + Bio bio = BioHelper.getInstance().bioCreate(); + byte[] buf = new byte[128]; + BioHelper.getInstance().bioInitEncoder(bio, buf, buf.length); + tgt.tgtEncode(bio, tree, 0, 1); + BioHelper.getInstance().bioFlush(bio); + } catch (RuntimeException ignored) { + // parent-chain edge cases in ported tgtEncode + } + }); + tgt.tgtDestroy(tree); + } + + private byte[] encode(OpenJpegImage image, JP2CodecFormat format, boolean useJpwl, boolean irreversible, + float rate) { + CompressionContextInfo cInfo = codec.createCompression(format); + CompressionParameters params = new CompressionParameters(); + codec.setDefaultEncodeParameters(params, useJpwl); + params.setTcpNoOfLayers(1); + params.setTcpRates(new float[] { rate }); + if (irreversible) { + params.setIrreversible(1); + } + codec.setupEncoder(cInfo, params, image, useJpwl); + Cio cio = CioHelper.getInstance().cioOpen(cInfo, null, 0); + int r = codec.encode(cInfo, cio, image, null, useJpwl); + assertEquals(0, r, "encode failed"); + int len = CioHelper.getInstance().cioTell(cio); + byte[] out = new byte[len]; + System.arraycopy(cio.getBuffer(), 0, out, 0, len); + CioHelper.getInstance().cioClose(cio); + codec.destroyCompression(cInfo); + return out; + } + + private void setupOnly(OpenJpegImage image, JP2CodecFormat format, boolean useJpwl) { + CompressionContextInfo cInfo = codec.createCompression(format); + assertNotNull(cInfo); + CompressionParameters params = new CompressionParameters(); + codec.setDefaultEncodeParameters(params, useJpwl); + params.setTcpNoOfLayers(1); + params.setTcpRates(new float[] { 0f }); + codec.setupEncoder(cInfo, params, image, useJpwl); + codec.destroyCompression(cInfo); + } + + private OpenJpegImage decode(byte[] data, JP2CodecFormat format, boolean useJpwl) { + DecompressionContextInfo dInfo = codec.createDecompression(format); + DecompressionParameters params = new DecompressionParameters(); + codec.setDefaultDecoderParameters(params, useJpwl); + codec.setupDecoder(dInfo, params, useJpwl); + Cio cio = CioHelper.getInstance().cioOpen(dInfo, data, data.length); + OpenJpegImage image = codec.decode(dInfo, cio, useJpwl); + CioHelper.getInstance().cioClose(cio); + codec.destroyDecompression(dInfo); + return image; + } + + private static OpenJpegImage createGrayImage(int w, int h) { + OpenJpegImageComponentParameters[] parms = { component(w, h) }; + OpenJpegImage image = ImageHelper.getInstance().imageCreate(1, parms, Jp2ColorSpace.CLRSPC_GRAY); + image.setX0(0); + image.setY0(0); + image.setX1(w); + image.setY1(h); + fillRamp(image.getComps()[0].getData()); + return image; + } + + private static OpenJpegImage createRgbImage(int w, int h) { + OpenJpegImageComponentParameters[] parms = { component(w, h), component(w, h), component(w, h) }; + OpenJpegImage image = ImageHelper.getInstance().imageCreate(3, parms, Jp2ColorSpace.CLRSPC_SRGB); + image.setX0(0); + image.setY0(0); + image.setX1(w); + image.setY1(h); + for (int c = 0; c < 3; c++) { + fillRamp(image.getComps()[c].getData()); + } + return image; + } + + private static OpenJpegImageComponentParameters component(int w, int h) { + OpenJpegImageComponentParameters p = new OpenJpegImageComponentParameters(); + p.setDx(1); + p.setDy(1); + p.setWidth(w); + p.setHeight(h); + p.setX0(0); + p.setY0(0); + p.setPrec(8); + p.setBpp(8); + p.setSgnd(0); + return p; + } + + private static void fillRamp(int[] data) { + for (int i = 0; i < data.length; i++) { + data[i] = i % 256; + } + } + + private static byte[] readResource(String name) throws IOException { + try (InputStream in = OpenJpegCodecPathTest.class.getClassLoader().getResourceAsStream(name)) { + assertNotNull(in, name); + return in.readAllBytes(); + } + } +} diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegCodingModesTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegCodingModesTest.java new file mode 100644 index 0000000..3c00072 --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegCodingModesTest.java @@ -0,0 +1,210 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.ValueSource; + +import io.mosip.imagedecoder.constant.openjpeg.OpenJpegConstant; +import io.mosip.imagedecoder.model.openjpeg.Cio; +import io.mosip.imagedecoder.model.openjpeg.CompressionContextInfo; +import io.mosip.imagedecoder.model.openjpeg.CompressionParameters; +import io.mosip.imagedecoder.model.openjpeg.DecompressionContextInfo; +import io.mosip.imagedecoder.model.openjpeg.DecompressionParameters; +import io.mosip.imagedecoder.model.openjpeg.JP2CodecFormat; +import io.mosip.imagedecoder.model.openjpeg.Jp2ColorSpace; +import io.mosip.imagedecoder.model.openjpeg.OpenJpegImage; +import io.mosip.imagedecoder.model.openjpeg.OpenJpegImageComponentParameters; +import io.mosip.imagedecoder.openjpeg.CioHelper; +import io.mosip.imagedecoder.openjpeg.ImageHelper; +import io.mosip.imagedecoder.openjpeg.OpenJpegHelper; + +/** + * Code-block styles, SOP/EPH markers, signed / mixed-precision components and + * decoder reduce / layer limits. + */ +class OpenJpegCodingModesTest { + + private OpenJpegHelper codec; + + @BeforeEach + void setUp() { + codec = new OpenJpegHelper(); + } + + @ParameterizedTest(name = "cblk style {0}") + @ValueSource(ints = { OpenJpegConstant.J2K_CCP_CBLKSTY_LAZY, OpenJpegConstant.J2K_CCP_CBLKSTY_RESET, + OpenJpegConstant.J2K_CCP_CBLKSTY_TERMALL, OpenJpegConstant.J2K_CCP_CBLKSTY_VSC, + OpenJpegConstant.J2K_CCP_CBLKSTY_PTERM, OpenJpegConstant.J2K_CCP_CBLKSTY_SEGSYM, + OpenJpegConstant.J2K_CCP_CBLKSTY_LAZY | OpenJpegConstant.J2K_CCP_CBLKSTY_TERMALL, + OpenJpegConstant.J2K_CCP_CBLKSTY_LAZY | OpenJpegConstant.J2K_CCP_CBLKSTY_PTERM, 0x3f }) + void encodeDecodeCodeBlockStyles(int mode) { + OpenJpegImage image = image(32, 32, 1, 8, 0); + CompressionParameters params = baseParams(); + params.setMode(mode); + byte[] encoded = encode(JP2CodecFormat.CODEC_J2K, image, params); + assertTrue(encoded.length > 20); + assertNotNull(decode(JP2CodecFormat.CODEC_J2K, encoded, 0, 0)); + } + + @ParameterizedTest(name = "coding style {0}") + @ValueSource(ints = { OpenJpegConstant.J2K_CP_CSTY_SOP, OpenJpegConstant.J2K_CP_CSTY_EPH, + OpenJpegConstant.J2K_CP_CSTY_SOP | OpenJpegConstant.J2K_CP_CSTY_EPH }) + void encodeDecodeSopEph(int style) { + OpenJpegImage image = image(24, 24, 3, 8, 0); + CompressionParameters params = baseParams(); + params.setCodingStyle(style); + params.setTcpNoOfLayers(2); + params.setTcpRates(new float[] { 20f, 0f }); + byte[] encoded = encode(JP2CodecFormat.CODEC_JP2, image, params); + assertNotNull(decode(JP2CodecFormat.CODEC_JP2, encoded, 0, 0)); + } + + @ParameterizedTest(name = "prec {0} signed {1}") + @CsvSource({ "12,0", "16,0", "8,1", "12,1", "4,0" }) + void encodeDecodePrecisionAndSign(int prec, int sgnd) { + OpenJpegImage image = image(16, 16, 1, prec, sgnd); + byte[] encoded = encode(JP2CodecFormat.CODEC_JP2, image, baseParams()); + OpenJpegImage decoded = decode(JP2CodecFormat.CODEC_JP2, encoded, 0, 0); + assertNotNull(decoded); + assertEquals(prec, decoded.getComps()[0].getPrec()); + } + + @Test + void encodeMixedPrecisionWritesBpccBox() { + OpenJpegImageComponentParameters[] parms = { component(16, 16, 8, 0), component(16, 16, 12, 0), + component(16, 16, 8, 1) }; + OpenJpegImage image = ImageHelper.getInstance().imageCreate(3, parms, Jp2ColorSpace.CLRSPC_SRGB); + frame(image, 16, 16); + CompressionParameters params = baseParams(); + params.setTcpMct(0); + byte[] encoded = encode(JP2CodecFormat.CODEC_JP2, image, params); + assertNotNull(decode(JP2CodecFormat.CODEC_JP2, encoded, 0, 0)); + } + + @Test + void encodeSubsampledComponents() { + OpenJpegImageComponentParameters luma = component(32, 32, 8, 0); + OpenJpegImageComponentParameters cb = component(16, 16, 8, 0); + cb.setDx(2); + cb.setDy(2); + OpenJpegImageComponentParameters cr = component(16, 16, 8, 0); + cr.setDx(2); + cr.setDy(2); + OpenJpegImage image = ImageHelper.getInstance().imageCreate(3, + new OpenJpegImageComponentParameters[] { luma, cb, cr }, Jp2ColorSpace.CLRSPC_SYCC); + frame(image, 32, 32); + CompressionParameters params = baseParams(); + params.setTcpMct(0); + byte[] encoded = encode(JP2CodecFormat.CODEC_JP2, image, params); + assertNotNull(decode(JP2CodecFormat.CODEC_JP2, encoded, 0, 0)); + } + + @ParameterizedTest(name = "reduce {0} layer {1}") + @CsvSource({ "1,0", "2,0", "0,1", "1,1", "0,2" }) + void decodeWithReduceAndLayerLimits(int reduce, int layer) { + OpenJpegImage image = image(64, 64, 1, 8, 0); + CompressionParameters params = baseParams(); + params.setNoOfResolution(4); + params.setTcpNoOfLayers(3); + params.setTcpRates(new float[] { 40f, 20f, 0f }); + byte[] encoded = encode(JP2CodecFormat.CODEC_J2K, image, params); + OpenJpegImage decoded = decode(JP2CodecFormat.CODEC_J2K, encoded, reduce, layer); + assertNotNull(decoded); + } + + @Test + void decodeReversibleWithIrreversibleSiblingTiles() { + OpenJpegImage image = image(48, 48, 3, 8, 0); + CompressionParameters params = baseParams(); + params.setIrreversible(1); + params.setTileSizeOn(1); + params.setCpTileDX(16); + params.setCpTileDY(16); + params.setMode(OpenJpegConstant.J2K_CCP_CBLKSTY_VSC | OpenJpegConstant.J2K_CCP_CBLKSTY_SEGSYM); + byte[] encoded = encode(JP2CodecFormat.CODEC_J2K, image, params); + assertTrue(encoded.length > 100); + } + + private CompressionParameters baseParams() { + CompressionParameters params = new CompressionParameters(); + codec.setDefaultEncodeParameters(params, false); + params.setTcpNoOfLayers(1); + params.setTcpRates(new float[] { 0f }); + return params; + } + + private byte[] encode(JP2CodecFormat format, OpenJpegImage image, CompressionParameters params) { + CompressionContextInfo cInfo = codec.createCompression(format); + codec.setupEncoder(cInfo, params, image, false); + Cio cio = CioHelper.getInstance().cioOpen(cInfo, null, 0); + assertEquals(0, codec.encode(cInfo, cio, image, null, false), "encode failed"); + int len = CioHelper.getInstance().cioTell(cio); + byte[] out = new byte[len]; + System.arraycopy(cio.getBuffer(), 0, out, 0, len); + CioHelper.getInstance().cioClose(cio); + codec.destroyCompression(cInfo); + return out; + } + + private OpenJpegImage decode(JP2CodecFormat format, byte[] data, int reduce, int layer) { + DecompressionContextInfo dInfo = codec.createDecompression(format); + DecompressionParameters params = new DecompressionParameters(); + codec.setDefaultDecoderParameters(params, false); + params.setCpReduce(reduce); + params.setCpLayer(layer); + codec.setupDecoder(dInfo, params, false); + Cio cio = CioHelper.getInstance().cioOpen(dInfo, data, data.length); + OpenJpegImage image = codec.decode(dInfo, cio, false); + CioHelper.getInstance().cioClose(cio); + codec.destroyDecompression(dInfo); + return image; + } + + private static OpenJpegImage image(int w, int h, int comps, int prec, int sgnd) { + OpenJpegImageComponentParameters[] parms = new OpenJpegImageComponentParameters[comps]; + for (int c = 0; c < comps; c++) { + parms[c] = component(w, h, prec, sgnd); + } + OpenJpegImage image = ImageHelper.getInstance().imageCreate(comps, parms, + comps == 1 ? Jp2ColorSpace.CLRSPC_GRAY : Jp2ColorSpace.CLRSPC_SRGB); + frame(image, w, h); + return image; + } + + private static void frame(OpenJpegImage image, int w, int h) { + image.setX0(0); + image.setY0(0); + image.setX1(w); + image.setY1(h); + for (int c = 0; c < image.getNoOfComps(); c++) { + int prec = image.getComps()[c].getPrec(); + boolean signed = image.getComps()[c].getSgnd() != 0; + int range = 1 << prec; + int[] data = image.getComps()[c].getData(); + for (int i = 0; i < data.length; i++) { + int v = (i * 31 + c * 7) % range; + data[i] = signed ? v - range / 2 : v; + } + } + } + + private static OpenJpegImageComponentParameters component(int w, int h, int prec, int sgnd) { + OpenJpegImageComponentParameters p = new OpenJpegImageComponentParameters(); + p.setDx(1); + p.setDy(1); + p.setWidth(w); + p.setHeight(h); + p.setX0(0); + p.setY0(0); + p.setPrec(prec); + p.setBpp(prec); + p.setSgnd(sgnd); + return p; + } +} diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegDecoderTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegDecoderTest.java index 34f2a16..bd4cf71 100644 --- a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegDecoderTest.java +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegDecoderTest.java @@ -26,21 +26,20 @@ import io.mosip.imagedecoder.util.Base64UrlUtil; import io.mosip.kernel.core.logger.spi.Logger; -public class OpenJpegDecoderTest { - +class OpenJpegDecoderTest { private static Logger logger = ImageDecoderLogger.getLogger(OpenJpegDecoderTest.class); private OpenJpegDecoder openJpegDecoder; private OpenJpegHelper mockOpenJpegHelper; @BeforeEach - public void setUp() { + void setUp() { mockOpenJpegHelper = mock(OpenJpegHelper.class); openJpegDecoder = new OpenJpegDecoder(); } @Test - public void testDecodeSuccess() { + void testDecodeSuccess() { // Arrange DecoderRequestInfo requestInfo = new DecoderRequestInfo(); requestInfo.setImageData(Base64UrlUtil.getInstance().decodeURLSafeBase64("AAAADGpQICANCocKAAAAFGZ0eXBqcDIgAAAAAGpwMiAAAABHanAyaAAAABZpaGRyAAABQAAAAPAAAwcHAAAAAAAPY29scgEAAAAAABAAAAAacmVzIAAAABJyZXNjA-gA_gPoAP4EBAAAAABqcDJj_0__UQAvAAAAAADwAAABQAAAAAAAAAAAAAAA8AAAAUAAAAAAAAAAAAADBwEBBwEBBwEB_1wAF0JnNWdMZ0xnZE8ITwhPhEbXRtdGbf9SAAwAAAABAQMEBAAA_2QADgABTFRfSlAyXzIyNv-QAAoAAAAARxgAAf-Tz-fWdJt6TanYMXQQOScICqcoIvo97xCBLu7OD1pVh0of0su2Y6YHDW-JLvHRkR3Qggjm02MRF82ipfmeXUQTeJMw4TFEB9rk6B0To6OlqQuGm2xg77x1xAlJ4Mo9MwtAXwSRPXA0rbFDI4XjJvmI3nkO1uUUZZuRnWiDWJG3o1w2ICOp5Xjx4nKybetcG314Rwyah9BY_cFyOOTVaz9ib2iYwCPgQTQqlMo0_n5NtkIyrA8xa46u8nQzsRXNgMI04_qmq8HJ115Ckd9FxFzHE009BZTtUCnAU5RGvX1DNzt73i6xDw0_0h3-qiu3ml4CLGwI76ezbHaJXYu0tN5I9UaxklRPU07CCkYrrYT9BKO4HgzxQ00gCTkHGEwofHwlAB1vIsKPkCAIhMSIDGuhhXlfHAq8QWzoVBZI5F1MIeAVzTE97EH3BG0iA-gGlHoLzvOlfprPcMKoYpn3HckjygC7MHMppM2GCkIDCMeT9WaYT5S931U2cvRu3J-E0EPmPIPCIrJBSXiMdIwdp6s9p8qXRQ2mkvK7EDJUHkYmjmVA-WBmBdkm6AZ2oOh96yz3Zgdwb0FwRe4MOO7RwsV4glf7qONvObMLgLmI6g9NxwMG22TY-kSz-InsbGdoaPdAskGN1oZZnWz5pjV5PvRfN_RthlEL7lVpAC8C_f8g2CZ3jy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3jzaK_OevUXYRpVa-dDN805imLpJE4AiBL-hJMCN3bQBn-NgDe1Ky61UuqPoSbS9eF-y9_w_HZjjaN4tS7SaEnMWoDQkDkkTc-RsR24cdYed3GkkzS_z0l7Iq_h5w3k4EvTVF1vOglxnKlkBtk44sW3JPi-g8b4lHEOXuOIQm7wWP7tTg6Wp8UKOVMa5AUaa46KpIjUDbD3Hwe_i4YJgygKWwLVqiUAG-KLv9-Zw_kfKi86WyXJnX7GaCW-pCoggP764gY7fNZ-JfFtRWXTt1ydzINQ3r8tecU8LM_o7gfFUWlequbeNWCb1sywI3iyQS19au7O_R6M8yg3fOnAsdX0uI0M29ljqvoX6JfD9UoKNy0D2C_vbd6k0-118Y61CC5do-1EgyRPSAX2mKWP_TlUsuHyT6xcoFfu2tYwbb2l_LYOI9AKmbjboDaI99Sfk0gasfmLVfsfZF50NuNeH_F_uRnV_Aare0VaO1ep4H8Ogy6WXYyr3tF7QAjVtKfYcwbhFKFv8GHi-KMFNOHzA9YbJSqrHP_AttwhFpdwmE66KQHrJynBUrAhj6dIBtv1Zqcj6UGQu3ipNSBIUcuwe9VKWSfxYKYePcGAQmTA46yaVbJFf1yek74zCRnGoMidi1NS2zLprKncBy41PKX5KnFaDw-o-iGMliJn6H8hUWXp63pIHaM5IxHP2Mxkj9ZRLjbiP2YplWh1cQCCBMb-P8BBo54W7DnyzKGlPS8OqC0MjLflba8sSSFsjIX3WCdjIJoQ3yTSuH3SG8lwuniSlXExsX2uaqh_g4HcmC6xsSoKa_fG0fduUoOw-0b-hs_tgH9YFuhoib2JPCHWoQmIGuZslHLX4hGd2-O0FymMk6FeMYtkVuOd1oCsjL1SIqLZtvjO9ppCUSQHOYEUMXsaTe3_9k")); @@ -53,10 +52,6 @@ public void testDecodeSuccess() { when(mockOpenJpegHelper.createDecompression(JP2CodecFormat.CODEC_JP2)).thenReturn(dInfo); when(mockOpenJpegHelper.decode(dInfo, cio, false)).thenReturn(image); - // Mock other methods and responses as needed - // ... - - // Act Response info = openJpegDecoder.decode(requestInfo); logger.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_EMPTY, MessageFormat.format("INFO :: WIDTH \t= {0}", info.getResponse().getImageWidth())); logger.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_EMPTY, MessageFormat.format("INFO :: HEIGHT \t= {0}", info.getResponse().getImageHeight())); @@ -73,8 +68,5 @@ public void testDecodeSuccess() { // Assert assertEquals(0, info.getStatusCode()); assertEquals(DecoderErrorCodes.SUCCESS.getErrorMessage(), info.getStatusMessage()); - // Add more assertions as needed } - - // Additional test cases to cover all paths } \ No newline at end of file diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegEncodeVariantsTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegEncodeVariantsTest.java new file mode 100644 index 0000000..87098a9 --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegEncodeVariantsTest.java @@ -0,0 +1,250 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.stream.Stream; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.junit.jupiter.params.provider.MethodSource; + +import io.mosip.imagedecoder.model.openjpeg.Cio; +import io.mosip.imagedecoder.model.openjpeg.CodeStreamInfo; +import io.mosip.imagedecoder.model.openjpeg.CompressionContextInfo; +import io.mosip.imagedecoder.model.openjpeg.CompressionParameters; +import io.mosip.imagedecoder.model.openjpeg.DecompressionContextInfo; +import io.mosip.imagedecoder.model.openjpeg.DecompressionParameters; +import io.mosip.imagedecoder.model.openjpeg.JP2CodecFormat; +import io.mosip.imagedecoder.model.openjpeg.Jp2ColorSpace; +import io.mosip.imagedecoder.model.openjpeg.OpenJpegImage; +import io.mosip.imagedecoder.model.openjpeg.OpenJpegImageComponentParameters; +import io.mosip.imagedecoder.model.openjpeg.ProgressionOrder; +import io.mosip.imagedecoder.openjpeg.CioHelper; +import io.mosip.imagedecoder.openjpeg.ImageHelper; +import io.mosip.imagedecoder.openjpeg.OpenJpegHelper; + +/** + * Encode variants that hit rare OpenJPEG paths: progression orders, tiles, + * fixed-quality, ROI, code-block / resolution knobs, decodeWithInfo. + */ +class OpenJpegEncodeVariantsTest { + + private OpenJpegHelper codec; + + @BeforeEach + void setUp() { + codec = new OpenJpegHelper(); + } + + @ParameterizedTest(name = "prog {0}") + @EnumSource(value = ProgressionOrder.class, names = { "LRCP", "RLCP", "RPCL", "PCRL", "CPRL" }) + void encodeDecodeEachProgressionOrder(ProgressionOrder order) { + OpenJpegImage image = gray(24, 24); + CompressionParameters params = baseParams(); + params.setProgressionOrder(order); + byte[] encoded = encode(JP2CodecFormat.CODEC_J2K, image, params, false); + assertTrue(encoded.length > 20, order.name()); + assertNotNull(decode(JP2CodecFormat.CODEC_J2K, encoded, false)); + } + + @Test + void encodeMultiTileHitsTcdInitEncode() { + OpenJpegImage image = gray(64, 64); + CompressionParameters params = baseParams(); + params.setTileSizeOn(1); + params.setCpTileDX(32); + params.setCpTileDY(32); + params.setCpTileX0(0); + params.setCpTileY0(0); + byte[] encoded = encode(JP2CodecFormat.CODEC_JP2, image, params, false); + assertTrue(encoded.length > 100); + // multi-tile round-trip may still fail on unfinished port edges; encode path is the coverage goal + } + + @Test + void encodeFixedQualityLayers() { + OpenJpegImage image = gray(32, 32); + CompressionParameters params = baseParams(); + params.setCpDistortionAllocation(0); + params.setCpFixedQuality(1); + params.setTcpNoOfLayers(2); + params.setTcpDistortionRatio(new float[] { 30f, 40f }); + params.setTcpRates(new float[] { 0f, 0f }); + byte[] encoded = encode(JP2CodecFormat.CODEC_J2K, image, params, false); + assertTrue(encoded.length > 30); + } + + @Test + void encodeWithRoiAndFewerResolutions() { + OpenJpegImage image = gray(40, 40); + CompressionParameters params = baseParams(); + params.setNoOfResolution(3); + params.setRoiCompNo(0); + params.setRoiShift(3); + params.setCodeBlockWidthInit(32); + params.setCodeBlockHeightInit(32); + byte[] encoded = encode(JP2CodecFormat.CODEC_JP2, image, params, false); + assertTrue(encoded.length > 40); + assertNotNull(decode(JP2CodecFormat.CODEC_JP2, encoded, false)); + } + + @Test + void encodeRgbMctIrreversibleMultiLayer() { + OpenJpegImage image = rgb(28, 28); + CompressionParameters params = baseParams(); + params.setIrreversible(1); + params.setTcpMct(1); + params.setTcpNoOfLayers(2); + params.setTcpRates(new float[] { 30f, 15f }); + params.setProgressionOrder(ProgressionOrder.RPCL); + byte[] encoded = encode(JP2CodecFormat.CODEC_JP2, image, params, false); + assertTrue(encoded.length > 80); + assertNotNull(decode(JP2CodecFormat.CODEC_JP2, encoded, false)); + } + + @Test + void encodeWithTileParts() { + OpenJpegImage image = gray(32, 32); + CompressionParameters params = baseParams(); + params.setTpOn(1); + params.setTpFlag(0); // tile-part on component + params.setProgressionOrder(ProgressionOrder.PCRL); + byte[] encoded = encode(JP2CodecFormat.CODEC_J2K, image, params, false); + assertTrue(encoded.length > 30); + } + + @Test + void encodeSmallCodeBlocksAndPrecincts() { + OpenJpegImage image = gray(48, 48); + CompressionParameters params = baseParams(); + params.setNoOfResolution(4); + params.setCodeBlockWidthInit(16); + params.setCodeBlockHeightInit(16); + params.setCodingStyle(0x01); // precincts + params.setResSpec(4); + for (int i = 0; i < 4; i++) { + params.getPrecinctWidthInit()[i] = 8; + params.getPrecinctHeightInit()[i] = 8; + } + params.setProgressionOrder(ProgressionOrder.CPRL); + byte[] encoded = encode(JP2CodecFormat.CODEC_JP2, image, params, false); + assertTrue(encoded.length > 50); + assertNotNull(decode(JP2CodecFormat.CODEC_JP2, encoded, false)); + } + + @Test + void decodeWithInfoAfterEncode() { + OpenJpegImage image = gray(16, 16); + byte[] encoded = encode(JP2CodecFormat.CODEC_JP2, image, baseParams(), false); + DecompressionContextInfo dInfo = codec.createDecompression(JP2CodecFormat.CODEC_JP2); + DecompressionParameters params = new DecompressionParameters(); + codec.setDefaultDecoderParameters(params, false); + codec.setupDecoder(dInfo, params, false); + Cio cio = CioHelper.getInstance().cioOpen(dInfo, encoded, encoded.length); + CodeStreamInfo csi = new CodeStreamInfo(); + OpenJpegImage decoded = codec.decodeWithInfo(dInfo, cio, csi, false); + assertNotNull(decoded); + CioHelper.getInstance().cioClose(cio); + codec.destroyCodeStreamInfo(csi); + codec.destroyDecompression(dInfo); + } + + static Stream formats() { + return Stream.of(JP2CodecFormat.CODEC_J2K, JP2CodecFormat.CODEC_JP2); + } + + @ParameterizedTest + @MethodSource("formats") + void encodeCommentAndIrreversibleGray(JP2CodecFormat format) { + OpenJpegImage image = gray(20, 20); + CompressionParameters params = baseParams(); + params.setIrreversible(1); + params.setCpComment("coverage".toCharArray()); + params.setNoOfResolution(5); + byte[] encoded = encode(format, image, params, false); + assertTrue(encoded.length > 20); + assertNotNull(decode(format, encoded, false)); + } + + private CompressionParameters baseParams() { + CompressionParameters params = new CompressionParameters(); + codec.setDefaultEncodeParameters(params, false); + params.setTcpNoOfLayers(1); + params.setTcpRates(new float[] { 0f }); + return params; + } + + private byte[] encode(JP2CodecFormat format, OpenJpegImage image, CompressionParameters params, boolean jpwl) { + CompressionContextInfo cInfo = codec.createCompression(format); + codec.setupEncoder(cInfo, params, image, jpwl); + Cio cio = CioHelper.getInstance().cioOpen(cInfo, null, 0); + int r = codec.encode(cInfo, cio, image, null, jpwl); + assertEquals(0, r, "encode failed for " + format); + int len = CioHelper.getInstance().cioTell(cio); + byte[] out = new byte[len]; + System.arraycopy(cio.getBuffer(), 0, out, 0, len); + CioHelper.getInstance().cioClose(cio); + codec.destroyCompression(cInfo); + return out; + } + + private OpenJpegImage decode(JP2CodecFormat format, byte[] data, boolean jpwl) { + DecompressionContextInfo dInfo = codec.createDecompression(format); + DecompressionParameters params = new DecompressionParameters(); + codec.setDefaultDecoderParameters(params, jpwl); + codec.setupDecoder(dInfo, params, jpwl); + Cio cio = CioHelper.getInstance().cioOpen(dInfo, data, data.length); + OpenJpegImage image = codec.decode(dInfo, cio, jpwl); + CioHelper.getInstance().cioClose(cio); + codec.destroyDecompression(dInfo); + return image; + } + + private static OpenJpegImage gray(int w, int h) { + OpenJpegImageComponentParameters[] parms = { component(w, h) }; + OpenJpegImage image = ImageHelper.getInstance().imageCreate(1, parms, Jp2ColorSpace.CLRSPC_GRAY); + image.setX0(0); + image.setY0(0); + image.setX1(w); + image.setY1(h); + fill(image.getComps()[0].getData()); + return image; + } + + private static OpenJpegImage rgb(int w, int h) { + OpenJpegImageComponentParameters[] parms = { component(w, h), component(w, h), component(w, h) }; + OpenJpegImage image = ImageHelper.getInstance().imageCreate(3, parms, Jp2ColorSpace.CLRSPC_SRGB); + image.setX0(0); + image.setY0(0); + image.setX1(w); + image.setY1(h); + for (int c = 0; c < 3; c++) { + fill(image.getComps()[c].getData()); + } + return image; + } + + private static OpenJpegImageComponentParameters component(int w, int h) { + OpenJpegImageComponentParameters p = new OpenJpegImageComponentParameters(); + p.setDx(1); + p.setDy(1); + p.setWidth(w); + p.setHeight(h); + p.setX0(0); + p.setY0(0); + p.setPrec(8); + p.setBpp(8); + p.setSgnd(0); + return p; + } + + private static void fill(int[] data) { + for (int i = 0; i < data.length; i++) { + data[i] = (i * 7) % 256; + } + } +} diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegHelperTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegHelperTest.java new file mode 100644 index 0000000..54dd66c --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegHelperTest.java @@ -0,0 +1,136 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import io.mosip.imagedecoder.model.openjpeg.CodeStreamInfo; +import io.mosip.imagedecoder.model.openjpeg.CompressionContextInfo; +import io.mosip.imagedecoder.model.openjpeg.CompressionParameters; +import io.mosip.imagedecoder.model.openjpeg.DecompressionContextInfo; +import io.mosip.imagedecoder.model.openjpeg.DecompressionParameters; +import io.mosip.imagedecoder.model.openjpeg.JP2CodecFormat; +import io.mosip.imagedecoder.model.openjpeg.OpenJpegImage; +import io.mosip.imagedecoder.model.openjpeg.OpenJpegImageComponent; +import io.mosip.imagedecoder.openjpeg.OpenJpegHelper; + +class OpenJpegHelperTest { + + private OpenJpegHelper helper; + + @BeforeEach + void setUp() { + helper = new OpenJpegHelper(); + } + + @Test + void versionIsNonEmpty() { + assertNotNull(helper.version()); + assertEquals(false, helper.version().isBlank()); + } + + @Test + void createAndDestroyDecompressionJp2() { + DecompressionContextInfo dInfo = helper.createDecompression(JP2CodecFormat.CODEC_JP2); + assertNotNull(dInfo); + assertEquals(JP2CodecFormat.CODEC_JP2, dInfo.getContextInfo().getCodecFormat()); + assertDoesNotThrow(() -> helper.destroyDecompression(dInfo)); + assertDoesNotThrow(() -> helper.destroyDecompression(null)); + } + + @Test + void createDecompressionJ2kAndJpt() { + assertNotNull(helper.createDecompression(JP2CodecFormat.CODEC_J2K)); + assertNotNull(helper.createDecompression(JP2CodecFormat.CODEC_JPT)); + } + + @Test + void createDecompressionUnknownReturnsNull() { + assertNull(helper.createDecompression(JP2CodecFormat.CODEC_UNKNOWN)); + } + + @Test + void setDefaultDecoderParameters() { + DecompressionParameters params = new DecompressionParameters(); + helper.setDefaultDecoderParameters(params, false); + assertEquals(0, params.getCpLayer()); + assertEquals(0, params.getCpReduce()); + helper.setDefaultDecoderParameters(params, true); + assertEquals(0, params.getJpwlCorrect()); + assertDoesNotThrow(() -> helper.setDefaultDecoderParameters(null, true)); + } + + @Test + void setupDecoderJp2() { + DecompressionContextInfo dInfo = helper.createDecompression(JP2CodecFormat.CODEC_JP2); + DecompressionParameters params = new DecompressionParameters(); + helper.setDefaultDecoderParameters(params, false); + assertDoesNotThrow(() -> helper.setupDecoder(dInfo, params, false)); + assertDoesNotThrow(() -> helper.setupDecoder(null, params, false)); + assertDoesNotThrow(() -> helper.setupDecoder(dInfo, null, false)); + helper.destroyDecompression(dInfo); + } + + @Test + void createAndDestroyCompressionJ2k() { + CompressionContextInfo cInfo = helper.createCompression(JP2CodecFormat.CODEC_J2K); + assertNotNull(cInfo); + assertDoesNotThrow(() -> helper.destroyCompression(cInfo)); + assertNull(helper.createCompression(JP2CodecFormat.CODEC_JPT)); + } + + @Test + void setupEncoderAndEncodeNullSafe() { + CompressionContextInfo cInfo = helper.createCompression(JP2CodecFormat.CODEC_JP2); + CompressionParameters params = new CompressionParameters(); + helper.setDefaultEncodeParameters(params, false); + OpenJpegImage image = new OpenJpegImage(); + image.setNoOfComps(1); + OpenJpegImageComponent comp = new OpenJpegImageComponent(); + comp.setWidth(8); + comp.setHeight(8); + comp.setData(new int[64]); + image.setComps(new OpenJpegImageComponent[] { comp }); + // setupEncoder needs a fully initialized codec handle — null args stay safe + assertDoesNotThrow(() -> helper.setupEncoder(null, params, image, false)); + assertDoesNotThrow(() -> helper.setupEncoder(cInfo, null, image, false)); + assertDoesNotThrow(() -> helper.setupEncoder(cInfo, params, null, false)); + assertDoesNotThrow(() -> helper.encode(null, null, null, null, false)); + assertDoesNotThrow(() -> helper.encode(cInfo, null, image, new char[] { 'x' }, false)); + assertDoesNotThrow(() -> helper.encodeWithInfo(null, null, null, null, false)); + helper.destroyCompression(cInfo); + } + + @Test + void decodeWithInfoAndDestroyCodeStreamInfo() { + DecompressionContextInfo dInfo = helper.createDecompression(JP2CodecFormat.CODEC_J2K); + DecompressionParameters params = new DecompressionParameters(); + helper.setDefaultDecoderParameters(params, true); + helper.setupDecoder(dInfo, params, true); + assertNull(helper.decodeWithInfo(dInfo, null, null, false)); + CodeStreamInfo csi = new CodeStreamInfo(); + assertDoesNotThrow(() -> helper.destroyCodeStreamInfo(csi)); + helper.destroyDecompression(dInfo); + + DecompressionContextInfo jpt = helper.createDecompression(JP2CodecFormat.CODEC_JPT); + helper.setupDecoder(jpt, params, false); + helper.destroyDecompression(jpt); + } + + @Test + void setDefaultEncodeParameters() { + CompressionParameters params = new CompressionParameters(); + helper.setDefaultEncodeParameters(params, false); + assertDoesNotThrow(() -> helper.setDefaultEncodeParameters(null, true)); + helper.setDefaultEncodeParameters(params, true); + } + + @Test + void destroyCodeStreamInfoNullSafe() { + assertDoesNotThrow(() -> helper.destroyCodeStreamInfo(null)); + } +} diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegRarePathsTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegRarePathsTest.java new file mode 100644 index 0000000..9d6e928 --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/OpenJpegRarePathsTest.java @@ -0,0 +1,238 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +import io.mosip.imagedecoder.model.openjpeg.Cio; +import io.mosip.imagedecoder.model.openjpeg.CompressionContextInfo; +import io.mosip.imagedecoder.model.openjpeg.CompressionParameters; +import io.mosip.imagedecoder.model.openjpeg.DecompressionContextInfo; +import io.mosip.imagedecoder.model.openjpeg.DecompressionParameters; +import io.mosip.imagedecoder.model.openjpeg.JP2CodecFormat; +import io.mosip.imagedecoder.model.openjpeg.Jp2ColorSpace; +import io.mosip.imagedecoder.model.openjpeg.OpenJpegImage; +import io.mosip.imagedecoder.model.openjpeg.OpenJpegImageComponentParameters; +import io.mosip.imagedecoder.model.openjpeg.Poc; +import io.mosip.imagedecoder.model.openjpeg.ProgressionOrder; +import io.mosip.imagedecoder.openjpeg.CioHelper; +import io.mosip.imagedecoder.openjpeg.ImageHelper; +import io.mosip.imagedecoder.openjpeg.OpenJpegHelper; + +/** + * Rare OpenJPEG encoder options: fixed-layer allocation, progression order + * changes (POC), tile-part flags, JPWL EPC and odd-sized irreversible DWT. + */ +class OpenJpegRarePathsTest { + + private OpenJpegHelper codec; + + @BeforeEach + void setUp() { + codec = new OpenJpegHelper(); + } + + @Test + void encodeFixedLayerAllocationWithMatrix() { + OpenJpegImage image = gray(32, 32); + CompressionParameters params = baseParams(); + int layers = 2; + int resolutions = 3; + params.setNoOfResolution(resolutions); + params.setTcpNoOfLayers(layers); + params.setTcpRates(new float[] { 0f, 0f }); + params.setCpDistortionAllocation(0); + params.setCpFixedQuality(0); + params.setCpFixedAllocation(1); + int[] matrice = new int[layers * resolutions * 3]; + for (int i = 0; i < matrice.length; i++) { + matrice[i] = i < resolutions * 3 ? 4 : 8; + } + params.setCpMatrice(matrice); + byte[] encoded = encode(JP2CodecFormat.CODEC_J2K, image, params, false); + assertTrue(encoded.length > 20); + assertNotNull(decode(JP2CodecFormat.CODEC_J2K, encoded, false)); + } + + @Test + void encodeWithProgressionOrderChanges() { + OpenJpegImage image = rgb(24, 24); + CompressionParameters params = baseParams(); + params.setNoOfResolution(3); + params.setTcpNoOfLayers(2); + params.setTcpRates(new float[] { 20f, 0f }); + params.setNoOfPocs(2); + params.getPocs()[0] = poc(0, 0, 1, 2, 3, ProgressionOrder.LRCP); + params.getPocs()[1] = poc(2, 0, 2, 3, 3, ProgressionOrder.RLCP); + // Decoding POC codestreams from this encoder is not yet supported by the port. + byte[] encoded = encode(JP2CodecFormat.CODEC_J2K, image, params, false); + assertTrue(encoded.length > 20); + } + + @ParameterizedTest(name = "tile-part flag {0} with {1}, encode only") + @CsvSource({ "R,RPCL", "L,RLCP", "R,LRCP", "C,CPRL", "C,PCRL" }) + void encodeTilePartsByFlagEncodeOnly(char flag, ProgressionOrder order) { + OpenJpegImage image = rgb(32, 32); + CompressionParameters params = baseParams(); + params.setNoOfResolution(3); + params.setTcpNoOfLayers(2); + params.setTcpRates(new float[] { 30f, 0f }); + params.setTpOn(1); + params.setTpFlag(flag); + params.setProgressionOrder(order); + assertTrue(encode(JP2CodecFormat.CODEC_J2K, image, params, false).length > 20); + } + + @ParameterizedTest(name = "tile-part flag {0} with {1}") + @CsvSource({ "P,PCRL" }) + void encodeTilePartsByFlag(char flag, ProgressionOrder order) { + OpenJpegImage image = rgb(32, 32); + CompressionParameters params = baseParams(); + params.setNoOfResolution(3); + params.setTcpNoOfLayers(2); + params.setTcpRates(new float[] { 30f, 0f }); + params.setTpOn(1); + params.setTpFlag(flag); + params.setProgressionOrder(order); + byte[] encoded = encode(JP2CodecFormat.CODEC_J2K, image, params, false); + assertTrue(encoded.length > 20); + assertNotNull(decode(JP2CodecFormat.CODEC_J2K, encoded, false)); + } + + @Test + void encodeJpwlWithEpcProtection() { + OpenJpegImage image = gray(16, 16); + CompressionParameters params = new CompressionParameters(); + codec.setDefaultEncodeParameters(params, true); + params.setTcpNoOfLayers(1); + params.setTcpRates(new float[] { 0f }); + params.setJpwlEpcOn(1); + params.setJpwlHprotMH(1); + params.getJpwlPprot()[0] = 1; + params.setJpwlSensSize(1); + params.setJpwlSensMH(1); + byte[] encoded = encode(JP2CodecFormat.CODEC_J2K, image, params, true); + assertTrue(encoded.length > 20); + } + + @ParameterizedTest(name = "irreversible {0}x{1}") + @CsvSource({ "33,17", "17,33", "7,5", "1,9", "9,1" }) + void encodeOddSizedIrreversible(int w, int h) { + OpenJpegImage image = gray(w, h); + CompressionParameters params = baseParams(); + params.setIrreversible(1); + params.setNoOfResolution(3); + byte[] encoded = encode(JP2CodecFormat.CODEC_J2K, image, params, false); + assertTrue(encoded.length > 10); + OpenJpegImage decoded = decode(JP2CodecFormat.CODEC_J2K, encoded, false); + assertNotNull(decoded); + assertEquals(w, decoded.getComps()[0].getWidth()); + } + + @ParameterizedTest(name = "reversible {0}x{1}") + @CsvSource({ "33,17", "7,5", "1,9", "9,1" }) + void encodeOddSizedReversible(int w, int h) { + OpenJpegImage image = gray(w, h); + CompressionParameters params = baseParams(); + params.setNoOfResolution(3); + byte[] encoded = encode(JP2CodecFormat.CODEC_J2K, image, params, false); + OpenJpegImage decoded = decode(JP2CodecFormat.CODEC_J2K, encoded, false); + assertNotNull(decoded); + assertEquals(h, decoded.getComps()[0].getHeight()); + } + + private static Poc poc(int resNo0, int compNo0, int layNo1, int resNo1, int compNo1, ProgressionOrder order) { + Poc poc = new Poc(); + poc.setResNo0(resNo0); + poc.setCompNo0(compNo0); + poc.setLayNo1(layNo1); + poc.setResNo1(resNo1); + poc.setCompNo1(compNo1); + poc.setProgressionOrder1(order); + poc.setTile(-1); + return poc; + } + + private CompressionParameters baseParams() { + CompressionParameters params = new CompressionParameters(); + codec.setDefaultEncodeParameters(params, false); + params.setTcpNoOfLayers(1); + params.setTcpRates(new float[] { 0f }); + return params; + } + + private byte[] encode(JP2CodecFormat format, OpenJpegImage image, CompressionParameters params, boolean jpwl) { + CompressionContextInfo cInfo = codec.createCompression(format); + codec.setupEncoder(cInfo, params, image, jpwl); + Cio cio = CioHelper.getInstance().cioOpen(cInfo, null, 0); + int r = codec.encode(cInfo, cio, image, null, jpwl); + assertEquals(0, r, "encode failed for " + format); + int len = CioHelper.getInstance().cioTell(cio); + byte[] out = new byte[len]; + System.arraycopy(cio.getBuffer(), 0, out, 0, len); + CioHelper.getInstance().cioClose(cio); + codec.destroyCompression(cInfo); + return out; + } + + private OpenJpegImage decode(JP2CodecFormat format, byte[] data, boolean jpwl) { + DecompressionContextInfo dInfo = codec.createDecompression(format); + DecompressionParameters params = new DecompressionParameters(); + codec.setDefaultDecoderParameters(params, jpwl); + codec.setupDecoder(dInfo, params, jpwl); + Cio cio = CioHelper.getInstance().cioOpen(dInfo, data, data.length); + OpenJpegImage image = codec.decode(dInfo, cio, jpwl); + CioHelper.getInstance().cioClose(cio); + codec.destroyDecompression(dInfo); + return image; + } + + private static OpenJpegImage gray(int w, int h) { + OpenJpegImageComponentParameters[] parms = { component(w, h) }; + OpenJpegImage image = ImageHelper.getInstance().imageCreate(1, parms, Jp2ColorSpace.CLRSPC_GRAY); + image.setX0(0); + image.setY0(0); + image.setX1(w); + image.setY1(h); + fill(image.getComps()[0].getData()); + return image; + } + + private static OpenJpegImage rgb(int w, int h) { + OpenJpegImageComponentParameters[] parms = { component(w, h), component(w, h), component(w, h) }; + OpenJpegImage image = ImageHelper.getInstance().imageCreate(3, parms, Jp2ColorSpace.CLRSPC_SRGB); + image.setX0(0); + image.setY0(0); + image.setX1(w); + image.setY1(h); + for (int c = 0; c < 3; c++) { + fill(image.getComps()[c].getData()); + } + return image; + } + + private static OpenJpegImageComponentParameters component(int w, int h) { + OpenJpegImageComponentParameters p = new OpenJpegImageComponentParameters(); + p.setDx(1); + p.setDy(1); + p.setWidth(w); + p.setHeight(h); + p.setX0(0); + p.setY0(0); + p.setPrec(8); + p.setBpp(8); + p.setSgnd(0); + return p; + } + + private static void fill(int[] data) { + for (int i = 0; i < data.length; i++) { + data[i] = (i * 13) % 256; + } + } +} diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/SampleBiometricDecoderTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/SampleBiometricDecoderTest.java new file mode 100644 index 0000000..e3893e7 --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/SampleBiometricDecoderTest.java @@ -0,0 +1,86 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; +import java.io.InputStream; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import io.mosip.imagedecoder.model.DecoderRequestInfo; +import io.mosip.imagedecoder.model.DecoderResponseInfo; +import io.mosip.imagedecoder.model.Response; +import io.mosip.imagedecoder.openjpeg.OpenJpegDecoder; +import io.mosip.imagedecoder.wsq.WsqDecoder; + +/** + * Decodes sample biometric JP2/WSQ fixtures to exercise codec helpers beyond + * the single embedded base64 samples. + */ +class SampleBiometricDecoderTest { + + static Stream jp2Resources() { + return Stream.of( + "biometric/info_face_auth.jp2", + "biometric/info_face_registration.jp2", + "biometric/info_finger_left_index_auth.jp2", + "biometric/info_finger_left_index_registration.jp2", + "biometric/info_iris_left_auth.jp2", + "biometric/info_iris_left_registration.jp2"); + } + + static Stream wsqResources() { + return Stream.of( + "biometric/info_finger_left_thumb_auth.wsq", + "biometric/Left_Index.wsq", + "biometric/Left_Little.wsq", + "biometric/Left_Middle.wsq", + "biometric/Left_Ring.wsq", + "biometric/Left_Thumb.wsq", + "biometric/Right_Index.wsq", + "biometric/Right_Little.wsq", + "biometric/Right_Ring.wsq", + "biometric/Right_Thumb.wsq"); + } + + @ParameterizedTest(name = "JP2 {0}") + @MethodSource("jp2Resources") + void decodeJp2Sample(String resource) throws IOException { + byte[] data = readResource(resource); + DecoderRequestInfo req = new DecoderRequestInfo(); + req.setImageData(data); + req.setBufferedImage(true); + Response info = new OpenJpegDecoder().decode(req); + assertEquals(0, info.getStatusCode(), () -> "JP2 decode failed for " + resource + ": " + info.getStatusMessage()); + assertNotNull(info.getResponse()); + assertTrue(Integer.parseInt(info.getResponse().getImageWidth()) > 0); + assertTrue(Integer.parseInt(info.getResponse().getImageHeight()) > 0); + assertNotNull(info.getResponse().getBufferedImage()); + } + + @ParameterizedTest(name = "WSQ {0}") + @MethodSource("wsqResources") + void decodeWsqSample(String resource) throws IOException { + byte[] data = readResource(resource); + DecoderRequestInfo req = new DecoderRequestInfo(); + req.setImageData(data); + req.setBufferedImage(true); + Response info = new WsqDecoder().decode(req); + assertEquals(0, info.getStatusCode(), () -> "WSQ decode failed for " + resource + ": " + info.getStatusMessage()); + assertNotNull(info.getResponse()); + assertTrue(Integer.parseInt(info.getResponse().getImageWidth()) > 0); + assertTrue(Integer.parseInt(info.getResponse().getImageHeight()) > 0); + assertNotNull(info.getResponse().getBufferedImage()); + } + + private static byte[] readResource(String name) throws IOException { + try (InputStream in = SampleBiometricDecoderTest.class.getClassLoader().getResourceAsStream(name)) { + assertNotNull(in, "missing test resource " + name); + return in.readAllBytes(); + } + } +} diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/UtilTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/UtilTest.java new file mode 100644 index 0000000..569d988 --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/UtilTest.java @@ -0,0 +1,1459 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.awt.image.BufferedImage; +import java.awt.image.DataBufferByte; +import java.math.BigInteger; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +import io.mosip.imagedecoder.constant.DecoderConstant; +import io.mosip.imagedecoder.constant.DecoderErrorCodes; +import io.mosip.imagedecoder.constant.wsq.WsqConstant; +import io.mosip.imagedecoder.exceptions.DecoderException; +import io.mosip.imagedecoder.model.ByteBufferContext; +import io.mosip.imagedecoder.model.openjpeg.Jp2ColorSpace; +import io.mosip.imagedecoder.model.openjpeg.OpenJpegImage; +import io.mosip.imagedecoder.model.openjpeg.OpenJpegImageComponent; +import io.mosip.imagedecoder.model.wsq.WsqQuantization; +import io.mosip.imagedecoder.model.wsq.WsqQuantizationTree; +import io.mosip.imagedecoder.model.wsq.WsqTableDqt; +import io.mosip.imagedecoder.model.wsq.WsqWavletTree; +import io.mosip.imagedecoder.util.Base64UrlUtil; +import io.mosip.imagedecoder.util.ByteStreamUtil; +import io.mosip.imagedecoder.util.ByteSwapperUtil; +import io.mosip.imagedecoder.util.StringUtil; +import io.mosip.imagedecoder.util.openjpeg.ImageUtil; +import io.mosip.imagedecoder.util.wsq.WsqUtil; + +class UtilTest { + private Base64UrlUtil base64UrlUtil; + private ByteStreamUtil byteStreamUtil; + private ByteBufferContext byteBufferContext; + private ByteSwapperUtil byteSwapperUtil; + private StringUtil stringUtil; + + private WsqUtil wsqUtil; + + private ImageUtil imageUtil; + + @BeforeEach + void setUp() { + base64UrlUtil = Base64UrlUtil.getInstance(); + byteStreamUtil = ByteStreamUtil.getInstance(); + byteBufferContext = new ByteBufferContext(); + + byteSwapperUtil = ByteSwapperUtil.getInstance(); + stringUtil = StringUtil.getInstance(); + + wsqUtil = WsqUtil.getInstance(); + + imageUtil = ImageUtil.getInstance(); + } + + @Test + void testBase64UrlUtilSingletonInstance() { + Base64UrlUtil instance1 = Base64UrlUtil.getInstance(); + Base64UrlUtil instance2 = Base64UrlUtil.getInstance(); + assertSame(instance1, instance2, "Instances should be the same"); + } + + @Test + void testBase64UrlUtilEncodeToURLSafeBase64_byteArray() { + byte[] input = "test".getBytes(); + String encoded = base64UrlUtil.encodeToURLSafeBase64(input); + assertNotNull(encoded, "Encoded value should not be null"); + assertEquals("dGVzdA", encoded, "Incorrect Base64 encoding"); + } + + @Test + void testBase64UrlUtilEncodeToURLSafeBase64_string() { + String input = "test"; + String encoded = base64UrlUtil.encodeToURLSafeBase64(input); + assertNotNull(encoded, "Encoded value should not be null"); + assertEquals("dGVzdA", encoded, "Incorrect Base64 encoding"); + } + + @Test + void testBase64UrlUtilDecodeURLSafeBase64_byteArray() { + byte[] input = "dGVzdA".getBytes(); + byte[] decoded = base64UrlUtil.decodeURLSafeBase64(input); + assertNotNull(decoded, "Decoded value should not be null"); + assertArrayEquals("test".getBytes(), decoded, "Incorrect Base64 decoding"); + } + + @Test + void testBase64UrlUtilDecodeURLSafeBase64_string() { + String input = "dGVzdA"; + byte[] decoded = base64UrlUtil.decodeURLSafeBase64(input); + assertNotNull(decoded, "Decoded value should not be null"); + assertArrayEquals("test".getBytes(), decoded, "Incorrect Base64 decoding"); + } + + @Test + void testBase64UrlUtilDecodeURLSafeBase64_nullInput() { + assertThrows(DecoderException.class, () -> base64UrlUtil.decodeURLSafeBase64((byte[]) null), + "Should throw DecoderException for null input"); + + assertThrows(DecoderException.class, () -> base64UrlUtil.decodeURLSafeBase64((String) null), + "Should throw DecoderException for null input"); + } + + @Test + void testBase64UrlUtilIsNullEmpty_byteArray() { + assertTrue(base64UrlUtil.isNullEmpty((byte[]) null), "Should return true for null byte array"); + assertTrue(base64UrlUtil.isNullEmpty(new byte[0]), "Should return true for empty byte array"); + assertFalse(base64UrlUtil.isNullEmpty("test".getBytes()), "Should return false for non-empty byte array"); + } + + @Test + void testBase64UrlUtilIsNullEmpty_string() { + assertTrue(base64UrlUtil.isNullEmpty((String) null), "Should return true for null string"); + assertTrue(base64UrlUtil.isNullEmpty(""), "Should return true for empty string"); + assertTrue(base64UrlUtil.isNullEmpty(" "), "Should return true for whitespace string"); + assertFalse(base64UrlUtil.isNullEmpty("test"), "Should return false for non-empty string"); + } + + @Test + void testBase64UrlUtilDecodeInvalidBase64() { + String invalidBase64 = null; + assertThrows(Exception.class, () -> base64UrlUtil.decodeURLSafeBase64(invalidBase64), + "Should throw Exception for invalid Base64 input"); + } + + @Test + void testByteStreamUtilGetByteOrder() { + assertEquals(ByteOrder.nativeOrder(), byteStreamUtil.getByteOrder()); + } + + @Test + void testByteStreamUtilArraySize() { + String[] testArray = { "A", "B", "C" }; + assertEquals(3, byteStreamUtil.arraySize(testArray)); + } + + @Test + void testByteStreamUtilInitWithValidBuffer() { + byte[] buf = { 1, 2, 3, 4 }; + byteStreamUtil.init(byteBufferContext, buf, buf.length); + assertEquals(0, byteBufferContext.getBuffer().position()); + assertEquals(4, byteBufferContext.getBuffer().capacity()); + } + + @Test + void testByteStreamUtilInitWithNegativeSize() { + byte[] buf = { 1, 2, 3, 4 }; + DecoderException exception = assertThrows(DecoderException.class, () -> { + byteStreamUtil.init(byteBufferContext, buf, -1); + }); + assertEquals(DecoderErrorCodes.INVALID_DATA_ERROR.getErrorCode(), exception.getErrorCode()); + } + + @Test + void testByteStreamUtilGetBuffer() { + byte[] buf = { 1, 2, 3, 4, 5 }; + byteStreamUtil.init(byteBufferContext, buf, buf.length); + byte[] target = new byte[3]; + int bytesRead = byteStreamUtil.getBuffer(byteBufferContext, target, 3); + + assertEquals(3, bytesRead); + assertArrayEquals(new byte[] { 1, 2, 3 }, target); + assertEquals(3, byteBufferContext.getBuffer().position()); + } + + @Test + void testByteStreamUtilGetBytesLeft() { + byte[] buf = { 1, 2, 3, 4 }; + byteStreamUtil.init(byteBufferContext, buf, buf.length); + byteStreamUtil.getBuffer(byteBufferContext, new byte[2], 2); + assertEquals(2, byteStreamUtil.getBytesLeft(byteBufferContext)); + } + + @Test + void testByteStreamUtilSkipBytesForSize() { + byte[] buf = { 1, 2, 3, 4, 5 }; + byteStreamUtil.init(byteBufferContext, buf, buf.length); + byteStreamUtil.skipBytesForSize(byteBufferContext, 2); + assertEquals(2, byteBufferContext.getBuffer().position()); + } + + @Test + void testByteStreamUtilCurrentSize() { + byte[] buf = { 1, 2, 3, 4 }; + byteStreamUtil.init(byteBufferContext, buf, buf.length); + byteStreamUtil.getBuffer(byteBufferContext, new byte[2], 2); + assertEquals(2, byteStreamUtil.currentSize(byteBufferContext)); + } + + @Test + void testByteStreamUtilGetByte() { + byte[] buf = { 0x01 }; + byteStreamUtil.init(byteBufferContext, buf, buf.length); + assertEquals(1, byteStreamUtil.getByte(byteBufferContext)); + } + + @Test + void testByteStreamUtilGetShort() { + byte[] buf = { 0x01, 0x02 }; + byteStreamUtil.init(byteBufferContext, buf, buf.length); + assertEquals(258, byteStreamUtil.getShort(byteBufferContext)); + } + + @Test + void testByteStreamUtilGet3Bytes() { + byte[] buf = { 0x01, 0x02, 0x03 }; + byteStreamUtil.init(byteBufferContext, buf, buf.length); + assertEquals(66051, byteStreamUtil.get3Bytes(byteBufferContext)); + } + + @Test + void testByteStreamUtilGetInt() { + byte[] buf = { 0x01, 0x02, 0x03, 0x04 }; + byteStreamUtil.init(byteBufferContext, buf, buf.length); + assertEquals(16909060, byteStreamUtil.getInt(byteBufferContext)); + } + + @Test + void testByteStreamUtilGetUByte() { + byte[] buf = { 0x01 }; + byteStreamUtil.init(byteBufferContext, buf, buf.length); + assertEquals(1, byteStreamUtil.getUByte(byteBufferContext)); + } + + @Test + void testByteStreamUtilGetUShort() { + byte[] buf = { 0x01, 0x02 }; + byteStreamUtil.init(byteBufferContext, buf, buf.length); + assertEquals(258, byteStreamUtil.getUShort(byteBufferContext)); + } + + @Test + void testByteStreamUtilGetU3Bytes() { + byte[] buf = { 0x01, 0x02, 0x03 }; + byteStreamUtil.init(byteBufferContext, buf, buf.length); + assertEquals(66051, byteStreamUtil.getU3Bytes(byteBufferContext)); + } + + @Test + void testByteStreamUtilGetUInt() { + byte[] buf = { 0x01, 0x02, 0x03, 0x04 }; + byteStreamUtil.init(byteBufferContext, buf, buf.length); + assertEquals(16909060, byteStreamUtil.getUInt(byteBufferContext)); + } + + @Test + void testByteStreamUtilAsUnsignedByte() { + assertEquals(0, byteStreamUtil.asUnsignedByte((byte) 0)); + assertEquals(255, byteStreamUtil.asUnsignedByte((byte) -1)); // -1 as unsigned is 255 + assertEquals(127, byteStreamUtil.asUnsignedByte((byte) 127)); + } + + @Test + void testByteStreamUtilAsSignedByte() { + assertEquals(0, byteStreamUtil.asSignedByte((byte) 0)); + assertEquals(-1, byteStreamUtil.asSignedByte((byte) -1)); // -1 remains -1 + assertEquals(127, byteStreamUtil.asSignedByte((byte) 127)); + } + + @Test + void testByteStreamUtilAsUnsignedShort() { + assertEquals(0, byteStreamUtil.asUnsignedShort((short) 0)); + assertEquals(65535, byteStreamUtil.asUnsignedShort((short) -1)); // -1 as unsigned is 65535 + assertEquals(32767, byteStreamUtil.asUnsignedShort((short) 32767)); + } + + @Test + void testByteStreamUtilAsSignedShort() { + assertEquals(0, byteStreamUtil.asSignedShort((short) 0)); + assertEquals(-1, byteStreamUtil.asSignedShort((short) -1)); // -1 remains -1 + assertEquals(32767, byteStreamUtil.asSignedShort((short) 32767)); + } + + @Test + void testByteStreamUtilMemCompare() { + int[] a = { 1, 2, 3 }; + int[] b = { 1, 2, 3 }; + assertEquals(0, byteStreamUtil.memCompare(a, b, 3)); + + int[] c = { 1, 2, 4 }; + assertTrue(byteStreamUtil.memCompare(a, c, 3) < 0); // a < c + + int[] d = { 1, 2, 2 }; + assertTrue(byteStreamUtil.memCompare(a, d, 3) > 0); // a > d + + int[] e = { 1, 2 }; // Smaller size + assertThrows(ArrayIndexOutOfBoundsException.class, () -> { + byteStreamUtil.memCompare(a, e, 3); // sz is larger than e's length + }); + } + + @Test + void testByteStreamUtilAvClip() { + assertEquals(5, byteStreamUtil.avClip(5, 0, 10)); // Within range + assertEquals(0, byteStreamUtil.avClip(-5, 0, 10)); // Below min + assertEquals(10, byteStreamUtil.avClip(15, 0, 10)); // Above max + assertEquals(0, byteStreamUtil.avClip(0, 0, 10)); // At min + assertEquals(10, byteStreamUtil.avClip(10, 0, 10)); // At max + } + + @Test + void testByteStreamUtilMakeTag() { + assertEquals(0x64636261, byteStreamUtil.makeTag('a', 'b', 'c', 'd')); // 'd' is the highest byte + assertEquals(0x00000000, byteStreamUtil.makeTag('\0', '\0', '\0', '\0')); // All zeros + assertEquals(0x7f7f7f7f, byteStreamUtil.makeTag('\u007F', '\u007F', '\u007F', '\u007F')); // Maximum ASCII char + } + + @Test + void testByteStreamUtilMakeBETag() { + assertEquals(0x61626364, byteStreamUtil.makeBETag('a', 'b', 'c', 'd')); // 'a' is the highest byte + assertEquals(0x00000000, byteStreamUtil.makeBETag('\0', '\0', '\0', '\0')); // All zeros + assertEquals(0x7f7f7f7f, byteStreamUtil.makeBETag('\u007F', '\u007F', '\u007F', '\u007F')); // Maximum ASCII + // char + } + + @Test + void testByteStreamUtilFfErrorTag() { + assertEquals(-1633837924, byteStreamUtil.ffErrorTag('a', 'b', 'c', 'd')); // Negative of makeTag result + assertEquals(-0, byteStreamUtil.ffErrorTag('\0', '\0', '\0', '\0')); // All zeros + assertEquals(-2139062143, byteStreamUtil.ffErrorTag('\u007F', '\u007F', '\u007F', '\u007F')); // Negative of max + // ASCII char + } + + @Test + void testByteStreamUtilCopyDirectBuffer() { + ByteBuffer original = ByteBuffer.allocateDirect(10); + original.put(new byte[] { 1, 2, 3, 4, 5 }); + original.flip(); // Prepare buffer for reading + + ByteBuffer copy = byteStreamUtil.copy(original, false); + + assertEquals(original.limit(), copy.limit()); + assertEquals(original.order(), copy.order()); + } + + @Test + void testByteStreamUtilPeekUByte() { + ByteBufferContext context = new ByteBufferContext(); + context.setBuffer(ByteBuffer.allocate(10)); + context.getBuffer().put(new byte[] { (byte) 0xFF }); // Unsigned byte value (255) + context.getBuffer().flip(); // Prepare buffer for reading + + long value = byteStreamUtil.peekUByte(context); + + assertEquals(255, value); + assertEquals(0, context.getBuffer().position()); // Ensure position is unchanged + } + + @Test + void testByteStreamUtilPeekUShort() { + ByteBufferContext context = new ByteBufferContext(); + context.setBuffer(ByteBuffer.allocate(10)); + context.getBuffer().putShort((short) 0xFFFF); // Unsigned short value (65535) + context.getBuffer().flip(); // Prepare buffer for reading + + long value = byteStreamUtil.peekUShort(context); + + assertEquals(65535, value); + assertEquals(0, context.getBuffer().position()); // Ensure position is unchanged + } + + @Test + void testByteStreamUtilPeekU3Bytes() { + ByteBufferContext context = new ByteBufferContext(); + context.setBuffer(ByteBuffer.allocate(10)); + context.getBuffer().put(new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }); // Unsigned 3 bytes (16777215) + context.getBuffer().flip(); // Prepare buffer for reading + + long value = byteStreamUtil.peekU3Bytes(context); + + assertEquals(16777215, value); + assertEquals(0, context.getBuffer().position()); // Ensure position is unchanged + } + + @Test + void testByteStreamUtilPeekUInt() { + ByteBufferContext context = new ByteBufferContext(); + context.setBuffer(ByteBuffer.allocate(10)); + context.getBuffer().putInt(0xFFFFFFFF); // Unsigned int value (4294967295) + context.getBuffer().flip(); // Prepare buffer for reading + + long value = byteStreamUtil.peekUInt(context); + + assertEquals(4294967295L, value); + assertEquals(0, context.getBuffer().position()); // Ensure position is unchanged + } + + @Test + void testByteStreamUtilCopyNonDirectBuffer() { + ByteBuffer original = ByteBuffer.allocate(10); + original.put(new byte[] { 1, 2, 3, 4, 5 }); + original.flip(); // Prepare buffer for reading + + ByteBuffer copy = byteStreamUtil.copy(original, false); + + assertEquals(original.limit(), copy.limit()); + assertEquals(original.order(), copy.order()); + } + + @Test + void testByteStreamUtilPeekByte() { + ByteBufferContext context = new ByteBufferContext(); + context.setBuffer(ByteBuffer.allocate(10)); + context.getBuffer().put(new byte[] { 10 }); + context.getBuffer().flip(); // Prepare buffer for reading + + long value = byteStreamUtil.peekByte(context); + + assertEquals(10, value); + assertEquals(0, context.getBuffer().position()); // Ensure position is unchanged + } + + @Test + void testByteStreamUtilPeekShort() { + ByteBufferContext context = new ByteBufferContext(); + context.setBuffer(ByteBuffer.allocate(10)); + context.getBuffer().putShort((short) 20); + context.getBuffer().flip(); // Prepare buffer for reading + + long value = byteStreamUtil.peekShort(context); + + assertEquals(20, value); + assertEquals(0, context.getBuffer().position()); // Ensure position is unchanged + } + + @Test + void testByteStreamUtilPeekInt() { + ByteBufferContext context = new ByteBufferContext(); + context.setBuffer(ByteBuffer.allocate(10)); + context.getBuffer().putInt(30); + context.getBuffer().flip(); // Prepare buffer for reading + + long value = byteStreamUtil.peekInt(context); + + assertEquals(30, value); + assertEquals(0, context.getBuffer().position()); // Ensure position is unchanged + } + + @Test + void testByteStreamUtilSeek() { + ByteBufferContext context = new ByteBufferContext(); + context.setBuffer(ByteBuffer.allocate(10)); + context.getBuffer().put(new byte[] { 1, 2, 3, 4, 5 }); + context.getBuffer().flip(); // Prepare buffer for reading + + int newPos = byteStreamUtil.seek(context, 2, DecoderConstant.WHENCE_SEEK_SET); + assertEquals(2, newPos); + assertEquals(2, context.getBuffer().position()); // Ensure position is updated + + newPos = byteStreamUtil.seek(context, -1, DecoderConstant.WHENCE_SEEK_CUR); + assertEquals(1, newPos); + assertEquals(1, context.getBuffer().position()); // Ensure position is updated + + newPos = byteStreamUtil.seek(context, -1, DecoderConstant.WHENCE_SEEK_END); + assertEquals(3, newPos); // Ensure correct seeking to end + assertEquals(3, context.getBuffer().position()); // Ensure position is updated + } + + @Test + void testByteStreamUtilInvalidSeek() { + ByteBufferContext context = new ByteBufferContext(); + context.setBuffer(ByteBuffer.allocate(10)); + context.getBuffer().put(new byte[] { 1, 2, 3, 4, 5 }); + context.getBuffer().flip(); // Prepare buffer for reading + + assertThrows(DecoderException.class, () -> { + byteStreamUtil.seek(context, 0, -1); // Invalid whence + }); + } + + @Test + void testByteStreamUtilToUnsignedBigInteger_PositiveValue() { + long input = 123456789L; + BigInteger expected = BigInteger.valueOf(input); + + BigInteger result = byteStreamUtil.toUnsignedBigInteger(input); + + assertEquals(expected, result); + } + + @Test + void testByteStreamUtilToUnsignedBigInteger_NegativeValue() { + long input = -123456789L; // Negative long value + // Expected value will be (2^32 + input) + BigInteger expected = BigInteger.valueOf(Integer.toUnsignedLong(-1)).shiftLeft(32) + .add(BigInteger.valueOf(Integer.toUnsignedLong(-123456789))); + + BigInteger result = byteStreamUtil.toUnsignedBigInteger(input); + + assertEquals(expected, result); + } + + @Test + void testByteStreamUtilToUnsignedBigInteger_Zero() { + long input = 0L; + BigInteger expected = BigInteger.valueOf(input); + + BigInteger result = byteStreamUtil.toUnsignedBigInteger(input); + + assertEquals(expected, result); + } + + @Test + void testByteStreamUtilToUnsignedBigInteger_MaxLongValue() { + long input = Long.MAX_VALUE; // Maximum long value + BigInteger expected = BigInteger.valueOf(input); + + BigInteger result = byteStreamUtil.toUnsignedBigInteger(input); + + assertEquals(expected, result); + } + + @Test + void testByteStreamUtilToUnsignedBigInteger_MinLongValue() { + long input = Long.MIN_VALUE; // Minimum long value + BigInteger expected = BigInteger.ONE.shiftLeft(63); // This represents 2^63 + + BigInteger result = byteStreamUtil.toUnsignedBigInteger(input); + + assertEquals(expected, result); + } + + @Test + void testByteStreamUtilToUnsignedBigInteger_NegativeUpperBound() { + long input = -1L; // Edge case for the smallest negative value + BigInteger expected = BigInteger.valueOf(Integer.toUnsignedLong(-1)).shiftLeft(32) + .add(BigInteger.valueOf(Integer.toUnsignedLong(-1))); + + BigInteger result = byteStreamUtil.toUnsignedBigInteger(input); + + assertEquals(expected, result); + } + + @Test + void testByteStreamUtilSkipBytes_ValidCase() { + ByteBuffer buffer = ByteBuffer.allocate(10); + buffer.put(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); + buffer.flip(); // Prepare buffer for reading + byteBufferContext.setBuffer(buffer); + + // Set initial position + buffer.position(2); + + // Skip 3 bytes + byteStreamUtil.skipBytesForSize(byteBufferContext, 3); + + // Verify new position + assertEquals(5, buffer.position()); + } + + @Test + void testByteStreamUtilSkipBytesForSizeU_ValidSkip() { + ByteBuffer buffer = ByteBuffer.allocate(10); + buffer.put(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); + buffer.flip(); // Prepare buffer for reading + byteBufferContext.setBuffer(buffer); + + // Set initial position + buffer.position(2); + + // Skip 3 bytes + byteStreamUtil.skipBytesForSizeU(byteBufferContext, 3); + + // Verify new position + assertEquals(5, buffer.position()); + } + + @Test + void testByteStreamUtilGetUnsignedLong_BigEndian() { + ByteBuffer buffer = ByteBuffer.allocate(8); + buffer.order(ByteOrder.BIG_ENDIAN); + buffer.put(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }); // 1 as unsigned long + buffer.flip(); // Prepare buffer for reading + + BigInteger result = byteStreamUtil.getUnsignedLong(buffer, 0, ByteOrder.BIG_ENDIAN); + + assertEquals(BigInteger.ONE, result); + } + + @Test + void testByteStreamUtilGetUnsignedLong_LittleEndian() { + ByteBuffer buffer = ByteBuffer.allocate(8); + buffer.order(ByteOrder.LITTLE_ENDIAN); + buffer.put(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0 }); // 1 as unsigned long + buffer.flip(); // Prepare buffer for reading + + BigInteger result = byteStreamUtil.getUnsignedLong(buffer, 0, ByteOrder.LITTLE_ENDIAN); + + assertEquals(BigInteger.ONE, result); + } + + @Test + void testByteStreamUtilGetUnsignedLong_Zero() { + ByteBuffer buffer = ByteBuffer.allocate(8); + buffer.put(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }); // 0 as unsigned long + buffer.flip(); // Prepare buffer for reading + + BigInteger result = byteStreamUtil.getUnsignedLong(buffer, 0, ByteOrder.BIG_ENDIAN); + + assertEquals(BigInteger.ZERO, result); + } + + @Test + void testByteStreamUtilGetUnsignedLong_MaxValue_BigEndian() { + ByteBuffer buffer = ByteBuffer.allocate(8); + buffer.order(ByteOrder.BIG_ENDIAN); + buffer.put(new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF }); + buffer.flip(); + + // Ported assembly sign-extends each byte before shift (not pure unsigned 2^64-1) + BigInteger result = byteStreamUtil.getUnsignedLong(buffer, 0, ByteOrder.BIG_ENDIAN); + assertEquals(new BigInteger("18374403900871474943"), result); + } + + @Test + void testByteStreamUtilGetUnsignedLong_MaxValue_LittleEndian() { + ByteBuffer buffer = ByteBuffer.allocate(8); + buffer.order(ByteOrder.LITTLE_ENDIAN); + buffer.put(new byte[] { -1, -1, -1, -1, -1, -1, -1, 127 }); + buffer.flip(); + + BigInteger result = byteStreamUtil.getUnsignedLong(buffer, 0, ByteOrder.LITTLE_ENDIAN); + assertEquals(new BigInteger("9151031864016699135"), result); + } + + @Test + void testByteStreamUtilGetSignedLong_BigEndian() { + ByteBuffer buffer = ByteBuffer.allocate(8); + buffer.order(ByteOrder.BIG_ENDIAN); + buffer.put(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }); // 1 as signed long + buffer.flip(); // Prepare buffer for reading + + BigInteger result = byteStreamUtil.getSignedLong(buffer, 0, ByteOrder.BIG_ENDIAN); + + assertEquals(BigInteger.ONE, result); + } + + @Test + void testByteStreamUtilGetSignedLong_LittleEndian() { + ByteBuffer buffer = ByteBuffer.allocate(8); + buffer.order(ByteOrder.LITTLE_ENDIAN); + buffer.put(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0 }); // 1 as signed long + buffer.flip(); // Prepare buffer for reading + + BigInteger result = byteStreamUtil.getSignedLong(buffer, 0, ByteOrder.LITTLE_ENDIAN); + + assertEquals(BigInteger.ONE, result); + } + + @Test + void testByteStreamUtilGetSignedLong_NegativeValue_BigEndian() { + ByteBuffer buffer = ByteBuffer.allocate(8); + buffer.order(ByteOrder.BIG_ENDIAN); + buffer.put(new byte[] { -1, -1, -1, -1, -1, -1, -1, -1 }); + buffer.flip(); + + BigInteger result = byteStreamUtil.getSignedLong(buffer, 0, ByteOrder.BIG_ENDIAN); + assertEquals(new BigInteger("-72340172838076673"), result); + } + + @Test + void testByteStreamUtilGetSignedLong_NegativeValue_LittleEndian() { + ByteBuffer buffer = ByteBuffer.allocate(8); + buffer.order(ByteOrder.LITTLE_ENDIAN); + buffer.put(new byte[] { -1, -1, -1, -1, -1, -1, -1, -1 }); + buffer.flip(); + + BigInteger result = byteStreamUtil.getSignedLong(buffer, 0, ByteOrder.LITTLE_ENDIAN); + assertEquals(new BigInteger("-72340172838076673"), result); + } + + @Test + void testByteStreamUtilGetSignedLong_MaxValue_BigEndian() { + ByteBuffer buffer = ByteBuffer.allocate(8); + buffer.order(ByteOrder.BIG_ENDIAN); + buffer.put(new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF }); + buffer.flip(); + + BigInteger result = byteStreamUtil.getUnsignedLong(buffer, 0, ByteOrder.BIG_ENDIAN); + assertEquals(new BigInteger("18374403900871474943"), result); + } + + @Test + void testByteStreamUtilGetSignedLong_MinValue_BigEndian() { + ByteBuffer buffer = ByteBuffer.allocate(8); + buffer.order(ByteOrder.BIG_ENDIAN); + buffer.put(new byte[] { -128, 0, 0, 0, 0, 0, 0, 0 }); // Min signed long value + buffer.flip(); // Prepare buffer for reading + + BigInteger result = byteStreamUtil.getSignedLong(buffer, 0, ByteOrder.BIG_ENDIAN); + + assertEquals(new BigInteger("-9223372036854775808"), result); + } + + @Test + void testByteStreamUtilGetSignedVarInt_1Byte_Positive() { + ByteBuffer buffer = ByteBuffer.allocate(1); + buffer.put((byte) 127); // 127 is the max positive value for a signed byte + long result = byteStreamUtil.getSignedVarInt(buffer, 0, 1); + assertEquals(127, result); + } + + @Test + void testByteStreamUtilGetSignedVarInt_1Byte_Negative() { + ByteBuffer buffer = ByteBuffer.allocate(1); + buffer.put((byte) -128); // -128 is the min negative value for a signed byte + long result = byteStreamUtil.getSignedVarInt(buffer, 0, 1); + assertEquals(-128, result); + } + + @Test + void testByteStreamUtilGetSignedVarInt_2Bytes_Positive() { + ByteBuffer buffer = ByteBuffer.allocate(2); + buffer.putShort((short) 32767); // 32767 is the max positive value for a signed short + buffer.flip(); // Prepare buffer for reading + long result = byteStreamUtil.getSignedVarInt(buffer, 0, 2); + assertEquals(32767, result); + } + + @Test + void testByteStreamUtilGetSignedVarInt_2Bytes_Negative() { + ByteBuffer buffer = ByteBuffer.allocate(2); + buffer.putShort((short) -32768); // -32768 is the min negative value for a signed short + buffer.flip(); // Prepare buffer for reading + long result = byteStreamUtil.getSignedVarInt(buffer, 0, 2); + assertEquals(-32768, result); + } + + @Test + void testByteStreamUtilGetSignedVarInt_3Bytes_Positive() { + ByteBuffer buffer = ByteBuffer.allocate(3); + buffer.order(ByteOrder.BIG_ENDIAN); + buffer.put(new byte[] { 0x7F, (byte) 0xFF, (byte) 0xFF }); + buffer.flip(); + // Per-byte sign-extension in get3SignedByteInt (not pure 24-bit 0x7FFFFF) + long result = byteStreamUtil.getSignedVarInt(buffer, 0, 3); + assertEquals(8322815, result); + } + + @Test + void testByteStreamUtilGetSignedVarInt_3Bytes_Negative() { + ByteBuffer buffer = ByteBuffer.allocate(3); + buffer.order(ByteOrder.BIG_ENDIAN); + buffer.put(new byte[] { (byte) 0x80, 0x00, 0x00 }); // Min negative 24-bit value: -8388608 + buffer.flip(); // Prepare buffer for reading + long result = byteStreamUtil.getSignedVarInt(buffer, 0, 3); + assertEquals(-8388608, result); + } + + @Test + void testByteStreamUtilGetSignedVarInt_4Bytes_Positive() { + ByteBuffer buffer = ByteBuffer.allocate(4); + buffer.order(ByteOrder.BIG_ENDIAN); + buffer.putInt(Integer.MAX_VALUE); + buffer.flip(); + // Per-byte sign-extension in getSignedInt (not pure 32-bit MAX_VALUE) + long result = byteStreamUtil.getSignedVarInt(buffer, 0, 4); + assertEquals(2130640639, result); + } + + @Test + void testByteStreamUtilGetSignedVarInt_4Bytes_Negative() { + ByteBuffer buffer = ByteBuffer.allocate(4); + buffer.order(ByteOrder.BIG_ENDIAN); + buffer.putInt(Integer.MIN_VALUE); // Min negative value for 32-bit signed int: -2147483648 + buffer.flip(); // Prepare buffer for reading + long result = byteStreamUtil.getSignedVarInt(buffer, 0, 4); + assertEquals(-2147483648, result); + } + + @Test + void testByteStreamUtilGetSignedVarInt_InvalidNumBytes() { + ByteBuffer buffer = ByteBuffer.allocate(4); + buffer.putInt(1234); + buffer.flip(); // Prepare buffer for reading + Exception exception = assertThrows(IllegalArgumentException.class, () -> { + byteStreamUtil.getSignedVarInt(buffer, 0, 5); // Invalid number of bytes + }); + assertTrue(exception.getMessage().contains("Invalid num bytes")); + } + + @Test + void testByteStreamUtilGetUnsignedVarInt_1Byte() { + ByteBuffer buffer = ByteBuffer.allocate(1); + buffer.put((byte) 0xFF); // Max value for 1 byte: 255 + buffer.flip(); // Prepare buffer for reading + long result = byteStreamUtil.getUnsignedVarInt(buffer, 0, 1); + assertEquals(255, result); + } + + @Test + void testByteStreamUtilGetUnsignedVarInt_2Bytes() { + ByteBuffer buffer = ByteBuffer.allocate(2); + buffer.putShort((short) 0xFFFF); // Max value for 2 bytes: 65535 + buffer.flip(); // Prepare buffer for reading + long result = byteStreamUtil.getUnsignedVarInt(buffer, 0, 2); + assertEquals(65535, result); + } + + @Test + void testByteStreamUtilGetUnsignedVarInt_3Bytes() { + ByteBuffer buffer = ByteBuffer.allocate(3); + buffer.put(new byte[]{(byte) 0xFF, (byte) 0xFF, (byte) 0xFF}); // Max value for 3 bytes: 16777215 + buffer.flip(); // Prepare buffer for reading + long result = byteStreamUtil.getUnsignedVarInt(buffer, 0, 3); + assertEquals(16777215, result); + } + + @Test + void testByteStreamUtilGetUnsignedVarInt_4Bytes() { + ByteBuffer buffer = ByteBuffer.allocate(4); + buffer.putInt(0xFFFFFFFF); // Max value for 4 bytes: 4294967295 + buffer.flip(); // Prepare buffer for reading + long result = byteStreamUtil.getUnsignedVarInt(buffer, 0, 4); + assertEquals(4294967295L, result); + } + + @Test + void testByteStreamUtilGetUnsignedVarInt_InvalidNumBytes() { + ByteBuffer buffer = ByteBuffer.allocate(1); + buffer.put((byte) 0xFF); + buffer.flip(); // Prepare buffer for reading + Exception exception = assertThrows(DecoderException.class, () -> { + byteStreamUtil.getUnsignedVarInt(buffer, 0, 5); // Invalid number of bytes + }); + assertTrue(exception.getMessage().contains("Invalid num bytes")); + } + + @Test + void testByteSwapperUtilSwapShort() { + short original = 0x1234; + short swapped = byteSwapperUtil.swapShort(original); + assertEquals(0x3412, swapped, "The short value should be swapped correctly"); + } + + @Test + void testByteSwapperUtilSwap3Bytes() { + int original = 0x123456; + int swapped = byteSwapperUtil.swap3Bytes(original); + assertEquals(0x563412, swapped, "The 3-byte int should be swapped correctly"); + } + + @Test + void testByteSwapperUtilSwapInt() { + int original = 0x12345678; + int swapped = byteSwapperUtil.swapInt(original); + assertEquals(0x78563412, swapped, "The int value should be swapped correctly"); + } + + @Test + void testByteSwapperUtilSwapLong() { + long original = 0x1234567890ABCDEFL; + long swapped = byteSwapperUtil.swapLong(original); + assertEquals(0xEFCDAB9078563412L, swapped, "The long value should be swapped correctly"); + } + + @Test + void testByteSwapperUtilSwapFloat() { + float original = 1234.56f; + float swapped = byteSwapperUtil.swapFloat(original); + assertNotEquals(original, swapped, "The float value should be swapped correctly"); + } + + @Test + void testByteSwapperUtilSwapDouble() { + double original = 12345678.90; + double swapped = byteSwapperUtil.swapDouble(original); + assertNotEquals(original, swapped, "The double value should be swapped correctly"); + } + + @Test + void testByteSwapperUtilSwapShortArray() { + short[] array = { 0x1234, 0x5678 }; + byteSwapperUtil.swap(array); + assertArrayEquals(new short[] { 0x3412, 0x7856 }, array, "The array of shorts should be swapped"); + } + + @Test + void testByteSwapperUtilSwapIntArray() { + int[] array = { 0x12345678, 0x90ABCDEF }; + byteSwapperUtil.swap(array); + assertArrayEquals(new int[] { 0x78563412, 0xEFCDAB90 }, array, "The array of ints should be swapped"); + } + + @Test + void testByteSwapperUtilSwapLongArray() { + long[] array = { 0x1234567890ABCDEFL, 0x0FEDCBA987654321L }; + byteSwapperUtil.swap(array); + System.out.printf("Swapped values: [%016X, %016X]%n", array[0], array[1]); + assertArrayEquals(new long[] { 0xEFCDAB9078563412L, 0x21436587A9CBED0FL }, array, + "The array of longs should be swapped"); + } + + @Test + void testByteSwapperUtilSwapFloatArray() { + float[] array = { 1234.56f, 7890.12f }; + byteSwapperUtil.swap(array); + assertNotEquals(array[0], 1234.56f); + assertNotEquals(array[1], 7890.12f); + } + + @Test + void testByteSwapperUtilSwapDoubleArray() { + double[] array = { 12345678.90, 98765432.10 }; + byteSwapperUtil.swap(array); + assertNotEquals(array[0], 12345678.90); + assertNotEquals(array[1], 98765432.10); + } + + @Test + void testStringUtilStringCompare_EqualStrings() { + assertEquals(0, stringUtil.stringCompare("Hello", "Hello"), "Strings should be equal"); + } + + @Test + void testStringUtilStringCompare_DifferentStrings() { + assertTrue(stringUtil.stringCompare("Hello", "World") < 0, "Hello should be less than World"); + assertTrue(stringUtil.stringCompare("World", "Hello") > 0, "World should be greater than Hello"); + } + + @Test + void testStringUtilStringCompare_LengthDifference() { + assertTrue(stringUtil.stringCompare("Hello", "Hello World") < 0, "Hello should be less than Hello World"); + assertTrue(stringUtil.stringCompare("Hello World", "Hello") > 0, "Hello World should be greater than Hello"); + } + + @Test + void testStringUtilAtoi_ValidInteger() { + char[] validInput = "12345".toCharArray(); + assertEquals(12345, stringUtil.atoi(validInput), "Should convert valid string to integer"); + } + + @Test + void testStringUtilAtoi_WhitespaceAndSigns() { + char[] input = " -678".toCharArray(); + assertEquals(-678, stringUtil.atoi(input), "Should handle whitespace and negative sign"); + } + + @Test + void testStringUtilAtoi_Overflow() { + char[] overflowInput = "2147483648".toCharArray(); // This is beyond Integer.MAX_VALUE + assertEquals(Integer.MAX_VALUE, stringUtil.atoi(overflowInput), "Should return Integer.MAX_VALUE on overflow"); + } + + @Test + void testStringUtilAtoi_InvalidInput() { + char[] invalidInput = "abc".toCharArray(); + assertEquals(0, stringUtil.atoi(invalidInput), "Should return 0 for invalid input"); + } + + @Test + void testStringUtilAtof_ValidDouble() { + assertEquals(123.45, stringUtil.atof("123.45"), 0.001, "Should convert valid string to double"); + } + + @Test + void testStringUtilAtof_WhitespaceAndSigns() { + assertEquals(-67.89, stringUtil.atof(" -67.89 "), 0.001, "Should handle whitespace and negative sign"); + } + + @Test + void testStringUtilAtof_InvalidDouble() { + assertEquals(0.0, stringUtil.atof("abc"), 0.001, "Should return 0.0 for invalid input"); + } + + @Test + void testStringUtilAtof_TooManySignsOrDots() { + assertEquals(0.0, stringUtil.atof("----123.45"), 0.001, + "Should return 0.0 for invalid input with too many signs"); + assertEquals(0.0, stringUtil.atof("123..45"), 0.001, "Should return 0.0 for invalid input with too many dots"); + } + + @Test + void testConvertImage2Floats() { + // Prepare data + int numOfPixels = 10; + float[] fImageData = new float[numOfPixels]; + float[] mShift = new float[1]; + float[] rScale = new float[1]; + byte[] data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + + // Execute + int result = wsqUtil.convertImage2Floats(fImageData, mShift, rScale, data, numOfPixels); + + // Verify + assertEquals(0, result); + assertNotNull(fImageData); + assertTrue(mShift[0] >= 0); + assertTrue(rScale[0] > 0); + } + + @Test + void testConvertImage2FloatsWithOverflow() { + // Prepare data that causes overflow + int numOfPixels = 5; + float[] fImageData = new float[numOfPixels]; + float[] mShift = new float[1]; + float[] rScale = new float[1]; + byte[] data = new byte[numOfPixels]; + for (int i = 0; i < numOfPixels; i++) { + data[i] = (byte) 255; // Setting max value to trigger overflow in sum + } + + // Execute + int result = wsqUtil.convertImage2Floats(fImageData, mShift, rScale, data, numOfPixels); + + // Verify + assertEquals(0, result); + } + + @Test + void testConvertImage2Bytes() { + // Prepare data + int width = 5; + int height = 2; + byte[] data = new byte[width * height]; + float[] img = { 0.0f, 128.0f, 255.0f, 300.0f, -10.0f, 100.0f, 50.0f, 200.0f, 10.0f, 150.0f }; + float mShift = 128.0f; + float rScale = 1.0f; + + // Execute + wsqUtil.convertImage2Bytes(data, img, width, height, mShift, rScale); + + // Verify + for (byte b : data) { + assertTrue(b >= -128 && b <= 128); + } + } + + @Test + void testVarianceWithVsumBelow20000() { + // Prepare data + int width = 10; + int height = 10; + float[] fImageData = new float[width * height]; + WsqQuantization quantValues = new WsqQuantization(); + quantValues.setVar(new float[WsqConstant.NUM_SUBBANDS]); + + WsqQuantizationTree[] quantizationTree = new WsqQuantizationTree[WsqConstant.NUM_SUBBANDS]; + for (int i = 0; i < quantizationTree.length; i++) { + quantizationTree[i] = new WsqQuantizationTree(); + quantizationTree[i].setX((short) 0); + quantizationTree[i].setY((short) 0); + quantizationTree[i].setLenX((short) 8); + quantizationTree[i].setLenY((short) 8); + } + + // Execute + wsqUtil.variance(quantValues, quantizationTree, quantizationTree.length, fImageData, width, height); + + // Verify + for (float var : quantValues.getVar()) { + assertTrue(var >= 0); + } + } + + @Test + void testVarianceWithVsumAbove20000() { + // Prepare data + int width = 10; + int height = 10; + float[] fImageData = new float[width * height]; + WsqQuantization quantValues = new WsqQuantization(); + quantValues.setVar(new float[WsqConstant.NUM_SUBBANDS]); + + WsqQuantizationTree[] quantizationTree = new WsqQuantizationTree[WsqConstant.NUM_SUBBANDS]; + for (int i = 0; i < quantizationTree.length; i++) { + quantizationTree[i] = new WsqQuantizationTree(); + quantizationTree[i].setX((short) 0); + quantizationTree[i].setY((short) 0); + quantizationTree[i].setLenX((short) 8); + quantizationTree[i].setLenY((short) 8); + } + + // Simulate a large `vsum` + quantValues.getVar()[0] = 25000.0f; + + // Execute + wsqUtil.variance(quantValues, quantizationTree, quantizationTree.length, fImageData, width, height); + + // Verify + for (float var1 : quantValues.getVar()) { + assertTrue(var1 >= 0); + } + } + + @Test + void testQuantize() { + // Set up test data + short[] sip = new short[100]; + int[] cmpSize = new int[1]; + WsqQuantization quantValues = new WsqQuantization(); + WsqQuantizationTree[] quantizationTree = new WsqQuantizationTree[60]; // Assuming 60 subbands + for (int i = 0; i < quantizationTree.length; i++) { + if (quantizationTree[i] == null) { // Check if the element is not already initialized + quantizationTree[i] = new WsqQuantizationTree(); + } + quantizationTree[i].setLenX((short) 10); // Example value for length X + quantizationTree[i].setLenY((short) 10); // Example value for length Y + quantizationTree[i].setX((short) 5); // Example starting X coordinate + quantizationTree[i].setY((short) 5); // Example starting Y coordinate + } + int qTreeLen = quantizationTree.length; + float[] fImageData = new float[1000]; // Example data size + int width = 100; + int height = 100; + + // Call the method + int result = wsqUtil.quantize(sip, cmpSize, quantValues, quantizationTree, qTreeLen, fImageData, width, height); + + // Add assertions to verify correctness + assertEquals(0, result); + // Additional checks for 'sip', 'cmpSize', etc. + } + + @Test + void testQuantizedBlockSizes() { + int[] qSize1 = new int[1]; + int[] qSize2 = new int[1]; + int[] qSize3 = new int[1]; + WsqQuantization quantValues = new WsqQuantization(); + WsqWavletTree[] wavletTree = new WsqWavletTree[20]; + // Initialize each element with some test data + for (int i = 0; i < wavletTree.length; i++) { + wavletTree[i] = new WsqWavletTree(); + wavletTree[i].setLenX(10); // Example value for length X + wavletTree[i].setLenY(10); // Example value for length Y + } + + WsqQuantizationTree[] quantizationTree = new WsqQuantizationTree[60]; + for (int i = 0; i < quantizationTree.length; i++) { + if (quantizationTree[i] == null) { // Check if the element is not already initialized + quantizationTree[i] = new WsqQuantizationTree(); + } + quantizationTree[i].setLenX((short) 10); // Example value for length X + quantizationTree[i].setLenY((short) 10); // Example value for length Y + quantizationTree[i].setX((short) 5); // Example starting X coordinate + quantizationTree[i].setY((short) 5); // Example starting Y coordinate + } + int waveletTreeLen = wavletTree.length; + int qTreeLen = quantizationTree.length; + + wsqUtil.quantizedBlockSizes(qSize1, qSize2, qSize3, quantValues, wavletTree, waveletTreeLen, quantizationTree, + qTreeLen); + + int expectedValue = -1800; + // Add assertions to verify correctness + // For example: + assertEquals(expectedValue, qSize1[0]); + } + + @Test + void testUnquantize() { + // Prepare test data + float[] fImageData = new float[100]; // Adjust size as necessary + WsqTableDqt dqtTable = new WsqTableDqt(); + // Initialize dqtTable properties as needed + WsqQuantizationTree[] quantizationTree = new WsqQuantizationTree[WsqConstant.NUM_SUBBANDS]; + + // Initialize the quantizationTree array + for (int i = 0; i < quantizationTree.length; i++) { + quantizationTree[i] = new WsqQuantizationTree(); + quantizationTree[i].setLenX((short) 10); // Set appropriate values + quantizationTree[i].setLenY((short) 10); + quantizationTree[i].setX((short) 5); + quantizationTree[i].setY((short) 5); + } + + long[] sip = new long[] { 0, 1, 2 }; // Example quantized values + int width = 10; // Set appropriate width + int height = 10; // Set appropriate height + + // Call the method under test + int result = wsqUtil.unquantize(fImageData, dqtTable, quantizationTree, quantizationTree.length, sip, width, + height); + + // Verify the results + assertEquals(-34, result); // Check for expected return value + // Further assertions to check the content of fImageData as needed + } + + @Test + void testWsqDecomposeNormal() { + float[] fImageData = new float[100]; // Sample image data + float[] highFilter = new float[] { 1.0f, 2.0f }; // Example filter coefficients + float[] lowFilter = new float[] { 1.0f, 2.0f }; // Example filter coefficients + + WsqWavletTree[] wavletTree = new WsqWavletTree[3]; // Adjust size as needed + for (int i = 0; i < wavletTree.length; i++) { + wavletTree[i] = new WsqWavletTree(); + wavletTree[i].setY(0); // Example values + wavletTree[i].setX(0); + wavletTree[i].setLenY(10); + wavletTree[i].setLenX(10); + wavletTree[i].setInvRow(0); + wavletTree[i].setInvCol(0); + } + int result = wsqUtil.wsqDecompose(fImageData, 10, 10, wavletTree, wavletTree.length, highFilter, + highFilter.length, lowFilter, lowFilter.length); + + assertEquals(0, result); // Expect success + // Validate fImageData or other outcomes as necessary + } + + @Test + void testImageSizeNormal() { + int blockLen = 100; + short[] huffBits1 = new short[16]; + short[] huffBits2 = new short[16]; + + // Fill huffman bits with some values + for (int i = 1; i < 16; i++) { + huffBits1[i] = (short) (i * 5); + huffBits2[i] = (short) (i * 3); + } + + int result = wsqUtil.imageSize(blockLen, huffBits1, huffBits2); + + // Calculate expected total size manually based on your understanding + int expectedSize = blockLen + 58 + 389 + 17 + 3 + 3 + 3 + 3 + 16 + (huffBits1[1] + huffBits1[2] + huffBits1[3] + + huffBits1[4] + huffBits1[5] + huffBits1[6] + huffBits1[7] + huffBits1[8] + huffBits1[9] + + huffBits1[10] + huffBits1[11] + huffBits1[12] + huffBits1[13] + huffBits1[14] + huffBits1[15]) + 3 + + 16 + + (huffBits2[1] + huffBits2[2] + huffBits2[3] + huffBits2[4] + huffBits2[5] + huffBits2[6] + + huffBits2[7] + huffBits2[8] + huffBits2[9] + huffBits2[10] + huffBits2[11] + huffBits2[12] + + huffBits2[13] + huffBits2[14] + huffBits2[15]) + + 20; + + assertEquals(expectedSize, result); + } + + @Test + void testSingleton() { + ImageUtil instance1 = ImageUtil.getInstance(); + ImageUtil instance2 = ImageUtil.getInstance(); + assertSame(instance1, instance2, "Singleton instances are not the same"); + } + + @Test + void testCalculateAspectRatio() { + assertEquals(2.0, imageUtil.calculateAspectRatio(4, 2), 0.01); + assertThrows(IllegalArgumentException.class, () -> imageUtil.calculateAspectRatio(0, 5)); + assertThrows(IllegalArgumentException.class, () -> imageUtil.calculateAspectRatio(5, -1)); + } + + @Test + void testCalculateCompressionRatio() { + // ratio = (w*h*depth)/len; if >100 then abs(100-ratio) + assertEquals(8, imageUtil.calculateCompressionRatio(100, 100, 8, 10000)); + assertEquals(700, imageUtil.calculateCompressionRatio(100, 100, 8, 100)); // 800 -> abs(100-800)=700 + assertThrows(IllegalArgumentException.class, () -> imageUtil.calculateCompressionRatio(100, 100, 1, 0)); + assertThrows(IllegalArgumentException.class, () -> imageUtil.calculateCompressionRatio(-100, 100, 1, 10000)); + } + + @Test + void testFromJ2kImageGrayscale() { + int w = 4; + int h = 4; + OpenJpegImageComponent comp = new OpenJpegImageComponent(); + comp.setWidth(w); + comp.setHeight(h); + comp.setFactor(0); + comp.setPrec(8); + comp.setDX(1); + comp.setDY(1); + comp.setData(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }); + + OpenJpegImage image = new OpenJpegImage(); + image.setNoOfComps(1); + image.setComps(new OpenJpegImageComponent[] { comp }); + + BufferedImage dib = imageUtil.fromJ2kImage(w, h, image); + assertNotNull(dib); + assertEquals(BufferedImage.TYPE_BYTE_GRAY, dib.getType()); + assertEquals(w, dib.getWidth()); + assertEquals(h, dib.getHeight()); + } + + @Test + void testFromJ2kImageRgb() { + int w = 2; + int h = 2; + OpenJpegImageComponent[] comps = new OpenJpegImageComponent[3]; + for (int i = 0; i < 3; i++) { + comps[i] = new OpenJpegImageComponent(); + comps[i].setWidth(w); + comps[i].setHeight(h); + comps[i].setFactor(0); + comps[i].setPrec(8); + comps[i].setDX(1); + comps[i].setDY(1); + comps[i].setSgnd(0); + comps[i].setData(new int[] { 10 * (i + 1), 20, 30, 40 }); + } + OpenJpegImage image = new OpenJpegImage(); + image.setNoOfComps(3); + image.setComps(comps); + BufferedImage dib = imageUtil.fromJ2kImage(w, h, image); + assertNotNull(dib); + assertEquals(BufferedImage.TYPE_INT_RGB, dib.getType()); + } + + @Test + void testFromJ2kImageRgba() { + int w = 2; + int h = 2; + OpenJpegImageComponent[] comps = new OpenJpegImageComponent[4]; + for (int i = 0; i < 4; i++) { + comps[i] = new OpenJpegImageComponent(); + comps[i].setWidth(w); + comps[i].setHeight(h); + comps[i].setFactor(0); + comps[i].setPrec(8); + comps[i].setDX(1); + comps[i].setDY(1); + comps[i].setSgnd(0); + comps[i].setData(new int[] { 50, 60, 70, 80 }); + } + OpenJpegImage image = new OpenJpegImage(); + image.setNoOfComps(4); + image.setComps(comps); + BufferedImage dib = imageUtil.fromJ2kImage(w, h, image); + assertNotNull(dib); + assertEquals(BufferedImage.TYPE_INT_ARGB, dib.getType()); + } + + @Test + void testFromJ2kImageGrayscale16Bit() { + int w = 2; + int h = 2; + OpenJpegImageComponent comp = new OpenJpegImageComponent(); + comp.setWidth(w); + comp.setHeight(h); + comp.setFactor(0); + comp.setPrec(16); + comp.setDX(1); + comp.setDY(1); + comp.setData(new int[] { 1000, 2000, 3000, 4000 }); + OpenJpegImage image = new OpenJpegImage(); + image.setNoOfComps(1); + image.setComps(new OpenJpegImageComponent[] { comp }); + BufferedImage dib = imageUtil.fromJ2kImage(w, h, image); + assertNotNull(dib); + assertEquals(BufferedImage.TYPE_USHORT_GRAY, dib.getType()); + } + + @Test + void testFromJ2kImageUnsupportedHighPrecision() { + OpenJpegImageComponent comp = new OpenJpegImageComponent(); + comp.setWidth(1); + comp.setHeight(1); + comp.setFactor(0); + comp.setPrec(32); + comp.setDX(1); + comp.setDY(1); + comp.setData(new int[] { 1 }); + OpenJpegImage image = new OpenJpegImage(); + image.setNoOfComps(1); + image.setComps(new OpenJpegImageComponent[] { comp }); + assertNull(imageUtil.fromJ2kImage(1, 1, image)); + } + + @Test + void testFromJ2kImageRgb16Bit() { + int w = 2; + int h = 2; + OpenJpegImageComponent[] comps = new OpenJpegImageComponent[3]; + for (int i = 0; i < 3; i++) { + comps[i] = new OpenJpegImageComponent(); + comps[i].setWidth(w); + comps[i].setHeight(h); + comps[i].setFactor(0); + comps[i].setPrec(16); + comps[i].setDX(1); + comps[i].setDY(1); + comps[i].setSgnd(0); + comps[i].setData(new int[] { 100, 200, 300, 400 }); + } + OpenJpegImage image = new OpenJpegImage(); + image.setNoOfComps(3); + image.setComps(comps); + BufferedImage dib = imageUtil.fromJ2kImage(w, h, image); + assertNotNull(dib); + assertEquals(BufferedImage.TYPE_INT_RGB, dib.getType()); + } + + @Test + void testFromJ2kImageUnsupportedZeroComps() { + OpenJpegImage image = new OpenJpegImage(); + image.setNoOfComps(0); + OpenJpegImageComponent comp = new OpenJpegImageComponent(); + comp.setWidth(1); + comp.setHeight(1); + comp.setFactor(0); + comp.setPrec(8); + comp.setData(new int[] { 0 }); + image.setComps(new OpenJpegImageComponent[] { comp }); + // fromJ2kImage swallows DecoderException and returns null + assertNull(imageUtil.fromJ2kImage(1, 1, image)); + } + + @Test + void testFromByteGray() { + byte[] grayData = new byte[800 * 600]; // Example data + BufferedImage grayImage = imageUtil.fromByteGray(800, 600, grayData); + assertNotNull(grayImage); + assertEquals(BufferedImage.TYPE_BYTE_GRAY, grayImage.getType()); + assertArrayEquals(grayData, ((DataBufferByte) grayImage.getRaster().getDataBuffer()).getData()); + } + + @Test + void testIntegersToBytes() { + int[] intData = { 1, 2, 3, 4, 5 }; + byte[] byteData = imageUtil.integersToBytes(intData); + assertArrayEquals(new byte[] { 1, 2, 3, 4, 5 }, byteData); + } + + private OpenJpegImage createMockOpenJpegImage() { + // Create a mocked instance of OpenJpegImage + OpenJpegImage mockImage = Mockito.mock(OpenJpegImage.class); + + // Set up the mock behavior + Mockito.when(mockImage.getX0()).thenReturn(0); + Mockito.when(mockImage.getY0()).thenReturn(0); + Mockito.when(mockImage.getX1()).thenReturn(1920); + Mockito.when(mockImage.getY1()).thenReturn(1080); + Mockito.when(mockImage.getNoOfComps()).thenReturn(3); + Mockito.when(mockImage.getQmfbid()).thenReturn(0); + Mockito.when(mockImage.getColorSpace()).thenReturn(Jp2ColorSpace.CLRSPC_SRGB); + + // Create and set up components if needed + OpenJpegImageComponent[] components = new OpenJpegImageComponent[3]; + for (int i = 0; i < 3; i++) { + components[i] = Mockito.mock(OpenJpegImageComponent.class); + Mockito.when(components[i].getData()).thenReturn(new int[1920 * 1080]); // Example data + } + Mockito.when(mockImage.getComps()).thenReturn(components); + + return mockImage; + } + + private OpenJpegImage createUnsupportedFormatImage() { + // Create a mocked instance of OpenJpegImage + return null; + } +} diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/WsqCodecMathTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/WsqCodecMathTest.java new file mode 100644 index 0000000..c629b66 --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/WsqCodecMathTest.java @@ -0,0 +1,219 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Random; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +import io.mosip.imagedecoder.constant.wsq.WsqConstant; +import io.mosip.imagedecoder.model.wsq.WsqQuantization; +import io.mosip.imagedecoder.model.wsq.WsqQuantizationTree; +import io.mosip.imagedecoder.model.wsq.WsqTableDqt; +import io.mosip.imagedecoder.model.wsq.WsqTableDtt; +import io.mosip.imagedecoder.model.wsq.WsqWavletTree; +import io.mosip.imagedecoder.util.wsq.WsqUtil; +import io.mosip.imagedecoder.wsq.WsqTreeHelper; + +/** + * WSQ wavelet decomposition / quantization / reconstruction round trips using + * the encoder-side routines of {@link WsqUtil}. + */ +class WsqCodecMathTest { + + private static final float[] LO_9 = { 0.037828455506995f, -0.023849465019380f, -0.110624404418423f, + 0.377402855612654f, 0.852698679009403f, 0.377402855612654f, -0.110624404418423f, -0.023849465019380f, + 0.037828455506995f }; + private static final float[] HI_7 = { 0.064538882628938f, -0.040689417609558f, -0.418092273222212f, + 0.788485616405664f, -0.418092273222212f, -0.040689417609558f, 0.064538882628938f }; + + private final WsqUtil util = WsqUtil.getInstance(); + + @ParameterizedTest(name = "{0}x{1} noise={2} bitrate={3}") + @CsvSource({ "128,128,60,0.75", "97,75,60,2.25", "128,96,2,0.75", "120,130,127,0.1", "80,80,127,6.0" }) + void wsqRoundTripReconstructsImage(int width, int height, int noise, float bitRate) { + byte[] pixels = texture(width, height, noise, 17L * width + height); + int n = width * height; + + float[] fImage = new float[n]; + float[] shift = new float[1]; + float[] scale = new float[1]; + assertEquals(0, util.convertImage2Floats(fImage, shift, scale, pixels, n)); + + WsqWavletTree[] wTree = waveletTree(); + WsqQuantizationTree[] qTree = quantizationTree(); + WsqTreeHelper.getInstance().buildWsqTrees(wTree, WsqConstant.W_TREELEN, qTree, WsqConstant.Q_TREELEN, width, + height); + + assertEquals(0, util.wsqDecompose(fImage, width, height, wTree, WsqConstant.W_TREELEN, HI_7.clone(), + HI_7.length, LO_9.clone(), LO_9.length)); + + WsqQuantization quant = new WsqQuantization(); + quant.setCompressionBitRate(bitRate); + util.variance(quant, qTree, WsqConstant.Q_TREELEN, fImage.clone(), width, height); + + short[] sip = new short[n]; + int[] cmpSize = new int[1]; + assertEquals(0, util.quantize(sip, cmpSize, quant, qTree, WsqConstant.Q_TREELEN, fImage, width, height)); + + int[] q1 = new int[1]; + int[] q2 = new int[1]; + int[] q3 = new int[1]; + util.quantizedBlockSizes(q1, q2, q3, quant, wTree, WsqConstant.W_TREELEN, qTree, WsqConstant.Q_TREELEN); + assertTrue(q1[0] + q2[0] + q3[0] <= n); + + WsqTableDqt dqt = new WsqTableDqt(); + dqt.setDqtDef(1); + dqt.setBinCenter(0.44f); + for (int i = 0; i < WsqConstant.MAX_SUBBANDS; i++) { + dqt.getQBin()[i] = quant.getQbss()[i]; + dqt.getZBin()[i] = quant.getQzbs()[i]; + } + long[] sipLong = new long[n]; + for (int i = 0; i < n; i++) { + sipLong[i] = sip[i]; + } + float[] restored = new float[n]; + assertEquals(0, util.unquantize(restored, dqt, qTree, WsqConstant.Q_TREELEN, sipLong, width, height)); + + WsqTableDtt dtt = dtt(LO_9, HI_7); + assertEquals(0, util.wsqReconstruct(restored, width, height, wTree, WsqConstant.W_TREELEN, dtt)); + + byte[] out = new byte[n]; + util.convertImage2Bytes(out, restored, width, height, shift[0], scale[0]); + assertTrue(meanAbsError(pixels, out) < 64.0, "reconstruction should resemble the source"); + } + + @ParameterizedTest(name = "lo={0} hi={1} len2={2} inv={3}") + @CsvSource({ "8,8,16,0", "8,8,17,1", "4,4,12,0", "4,4,13,1", "2,2,10,0", "2,2,11,1", "9,7,16,1", "9,7,17,0", + "6,2,14,0", "2,6,15,1" }) + void getLetsAndJoinLetsHandleFilterAndLengthParity(int loSize, int hiSize, int len2, int inv) { + int len1 = len2; + float[] lo = filter(loSize, 0.5f); + float[] hi = filter(hiSize, -0.25f); + float[] src = new float[len1 * len2]; + Random random = new Random(len2 * 31L + loSize); + for (int i = 0; i < src.length; i++) { + src[i] = random.nextFloat() * 200f - 100f; + } + + float[] split = new float[src.length]; + util.getLets(split, 0, src.clone(), 0, len1, len2, len2, 1, hi, hiSize, lo, loSize, inv); + float[] joined = new float[src.length]; + util.joinLets(joined, 0, split, 0, len1, len2, len2, 1, hi, hiSize, lo, loSize, inv); + + float[] column = new float[src.length]; + util.getLets(column, 0, src.clone(), 0, len2, len1, 1, len2, hi, hiSize, lo, loSize, inv); + float[] columnJoined = new float[src.length]; + util.joinLets(columnJoined, 0, column, 0, len2, len1, 1, len2, hi, hiSize, lo, loSize, inv); + + assertTrue(isFinite(joined) && isFinite(columnJoined)); + assertNotEquals(0f, sumAbs(split)); + assertEquals(filter(hiSize, -0.25f)[0], hi[0], 0f, "high-pass filter must be restored after use"); + } + + @Test + void reconstructRejectsUndefinedFilters() { + WsqWavletTree[] wTree = waveletTree(); + float[] image = new float[64 * 64]; + WsqTableDtt dtt = dtt(LO_9, HI_7); + dtt.setLowDef(0); + assertNotEquals(0, util.wsqReconstruct(image, 64, 64, wTree, WsqConstant.W_TREELEN, dtt)); + dtt.setLowDef(1); + dtt.setHighDef(0); + assertNotEquals(0, util.wsqReconstruct(image, 64, 64, wTree, WsqConstant.W_TREELEN, dtt)); + } + + @Test + void unquantizeRejectsUndefinedTable() { + WsqTableDqt dqt = new WsqTableDqt(); + assertNotEquals(0, util.unquantize(new float[16], dqt, quantizationTree(), WsqConstant.Q_TREELEN, + new long[16], 4, 4)); + } + + @Test + void convertImage2BytesClampsOutOfRange() { + byte[] out = new byte[3]; + util.convertImage2Bytes(out, new float[] { -10f, 0f, 10f }, 3, 1, 128f, 64f); + assertEquals(0, out[0]); + assertEquals((byte) 128, out[1]); + assertEquals((byte) 255, out[2]); + } + + private static WsqWavletTree[] waveletTree() { + WsqWavletTree[] tree = new WsqWavletTree[WsqConstant.W_TREELEN]; + for (int i = 0; i < tree.length; i++) { + tree[i] = new WsqWavletTree(); + } + return tree; + } + + private static WsqQuantizationTree[] quantizationTree() { + WsqQuantizationTree[] tree = new WsqQuantizationTree[WsqConstant.Q_TREELEN]; + for (int i = 0; i < tree.length; i++) { + tree[i] = new WsqQuantizationTree(); + } + return tree; + } + + private static WsqTableDtt dtt(float[] lo, float[] hi) { + WsqTableDtt dtt = new WsqTableDtt(); + dtt.setLowFilter(lo.clone()); + dtt.setHighFilter(hi.clone()); + dtt.setLowSize(lo.length); + dtt.setHighSize(hi.length); + dtt.setLowDef(1); + dtt.setHighDef(1); + return dtt; + } + + private static float[] filter(int size, float base) { + float[] f = new float[size]; + for (int i = 0; i < size; i++) { + f[i] = base / (1 + Math.abs(i - size / 2)); + } + return f; + } + + private static byte[] texture(int width, int height, int noise, long seed) { + Random random = new Random(seed); + byte[] data = new byte[width * height]; + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + int ridge = (int) (64 * Math.sin((x + y) / 3.0)); + int v = 128 + ridge + random.nextInt(2 * noise + 1) - noise; + data[y * width + x] = (byte) Math.max(0, Math.min(255, v)); + } + } + return data; + } + + private static double meanAbsError(byte[] a, byte[] b) { + long sum = 0; + for (int i = 0; i < a.length; i++) { + sum += Math.abs((a[i] & 0xff) - (b[i] & 0xff)); + } + return sum / (double) a.length; + } + + private static boolean isFinite(float[] values) { + for (float v : values) { + if (!Float.isFinite(v)) { + return false; + } + } + return true; + } + + private static float sumAbs(float[] values) { + float s = 0; + for (float v : values) { + s += Math.abs(v); + } + return s; + } +} diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/WsqDecoderTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/WsqDecoderTest.java index 5b34b78..e5baaae 100644 --- a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/WsqDecoderTest.java +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/WsqDecoderTest.java @@ -19,19 +19,19 @@ import io.mosip.imagedecoder.wsq.WsqDecoder; import io.mosip.kernel.core.logger.spi.Logger; -public class WsqDecoderTest { +class WsqDecoderTest { private static Logger logger = ImageDecoderLogger.getLogger(WsqDecoderTest.class); private WsqDecoder wsqDecoder; @BeforeEach - public void setUp() { + void setUp() { wsqDecoder = new WsqDecoder(); } @Test - public void testDecodeSuccess() { + void testDecodeSuccess() { // Arrange DecoderRequestInfo requestInfo = new DecoderRequestInfo(); requestInfo.setImageData(Base64UrlUtil.getInstance().decodeURLSafeBase64( diff --git a/imagedecoder/src/test/java/io/mosip/imagedecoder/test/WsqFetHelperTest.java b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/WsqFetHelperTest.java new file mode 100644 index 0000000..a44323e --- /dev/null +++ b/imagedecoder/src/test/java/io/mosip/imagedecoder/test/WsqFetHelperTest.java @@ -0,0 +1,120 @@ +package io.mosip.imagedecoder.test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; + +import org.junit.jupiter.api.Test; + +import io.mosip.imagedecoder.constant.wsq.WsqConstant; +import io.mosip.imagedecoder.model.ByteBufferContext; +import io.mosip.imagedecoder.model.wsq.WsqFet; +import io.mosip.imagedecoder.model.wsq.WsqHeaderForm; +import io.mosip.imagedecoder.util.ByteStreamUtil; +import io.mosip.imagedecoder.wsq.WsqFetHelper; +import io.mosip.imagedecoder.wsq.WsqFetInfoHelper; + +/** + * Covers NIST FET helpers previously excluded from JaCoCo. + */ +class WsqFetHelperTest { + + @Test + void singleton() { + assertSame(WsqFetHelper.getInstance(), WsqFetHelper.getInstance()); + assertSame(WsqFetInfoHelper.getInstance(), WsqFetInfoHelper.getInstance()); + } + + @Test + void allocUpdateExtractAndString2Fet() { + WsqFetHelper helper = WsqFetHelper.getInstance(); + WsqFet fet = helper.allocFet(8); + assertNotNull(fet); + assertEquals(0, fet.getNum()); + + assertEquals(0, helper.updateFet("PPI".toCharArray(), "500".toCharArray(), fet)); + StringBuilder value = new StringBuilder(); + assertEquals(0, helper.extractFet(value, WsqConstant.NCM_PPI.toCharArray(), fet)); + + char[] data = "LOSSY 1\nCOLORSPACE GRAY\n\0".toCharArray(); + assertEquals(0, helper.string2fet(fet, data)); + } + + @Test + void fetInfoHelperNullNistcomDefaults() { + WsqFetInfoHelper info = WsqFetInfoHelper.getInstance(); + + int[] ppi = new int[1]; + assertEquals(0, info.getWsqPPI(null, ppi)); + assertEquals(-1, ppi[0]); + + int[] lossy = new int[1]; + assertEquals(0, info.getWsqLossyFlag(null, lossy)); + assertEquals(1, lossy[0]); + + double[] bitRate = new double[1]; + assertEquals(0, info.getWsqBitRate(null, bitRate)); + assertEquals(0.0, bitRate[0], 0.001); + + StringBuilder color = new StringBuilder(); + assertEquals(0, info.getWsqColorSpace(null, color)); + } + + @Test + void fetInfoHelperWithPopulatedFet() { + WsqFetHelper helper = WsqFetHelper.getInstance(); + WsqFet fet = helper.allocFet(8); + helper.updateFet(WsqConstant.NCM_PPI.toCharArray(), "500".toCharArray(), fet); + helper.updateFet(WsqConstant.NCM_LOSSY.toCharArray(), "0".toCharArray(), fet); + helper.updateFet(WsqConstant.NCM_WSQ_RATE.toCharArray(), "0.75".toCharArray(), fet); + helper.updateFet(WsqConstant.NCM_COLORSPACE.toCharArray(), "GRAY".toCharArray(), fet); + + WsqFetInfoHelper info = WsqFetInfoHelper.getInstance(); + int[] ppi = new int[1]; + assertEquals(0, info.getWsqPPI(fet, ppi)); + assertEquals(500, ppi[0]); + + int[] lossy = new int[1]; + assertEquals(0, info.getWsqLossyFlag(fet, lossy)); + assertEquals(0, lossy[0]); + + double[] bitRate = new double[1]; + assertEquals(0, info.getWsqBitRate(fet, bitRate)); + + StringBuilder color = new StringBuilder(); + assertEquals(0, info.getWsqColorSpace(fet, color)); + assertEquals("GRAY", color.toString()); + } + + @Test + void getWsqFrameHeaderFromBuffer() { + // Minimal synthetic SOF frame payload matching getWsqFrameHeader reads + byte[] buf = new byte[] { + 0, 17, // hdrSize + 0, // black + (byte) 255, // white + 0, 10, // height + 0, 10, // width + 0, // scale mShift + 0, 100, // mShift short + 0, // scale rScale + 0, 100, // rScale short + 1, // encoder + 0, 1 // software + }; + ByteBufferContext ctx = new ByteBufferContext(); + ByteStreamUtil.getInstance().init(ctx, buf, buf.length); + WsqHeaderForm header = new WsqHeaderForm(); + assertEquals(0, WsqFetInfoHelper.getInstance().getWsqFrameHeader(header, ctx)); + assertEquals(10, header.getWidth()); + assertEquals(10, header.getHeight()); + } + + @Test + void getNistCommentsDoesNotThrowOnRandomBytes() { + WsqFet nistcom = WsqFetHelper.getInstance().allocFet(8); + byte[] data = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 }; + assertDoesNotThrow(() -> WsqFetInfoHelper.getInstance().getNistComments(nistcom, data, data.length)); + } +} diff --git a/imagedecoder/src/test/resources/biometric/Left_Index.wsq b/imagedecoder/src/test/resources/biometric/Left_Index.wsq new file mode 100644 index 0000000..3c881de Binary files /dev/null and b/imagedecoder/src/test/resources/biometric/Left_Index.wsq differ diff --git a/imagedecoder/src/test/resources/biometric/Left_Little.wsq b/imagedecoder/src/test/resources/biometric/Left_Little.wsq new file mode 100644 index 0000000..ea88df6 Binary files /dev/null and b/imagedecoder/src/test/resources/biometric/Left_Little.wsq differ diff --git a/imagedecoder/src/test/resources/biometric/Left_Middle.wsq b/imagedecoder/src/test/resources/biometric/Left_Middle.wsq new file mode 100644 index 0000000..3ce4c28 Binary files /dev/null and b/imagedecoder/src/test/resources/biometric/Left_Middle.wsq differ diff --git a/imagedecoder/src/test/resources/biometric/Left_Ring.wsq b/imagedecoder/src/test/resources/biometric/Left_Ring.wsq new file mode 100644 index 0000000..5885987 Binary files /dev/null and b/imagedecoder/src/test/resources/biometric/Left_Ring.wsq differ diff --git a/imagedecoder/src/test/resources/biometric/Left_Thumb.wsq b/imagedecoder/src/test/resources/biometric/Left_Thumb.wsq new file mode 100644 index 0000000..4562076 Binary files /dev/null and b/imagedecoder/src/test/resources/biometric/Left_Thumb.wsq differ diff --git a/imagedecoder/src/test/resources/biometric/Right_Index.wsq b/imagedecoder/src/test/resources/biometric/Right_Index.wsq new file mode 100644 index 0000000..4ba9811 Binary files /dev/null and b/imagedecoder/src/test/resources/biometric/Right_Index.wsq differ diff --git a/imagedecoder/src/test/resources/biometric/Right_Little.wsq b/imagedecoder/src/test/resources/biometric/Right_Little.wsq new file mode 100644 index 0000000..a60cd11 Binary files /dev/null and b/imagedecoder/src/test/resources/biometric/Right_Little.wsq differ diff --git a/imagedecoder/src/test/resources/biometric/Right_Ring.wsq b/imagedecoder/src/test/resources/biometric/Right_Ring.wsq new file mode 100644 index 0000000..c6978e8 Binary files /dev/null and b/imagedecoder/src/test/resources/biometric/Right_Ring.wsq differ diff --git a/imagedecoder/src/test/resources/biometric/Right_Thumb.wsq b/imagedecoder/src/test/resources/biometric/Right_Thumb.wsq new file mode 100644 index 0000000..4205e7e Binary files /dev/null and b/imagedecoder/src/test/resources/biometric/Right_Thumb.wsq differ diff --git a/imagedecoder/src/test/resources/biometric/info_face_auth.jp2 b/imagedecoder/src/test/resources/biometric/info_face_auth.jp2 new file mode 100644 index 0000000..6b5fb50 Binary files /dev/null and b/imagedecoder/src/test/resources/biometric/info_face_auth.jp2 differ diff --git a/imagedecoder/src/test/resources/biometric/info_face_registration.jp2 b/imagedecoder/src/test/resources/biometric/info_face_registration.jp2 new file mode 100644 index 0000000..35914aa Binary files /dev/null and b/imagedecoder/src/test/resources/biometric/info_face_registration.jp2 differ diff --git a/imagedecoder/src/test/resources/biometric/info_finger_left_index_auth.jp2 b/imagedecoder/src/test/resources/biometric/info_finger_left_index_auth.jp2 new file mode 100644 index 0000000..f149084 Binary files /dev/null and b/imagedecoder/src/test/resources/biometric/info_finger_left_index_auth.jp2 differ diff --git a/imagedecoder/src/test/resources/biometric/info_finger_left_index_registration.jp2 b/imagedecoder/src/test/resources/biometric/info_finger_left_index_registration.jp2 new file mode 100644 index 0000000..e1f1549 Binary files /dev/null and b/imagedecoder/src/test/resources/biometric/info_finger_left_index_registration.jp2 differ diff --git a/imagedecoder/src/test/resources/biometric/info_finger_left_thumb_auth.wsq b/imagedecoder/src/test/resources/biometric/info_finger_left_thumb_auth.wsq new file mode 100644 index 0000000..ac6c6c6 Binary files /dev/null and b/imagedecoder/src/test/resources/biometric/info_finger_left_thumb_auth.wsq differ diff --git a/imagedecoder/src/test/resources/biometric/info_iris_left_auth.jp2 b/imagedecoder/src/test/resources/biometric/info_iris_left_auth.jp2 new file mode 100644 index 0000000..3183a47 Binary files /dev/null and b/imagedecoder/src/test/resources/biometric/info_iris_left_auth.jp2 differ diff --git a/imagedecoder/src/test/resources/biometric/info_iris_left_registration.jp2 b/imagedecoder/src/test/resources/biometric/info_iris_left_registration.jp2 new file mode 100644 index 0000000..01d52bb Binary files /dev/null and b/imagedecoder/src/test/resources/biometric/info_iris_left_registration.jp2 differ diff --git a/imagedecoder/src/test/resources/sample-jp2.b64 b/imagedecoder/src/test/resources/sample-jp2.b64 new file mode 100644 index 0000000..93d9429 --- /dev/null +++ b/imagedecoder/src/test/resources/sample-jp2.b64 @@ -0,0 +1 @@ +AAAADGpQICANCocKAAAAFGZ0eXBqcDIgAAAAAGpwMiAAAABHanAyaAAAABZpaGRyAAABQAAAAPAAAwcHAAAAAAAPY29scgEAAAAAABAAAAAacmVzIAAAABJyZXNjA-gA_gPoAP4EBAAAAABqcDJj_0__UQAvAAAAAADwAAABQAAAAAAAAAAAAAAA8AAAAUAAAAAAAAAAAAADBwEBBwEBBwEB_1wAF0JnNWdMZ0xnZE8ITwhPhEbXRtdGbf9SAAwAAAABAQMEBAAA_2QADgABTFRfSlAyXzIyNv-QAAoAAAAARxgAAf-Tz-fWdJt6TanYMXQQOScICqcoIvo97xCBLu7OD1pVh0of0su2Y6YHDW-JLvHRkR3Qggjm02MRF82ipfmeXUQTeJMw4TFEB9rk6B0To6OlqQuGm2xg77x1xAlJ4Mo9MwtAXwSRPXA0rbFDI4XjJvmI3nkO1uUUZZuRnWiDWJG3o1w2ICOp5Xjx4nKybetcG314Rwyah9BY_cFyOOTVaz9ib2iYwCPgQTQqlMo0_n5NtkIyrA8xa46u8nQzsRXNgMI04_qmq8HJ115Ckd9FxFzHE009BZTtUCnAU5RGvX1DNzt73i6xDw0_0h3-qiu3ml4CLGwI76ezbHaJXYu0tN5I9UaxklRPU07CCkYrrYT9BKO4HgzxQ00gCTkHGEwofHwlAB1vIsKPkCAIhMSIDGuhhXlfHAq8QWzoVBZI5F1MIeAVzTE97EH3BG0iA-gGlHoLzvOlfprPcMKoYpn3HckjygC7MHMppM2GCkIDCMeT9WaYT5S931U2cvRu3J-E0EPmPIPCIrJBSXiMdIwdp6s9p8qXRQ2mkvK7EDJUHkYmjmVA-WBmBdkm6AZ2oOh96yz3Zgdwb0FwRe4MOO7RwsV4glf7qONvObMLgLmI6g9NxwMG22TY-kSz-InsbGdoaPdAskGN1oZZnWz5pjV5PvRfN_Rth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Z8Jcp_69gEGeSqaen5Svyy3jzaK_OevUXYRpVa-dDN805imLpJE4AiBL-hJMCN3bQBn-NgDe1Ky61UuqPoSbS9eF-y9_w_HZjjaN4tS7SaEnMWoDQkDkkTc-RsR24cdYed3GkkzS_z0l7Iq_h5w3k4EvTVF1vOglxnKlkBtk44sW3JPi-g8b4lHEOXuOIQm7wWP7tTg6Wp8UKOVMa5AUaa46KpIjUDbD3Hwe_i4YJgygKWwLVqiUAG-KLv9-Zw_kfKi86WyXJnX7GaCW-pCoggP764gY7fNZ-JfFtRWXTt1ydzINQ3r8tecU8LM_o7gfFUWlequbeNWCb1sywI3iyQS19au7O_R6M8yg3fOnAsdX0uI0M29ljqvoX6JfD9UoKNy0D2C_vbd6k0-118Y61CC5do-1EgyRPSAX2mKWP_TlUsuHyT6xcoFfu2tYwbb2l_LYOI9AKmbjboDaI99Sfk0gasfmLVfsfZF50NuNeH_F_uRnV_Aare0VaO1ep4H8Ogy6WXYyr3tF7QAjVtKfYcwbhFKFv8GHi-KMFNOHzA9YbJSqrHP_AttwhFpdwmE66KQHrJynBUrAhj6dIBtv1Zqcj6UGQu3ipNSBIUcuwe9VKWSfxYKYePcGAQmTA46yaVbJFf1yek74zCRnGoMidi1NS2zLprKncBy41PKX5KnFaDw-o-iGMliJn6H8hUWXp63pIHaM5IxHP2Mxkj9ZRLjbiP2YplWh1cQCCBMb-P8BBo54W7DnyzKGlPS8OqC0MjLflba8sSSFsjIX3WCdjIJoQ3yTSuH3SG8lwuniSlXExsX2uaqh_g4HcmC6xsSoKa_fG0fduUoOw-0b-hs_tgH9YFuhoib2JPCHWoQmIGuZslHLX4hGd2-O0FymMk6FeMYtkVuOd1oCsjL1SIqLZtvjO9ppCUSQHOYEUMXsaTe3_9k \ No newline at end of file diff --git a/imagedecoder/src/test/resources/sample-wsq.b64 b/imagedecoder/src/test/resources/sample-wsq.b64 new file mode 100644 index 0000000..efcd946 --- /dev/null +++ b/imagedecoder/src/test/resources/sample-wsq.b64 @@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w0GAAq06LRq0fuLJ87d5FnwWGj4-h_q9j9p_F-4i_Efjbv73-Zs0eMMXfuN3vfxMHtP1vg_-D978J9D_ANm59yfA_S_c2e9_E9rZ_mbn73_UpuQs_a-NQcz-42P3n_2fY3PaA8J_B0faAjz_AMHtA8d-49oCNHjkNmPjEJ_N0P5H_oePSeLu-Lsx8ec8fN-R-t8Yd8Zk_oe0BjHx0H2gIA_C2f8A1PsfxlP2Pi6HtASM9oCknpPaA07GPjDPtAQd9oHUntClM9oDXvtAph8dx-t8d99oCEHtAy4_o-0e_f-h \ No newline at end of file diff --git a/licenses/Apache-2.0.txt b/licenses/Apache-2.0.txt index acd38f0..89522cb 100644 --- a/licenses/Apache-2.0.txt +++ b/licenses/Apache-2.0.txt @@ -198,3 +198,4 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + diff --git a/licenses/BSD-2-Clause.txt b/licenses/BSD-2-Clause.txt new file mode 100644 index 0000000..64a0b64 --- /dev/null +++ b/licenses/BSD-2-Clause.txt @@ -0,0 +1,9 @@ +Copyright © 1997-present PostgreSQL Global Development Group + +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 HOLDER 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. diff --git a/licenses/BSD-3-Clause-No-Nuclear-License.txt b/licenses/BSD-3-Clause-No-Nuclear-License.txt new file mode 100644 index 0000000..07786ca --- /dev/null +++ b/licenses/BSD-3-Clause-No-Nuclear-License.txt @@ -0,0 +1,15 @@ +BSD-3-Clause-No-Nuclear-License +----------------------------------- +Copyright © 2005 Sun Microsystems, Inc. All Rights Reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistribution of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + + * Redistribution 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. + + * Neither the name of Sun Microsystems, Inc. or the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +This software is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +You acknowledge that this software is not designed, licensed or intended for use in the design, construction, operation or maintenance of any nuclear facility. diff --git a/licenses/BSD-3-Clause.txt b/licenses/BSD-3-Clause.txt new file mode 100644 index 0000000..2f67e63 --- /dev/null +++ b/licenses/BSD-3-Clause.txt @@ -0,0 +1,9 @@ +BSD-3-Clause +--------------------- +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 HOLDER 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. diff --git a/licenses/COMMON-DEVLOPMENT-AND-DISTRIBUTION-1.1.txt b/licenses/COMMON-DEVLOPMENT-AND-DISTRIBUTION-1.1.txt new file mode 100644 index 0000000..00cb825 --- /dev/null +++ b/licenses/COMMON-DEVLOPMENT-AND-DISTRIBUTION-1.1.txt @@ -0,0 +1,11 @@ +Common Development and Distribution License 1.1 + +Copyright © 1997-2010 Oracle Corporation (formerly Sun Microsystems, Inc.) + +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 HOLDER 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. diff --git "a/licenses/EPL-2.0.txt\342\200\216" b/licenses/EPL-1.0.txt similarity index 69% rename from "licenses/EPL-2.0.txt\342\200\216" rename to licenses/EPL-1.0.txt index 2375819..70ed0f3 100644 --- "a/licenses/EPL-2.0.txt\342\200\216" +++ b/licenses/EPL-1.0.txt @@ -1,20 +1,16 @@ -Eclipse Public License - v 2.0 +Eclipse Public License - v 1.0 + THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 1. DEFINITIONS "Contribution" means: - -a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and - -b) in the case of each subsequent Contributor: - -i) changes to the Program, and - -ii) additions to the Program; + a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and + b) in the case of each subsequent Contributor: + i) changes to the Program, and + ii) additions to the Program; where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. - "Contributor" means any person or entity that distributes the Program. "Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. @@ -25,52 +21,43 @@ where such changes and/or additions to the Program originate from and are distri 2. GRANT OF RIGHTS -a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. + a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. -b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. + b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. -c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. + c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. -d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. + d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. 3. REQUIREMENTS - A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: -a) it complies with the terms and conditions of this Agreement; and - -b) its license agreement: + a) it complies with the terms and conditions of this Agreement; and -i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; - -ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; - -iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and - -iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. + b) its license agreement: + i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; + ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; + iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and + iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. When the Program is made available in source code form: -a) it must be made available under this Agreement; and - -b) a copy of this Agreement must be included with each copy of the Program. + a) it must be made available under this Agreement; and + b) a copy of this Agreement must be included with each copy of the Program. Contributors may not remove or alter any copyright notices contained within the Program. Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. 4. COMMERCIAL DISTRIBUTION - Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. 5. NO WARRANTY - EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. 6. DISCLAIMER OF LIABILITY - EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), 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 OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 7. GENERAL diff --git a/licenses/EPL-2.0.txt b/licenses/EPL-2.0.txt new file mode 100644 index 0000000..78756b5 --- /dev/null +++ b/licenses/EPL-2.0.txt @@ -0,0 +1,80 @@ +Eclipse Public License - v 2.0 +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (“AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS +“Contribution” means: + +a) in the case of the initial Contributor, the initial content Distributed under this Agreement, and +b) in the case of each subsequent Contributor: +i) changes to the Program, and +ii) additions to the Program; +where such changes and/or additions to the Program originate from and are Distributed by that particular Contributor. A Contribution “originates” from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include changes or additions to the Program that are not Modified Works. +“Contributor” means any person or entity that Distributes the Program. + +“Licensed Patents” mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. + +“Program” means the Contributions Distributed in accordance with this Agreement. + +“Recipient” means anyone who receives the Program under this Agreement or any Secondary License (as applicable), including Contributors. + +“Derivative Works” shall mean any work, whether in Source Code or other form, that is based on (or derived from) the Program and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. + +“Modified Works” shall mean any work in Source Code or other form that results from an addition to, deletion from, or modification of the contents of the Program, including, for purposes of clarity any new file in Source Code form that contains any contents of the Program. Modified Works shall not include works that contain only declarations, interfaces, types, classes, structures, or files of the Program solely in each case in order to link to, bind by name, or subclass the Program or Modified Works thereof. + +“Distribute” means the acts of a) distributing or b) making available in any manner that enables the transfer of a copy. + +“Source Code” means the form of a Program preferred for making modifications, including but not limited to software source code, documentation source, and configuration files. + +“Secondary License” means either the GNU General Public License, Version 2.0, or any later versions of that license, including any exceptions or additional permissions as identified by the initial Contributor. + +2. GRANT OF RIGHTS +a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, Distribute and sublicense the Contribution of such Contributor, if any, and such Derivative Works. +b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in Source Code or other form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. +c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to Distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. +d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. +e) Notwithstanding the terms of any Secondary License, no Contributor makes additional grants to any Recipient (other than those set forth in this Agreement) as a result of such Recipient's receipt of the Program under the terms of a Secondary License (if permitted under the terms of Section 3). +3. REQUIREMENTS +3.1 If a Contributor Distributes the Program in any form, then: + +a) the Program must also be made available as Source Code, in accordance with section 3.2, and the Contributor must accompany the Program with a statement that the Source Code for the Program is available under this Agreement, and informs Recipients how to obtain it in a reasonable manner on or through a medium customarily used for software exchange; and +b) the Contributor may Distribute the Program under a license different than this Agreement, provided that such license: +i) effectively disclaims on behalf of all other Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; +ii) effectively excludes on behalf of all other Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; +iii) does not attempt to limit or alter the recipients' rights in the Source Code under section 3.2; and +iv) requires any subsequent distribution of the Program by any party to be under a license that satisfies the requirements of this section 3. +3.2 When the Program is Distributed as Source Code: + +a) it must be made available under this Agreement, or if the Program (i) is combined with other material in a separate file or files made available under a Secondary License, and (ii) the initial Contributor attached to the Source Code the notice described in Exhibit A of this Agreement, then the Program may be made available under the terms of such Secondary Licenses, and +b) a copy of this Agreement must be included with each copy of the Program. +3.3 Contributors may not remove or alter any copyright, patent, trademark, attribution notices, disclaimers of warranty, or limitations of liability (‘notices’) contained within the Program from any copy of the Program which they Distribute, provided that Contributors may add their own appropriate notices. + +4. COMMERCIAL DISTRIBUTION +Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor (“Commercial Contributor”) hereby agrees to defend and indemnify every other Contributor (“Indemnified Contributor”) against any losses, damages and costs (collectively “Losses”) arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. + +5. NO WARRANTY +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), 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 OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL +If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be Distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to Distribute the Program (including its Contributions) under the new version. + +Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. Nothing in this Agreement is intended to be enforceable by any entity that is not a Contributor or Recipient. No third-party beneficiary rights are created under this Agreement. + +Exhibit A – Form of Secondary Licenses Notice +“This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), version(s), and exceptions or additional permissions here}.” + +Simply including a copy of this Agreement, including this Exhibit A is not sufficient to license the Source Code under Secondary Licenses. + +If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. + +You may add additional accurate notices of copyright ownership. diff --git a/licenses/LGPL-3.0.txt b/licenses/LGPL-3.0.txt new file mode 100644 index 0000000..489e1fc --- /dev/null +++ b/licenses/LGPL-3.0.txt @@ -0,0 +1,304 @@ +GNU LESSER GENERAL PUBLIC LICENSE +Version 3, 29 June 2007 + +Copyright (C) 2010 Konrad Malawski + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. + +0. Additional Definitions. + +As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. + +"The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. + +An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. + +A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". + +The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. + +The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. + +1. Exception to Section 3 of the GNU GPL. +You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. + +2. Conveying Modified Versions. +If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: + + a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. + +3. Object Code Incorporating Material from Library Header Files. +The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license document. + +4. Combined Works. +You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: + + a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license document. + + c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. + + e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) + +5. Combined Libraries. +You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. + +6. Revised Versions of the GNU Lesser General Public License. +The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. + +If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. + +GNU GENERAL PUBLIC LICENSE +Version 3, 29 June 2007 + +Copyright © 2007 Free Software Foundation, Inc. + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The GNU General Public License is a free, copyleft license for software and other kinds of works. + +The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. + +Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. + +Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS + +0. Definitions. + +“This License” refers to version 3 of the GNU General Public License. + +“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. + +“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations. + +To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work. + +A “covered work” means either the unmodified Program or a work based on the Program. + +To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. + +To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. + +1. Source Code. +The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work. + +A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. + +The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. + +The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same work. + +2. Basic Permissions. +All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. + +3. Protecting Users' Legal Rights From Anti-Circumvention Law. +No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. + +4. Conveying Verbatim Copies. +You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. + +5. Conveying Modified Source Versions. +You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”. + + c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. + +A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. + +6. Conveying Non-Source Forms. +You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: + + a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. + + d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. + +A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. + +“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. + +If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. + +7. Additional Terms. +“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or authors of the material; or + + e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. + +All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. + +8. Termination. +You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. + +Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. + +9. Acceptance Not Required for Having Copies. +You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. + +10. Automatic Licensing of Downstream Recipients. +Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. + +An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. + +11. Patents. +A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”. + +A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. + +In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. + +A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. + +12. No Surrender of Others' Freedom. +If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. + +13. Use with the GNU Affero General Public License. +Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. + +14. Revised Versions of this License. +The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. + +15. Disclaimer of Warranty. +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. Limitation of Liability. +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +17. Interpretation of Sections 15 and 16. +If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”. + +You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . + +The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . diff --git a/licenses/MIT.txt b/licenses/MIT.txt index cc178a3..e22f217 100644 --- a/licenses/MIT.txt +++ b/licenses/MIT.txt @@ -1,6 +1,11 @@ The MIT License (MIT) --------------------------- -Copyright (c) 2004-2022 QOS.ch Sarl (Switzerland) +Copyright © 2009-2026 The Project Lombok Authors +Copyright © 2004-2026 QOS.ch +Copyright © 2007-2026 Mockito contributors +Copyright © 2015-2026 Auth0, Inc. +Copyright © 2000-2026 Legion of the Bouncy Castle Inc. +Copyright © 2009-2026 Jonathan Hedley Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/licenses/MOZILLA-2.0.txt b/licenses/MOZILLA-2.0.txt new file mode 100644 index 0000000..b3b8d93 --- /dev/null +++ b/licenses/MOZILLA-2.0.txt @@ -0,0 +1,151 @@ +Mozilla Public License +Version 2.0 +1. Definitions +1.1. “Contributor” +means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software. + +1.2. “Contributor Version” +means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor’s Contribution. + +1.3. “Contribution” +means Covered Software of a particular Contributor. + +1.4. “Covered Software” +means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof. + +1.5. “Incompatible With Secondary Licenses” +means + +that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or + +that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License. + +1.6. “Executable Form” +means any form of the work other than Source Code Form. + +1.7. “Larger Work” +means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. + +1.8. “License” +means this document. + +1.9. “Licensable” +means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License. + +1.10. “Modifications” +means any of the following: + +any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or + +any new file in Source Code Form that contains any Covered Software. + +1.11. “Patent Claims” of a Contributor +means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version. + +1.12. “Secondary License” +means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses. + +1.13. “Source Code Form” +means the form of the work preferred for making modifications. + +1.14. “You” (or “Your”) +means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. + +2. License Grants and Conditions +2.1. Grants +Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: + +under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and + +under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version. + +2.2. Effective Date +The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution. + +2.3. Limitations on Grant Scope +The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor: + +for any code that a Contributor has removed from Covered Software; or + +for infringements caused by: (i) Your and any other third party’s modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or + +under Patent Claims infringed by Covered Software in the absence of its Contributions. + +This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4). + +2.4. Subsequent Licenses +No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3). + +2.5. Representation +Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use +This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents. + +2.7. Conditions +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. + +3. Responsibilities +3.1. Distribution of Source Form +All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients’ rights in the Source Code Form. + +3.2. Distribution of Executable Form +If You distribute Covered Software in Executable Form then: + +such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and + +You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients’ rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work +You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s). + +3.4. Notices +You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms +You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. + +5. Termination +5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination. + +6. Disclaimer of Warranty +Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer. + +7. Limitation of Liability +Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such party’s negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You. + +8. Litigation +Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party’s ability to bring cross-claims or counter-claims. + +9. Miscellaneous +This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. + +10. Versions of the License +10.1. New Versions +Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number. + +10.2. Effect of New Versions +You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward. + +10.3. Modified Versions +If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses +If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - “Incompatible With Secondary Licenses” Notice +This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0. diff --git a/licenses/NOTICE b/licenses/NOTICE index bd0709c..f246ee3 100644 --- a/licenses/NOTICE +++ b/licenses/NOTICE @@ -4,70 +4,71 @@ COPYRIGHT NOTICES This software includes components from the following open source projects. All copyright notices must be preserved as required by their respective licenses. +Versions match Spring Boot 4.1.1 parent and imagedecoder-parent pom.xml. +Full license texts: licenses/*.txt ================================================================================ 1. SLF4J (MIT License) ================================================================================ Copyright (c) 2004-2022 QOS.ch Sarl (Switzerland) -All rights reserved. -Packages: org.slf4j:jcl-over-slf4j, org.slf4j:jul-to-slf4j -License: MIT License +Packages: org.slf4j:slf4j-api, jul-to-slf4j, jcl-over-slf4j +License: MIT License — licenses/MIT.txt Homepage: https://www.slf4j.org -Full license text: See LICENSE-MIT.txt ================================================================================ 2. Jackson (Apache License 2.0) ================================================================================ -Copyright 2007- Tatu Saloranta (tatu.saloranta@iki.fi) -Copyright 2008-present FasterXML, LLC +Copyright FasterXML, LLC Packages: com.fasterxml.jackson.core:jackson-core, jackson-databind -License: Apache License 2.0 + (Jackson 2 via org.springframework.boot:spring-boot-jackson2) +License: Apache License 2.0 — licenses/Apache-2.0.txt Homepage: https://github.com/FasterXML/jackson-core -Full license text: See LICENSE-APACHE-2.0.txt - -NOTICE: This product includes Jackson software developed by -FasterXML, LLC (http://fasterxml.com/). ================================================================================ -3. JUnit 5 (Eclipse Public License 2.0) +3. Spring Boot / Spring Framework (Apache License 2.0) ================================================================================ -Copyright (c) 2015-present The JUnit Team -Eclipse Public License - v 2.0 +Copyright VMware, Inc. / Broadcom + +Packages: org.springframework.boot:spring-boot-starter-parent 4.1.1, + spring-boot-starter-test, spring-boot-jackson2 +License: Apache License 2.0 — licenses/Apache-2.0.txt +Homepage: https://spring.io/projects/spring-boot +================================================================================ +4. JUnit Vintage (Eclipse Public License 2.0) — test only +================================================================================ Package: org.junit.vintage:junit-vintage-engine -License: Eclipse Public License 2.0 +License: EPL-2.0 — licenses/EPL-2.0.txt Homepage: https://junit.org/junit5/ -Full license text: See LICENSE-EPL-2.0.txt ================================================================================ -4. Apache Maven Plugins (Apache License 2.0) +5. Apache Maven Plugins (Apache License 2.0) ================================================================================ -Apache Maven -Copyright 2001-2019 The Apache Software Foundation - -This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). - -Packages: maven-source-plugin, maven-gpg-plugin, maven-assembly-plugin, - maven-compiler-plugin, maven-javadoc-plugin, maven-surefire-plugin, - maven-jar-plugin, maven-dependency-plugin -License: Apache License 2.0 +Packages: maven-compiler-plugin, maven-surefire-plugin, maven-jar-plugin, + maven-source-plugin, maven-javadoc-plugin, maven-gpg-plugin, + maven-deploy-plugin, maven-assembly-plugin, maven-dependency-plugin, + maven-resources-plugin, jacoco-maven-plugin +License: Apache License 2.0 — licenses/Apache-2.0.txt Homepage: https://maven.apache.org/plugins/ -Full license text: See LICENSE-APACHE-2.0.txt - ================================================================================ -5. MOSIP Kernel (Mozilla Public License 2.0) +6. MOSIP Kernel Core (Mozilla Public License 2.0) ================================================================================ Copyright (c) MOSIP -Packages: io.mosip.kernel:kernel-bom, kernel-core, kernel-logger-logback, - io.mosip.imagedecoder:imagedecoder -License: Mozilla Public License 2.0 +Package: io.mosip.kernel:kernel-core + (includes io.mosip.kernel.logger.logback.factory.Logfactory) +License: MPL-2.0 — LICENSE / licenses/MPL-2.0.txt Homepage: https://github.com/mosip/commons -Full license text: See LICENSE-MPL-2.0.txt + +================================================================================ +7. This project (Mozilla Public License 2.0) +================================================================================ +Package: io.mosip.imagedecoder:imagedecoder +License: MPL-2.0 — LICENSE +Homepage: https://github.com/mosip/imagedecoder ================================================================================ END OF COPYRIGHT NOTICES diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..c7b2cc6 --- /dev/null +++ b/pom.xml @@ -0,0 +1,436 @@ + + + 4.0.0 + + + + org.springframework.boot + spring-boot-starter-parent + 4.1.1 + + + + io.mosip.imagedecoder + imagedecoder-parent + 0.10.1-SNAPSHOT + pom + + imagedecoder-parent + + MOSIP pure-Java biometric image decoding library parent. Publishes JPEG2000 + (OpenJPEG port) and WSQ (NBIS port) codecs as Maven Central JARs. Spring Boot + 4.1.1 parent, Java 21, no kernel-bom. Depends on commons kernel-core + (version: kernel.core.version; logging facades live in kernel-core — do not add + kernel-logger-logback). + + https://github.com/mosip/imagedecoder + + + + imagedecoder + + + + + 21 + 21 + 21 + + + false + + + 3.16.0 + 3.5.1 + 3.5.1 + 3.6.0 + 0.8.15 + 5.8.0.7211 + 3.12.0 + 3.1.4 + 3.4.0 + 3.2.8 + 3.7.1 + 3.8.1 + 3.3.1 + + 4.9.10 + 0.11.0 + 1.7.0 + + + + **/config/**,**/dto/**,**/entity/** + + **/dto/**,**/entity/**,**/config/**,**/model/** + 0.85 + + + + 1.4.1-SNAPSHOT + + ${project.version} + + + + + + + io.mosip.kernel + kernel-core + ${kernel.core.version} + + + + io.mosip.imagedecoder + imagedecoder + ${mosip.imagedecoder.version} + + + + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.junit.vintage + junit-vintage-engine + test + + + + org.projectlombok + lombok + provided + + + + + + ossrh + https://central.sonatype.com/repository/maven-snapshots/ + + + ossrh + https://central.sonatype.com/api/v1/publisher + + + + + + + + org.sonarsource.scanner.maven + sonar-maven-plugin + ${maven.sonar.plugin.version} + + + + + + + org.sonatype.central + central-publishing-maven-plugin + ${central.publishing.maven.plugin.version} + true + + ossrh + false + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven.surefire.plugin.version} + + ${skipTests} + false + + @{argLine} --add-modules=ALL-SYSTEM --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang.stream=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED + + + + org.jacoco + jacoco-maven-plugin + ${maven.jacoco.version} + + + **/config/** + **/dto/** + **/entity/** + + + + + + prepare-agent + + + + report + prepare-package + + report + + + + jacoco-check + + check + + + + + BUNDLE + + + INSTRUCTION + COVEREDRATIO + ${jacoco.coverage.minimum} + + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + ${maven.jar.plugin.version} + + + + true + true + + + ${project.name} + ${project.version} + + + + + + org.apache.maven.plugins + maven-deploy-plugin + ${maven.deploy.plugin.version} + + + default-deploy + deploy + + deploy + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + ${nexus.staging.maven.plugin.version} + true + + + default-deploy + deploy + + deploy + + + + + ossrh + https://oss.sonatype.org/ + false + + + + org.apache.maven.plugins + maven-source-plugin + ${maven.source.plugin.version} + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven.javadoc.version} + + + attach-javadocs + + jar + + + + + none + false + false + + + + org.apache.maven.plugins + maven-gpg-plugin + ${maven.gpg.plugin.version} + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + pl.project13.maven + git-commit-id-plugin + ${git.commit.id.plugin.version} + + + get-the-git-infos + + revision + + validate + + + + true + ${project.build.outputDirectory}/git.properties + + ^git.build.(time|version)$ + ^git.commit.id.(abbrev|full)$ + + full + ${maven.multiModuleProjectDirectory}/.git + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.plugin.version} + + ${java.version} + true + + + org.projectlombok + lombok + ${lombok.version} + + + + + + + + + + sonar + + . + src/main/java/**,src/main/resources/** + ${sonar.coverage.exclusions} + ${project.build.directory}/site/jacoco/jacoco.xml + https://sonarcloud.io + + + false + + + + + org.sonarsource.scanner.maven + sonar-maven-plugin + + + verify + + sonar + + + + + + + + + + + + ossrh + Central Snapshots + https://central.sonatype.com/repository/maven-snapshots/ + + false + + + true + + + + + + + MPL 2.0 + https://www.mozilla.org/en-US/MPL/2.0/ + repo + + + + scm:git:git://github.com/mosip/imagedecoder.git + scm:git:ssh://github.com:mosip/imagedecoder.git + https://github.com/mosip/imagedecoder + HEAD + + + + MOSIP + mosip.emailnotifier@gmail.com + io.mosip + https://github.com/mosip + + + diff --git a/sample/README.md b/sample/README.md new file mode 100644 index 0000000..9ed717d --- /dev/null +++ b/sample/README.md @@ -0,0 +1,25 @@ +# sample-imagedecoder + +CLI demos for JPEG2000 and WSQ decoding. **Not** in the Maven reactor / not published. + +Package first (from repo root or after library `run-local init`): + +```text +cd sample +mvn clean package -DskipTests -Dgpg.skip=true +``` + +Then: + +```bat +run-jp2000-decoder.bat +run-wsq-decoder.bat +``` + +```bash +chmod +x run-*-decoder.sh +./run-jp2000-decoder.sh +./run-wsq-decoder.sh +``` + +Library build/test: use `imagedecoder/run-local.(bat|sh)`. See root [README.md](../README.md). diff --git a/sample/pom.xml b/sample/pom.xml index 909d929..25183b2 100644 --- a/sample/pom.xml +++ b/sample/pom.xml @@ -1,86 +1,56 @@ + + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - io.mosip.imagedecoder + + + io.mosip.imagedecoder + imagedecoder-parent + 0.10.1-SNAPSHOT + ../pom.xml + + sample-imagedecoder + 0.10.1-SNAPSHOT jar - 0.10.0-SNAPSHOT - imagedecoder - http://maven.apache.org - Image decoder testing sample - - UTF-8 - 21 - - - ${java.version} - ${java.version} - 3.11.0 - 3.0.2 - 3.1.0 - 3.2.0 - 2.3 - 0.8.11 - 3.1.1 - 3.3.1 - 3.2.0 - 3.2.3 - 3.0.2 - 3.1.0 - 2.22.0 - 3.1.2 - 3.0.2 - - 1.6.14 - 3.2.5 - - - 3.0.1 - - - 1.3.1-rc.1 - 1.3.1-rc.1 - 1.3.1-rc.1 - 0.10.0-SNAPSHOT - - - - - io.mosip.kernel - kernel-bom - ${kernel.bom.version} - pom - import - - - + sample-imagedecoder + https://github.com/mosip/imagedecoder + + Standalone CLI demo for imagedecoder: batch-decode JPEG2000 (.jp2) or WSQ (.wsq) files + from a folder (BiometricInfo). Not published to Maven Central. Use + run-jp2000-decoder / run-wsq-decoder scripts after packaging this module. + Library local runner lives under imagedecoder/run-local.(bat|sh). + + io.mosip.imagedecoder imagedecoder - ${mosip.imagedecoder.version} + io.mosip.kernel kernel-core - ${kernel.core.version} org.springframework.boot - - spring-boot-starter-security - + spring-boot-starter-security - - io.mosip.kernel - kernel-logger-logback - ${kernel.logger.logback.version} - + org.slf4j jul-to-slf4j @@ -89,34 +59,10 @@ org.slf4j jcl-over-slf4j - - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven.compiler.version} - - ${java.version} - - --enable-preview - - - - org.apache.maven.plugins maven-jar-plugin @@ -125,13 +71,11 @@ true - - io.mosip.imagedecoder.test.ImageDecoderApplication.class + io.mosip.imagedecoder.sample.SampleImageDecoderApplication - org.apache.maven.plugins maven-dependency-plugin @@ -144,9 +88,7 @@ copy-dependencies - - ${project.build.directory}/lib - + ${project.build.directory}/lib false false true @@ -154,14 +96,12 @@ - maven-resources-plugin ${maven.resources.plugin.version} - copy-resources-1 - + copy-biometric-info validate copy-resources @@ -176,8 +116,7 @@ - copy-resources-2 - + copy-run-scripts validate copy-resources @@ -188,9 +127,11 @@ ${basedir} true - - run_jp2000_decoder.bat - run_wsq_decoder.bat + + run-jp2000-decoder.bat + run-jp2000-decoder.sh + run-wsq-decoder.bat + run-wsq-decoder.sh @@ -200,5 +141,4 @@ - diff --git a/sample/run-jp2000-decoder.bat b/sample/run-jp2000-decoder.bat new file mode 100644 index 0000000..44350b8 --- /dev/null +++ b/sample/run-jp2000-decoder.bat @@ -0,0 +1,28 @@ +@echo off +REM Decode JPEG2000 (.jp2) samples. Package sample first: mvn clean package -DskipTests -Dgpg.skip=true +setlocal +set "DIR=%~dp0" +if exist "%DIR%target\sample-imagedecoder-*.jar" ( + pushd "%DIR%target" +) else ( + pushd "%DIR%" +) +set "JAR=" +for %%F in (sample-imagedecoder-*.jar) do ( + echo %%~nxF | findstr /I /C:"sources" /C:"javadoc" /C:"with-dependencies" >nul + if errorlevel 1 set "JAR=%%~fF" +) +if not defined JAR ( + echo error: sample jar not found. Package sample first ^(mvn clean package -DskipTests -Dgpg.skip=true^). + popd + exit /b 1 +) +if not exist "lib" ( + echo error: lib\ missing. Package sample first ^(mvn clean package -DskipTests -Dgpg.skip=true^). + popd + exit /b 1 +) +java -cp "%JAR%;lib\*" io.mosip.imagedecoder.sample.SampleImageDecoderApplication "io.mosip.imagedecoder.image.type=0" "io.mosip.imagedecoder.image.folder.path=/BiometricInfo" +set "RC=%ERRORLEVEL%" +popd +exit /b %RC% diff --git a/sample/run-jp2000-decoder.sh b/sample/run-jp2000-decoder.sh new file mode 100644 index 0000000..9a7ae31 --- /dev/null +++ b/sample/run-jp2000-decoder.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Decode JPEG2000 (.jp2) samples. Package sample first: mvn clean package -DskipTests -Dgpg.skip=true +set -euo pipefail +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +if compgen -G "${DIR}/target/sample-imagedecoder-*.jar" >/dev/null; then + cd "${DIR}/target" +else + cd "${DIR}" +fi +JAR="" +for f in sample-imagedecoder-*.jar; do + [[ -f "$f" ]] || continue + case "$f" in *sources*|*javadoc*|*with-dependencies*) continue ;; esac + JAR="$f" + break +done +if [[ -z "$JAR" ]]; then + echo "error: sample jar not found. Package sample first: mvn clean package -DskipTests -Dgpg.skip=true" >&2 + exit 1 +fi +if [[ ! -d lib ]]; then + echo "error: lib/ missing. Package sample first: mvn clean package -DskipTests -Dgpg.skip=true" >&2 + exit 1 +fi +exec java -cp "${JAR}:lib/*" \ + io.mosip.imagedecoder.sample.SampleImageDecoderApplication \ + "io.mosip.imagedecoder.image.type=0" \ + "io.mosip.imagedecoder.image.folder.path=/BiometricInfo" diff --git a/sample/run-wsq-decoder.bat b/sample/run-wsq-decoder.bat new file mode 100644 index 0000000..6e86467 --- /dev/null +++ b/sample/run-wsq-decoder.bat @@ -0,0 +1,28 @@ +@echo off +REM Decode WSQ (.wsq) samples. Package sample first: mvn clean package -DskipTests -Dgpg.skip=true +setlocal +set "DIR=%~dp0" +if exist "%DIR%target\sample-imagedecoder-*.jar" ( + pushd "%DIR%target" +) else ( + pushd "%DIR%" +) +set "JAR=" +for %%F in (sample-imagedecoder-*.jar) do ( + echo %%~nxF | findstr /I /C:"sources" /C:"javadoc" /C:"with-dependencies" >nul + if errorlevel 1 set "JAR=%%~fF" +) +if not defined JAR ( + echo error: sample jar not found. Package sample first ^(mvn clean package -DskipTests -Dgpg.skip=true^). + popd + exit /b 1 +) +if not exist "lib" ( + echo error: lib\ missing. Package sample first ^(mvn clean package -DskipTests -Dgpg.skip=true^). + popd + exit /b 1 +) +java -cp "%JAR%;lib\*" io.mosip.imagedecoder.sample.SampleImageDecoderApplication "io.mosip.imagedecoder.image.type=1" "io.mosip.imagedecoder.image.folder.path=/BiometricInfo" +set "RC=%ERRORLEVEL%" +popd +exit /b %RC% diff --git a/sample/run-wsq-decoder.sh b/sample/run-wsq-decoder.sh new file mode 100644 index 0000000..4bef682 --- /dev/null +++ b/sample/run-wsq-decoder.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Decode WSQ (.wsq) samples. Package sample first: mvn clean package -DskipTests -Dgpg.skip=true +set -euo pipefail +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +if compgen -G "${DIR}/target/sample-imagedecoder-*.jar" >/dev/null; then + cd "${DIR}/target" +else + cd "${DIR}" +fi +JAR="" +for f in sample-imagedecoder-*.jar; do + [[ -f "$f" ]] || continue + case "$f" in *sources*|*javadoc*|*with-dependencies*) continue ;; esac + JAR="$f" + break +done +if [[ -z "$JAR" ]]; then + echo "error: sample jar not found. Package sample first: mvn clean package -DskipTests -Dgpg.skip=true" >&2 + exit 1 +fi +if [[ ! -d lib ]]; then + echo "error: lib/ missing. Package sample first: mvn clean package -DskipTests -Dgpg.skip=true" >&2 + exit 1 +fi +exec java -cp "${JAR}:lib/*" \ + io.mosip.imagedecoder.sample.SampleImageDecoderApplication \ + "io.mosip.imagedecoder.image.type=1" \ + "io.mosip.imagedecoder.image.folder.path=/BiometricInfo" diff --git a/sample/run_jp2000_decoder.bat b/sample/run_jp2000_decoder.bat deleted file mode 100644 index 8e435b5..0000000 --- a/sample/run_jp2000_decoder.bat +++ /dev/null @@ -1 +0,0 @@ -java -cp sample-imagedecoder-0.10.0-SNAPSHOT.jar;lib\* io.mosip.imagedecoder.sample.SampleImageDecoderApplication "io.mosip.imagedecoder.image.type=0" "io.mosip.imagedecoder.image.folder.path=/BiometricInfo" \ No newline at end of file diff --git a/sample/run_wsq_decoder.bat b/sample/run_wsq_decoder.bat deleted file mode 100644 index d6f77bd..0000000 --- a/sample/run_wsq_decoder.bat +++ /dev/null @@ -1 +0,0 @@ -java -cp sample-imagedecoder-0.10.0-SNAPSHOT.jar;lib\* io.mosip.imagedecoder.sample.SampleImageDecoderApplication "io.mosip.imagedecoder.image.type=1" "io.mosip.imagedecoder.image.folder.path=/BiometricInfo" \ No newline at end of file