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

TIFF: Fix spec() and spec_dimensions() for mipmapped tiff files #2723

Merged
merged 1 commit into from
Sep 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 28 additions & 2 deletions src/tiff.imageio/tiffinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,20 @@ ImageSpec
TIFFInput::spec(int subimage, int miplevel)
{
ImageSpec ret;
int s = m_emulate_mipmap ? miplevel : subimage;

// s == index of the spec list to retrieve. Start by presuming it's
// the sublevel number.
int s = subimage;
if (m_emulate_mipmap) {
// This is the kind of TIFF file where we are emulating MIPmap
// levels with TIFF subimages.
if (subimage != 0)
return ret; // Invalid subimage request, return the empty spec
// Index into the spec list by miplevel instead, because that's
// what it really contains.
s = miplevel;
}

lock_guard lock(m_mutex);
if (s >= 0 && s < int(m_subimage_specs.size())
&& !m_subimage_specs[s].undefined()) {
Expand All @@ -747,7 +760,20 @@ ImageSpec
TIFFInput::spec_dimensions(int subimage, int miplevel)
{
ImageSpec ret;
int s = m_emulate_mipmap ? miplevel : subimage;

// s == index of the spec list to retrieve. Start by presuming it's
// the sublevel number.
int s = subimage;
if (m_emulate_mipmap) {
// This is the kind of TIFF file where we are emulating MIPmap
// levels with TIFF subimages.
if (subimage != 0)
return ret; // Invalid subimage request, return the empty spec
// Index into the spec list by miplevel instead, because that's
// what it really contains.
s = miplevel;
}

lock_guard lock(m_mutex);
if (s >= 0 && s < int(m_subimage_specs.size())
&& !m_subimage_specs[s].undefined()) {
Expand Down