Merge pull request #1882 from yurydelendik/jpx-segsymbol
Segmentation symbol check for JPX
This commit is contained in:
commit
f4c16aab9e
20
src/jpx.js
20
src/jpx.js
@ -254,8 +254,7 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
cod.selectiveArithmeticCodingBypass ||
|
cod.selectiveArithmeticCodingBypass ||
|
||||||
cod.resetContextProbabilities ||
|
cod.resetContextProbabilities ||
|
||||||
cod.terminationOnEachCodingPass ||
|
cod.terminationOnEachCodingPass ||
|
||||||
cod.verticalyStripe || cod.predictableTermination ||
|
cod.verticalyStripe || cod.predictableTermination)
|
||||||
cod.segmentationSymbolUsed)
|
|
||||||
throw 'Unsupported COD options: ' + uneval(cod);
|
throw 'Unsupported COD options: ' + uneval(cod);
|
||||||
|
|
||||||
if (context.mainHeader)
|
if (context.mainHeader)
|
||||||
@ -832,7 +831,8 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
function copyCoefficients(coefficients, x0, y0, width, height,
|
function copyCoefficients(coefficients, x0, y0, width, height,
|
||||||
delta, mb, codeblocks, transformation) {
|
delta, mb, codeblocks, transformation,
|
||||||
|
segmentationSymbolUsed) {
|
||||||
var r = 0.5; // formula (E-6)
|
var r = 0.5; // formula (E-6)
|
||||||
for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
|
for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
|
||||||
var codeblock = codeblocks[i];
|
var codeblock = codeblocks[i];
|
||||||
@ -876,6 +876,8 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
bitModel.runCleanupPass();
|
bitModel.runCleanupPass();
|
||||||
|
if (segmentationSymbolUsed)
|
||||||
|
bitModel.checkSegmentationSymbol();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
currentCodingpassType = (currentCodingpassType + 1) % 3;
|
currentCodingpassType = (currentCodingpassType + 1) % 3;
|
||||||
@ -912,6 +914,7 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
var scalarExpounded = quantizationParameters.scalarExpounded;
|
var scalarExpounded = quantizationParameters.scalarExpounded;
|
||||||
var guardBits = quantizationParameters.guardBits;
|
var guardBits = quantizationParameters.guardBits;
|
||||||
var transformation = codingStyleParameters.transformation;
|
var transformation = codingStyleParameters.transformation;
|
||||||
|
var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
|
||||||
var precision = context.components[c].precision;
|
var precision = context.components[c].precision;
|
||||||
|
|
||||||
var subbandCoefficients = [];
|
var subbandCoefficients = [];
|
||||||
@ -942,7 +945,8 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
|
|
||||||
var coefficients = new Float32Array(width * height);
|
var coefficients = new Float32Array(width * height);
|
||||||
copyCoefficients(coefficients, subband.tbx0, subband.tby0,
|
copyCoefficients(coefficients, subband.tbx0, subband.tby0,
|
||||||
width, height, delta, mb, subband.codeblocks, transformation);
|
width, height, delta, mb, subband.codeblocks, transformation,
|
||||||
|
segmentationSymbolUsed);
|
||||||
|
|
||||||
subbandCoefficients.push({
|
subbandCoefficients.push({
|
||||||
width: width,
|
width: width,
|
||||||
@ -1645,6 +1649,14 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
|
||||||
|
var decoder = this.decoder;
|
||||||
|
var cx = this.uniformContext;
|
||||||
|
var symbol = (decoder.readBit(cx) << 3) | (decoder.readBit(cx) << 2) |
|
||||||
|
(decoder.readBit(cx) << 1) | decoder.readBit(cx);
|
||||||
|
if (symbol != 0xA)
|
||||||
|
throw 'Invalid segmentation symbol';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user