Skip to content
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
6 changes: 4 additions & 2 deletions src/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ void avifSetTileConfiguration(int threads, uint32_t width, uint32_t height, int
// number of threads would result in a compression penalty without much benefit.
const uint32_t kMinTileArea = 512 * 512;
const uint32_t kMaxTiles = 32;
uint32_t imageArea = width * height;
uint32_t tiles = (imageArea + kMinTileArea - 1) / kMinTileArea;
// AV1 requires width <= 65536 and height <= 65536, so their product fits
// in uint64_t and the resulting tile count fits in uint32_t.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I merged PR #3061, so the caller now validates width <= 65536 and height <= 65536.

Note: For the purpose of this function, we could also clamp width and height to 65536 within this function. Then we don't need the caller to validate that.

const uint64_t imageArea = (uint64_t)width * height;
uint32_t tiles = (uint32_t)((imageArea + kMinTileArea - 1) / kMinTileArea);
if (tiles > kMaxTiles) {
tiles = kMaxTiles;
}
Expand Down
Loading