Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions codestream/aclosslessscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,23 +467,21 @@ bool ACLosslessScan::ParseMCU(void)

// Loop over lines and columns
do {
bool startofline = true;
do {
if (BeginReadMCU(m_Coder.ByteStreamOf())) {
ParseMCU(prev,top);
} else {
// Only if this is not due to a DNL marker that has been detected.
if (m_ulPixelHeight != 0 && !hasFoundDNL()) {
ClearMCU(top);
} else if (!startofline) {
} else {
// The problem is here that the DNL marker might have been detected, even though decoding
// is not yet done completely. This may be because there are still just enough bits in the
// AC coding engine present to run a single decode. Big Outch! Just continue decoding in
// this case.
ParseMCU(prev,top);
} else break;
}
}
startofline = false;
} while(AdvanceToTheRight());
//
// Reset conditioning to the left
Expand Down
6 changes: 5 additions & 1 deletion codestream/acrefinementscan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@ class ACRefinementScan : public EntropyParser {
virtual bool ParseMCU(void);
//
// Write a single MCU in this scan.
virtual bool WriteMCU(void);
virtual bool WriteMCU(void);
//
// Post the height of the frame in lines. This happens
// when the DNL marker is processed.
virtual void PostImageHeight(ULONG) {}
//
// Make an R/D optimization for the given scan by potentially pushing
// coefficients into other bins.
Expand Down
4 changes: 4 additions & 0 deletions codestream/acsequentialscan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ class ACSequentialScan : public EntropyParser {
// Write a single MCU in this scan.
virtual bool WriteMCU(void);
//
// Post the height of the frame in lines. This happens
// when the DNL marker is processed.
virtual void PostImageHeight(ULONG) {}
//
// Make an R/D optimization for the given scan by potentially pushing
// coefficients into other bins.
virtual void OptimizeBlock(LONG bx,LONG by,UBYTE component,double critical,
Expand Down
1 change: 1 addition & 0 deletions codestream/entropyparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ bool EntropyParser::ParseDNLMarker(class ByteStream *io)
JPG_THROW(MALFORMED_STREAM,"EntropyParser::ParseDNLMarker",
"frame height as indicated by the DNL marker is corrupt, must be > 0");

PostImageHeight(dt);
m_pFrame->PostImageHeight(dt);

m_bDNLFound = true;
Expand Down
6 changes: 5 additions & 1 deletion codestream/entropyparser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,11 @@ class EntropyParser : public JKeeper {
virtual bool ParseMCU(void) = 0;
//
// Write a single MCU in this scan.
virtual bool WriteMCU(void) = 0;
virtual bool WriteMCU(void) = 0;
//
// Define the image size if it is not yet known here. This is
// called whenever the DNL marker is parsed in.
virtual void PostImageHeight(ULONG height) = 0;
//
// Make an R/D optimization for the given scan by potentially pushing
// coefficients into other bins. This runs an optimization for a single
Expand Down
6 changes: 5 additions & 1 deletion codestream/jpeglsscan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,11 @@ class JPEGLSScan : public EntropyParser {
virtual bool ParseMCU(void) = 0;
//
// Write a single MCU in this scan.
virtual bool WriteMCU(void) = 0;
virtual bool WriteMCU(void) = 0;
//
// Post the height of the frame in lines. This happens
// when the DNL marker is processed.
virtual void PostImageHeight(ULONG) {}
//
// Make an R/D optimization for the given scan by potentially pushing
// coefficients into other bins.
Expand Down
6 changes: 2 additions & 4 deletions codestream/losslessscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,22 +432,20 @@ bool LosslessScan::ParseMCU(void)

// Loop over lines and columns
do {
bool startofline = true;
do {
if (BeginReadMCU(m_Stream.ByteStreamOf())) {
ParseMCU(prev,top);
} else {
// Only if this is not due to a DNL marker that has been detected.
if (m_ulPixelHeight != 0 && !hasFoundDNL()) {
ClearMCU(top);
} else if (!startofline) {
} else {
// The problem is here that the DNL marker might have been detected, even though decoding
// is not yet done completely. This may be because there are still just enough bits in the
// bitream present to run a single decode. Big Outch! Just continue decoding in this case.
ParseMCU(prev,top);
} else break;
}
}
startofline = false;
} while(AdvanceToTheRight());
//
// Advance to the next line.
Expand Down
9 changes: 9 additions & 0 deletions codestream/predictivescan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,15 @@ void PredictiveScan::RestartOnMarker(void)
}
///

/// PredictiveScan::PostImageHeight
// Post the height of the frame in lines. This happens
// when the DNL marker is processed.
void PredictiveScan::PostImageHeight(ULONG height)
{
m_ulPixelHeight = height;
}
///

/// PredictiveScan::OptimizeBlock
// Make an R/D optimization for the given scan by potentially pushing
// coefficients into other bins.
Expand Down
4 changes: 4 additions & 0 deletions codestream/predictivescan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ class PredictiveScan : public EntropyParser {
// of the restart interval.
void RestartOnMarker(void);
//
// Post the height of the frame in lines. This happens
// when the DNL marker is processed.
void PostImageHeight(ULONG height);
//
// Start making an optimization run to adjust the coefficients.
virtual void StartOptimizeScan(class BufferCtrl *ctrl);
//
Expand Down
4 changes: 4 additions & 0 deletions codestream/refinementscan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ class RefinementScan : public EntropyParser {
// Write a single MCU in this scan.
virtual bool WriteMCU(void);
//
// Post the height of the frame in lines. This happens
// when the DNL marker is processed.
virtual void PostImageHeight(ULONG) {}
//
// Make an R/D optimization for the given scan by potentially pushing
// coefficients into other bins.
virtual void OptimizeBlock(LONG bx,LONG by,UBYTE component,double critical,
Expand Down
4 changes: 4 additions & 0 deletions codestream/sequentialscan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ class SequentialScan : public EntropyParser {
// Write a single MCU in this scan.
virtual bool WriteMCU(void);
//
// Post the height of the frame in lines. This happens
// when the DNL marker is processed.
virtual void PostImageHeight(ULONG) {}
//
// Make an R/D optimization for the given scan by potentially pushing
// coefficients into other bins. This runs an optimization for a single
// block and requires external control to run over the blocks.
Expand Down