Merge pull request #1882 from yurydelendik/jpx-segsymbol

Segmentation symbol check for JPX
This commit is contained in:
Brendan Dahl 2012-07-09 14:38:14 -07:00
commit f4c16aab9e

View File

@ -254,8 +254,7 @@ var JpxImage = (function JpxImageClosure() {
cod.selectiveArithmeticCodingBypass ||
cod.resetContextProbabilities ||
cod.terminationOnEachCodingPass ||
cod.verticalyStripe || cod.predictableTermination ||
cod.segmentationSymbolUsed)
cod.verticalyStripe || cod.predictableTermination)
throw 'Unsupported COD options: ' + uneval(cod);
if (context.mainHeader)
@ -832,7 +831,8 @@ var JpxImage = (function JpxImageClosure() {
return position;
}
function copyCoefficients(coefficients, x0, y0, width, height,
delta, mb, codeblocks, transformation) {
delta, mb, codeblocks, transformation,
segmentationSymbolUsed) {
var r = 0.5; // formula (E-6)
for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
var codeblock = codeblocks[i];
@ -876,6 +876,8 @@ var JpxImage = (function JpxImageClosure() {
break;
case 2:
bitModel.runCleanupPass();
if (segmentationSymbolUsed)
bitModel.checkSegmentationSymbol();
break;
}
currentCodingpassType = (currentCodingpassType + 1) % 3;
@ -912,6 +914,7 @@ var JpxImage = (function JpxImageClosure() {
var scalarExpounded = quantizationParameters.scalarExpounded;
var guardBits = quantizationParameters.guardBits;
var transformation = codingStyleParameters.transformation;
var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
var precision = context.components[c].precision;
var subbandCoefficients = [];
@ -942,7 +945,8 @@ var JpxImage = (function JpxImageClosure() {
var coefficients = new Float32Array(width * height);
copyCoefficients(coefficients, subband.tbx0, subband.tby0,
width, height, delta, mb, subband.codeblocks, transformation);
width, height, delta, mb, subband.codeblocks, transformation,
segmentationSymbolUsed);
subbandCoefficients.push({
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';
}
};