codecfixture

package
v0.0.0-...-1098021 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package codecfixture builds synthetic DICOM pixel-data conformance cases.

The package is intentionally public so applications that consume dicom-go, including Twin-Viewer, can prove that the same generated fixture shape loads through their integration paths. The default corpus is generated in memory from synthetic pixel values and carries no PHI.

Index

Constants

View Source
const (
	SizeSmall  SizeClass = "small"
	SizeMedium SizeClass = "medium"
	SizeLarge  SizeClass = "large"

	ErrorNone                   ErrorKind = ""
	ErrorUnknown                ErrorKind = "unknown"
	ErrorDecodeMismatch         ErrorKind = "decode_mismatch"
	ErrorUnsupportedMetadata    ErrorKind = "unsupported_metadata"
	ErrorMalformedStream        ErrorKind = "malformed_stream"
	ErrorMissingOptionalAdapter ErrorKind = "missing_optional_adapter"
	ErrorDependencyUnavailable  ErrorKind = "dependency_unavailable"
	ErrorMetadataMismatch       ErrorKind = "metadata_mismatch"
)

Variables

View Source
var (
	ErrDecodeMismatch        = errors.New("codecfixture: decoded frames do not match expected frames")
	ErrUnexpectedSuccess     = errors.New("codecfixture: decode succeeded but expected an error")
	ErrUnexpectedError       = errors.New("codecfixture: decode failed unexpectedly")
	ErrUnexpectedErrorKind   = errors.New("codecfixture: decode failed with unexpected error kind")
	ErrDependencyUnavailable = errors.New("codecfixture: optional codec dependency unavailable")
)

Functions

func RegisterBuiltinCodecs

func RegisterBuiltinCodecs(registry pixeldata.Registry) error

RegisterBuiltinCodecs registers built-in pure-Go codecs used by the baseline.

func RegisterUnavailableJPEGLS

func RegisterUnavailableJPEGLS(registry pixeldata.Registry) error

RegisterUnavailableJPEGLS registers a JPEG-LS codec that reports unavailable dependency.

func RegisterUnavailableJPEGXL

func RegisterUnavailableJPEGXL(registry pixeldata.Registry) error

RegisterUnavailableJPEGXL registers a JPEG XL codec that reports unavailable dependency.

func ValidateCase

func ValidateCase(registry pixeldata.Registry, c Case) error

ValidateCase returns nil when the case outcome matches its expectation.

func ValidateCodecFullReleaseEvidence

func ValidateCodecFullReleaseEvidence(moduleRoot string) error

ValidateCodecFullReleaseEvidence verifies the checked-in codecfull corpus provenance, fixture hashes, and reproducible performance report. moduleRoot must be the root of the github.com/ThalesMMS/dicom-go module.

Types

type Case

type Case struct {
	Name           string
	Description    string
	Syntax         transfer.Syntax
	Size           SizeClass
	Provenance     Provenance
	Elements       []core.Element
	ExpectedFrames [][]byte
	ExpectedError  ErrorKind
	Tolerance      byte
	RegisterCodecs func(pixeldata.Registry) error
}

Case is a synthetic pixel-data conformance fixture.

func DependencyUnavailableJPEGLS

func DependencyUnavailableJPEGLS() Case

DependencyUnavailableJPEGLS returns a JPEG-LS case with a registered unavailable dependency.

func DependencyUnavailableJPEGXL

func DependencyUnavailableJPEGXL() Case

DependencyUnavailableJPEGXL returns a JPEG XL case with a registered codec boundary that reports unavailable dependency.

func HTJ2KLosslessRPCL

func HTJ2KLosslessRPCL(rows, columns int, fragment []byte, expectedFrame []byte) Case

HTJ2KLosslessRPCL builds an HTJ2K RPCL lossless case from caller-supplied codestream bytes.

func HTJ2KLosslessSmall

func HTJ2KLosslessSmall(fragment []byte, expectedFrame []byte) Case

HTJ2KLosslessSmall builds an HTJ2K case from caller-supplied codestream bytes.

func HTJ2KLossy

func HTJ2KLossy(rows, columns int, fragment []byte, expectedFrame []byte, tolerance byte) Case

HTJ2KLossy builds an HTJ2K lossy case from caller-supplied codestream bytes.

func JPEG2000Lossless

func JPEG2000Lossless(rows, columns int, fragment []byte, expectedFrame []byte) Case

JPEG2000Lossless builds a JPEG 2000 case from caller-supplied codestream bytes.

func JPEG2000LosslessSmall

func JPEG2000LosslessSmall(fragment []byte, expectedFrame []byte) Case

