Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed multiple SpectralConverter.CommitConversion() calls #2000

Merged
merged 1 commit into from
Feb 15, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal class HuffmanScanDecoder
/// <summary>
/// Number of component in the current scan.
/// </summary>
private int componentsCount;
private int scanComponentCount;

/// <summary>
/// The reset interval determined by RST markers.
Expand Down Expand Up @@ -112,11 +112,12 @@ public int ResetInterval
/// <summary>
/// Decodes the entropy coded data.
/// </summary>
public void ParseEntropyCodedData(int componentCount)
/// <param name="scanComponentCount">Component count in the current scan.</param>
public void ParseEntropyCodedData(int scanComponentCount)
{
this.cancellationToken.ThrowIfCancellationRequested();

this.componentsCount = componentCount;
this.scanComponentCount = scanComponentCount;

this.scanBuffer = new HuffmanScanBuffer(this.stream);

Expand Down Expand Up @@ -148,7 +149,7 @@ public void InjectFrameData(JpegFrame frame, IRawJpegData jpegData)

private void ParseBaselineData()
{
if (this.componentsCount != 1)
if (this.scanComponentCount != 1)
{
this.ParseBaselineDataInterleaved();
this.spectralConverter.CommitConversion();
Expand Down Expand Up @@ -180,7 +181,7 @@ private void ParseBaselineDataInterleaved()
{
// Scan an interleaved mcu... process components in order
int mcuCol = mcu % mcusPerLine;
for (int k = 0; k < this.componentsCount; k++)
for (int k = 0; k < this.scanComponentCount; k++)
{
int order = this.frame.ComponentOrder[k];
JpegComponent component = this.components[order];
Expand Down Expand Up @@ -228,9 +229,6 @@ ref Unsafe.Add(ref blockRef, blockCol),
// Convert from spectral to actual pixels via given converter
this.spectralConverter.ConvertStrideBaseline();
}

// Stride conversion must be sealed for stride conversion approach
this.spectralConverter.CommitConversion();
}

private void ParseBaselineDataNonInterleaved()
Expand Down Expand Up @@ -336,7 +334,7 @@ private void CheckProgressiveData()
}

// AC scans may have only one component.
if (this.componentsCount != 1)
if (this.scanComponentCount != 1)
{
invalid = true;
}
Expand Down Expand Up @@ -368,7 +366,7 @@ private void ParseProgressiveData()
{
this.CheckProgressiveData();

if (this.componentsCount == 1)
if (this.scanComponentCount == 1)
{
this.ParseProgressiveDataNonInterleaved();
}
Expand All @@ -393,7 +391,7 @@ private void ParseProgressiveDataInterleaved()
// Scan an interleaved mcu... process components in order
int mcuRow = mcu / mcusPerLine;
int mcuCol = mcu % mcusPerLine;
for (int k = 0; k < this.componentsCount; k++)
for (int k = 0; k < this.scanComponentCount; k++)
{
int order = this.frame.ComponentOrder[k];
JpegComponent component = this.components[order];
Expand Down