Skip to content

Commit 103fbbf

Browse files
committed
Merge branch 'v0.27'
2 parents c6ee004 + 82d6ce1 commit 103fbbf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+7802
-11031
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ build
88
# misc
99
npm-debug.log
1010
yarn-error.log
11+
package-lock.json

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
# ignore resources
66
/resources
77

8+
# ignore build
9+
/build
10+
811
# root files (will keep package, license and readme)
912
/*.*

Gruntfile.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* global module */
22
module.exports = function(grunt) {
3+
// copy target for dev deploy
4+
// call: yarn run dev --copy-target=../dwv-jqui
35
var cpTarget = grunt.option('copy-target') || '../dwv-jqmobile';
46
// Project configuration.
57
grunt.initConfig({
@@ -57,7 +59,7 @@ module.exports = function(grunt) {
5759
src: ['src/**/*.js', 'tests/**/*.js', 'resources/doc/readme-doc.md'],
5860
options: {
5961
destination: 'build/doc',
60-
template: 'node_modules/ink-docstrap/template',
62+
template: 'node_modules/docdash',
6163
configure: 'resources/doc/jsdoc.conf.json'
6264
}
6365
}

decoders/dwv/rle.js

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,40 @@ dwv.decoder.RleDecoder.prototype.decode = function ( buffer,
3535

3636
// first value of the RLE header is the number of segments
3737
var numberOfSegments = inputDataView.getInt32(0, true);
38-
// loop on segments
39-
var outputIndex = 0;
38+
39+
// index increment in output array
4040
var outputIndexIncrement = 1;
41-
if (planarConfiguration === 0) {
42-
outputIndexIncrement = samplesPerPixel;
41+
var incrementFactor = 1;
42+
if (samplesPerPixel !== 1 && planarConfiguration === 0) {
43+
incrementFactor *= samplesPerPixel;
4344
}
45+
if (bpe !== 1 ) {
46+
incrementFactor *= bpe;
47+
}
48+
outputIndexIncrement *= incrementFactor;
49+
50+
// loop on segments
51+
var outputIndex = 0;
4452
var inputIndex = 0;
53+
var remainder = 0;
54+
var maxOutputIndex = 0;
55+
var groupOutputIndex = 0;
4556
for (var segment = 0; segment < numberOfSegments; ++segment) {
46-
// one segment per channel, interlace them if needed
47-
if (samplesPerPixel !== 1 && planarConfiguration === 0) {
48-
outputIndex = segment;
57+
// handle special cases:
58+
// - more than one sample per pixel: one segment per channel
59+
// - 16bits: sort high and low bytes
60+
if (incrementFactor !== 1) {
61+
remainder = segment % incrementFactor;
62+
if (remainder === 0) {
63+
groupOutputIndex = maxOutputIndex;
64+
}
65+
outputIndex = groupOutputIndex + remainder;
66+
// 16bits data
67+
if (bpe === 2) {
68+
outputIndex += (remainder % bpe ? -1 : 1);
69+
}
4970
}
71+
5072
// RLE header: list of segment sizes
5173
var segmentStartIndex = inputDataView.getInt32((segment + 1) * 4, true);
5274
var nextSegmentStartIndex = inputDataView.getInt32((segment + 2) * 4, true);
@@ -65,7 +87,7 @@ dwv.decoder.RleDecoder.prototype.decode = function ( buffer,
6587
// output the next count+1 bytes literally
6688
for (var i = 0; i < count + 1; ++i) {
6789
// store
68-
outputArray[outputIndex * bpe] = inputArray[inputIndex];
90+
outputArray[outputIndex] = inputArray[inputIndex];
6991
// increment indexes
7092
++inputIndex;
7193
outputIndex += outputIndexIncrement;
@@ -76,12 +98,16 @@ dwv.decoder.RleDecoder.prototype.decode = function ( buffer,
7698
++inputIndex;
7799
for (var j = 0; j < -count + 1; ++j) {
78100
// store
79-
outputArray[outputIndex * bpe] = value;
101+
outputArray[outputIndex] = value;
80102
// increment index
81103
outputIndex += outputIndexIncrement;
82104
}
83105
}
84106
}
107+
108+
if (outputIndex > maxOutputIndex) {
109+
maxOutputIndex = outputIndex;
110+
}
85111
}
86112

87113
var decodedBuffer = null;

0 commit comments

Comments
 (0)