JPEG2000LosslessSmall builds a JPEG 2000 case from caller-supplied codestream bytes.

func JPEG2000Lossy

func JPEG2000Lossy(rows, columns int, fragment []byte, expectedFrame []byte, tolerance byte) Case

JPEG2000Lossy builds a JPEG 2000 lossy case from caller-supplied codestream bytes.

func JPEG2000Part2Lossless

func JPEG2000Part2Lossless(rows, columns int, fragment []byte, expectedFrame []byte) Case

JPEG2000Part2Lossless builds a JPEG 2000 Part 2 lossless case from caller-supplied codestream bytes.

func JPEG2000Part2Lossy

func JPEG2000Part2Lossy(rows, columns int, fragment []byte, expectedFrame []byte, tolerance byte) Case

JPEG2000Part2Lossy builds a JPEG 2000 Part 2 lossy case from caller-supplied codestream bytes.

func JPEGBaselineSmall

func JPEGBaselineSmall() Case

JPEGBaselineSmall returns a supported JPEG Baseline 8-bit case.

func JPEGExtendedSmall

func JPEGExtendedSmall() Case

JPEGExtendedSmall returns a supported JPEG Extended 8-bit case.

func JPEGLSLossless

func JPEGLSLossless(rows, columns int, fragment []byte, expectedFrame []byte) Case

JPEGLSLossless builds a JPEG-LS Lossless case from caller-supplied codestream bytes.

func JPEGLSLosslessSmall

func JPEGLSLosslessSmall(fragment []byte, expectedFrame []byte) Case

JPEGLSLosslessSmall builds a JPEG-LS Lossless case from caller-supplied codestream bytes.

func JPEGLosslessSmall

func JPEGLosslessSmall() Case

JPEGLosslessSmall returns a supported JPEG Lossless Process 14 case.

func MalformedJPEGExtended

func MalformedJPEGExtended() Case

MalformedJPEGExtended returns a JPEG case with malformed encoded bytes.

func MetadataMismatchRLE

func MetadataMismatchRLE() Case

MetadataMismatchRLE returns an RLE case whose frame count and fragments differ.

func MissingJPEGXLAdapter

func MissingJPEGXLAdapter() Case

MissingJPEGXLAdapter returns a recognized JPEG XL syntax with no registered adapter.

func NativeLarge

func NativeLarge() Case

NativeLarge returns a 256x256 native Explicit VR Little Endian case.

func NativeMedium

func NativeMedium() Case

NativeMedium returns a 64x64 native Explicit VR Little Endian case.

func NativeMultiFrame

func NativeMultiFrame() Case

NativeMultiFrame returns a 2-frame native case.

func NativeSmall

func NativeSmall() Case

NativeSmall returns a 2x2 native Explicit VR Little Endian case.

func RLELosslessSmall

func RLELosslessSmall() Case

RLELosslessSmall returns a supported RLE Lossless case.

func UnsupportedMetadataJPEGExtended

func UnsupportedMetadataJPEGExtended() Case

UnsupportedMetadataJPEGExtended returns a JPEG case with unsupported metadata.

func (Case) File

func (c Case) File() *object.File

File builds a Part 10 file model for the case.

func (Case) Object

func (c Case) Object() *object.Object

Object builds a fresh DICOM object for the case.

func (Case) Part10Bytes

func (c Case) Part10Bytes() ([]byte, error)

Part10Bytes serializes the case as a DICOM Part 10 file.

func (Case) PixelData

func (c Case) PixelData() (pixeldata.PixelData, error)

PixelData extracts a fresh PixelData value from the case.

func (Case) Registry

func (c Case) Registry() (*pixeldata.MemoryRegistry, error)

Registry builds a fresh registry for this case.

type ErrorKind

type ErrorKind string

ErrorKind is the normalized conformance outcome for a decode failure.

func ClassifyError

func ClassifyError(err error) ErrorKind

ClassifyError normalizes codec and registry errors for conformance reports.

type Provenance

type Provenance struct {
	Source     string
	Synthetic  bool
	License    string
	Permission string
	NoPHI      bool
	Notes      string
}

Provenance documents where fixture bytes came from.

type Result

type Result struct {
	Frames pixeldata.Frames
	Err    error
	Kind   ErrorKind
}

Result captures the raw outcome of running a case through a registry.

func RunCase

func RunCase(registry pixeldata.Registry, c Case) Result

RunCase decodes a case and classifies the outcome.

type SizeClass

type SizeClass string

SizeClass groups synthetic cases for benchmark smoke reporting.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL