Skip to main content

j2k/
lib.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3//! Pure-Rust JPEG 2000 Part 1 and HTJ2K Part 15 codec APIs.
4//!
5//! This crate provides inspection, decode, encode, lossless J2K-to-HTJ2K
6//! recoding, still-image container wrapping, and device-decode planning. Shared
7//! encode-stage SPI types are re-exported at the crate root for adapter
8//! interoperability, while concrete CUDA and Metal device surfaces and runtime
9//! integration live in the `j2k-cuda` and `j2k-metal` crates.
10
11#![deny(missing_docs)]
12extern crate alloc;
13
14mod backend;
15mod batch;
16mod decode;
17mod encode;
18mod metadata;
19mod owned_batch;
20mod parallelism;
21mod recode;
22mod wrap;
23
24mod context;
25pub use context::J2kContext;
26
27mod error;
28pub use error::{BackendError, BackendErrorKind, J2kError, NativeBackendError};
29
30mod scratch;
31pub use scratch::J2kScratchPool;
32
33/// Adapter-facing encode-stage contracts shared with GPU crates.
34mod adapter;
35pub use adapter::device_plan::{DeviceDecodePlan, DeviceDecodeRequest};
36#[doc(hidden)]
37pub use j2k_types::{
38    CpuOnlyJ2kEncodeStageAccelerator, EncodedHtJ2kCodeBlock, EncodedHtJ2kCodeBlockSet,
39    EncodedJ2kCodeBlock, IrreversibleQuantizationStep, IrreversibleQuantizationSubbandScales,
40    J2kCodeBlockSegment, J2kCodeBlockStyle, J2kDeinterleaveMctToF32Job, J2kDeinterleaveToF32Job,
41    J2kEncodeContext, J2kEncodeDispatchReport, J2kEncodeStageAccelerator, J2kEncodeStageError,
42    J2kEncodeStageErrorKind, J2kEncodeStageResult, J2kForwardDwt53Job, J2kForwardDwt53Level,
43    J2kForwardDwt53Output, J2kForwardDwt97Job, J2kForwardDwt97Level, J2kForwardDwt97Output,
44    J2kForwardIctJob, J2kForwardRctJob, J2kHtCodeBlockEncodeJob, J2kHtCodeBlockSetEncodeJob,
45    J2kHtSubbandEncodeJob, J2kHtj2kTileEncodeJob, J2kPacketizationBlockCodingMode,
46    J2kPacketizationCodeBlock, J2kPacketizationEncodeJob, J2kPacketizationPacketDescriptor,
47    J2kPacketizationProgressionOrder, J2kPacketizationResolution, J2kPacketizationSubband,
48    J2kQuantizeSubbandJob, J2kResidentEncodeInput, J2kResidentEncodeInputError,
49    J2kResidentHtj2kTileEncodeJob, J2kSubBandType, J2kTier1CodeBlockEncodeJob,
50    PrecomputedHtj2k53Component, PrecomputedHtj2k53Image, PrecomputedHtj2k97Component,
51    PrecomputedHtj2k97Image, PreencodedHtj2k97CodeBlock, PreencodedHtj2k97CompactCodeBlock,
52    PreencodedHtj2k97CompactComponent, PreencodedHtj2k97CompactImage,
53    PreencodedHtj2k97CompactResolution, PreencodedHtj2k97CompactSubband,
54    PreencodedHtj2k97Component, PreencodedHtj2k97Image, PreencodedHtj2k97Resolution,
55    PreencodedHtj2k97Subband, PrequantizedHtj2k97CodeBlock, PrequantizedHtj2k97Component,
56    PrequantizedHtj2k97Image, PrequantizedHtj2k97Resolution, PrequantizedHtj2k97Subband,
57};
58
59mod view;
60pub use view::{J2kCodec, J2kDecoder, J2kRowDecodeOptions, J2kView};
61
62pub use batch::{
63    decode_tile_into_in_context, decode_tile_region_into_in_context,
64    decode_tile_region_scaled_into_in_context, decode_tile_scaled_into_in_context,
65    decode_tiles_into, decode_tiles_region_into, decode_tiles_region_scaled_into,
66    decode_tiles_scaled_into, TileBatchError, TileBatchOptions, TileDecodeJob, TileDecodeOutput,
67    TileRegionDecodeJob, TileRegionScaledDecodeJob, TileScaledDecodeJob,
68};
69
70pub use decode::{
71    DecodeSettings, J2kComponentPlane, J2kDecodeWarning, J2kDecodedColorSpace,
72    J2kDecodedComponents, J2kDecodedNativeComponents, J2kNativeComponentPlane, J2kSrgb8Image,
73    J2kSrgb8Layout,
74};
75
76pub use parallelism::CpuDecodeParallelism;
77
78pub use metadata::{
79    J2kChannelAssociation, J2kChannelDefinition, J2kChannelType, J2kColorSpec, J2kComponentInfo,
80    J2kComponentMapping, J2kComponentMappingType, J2kFileMetadata, J2kPaletteColumn,
81    J2kPaletteMetadata, J2kSupportInfo,
82};
83
84pub use owned_batch::{
85    prepare_batch, prepare_batch_from_images, BatchAlpha, BatchCodecRoute, BatchColor,
86    BatchDecodeOptions, BatchDecoder, BatchErrorStage, BatchGroupInfo, BatchItemError, BatchLayout,
87    BatchWaveletTransform, ClassicCodeBlockPayload, ClassicPreparedGeometry, CpuBatchDecodeResult,
88    CpuBatchDecoder, CpuBatchGroup, CpuBatchSamples, CpuBatchWorkspaceStats, DecodeRequest,
89    EncodedImage, Htj2kPayloadRanges, Htj2kPreparedGeometry, IndexedBatchError, J2kCodestreamRange,
90    NativeSampleType, NonRepresentableReason, PreparationDepth, PreparedBatch, PreparedBatchGroup,
91    PreparedClassicPlan, PreparedHtj2kPlan, PreparedImage, PreparedImageGeometry,
92};
93
94pub use encode::{
95    encode_j2k_lossless, encode_j2k_lossless_components,
96    encode_j2k_lossless_resident_with_accelerator, encode_j2k_lossless_typed_components,
97    encode_j2k_lossless_with_accelerator, encode_j2k_lossless_with_roi_regions, encode_j2k_lossy,
98    encode_j2k_lossy_with_accelerator, encode_j2k_lossy_with_roi_regions,
99    j2k_lossless_decomposition_levels, j2k_lossless_decomposition_levels_for_options,
100    j2k_lossless_decomposition_levels_for_progression, EncodeBackendPreference, EncodedJ2k,
101    EncodedLossyJ2k, J2kBlockCodingMode, J2kEncodeValidation, J2kLosslessComponentPlane,
102    J2kLosslessComponentSamples, J2kLosslessEncodeOptions, J2kLosslessSamples,
103    J2kLosslessTypedComponentPlane, J2kLosslessTypedComponentSamples, J2kLossyEncodeOptions,
104    J2kLossyEncodeReport, J2kLossySamples, J2kMarkerSegment, J2kProgressionOrder, J2kQualityLayer,
105    J2kRateTarget, J2kRoiRegion, ReversibleTransform,
106};
107
108pub use recode::{
109    recode_j2k_to_htj2k_lossless, J2kToHtj2kMode, J2kToHtj2kOptions, J2kToHtj2kReport,
110    ReencodedHtj2k,
111};
112
113pub use wrap::{wrap_j2k_codestream, J2kFileBoxMetadata, J2kFileColorSpec, J2kFileWrapOptions};
114
115pub use parse::{extract_j2k_codestream_payload, J2kCodestreamPayload};
116
117pub use j2k_core::{
118    BackendKind, BackendRequest, BatchInfrastructureError, BufferError, CodecError,
119    CompressedPayloadKind, CompressedTransferSyntax, DecodeOutcome, DecodeRowsError, Downscale,
120    ImageCodec, ImageDecode, ImageDecodeRows, PassthroughCandidate, PassthroughDecision,
121    PassthroughRejectReason, PassthroughRequirements, PixelFormat, Rect, RowSink, TileBatchDecode,
122};
123
124pub(crate) mod parse;