Skip to content

Commit

Permalink
renderer: avoid integer overflow
Browse files Browse the repository at this point in the history
Not the correct solution, but an improvement on the status quo.

See-Also: https://code.videolan.org/videolan/libplacebo/-/issues/319
  • Loading branch information
haasn committed Dec 4, 2023
1 parent b453387 commit 52314e0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,7 @@ static bool pass_read_image(struct pass_state *pass)
}

int bits = image->repr.bits.sample_depth;
float out_scale = bits ? (1 << bits) / ((1 << bits) - 1.0f) : 1.0f;
float out_scale = bits ? (1llu << bits) / ((1llu << bits) - 1.0f) : 1.0f;
float neutral_luma = 0.0, neutral_chroma = 0.5f * out_scale;
if (pl_color_levels_guess(&image->repr) == PL_COLOR_LEVELS_LIMITED)
neutral_luma = 16 / 256.0f * out_scale;
Expand Down

0 comments on commit 52314e0

Please sign in to comment.