mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-02-02 10:27:12 +01:00
JBIG2 - bugfixing
This commit is contained in:
parent
b66ecd3b45
commit
ab10a6923e
@ -208,7 +208,7 @@ struct PDFJBIG2TextRegionDecodingParameters : public PDFJBIG2ArithmeticDecoderSt
|
|||||||
PDFJBIG2BitOperation SBCOMBOP = PDFJBIG2BitOperation::Invalid;
|
PDFJBIG2BitOperation SBCOMBOP = PDFJBIG2BitOperation::Invalid;
|
||||||
bool TRANSPOSED = false;
|
bool TRANSPOSED = false;
|
||||||
uint8_t REFCORNER = 0;
|
uint8_t REFCORNER = 0;
|
||||||
uint8_t SBDSOFFSET = 0;
|
int32_t SBDSOFFSET = 0;
|
||||||
uint32_t SBW = 0;
|
uint32_t SBW = 0;
|
||||||
uint32_t SBH = 0;
|
uint32_t SBH = 0;
|
||||||
uint32_t SBNUMINSTANCES = 0;
|
uint32_t SBNUMINSTANCES = 0;
|
||||||
@ -1344,6 +1344,7 @@ void PDFJBIG2Decoder::processSymbolDictionary(const PDFJBIG2SegmentHeader& heade
|
|||||||
{
|
{
|
||||||
arithmeticDecoderStates.resetArithmeticStatesGeneric(parameters.SDTEMPLATE, nullptr);
|
arithmeticDecoderStates.resetArithmeticStatesGeneric(parameters.SDTEMPLATE, nullptr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (parameters.SDREFAGG)
|
if (parameters.SDREFAGG)
|
||||||
{
|
{
|
||||||
@ -1361,7 +1362,6 @@ void PDFJBIG2Decoder::processSymbolDictionary(const PDFJBIG2SegmentHeader& heade
|
|||||||
arithmeticDecoderStates.resetArithmeticStatesGenericRefinement(parameters.SDRTEMPLATE, nullptr);
|
arithmeticDecoderStates.resetArithmeticStatesGenericRefinement(parameters.SDRTEMPLATE, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t SBSYMCODELENGTH = log2ceil(parameters.SDNUMINSYMS + parameters.SDNUMNEWSYMS);
|
uint8_t SBSYMCODELENGTH = log2ceil(parameters.SDNUMINSYMS + parameters.SDNUMNEWSYMS);
|
||||||
if (parameters.SDHUFF)
|
if (parameters.SDHUFF)
|
||||||
@ -1487,10 +1487,13 @@ void PDFJBIG2Decoder::processSymbolDictionary(const PDFJBIG2SegmentHeader& heade
|
|||||||
refinementParameters.GRREFERENCEY = RDYI;
|
refinementParameters.GRREFERENCEY = RDYI;
|
||||||
refinementParameters.TPGRON = false;
|
refinementParameters.TPGRON = false;
|
||||||
refinementParameters.GRAT = parameters.SDRAT;
|
refinementParameters.GRAT = parameters.SDRAT;
|
||||||
|
refinementParameters.decoder = &arithmeticDecoder;
|
||||||
|
refinementParameters.arithmeticDecoderState = &arithmeticDecoderStates.states[PDFJBIG2ArithmeticDecoderStates::Refinement];
|
||||||
parameters.SDNEWSYMS[NSYMSDECODED] = readRefinementBitmap(refinementParameters);
|
parameters.SDNEWSYMS[NSYMSDECODED] = readRefinementBitmap(refinementParameters);
|
||||||
|
|
||||||
if (parameters.SDHUFF)
|
if (parameters.SDHUFF)
|
||||||
{
|
{
|
||||||
|
arithmeticDecoder.finalize();
|
||||||
m_reader.alignToBytes();
|
m_reader.alignToBytes();
|
||||||
m_reader.seek(oldPosition + BMSIZE);
|
m_reader.seek(oldPosition + BMSIZE);
|
||||||
}
|
}
|
||||||
@ -1693,8 +1696,9 @@ void PDFJBIG2Decoder::processTextRegion(const PDFJBIG2SegmentHeader& header)
|
|||||||
const uint8_t SBCOMBOOP_value = (flags >> 7) & 0x03;
|
const uint8_t SBCOMBOOP_value = (flags >> 7) & 0x03;
|
||||||
const PDFJBIG2BitOperation SBCOMBOOP = getSBCOMBOOP(SBCOMBOOP_value);
|
const PDFJBIG2BitOperation SBCOMBOOP = getSBCOMBOOP(SBCOMBOOP_value);
|
||||||
const uint8_t SBDEFPIXEL = ((flags >> 9) & 0x01) ? 0xFF : 0x00;
|
const uint8_t SBDEFPIXEL = ((flags >> 9) & 0x01) ? 0xFF : 0x00;
|
||||||
const uint8_t SBDSOFFSET = (flags >> 10) & 0x1F;
|
const int32_t SBDSOFFSET = (flags >> 10) & 0x1F;
|
||||||
const uint8_t SBRTEMPLATE = (flags >> 15) & 0x01;
|
const uint8_t SBRTEMPLATE = (flags >> 15) & 0x01;
|
||||||
|
const int32_t SBDSOFFSET_SIGNED = (SBDSOFFSET & 0b10000) ? (SBDSOFFSET - 0b100000) : SBDSOFFSET;
|
||||||
|
|
||||||
// Decoding parameters
|
// Decoding parameters
|
||||||
PDFJBIG2TextRegionDecodingParameters parameters;
|
PDFJBIG2TextRegionDecodingParameters parameters;
|
||||||
@ -1704,7 +1708,7 @@ void PDFJBIG2Decoder::processTextRegion(const PDFJBIG2SegmentHeader& header)
|
|||||||
parameters.SBCOMBOP = SBCOMBOOP;
|
parameters.SBCOMBOP = SBCOMBOOP;
|
||||||
parameters.TRANSPOSED = TRANSPOSED;
|
parameters.TRANSPOSED = TRANSPOSED;
|
||||||
parameters.REFCORNER = REFCORNER;
|
parameters.REFCORNER = REFCORNER;
|
||||||
parameters.SBDSOFFSET = SBDSOFFSET;
|
parameters.SBDSOFFSET = SBDSOFFSET_SIGNED;
|
||||||
parameters.SBW = regionSegmentInfo.width;
|
parameters.SBW = regionSegmentInfo.width;
|
||||||
parameters.SBH = regionSegmentInfo.height;
|
parameters.SBH = regionSegmentInfo.height;
|
||||||
parameters.SBRTEMPLATE = SBRTEMPLATE;
|
parameters.SBRTEMPLATE = SBRTEMPLATE;
|
||||||
@ -2431,7 +2435,7 @@ PDFJBIG2Bitmap PDFJBIG2Decoder::readBitmap(PDFJBIG2BitmapDecodingParameters& par
|
|||||||
{
|
{
|
||||||
for (unsigned int column = 0; column < data.getWidth(); ++column)
|
for (unsigned int column = 0; column < data.getWidth(); ++column)
|
||||||
{
|
{
|
||||||
bitmap.setPixel(column, row, (reader.read()) ? 0xFF : 0x00);
|
bitmap.setPixel(column, row, (reader.read()) ? 0x00 : 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.alignToBytes();
|
reader.alignToBytes();
|
||||||
@ -2694,10 +2698,6 @@ PDFJBIG2Bitmap PDFJBIG2Decoder::readRefinementBitmap(PDFJBIG2BitmapRefinementDec
|
|||||||
if (parameters.TPGRON)
|
if (parameters.TPGRON)
|
||||||
{
|
{
|
||||||
LTP = LTP ^ decoder.readBit(LTPContext, parameters.arithmeticDecoderState);
|
LTP = LTP ^ decoder.readBit(LTPContext, parameters.arithmeticDecoderState);
|
||||||
if (LTP)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!LTP)
|
if (!LTP)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user