j2k 0.8.1

Pure-Rust JPEG 2000 and HTJ2K codec APIs with optional CUDA and Metal adapters
Documentation
// SPDX-License-Identifier: MIT OR Apache-2.0

//! Pure-Rust JPEG 2000 Part 1 and HTJ2K Part 15 codec APIs.
//!
//! This crate provides inspection, decode, encode, lossless J2K-to-HTJ2K
//! recoding, still-image container wrapping, and device-decode planning. Shared
//! encode-stage SPI types are re-exported at the crate root for adapter
//! interoperability, while concrete CUDA and Metal device surfaces and runtime
//! integration live in the `j2k-cuda` and `j2k-metal` crates.

#![deny(missing_docs)]
extern crate alloc;

mod backend;
mod batch;
mod decode;
mod encode;
mod metadata;
mod owned_batch;
mod parallelism;
mod recode;
mod wrap;

mod context;
pub use context::J2kContext;

mod error;
pub use error::{BackendError, BackendErrorKind, J2kError, NativeBackendError};

mod scratch;
pub use scratch::J2kScratchPool;

/// Adapter-facing encode-stage contracts shared with GPU crates.
mod adapter;
pub use adapter::device_plan::{DeviceDecodePlan, DeviceDecodeRequest};
#[doc(hidden)]
pub use j2k_types::{
    CpuOnlyJ2kEncodeStageAccelerator, EncodedHtJ2kCodeBlock, EncodedJ2kCodeBlock,
    IrreversibleQuantizationStep, IrreversibleQuantizationSubbandScales, J2kCodeBlockSegment,
    J2kCodeBlockStyle, J2kDeinterleaveToF32Job, J2kEncodeContext, J2kEncodeDispatchReport,
    J2kEncodeStageAccelerator, J2kEncodeStageError, J2kEncodeStageErrorKind, J2kEncodeStageResult,
    J2kForwardDwt53Job, J2kForwardDwt53Level, J2kForwardDwt53Output, J2kForwardDwt97Job,
    J2kForwardDwt97Level, J2kForwardDwt97Output, J2kForwardIctJob, J2kForwardRctJob,
    J2kHtCodeBlockEncodeJob, J2kHtSubbandEncodeJob, J2kHtj2kTileEncodeJob,
    J2kPacketizationBlockCodingMode, J2kPacketizationCodeBlock, J2kPacketizationEncodeJob,
    J2kPacketizationPacketDescriptor, J2kPacketizationProgressionOrder, J2kPacketizationResolution,
    J2kPacketizationSubband, J2kQuantizeSubbandJob, J2kResidentEncodeInput,
    J2kResidentEncodeInputError, J2kResidentHtj2kTileEncodeJob, J2kSubBandType,
    J2kTier1CodeBlockEncodeJob, PrecomputedHtj2k53Component, PrecomputedHtj2k53Image,
    PrecomputedHtj2k97Component, PrecomputedHtj2k97Image, PreencodedHtj2k97CodeBlock,
    PreencodedHtj2k97CompactCodeBlock, PreencodedHtj2k97CompactComponent,
    PreencodedHtj2k97CompactImage, PreencodedHtj2k97CompactResolution,
    PreencodedHtj2k97CompactSubband, PreencodedHtj2k97Component, PreencodedHtj2k97Image,
    PreencodedHtj2k97Resolution, PreencodedHtj2k97Subband, PrequantizedHtj2k97CodeBlock,
    PrequantizedHtj2k97Component, PrequantizedHtj2k97Image, PrequantizedHtj2k97Resolution,
    PrequantizedHtj2k97Subband,
};

mod view;
pub use view::{J2kCodec, J2kDecoder, J2kRowDecodeOptions, J2kView};

