Skip to content

Commit

Permalink
Merge branch 'v0.27'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Mar 10, 2020
2 parents c6ee004 + 82d6ce1 commit 103fbbf
Show file tree
Hide file tree
Showing 97 changed files with 7,802 additions and 11,031 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ build
# misc
npm-debug.log
yarn-error.log
package-lock.json
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
# ignore resources
/resources

# ignore build
/build

# root files (will keep package, license and readme)
/*.*
4 changes: 3 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* global module */
module.exports = function(grunt) {
// copy target for dev deploy
// call: yarn run dev --copy-target=../dwv-jqui
var cpTarget = grunt.option('copy-target') || '../dwv-jqmobile';
// Project configuration.
grunt.initConfig({
Expand Down Expand Up @@ -57,7 +59,7 @@ module.exports = function(grunt) {
src: ['src/**/*.js', 'tests/**/*.js', 'resources/doc/readme-doc.md'],
options: {
destination: 'build/doc',
template: 'node_modules/ink-docstrap/template',
template: 'node_modules/docdash',
configure: 'resources/doc/jsdoc.conf.json'
}
}
Expand Down
44 changes: 35 additions & 9 deletions decoders/dwv/rle.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,40 @@ dwv.decoder.RleDecoder.prototype.decode = function ( buffer,

// first value of the RLE header is the number of segments
var numberOfSegments = inputDataView.getInt32(0, true);
// loop on segments
var outputIndex = 0;

// index increment in output array
var outputIndexIncrement = 1;
if (planarConfiguration === 0) {
outputIndexIncrement = samplesPerPixel;
var incrementFactor = 1;
if (samplesPerPixel !== 1 && planarConfiguration === 0) {
incrementFactor *= samplesPerPixel;
}
if (bpe !== 1 ) {
incrementFactor *= bpe;
}
outputIndexIncrement *= incrementFactor;

// loop on segments
var outputIndex = 0;
var inputIndex = 0;
var remainder = 0;
var maxOutputIndex = 0;
var groupOutputIndex = 0;
for (var segment = 0; segment < numberOfSegments; ++segment) {
// one segment per channel, interlace them if needed
if (samplesPerPixel !== 1 && planarConfiguration === 0) {
outputIndex = segment;
// handle special cases:
// - more than one sample per pixel: one segment per channel
// - 16bits: sort high and low bytes
if (incrementFactor !== 1) {
remainder = segment % incrementFactor;
if (remainder === 0) {
groupOutputIndex = maxOutputIndex;
}
outputIndex = groupOutputIndex + remainder;
// 16bits data
if (bpe === 2) {
outputIndex += (remainder % bpe ? -1 : 1);
}
}

// RLE header: list of segment sizes
var segmentStartIndex = inputDataView.getInt32((segment + 1) * 4, true);
var nextSegmentStartIndex = inputDataView.getInt32((segment + 2) * 4, true);
Expand All @@ -65,7 +87,7 @@ dwv.decoder.RleDecoder.prototype.decode = function ( buffer,
// output the next count+1 bytes literally
for (var i = 0; i < count + 1; ++i) {
// store
outputArray[outputIndex * bpe] = inputArray[inputIndex];
outputArray[outputIndex] = inputArray[inputIndex];
// increment indexes
++inputIndex;
outputIndex += outputIndexIncrement;
Expand All @@ -76,12 +98,16 @@ dwv.decoder.RleDecoder.prototype.decode = function ( buffer,
++inputIndex;
for (var j = 0; j < -count + 1; ++j) {
// store
outputArray[outputIndex * bpe] = value;
outputArray[outputIndex] = value;
// increment index
outputIndex += outputIndexIncrement;
}
}
}

if (outputIndex > maxOutputIndex) {
maxOutputIndex = outputIndex;
}
}

var decodedBuffer = null;
Expand Down
Loading

0 comments on commit 103fbbf

Please sign in to comment.