dwv 0.37.0-beta.9 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"assets/workers/rle.worker.min.js","mappings":"AAGO,MAAMA,EAgBX,MAAAC,CACEC,EACAC,EACAC,EACAC,EACAC,EACAC,GAGA,MAAMC,EAAML,EAAgB,EAGtBM,EAAgB,IAAIC,SAASR,EAAOA,OAAQA,EAAOS,YACnDC,EAAa,IAAIC,UAAUX,EAAOA,OAAQA,EAAOS,YAEjDG,EAAe,IAAIC,YAAYV,EAAYC,EAAkBE,GAC7DQ,EAAc,IAAIH,UAAUC,GAG5BG,EAAmBR,EAAcS,SAAS,GAAG,GAGnD,IAAIC,EAAuB,EACvBC,EAAkB,EACE,IAApBd,GAAiD,IAAxBC,IAC3Ba,GAAmBd,GAET,IAARE,IACFY,GAAmBZ,GAErBW,GAAwBC,EAGxB,IACIC,EACAC,EAFAC,EAAc,EAGdC,EAAiB,EACjBC,EAAmB,EACvB,IAAK,IAAIC,EAAU,EAAGA,EAAUT,IAAoBS,EAAS,CAInC,IAApBN,IACFE,EAAYI,EAAUN,EACJ,IAAdE,IACFG,EAAmBD,GAErBD,EAAcE,EAAmBH,EAErB,IAARd,IACFe,GAAgBD,EAAYd,GAAO,EAAI,IAK3C,MAAMmB,EACJlB,EAAcS,SAAyB,GAAfQ,EAAU,IAAQ,GAC5C,IAOIE,EAPAC,EACFpB,EAAcS,SAAyB,GAAfQ,EAAU,IAAQ,GAO5C,IANIA,IAAYT,EAAmB,GAA+B,IAA1BY,IACtCA,EAAwB3B,EAAO4B,QAGjCT,EAAaM,EAENN,EAAaQ,GAKlB,GAHAD,EAAQhB,EAAWS,KACjBA,EAEEO,GAAS,GAAKA,GAAS,IAEzB,IAAK,IAAIG,EAAI,EAAGA,EAAIH,EAAQ,IAAKG,EAE/Bf,EAAYO,GAAeX,EAAWS,KAEpCA,EACFE,GAAeJ,OAEZ,GAAIS,IAAU,GAAKA,IAAU,IAAK,CAEvC,MAAMI,EAAQpB,EAAWS,KACvBA,EACF,IAAK,IAAIY,EAAI,EAAGA,EAAa,EAARL,IAAaK,EAEhCjB,EAAYO,GAAeS,EAE3BT,GAAeJ,CAEnB,CAGEI,EAAcC,IAChBA,EAAiBD,EAErB,CAEA,IAAIW,EAAgB,KAepB,OAdsB,IAAlB/B,EAEA+B,EADE9B,EACc,IAAIS,UAAUC,GAEd,IAAIqB,WAAWrB,GAEN,KAAlBX,IAEP+B,EADE9B,EACc,IAAIgC,WAAWtB,GAEf,IAAIuB,YAAYvB,IAI7BoB,CACT,EC9HFI,KAAKC,iBAAiB,WAAW,SAAUC,GAGzC,MAAMC,EAAU,IAAIzC,EAEpBsC,KAAKI,YAAY,CAACD,EAAQxC,OACxBuC,EAAMG,KAAKzC,OACXsC,EAAMG,KAAKC,KAAKzC,cAChBqC,EAAMG,KAAKC,KAAKxC,SAChBoC,EAAMG,KAAKC,KAAKvC,UAChBmC,EAAMG,KAAKC,KAAKtC,gBAChBkC,EAAMG,KAAKC,KAAKrC,sBAEpB,IAAG","sources":["webpack://dwv/./src/decoders/dwv/rle.js","webpack://dwv/./src/decoders/dwv/rle.worker.js"],"sourcesContent":["/**\n * RLE (Run-length encoding) decoder class.\n */\nexport class RleDecoder {\n\n /**\n * Decode a RLE buffer.\n * Ref: {@link http://dicom.nema.org/dicom/2013/output/chtml/part05/sect_G.3.html}.\n *\n * @param {Array} buffer The buffer to decode.\n * @param {number} bitsAllocated The bits allocated per element in the buffer.\n * @param {boolean} isSigned Is the data signed.\n * @param {number} sliceSize The size of a slice\n * (number of rows per number of columns).\n * @param {number} samplesPerPixel The number of samples\n * per pixel (3 for RGB).\n * @param {number} planarConfiguration The planar configuration.\n * @returns {Array} The decoded buffer as a typed array.\n */\n decode(\n buffer,\n bitsAllocated,\n isSigned,\n sliceSize,\n samplesPerPixel,\n planarConfiguration) {\n\n // bytes per element\n const bpe = bitsAllocated / 8;\n\n // input\n const inputDataView = new DataView(buffer.buffer, buffer.byteOffset);\n const inputArray = new Int8Array(buffer.buffer, buffer.byteOffset);\n // output\n const outputBuffer = new ArrayBuffer(sliceSize * samplesPerPixel * bpe);\n const outputArray = new Int8Array(outputBuffer);\n\n // first value of the RLE header is the number of segments\n const numberOfSegments = inputDataView.getInt32(0, true);\n\n // index increment in output array\n let outputIndexIncrement = 1;\n let incrementFactor = 1;\n if (samplesPerPixel !== 1 && planarConfiguration === 0) {\n incrementFactor *= samplesPerPixel;\n }\n if (bpe !== 1) {\n incrementFactor *= bpe;\n }\n outputIndexIncrement *= incrementFactor;\n\n // loop on segments\n let outputIndex = 0;\n let inputIndex;\n let remainder;\n let maxOutputIndex = 0;\n let groupOutputIndex = 0;\n for (let segment = 0; segment < numberOfSegments; ++segment) {\n // handle special cases:\n // - more than one sample per pixel: one segment per channel\n // - 16bits: sort high and low bytes\n if (incrementFactor !== 1) {\n remainder = segment % incrementFactor;\n if (remainder === 0) {\n groupOutputIndex = maxOutputIndex;\n }\n outputIndex = groupOutputIndex + remainder;\n // 16bits data\n if (bpe === 2) {\n outputIndex += (remainder % bpe ? -1 : 1);\n }\n }\n\n // RLE header: list of segment sizes\n const segmentStartIndex =\n inputDataView.getInt32((segment + 1) * 4, true);\n let nextSegmentStartIndex =\n inputDataView.getInt32((segment + 2) * 4, true);\n if (segment === numberOfSegments - 1 || nextSegmentStartIndex === 0) {\n nextSegmentStartIndex = buffer.length;\n }\n // decode segment\n inputIndex = segmentStartIndex;\n let count;\n while (inputIndex < nextSegmentStartIndex) {\n // get the count value\n count = inputArray[inputIndex];\n ++inputIndex;\n // store according to count\n if (count >= 0 && count <= 127) {\n // output the next count+1 bytes literally\n for (let i = 0; i < count + 1; ++i) {\n // store\n outputArray[outputIndex] = inputArray[inputIndex];\n // increment indexes\n ++inputIndex;\n outputIndex += outputIndexIncrement;\n }\n } else if (count <= -1 && count >= -127) {\n // output the next byte -count+1 times\n const value = inputArray[inputIndex];\n ++inputIndex;\n for (let j = 0; j < -count + 1; ++j) {\n // store\n outputArray[outputIndex] = value;\n // increment index\n outputIndex += outputIndexIncrement;\n }\n }\n }\n\n if (outputIndex > maxOutputIndex) {\n maxOutputIndex = outputIndex;\n }\n }\n\n let decodedBuffer = null;\n if (bitsAllocated === 8) {\n if (isSigned) {\n decodedBuffer = new Int8Array(outputBuffer);\n } else {\n decodedBuffer = new Uint8Array(outputBuffer);\n }\n } else if (bitsAllocated === 16) {\n if (isSigned) {\n decodedBuffer = new Int16Array(outputBuffer);\n } else {\n decodedBuffer = new Uint16Array(outputBuffer);\n }\n }\n\n return decodedBuffer;\n };\n\n}\n","/**\n * RLE decoder worker.\n */\n\nimport {RleDecoder} from './rle.js';\n\nself.addEventListener('message', function (event) {\n\n // decode DICOM buffer\n const decoder = new RleDecoder();\n // post decoded data\n self.postMessage([decoder.decode(\n event.data.buffer,\n event.data.meta.bitsAllocated,\n event.data.meta.isSigned,\n event.data.meta.sliceSize,\n event.data.meta.samplesPerPixel,\n event.data.meta.planarConfiguration)]);\n\n}, false);\n"],"names":["RleDecoder","decode","buffer","bitsAllocated","isSigned","sliceSize","samplesPerPixel","planarConfiguration","bpe","inputDataView","DataView","byteOffset","inputArray","Int8Array","outputBuffer","ArrayBuffer","outputArray","numberOfSegments","getInt32","outputIndexIncrement","incrementFactor","inputIndex","remainder","outputIndex","maxOutputIndex","groupOutputIndex","segment","segmentStartIndex","count","nextSegmentStartIndex","length","i","value","j","decodedBuffer","Uint8Array","Int16Array","Uint16Array","self","addEventListener","event","decoder","postMessage","data","meta"],"sourceRoot":""}
1
+ {"version":3,"file":"assets/workers/rle.worker.min.js","mappings":"AAGO,MAAAA,EAgBP,MAAAC,CACAC,EACAC,EACAC,EACAC,EACAC,EACAC,GAGA,MAAAC,EAAAL,EAAA,EAGAM,EAAA,IAAAC,SAAAR,EAAAA,OAAAA,EAAAS,YACAC,EAAA,IAAAC,UAAAX,EAAAA,OAAAA,EAAAS,YAEAG,EAAA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xC,OACAsC,EAAAE,KAAAC,KAAAxC,cACAqC,EAAAE,KAAAC,KAAAvC,SACAoC,EAAAE,KAAAC,KAAAtC,UACAmC,EAAAE,KAAAC,KAAArC,gBACAkC,EAAAE,KAAAC,KAAApC,qBAEA+B,KAAAM,YAAA,CAAAH,GAAAA,EAAA,CAAAA,EAAAvC,QAAA,GAEA,GAAC","sources":["webpack://dwv/./src/decoders/dwv/rle.js","webpack://dwv/./src/decoders/dwv/rle.worker.js"],"sourcesContent":["/**\n * RLE (Run-length encoding) decoder class.\n */\nexport class RleDecoder {\n\n /**\n * Decode a RLE buffer.\n * Ref: {@link https://dicom.nema.org/medical/dicom/2024a/output/chtml/part05/sect_G.3.html}.\n *\n * @param {Array} buffer The buffer to decode.\n * @param {number} bitsAllocated The bits allocated per element in the buffer.\n * @param {boolean} isSigned Is the data signed.\n * @param {number} sliceSize The size of a slice\n * (number of rows per number of columns).\n * @param {number} samplesPerPixel The number of samples\n * per pixel (3 for RGB).\n * @param {number} planarConfiguration The planar configuration.\n * @returns {Array} The decoded buffer as a typed array.\n */\n decode(\n buffer,\n bitsAllocated,\n isSigned,\n sliceSize,\n samplesPerPixel,\n planarConfiguration) {\n\n // bytes per element\n const bpe = bitsAllocated / 8;\n\n // input\n const inputDataView = new DataView(buffer.buffer, buffer.byteOffset);\n const inputArray = new Int8Array(buffer.buffer, buffer.byteOffset);\n // output\n const outputBuffer = new ArrayBuffer(sliceSize * samplesPerPixel * bpe);\n const outputArray = new Int8Array(outputBuffer);\n\n // first value of the RLE header is the number of segments\n const numberOfSegments = inputDataView.getInt32(0, true);\n\n // index increment in output array\n let outputIndexIncrement = 1;\n let incrementFactor = 1;\n if (samplesPerPixel !== 1 && planarConfiguration === 0) {\n incrementFactor *= samplesPerPixel;\n }\n if (bpe !== 1) {\n incrementFactor *= bpe;\n }\n outputIndexIncrement *= incrementFactor;\n\n // loop on segments\n let outputIndex = 0;\n let inputIndex;\n let remainder;\n let maxOutputIndex = 0;\n let groupOutputIndex = 0;\n for (let segment = 0; segment < numberOfSegments; ++segment) {\n // handle special cases:\n // - more than one sample per pixel: one segment per channel\n // - 16bits: sort high and low bytes\n if (incrementFactor !== 1) {\n remainder = segment % incrementFactor;\n if (remainder === 0) {\n groupOutputIndex = maxOutputIndex;\n }\n outputIndex = groupOutputIndex + remainder;\n // 16bits data\n if (bpe === 2) {\n outputIndex += (remainder % bpe ? -1 : 1);\n }\n }\n\n // RLE header: list of segment sizes\n const segmentStartIndex =\n inputDataView.getInt32((segment + 1) * 4, true);\n let nextSegmentStartIndex =\n inputDataView.getInt32((segment + 2) * 4, true);\n if (segment === numberOfSegments - 1 || nextSegmentStartIndex === 0) {\n nextSegmentStartIndex = buffer.length;\n }\n // decode segment\n inputIndex = segmentStartIndex;\n let count;\n while (inputIndex < nextSegmentStartIndex) {\n // get the count value\n count = inputArray[inputIndex];\n ++inputIndex;\n // store according to count\n if (count >= 0 && count <= 127) {\n // output the next count+1 bytes literally\n for (let i = 0; i < count + 1; ++i) {\n // store\n outputArray[outputIndex] = inputArray[inputIndex];\n // increment indexes\n ++inputIndex;\n outputIndex += outputIndexIncrement;\n }\n } else if (count <= -1 && count >= -127) {\n // output the next byte -count+1 times\n const value = inputArray[inputIndex];\n ++inputIndex;\n for (let j = 0; j < -count + 1; ++j) {\n // store\n outputArray[outputIndex] = value;\n // increment index\n outputIndex += outputIndexIncrement;\n }\n }\n }\n\n if (outputIndex > maxOutputIndex) {\n maxOutputIndex = outputIndex;\n }\n }\n\n let decodedBuffer = null;\n if (bitsAllocated === 8) {\n if (isSigned) {\n decodedBuffer = new Int8Array(outputBuffer);\n } else {\n decodedBuffer = new Uint8Array(outputBuffer);\n }\n } else if (bitsAllocated === 16) {\n if (isSigned) {\n decodedBuffer = new Int16Array(outputBuffer);\n } else {\n decodedBuffer = new Uint16Array(outputBuffer);\n }\n }\n\n return decodedBuffer;\n };\n\n}\n","/**\n * RLE decoder worker.\n */\n\nimport {RleDecoder} from './rle.js';\n\nself.addEventListener('message', function (event) {\n\n // decode DICOM buffer\n const decoder = new RleDecoder();\n const res = decoder.decode(\n event.data.buffer,\n event.data.meta.bitsAllocated,\n event.data.meta.isSigned,\n event.data.meta.sliceSize,\n event.data.meta.samplesPerPixel,\n event.data.meta.planarConfiguration);\n // post decoded data, transfer its buffer to avoid a copy\n self.postMessage([res], res ? [res.buffer] : []);\n\n}, false);\n"],"names":["RleDecoder","decode","buffer","bitsAllocated","isSigned","sliceSize","samplesPerPixel","planarConfiguration","bpe","inputDataView","DataView","byteOffset","inputArray","Int8Array","outputBuffer","ArrayBuffer","outputArray","numberOfSegments","getInt32","outputIndexIncrement","incrementFactor","inputIndex","remainder","outputIndex","maxOutputIndex","groupOutputIndex","segment","segmentStartIndex","count","nextSegmentStartIndex","length","i","value","j","decodedBuffer","Uint8Array","Int16Array","Uint16Array","self","addEventListener","event","res","data","meta","postMessage"],"sourceRoot":""}