pub use batch::{
    decode_tile_into_in_context, decode_tile_region_into_in_context,
    decode_tile_region_scaled_into_in_context, decode_tile_scaled_into_in_context,
    decode_tiles_into, decode_tiles_region_into, decode_tiles_region_scaled_into,
    decode_tiles_scaled_into, TileBatchError, TileBatchOptions, TileDecodeJob, TileDecodeOutput,
    TileRegionDecodeJob, TileRegionScaledDecodeJob, TileScaledDecodeJob,
};

pub use decode::{
    DecodeSettings, J2kComponentPlane, J2kDecodeWarning, J2kDecodedColorSpace,
    J2kDecodedComponents, J2kDecodedNativeComponents, J2kNativeComponentPlane, J2kSrgb8Image,
    J2kSrgb8Layout,
};

pub use parallelism::CpuDecodeParallelism;

pub use metadata::{
    J2kChannelAssociation, J2kChannelDefinition, J2kChannelType, J2kColorSpec, J2kComponentInfo,
    J2kComponentMapping, J2kComponentMappingType, J2kFileMetadata, J2kPaletteColumn,
    J2kPaletteMetadata, J2kSupportInfo,
};

pub use owned_batch::{
    prepare_batch, prepare_batch_from_images, BatchAlpha, BatchCodecRoute, BatchColor,
    BatchDecodeOptions, BatchDecoder, BatchErrorStage, BatchGroupInfo, BatchItemError, BatchLayout,
    BatchWaveletTransform, ClassicCodeBlockPayload, CpuBatchDecodeResult, CpuBatchDecoder,
    CpuBatchGroup, CpuBatchSamples, CpuBatchWorkspaceStats, DecodeRequest, EncodedImage,
    Htj2kPayloadRanges, IndexedBatchError, J2kCodestreamRange, NativeSampleType,
    NonRepresentableReason, PreparationDepth, PreparedBatch, PreparedBatchGroup,
    PreparedClassicPlan, PreparedHtj2kPlan, PreparedImage,
};

pub use encode::{
    encode_j2k_lossless, encode_j2k_lossless_components,
    encode_j2k_lossless_resident_with_accelerator, encode_j2k_lossless_typed_components,
    encode_j2k_lossless_with_accelerator, encode_j2k_lossless_with_roi_regions, encode_j2k_lossy,
    encode_j2k_lossy_with_accelerator, encode_j2k_lossy_with_roi_regions,
    j2k_lossless_decomposition_levels, j2k_lossless_decomposition_levels_for_options,
    j2k_lossless_decomposition_levels_for_progression, EncodeBackendPreference, EncodedJ2k,
    EncodedLossyJ2k, J2kBlockCodingMode, J2kEncodeValidation, J2kLosslessComponentPlane,
    J2kLosslessComponentSamples, J2kLosslessEncodeOptions, J2kLosslessSamples,
    J2kLosslessTypedComponentPlane, J2kLosslessTypedComponentSamples, J2kLossyEncodeOptions,
    J2kLossyEncodeReport, J2kLossySamples, J2kMarkerSegment, J2kProgressionOrder, J2kQualityLayer,
    J2kRateTarget, J2kRoiRegion, ReversibleTransform,
};

pub use recode::{
    recode_j2k_to_htj2k_lossless, J2kToHtj2kMode, J2kToHtj2kOptions, J2kToHtj2kReport,
    ReencodedHtj2k,
};

pub use wrap::{wrap_j2k_codestream, J2kFileBoxMetadata, J2kFileColorSpec, J2kFileWrapOptions};

pub use parse::{extract_j2k_codestream_payload, J2kCodestreamPayload};

pub use j2k_core::{
    BackendKind, BackendRequest, BatchInfrastructureError, BufferError, CodecError,
    CompressedPayloadKind, CompressedTransferSyntax, DecodeOutcome, DecodeRowsError, Downscale,
    ImageCodec, ImageDecode, ImageDecodeRows, PassthroughCandidate, PassthroughDecision,
    PassthroughRejectReason, PassthroughRequirements, PixelFormat, Rect, RowSink, TileBatchDecode,
};

pub(crate) mod parse;