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

Check that >0 pixi planes have the same depth #2058

Merged
merged 1 commit into from
Mar 15, 2024
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
14 changes: 8 additions & 6 deletions src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -2222,12 +2222,19 @@ static avifBool avifParsePixelInformationProperty(avifProperty * prop, const uin

avifPixelInformationProperty * pixi = &prop->u.pixi;
AVIF_CHECK(avifROStreamRead(&s, &pixi->planeCount, 1)); // unsigned int (8) num_channels;
if (pixi->planeCount > MAX_PIXI_PLANE_DEPTHS) {
if (pixi->planeCount < 1 || pixi->planeCount > MAX_PIXI_PLANE_DEPTHS) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: Since pixi->planeCount is an unsigned type, I probably would test pixi->planeCount == 0 (as in the original code, at line 4612).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is fine with me.

avifDiagnosticsPrintf(diag, "Box[pixi] contains unsupported plane count [%u]", pixi->planeCount);
return AVIF_FALSE;
}
for (uint8_t i = 0; i < pixi->planeCount; ++i) {
AVIF_CHECK(avifROStreamRead(&s, &pixi->planeDepths[i], 1)); // unsigned int (8) bits_per_channel;
if (pixi->planeDepths[i] != pixi->planeDepths[0]) {
avifDiagnosticsPrintf(diag,
"Box[pixi] contains unsupported mismatched plane depths [%u != %u]",
pixi->planeDepths[i],
pixi->planeDepths[0]);
return AVIF_FALSE;
}
}
return AVIF_TRUE;
}
Expand Down Expand Up @@ -4609,12 +4616,7 @@ static avifResult avifDecoderFindGainMapItem(const avifDecoder * decoder,

const avifProperty * pixiProp = avifPropertyArrayFind(&toneMappedImageItemTmp->properties, "pixi");
if (pixiProp) {
if (pixiProp->u.pixi.planeCount == 0) {
avifDiagnosticsPrintf(data->diag, "Box[pixi] of tmap item contains unsupported plane count [%u]", pixiProp->u.pixi.planeCount);
return AVIF_RESULT_BMFF_PARSE_FAILED;
}
gainMap->altPlaneCount = pixiProp->u.pixi.planeCount;
// Assume all planes have the same depth.
gainMap->altDepth = pixiProp->u.pixi.planeDepths[0];
}
}
Expand Down
Loading