Commit 62dd32c4 authored by Janne Grunau's avatar Janne Grunau

film_grain: copy unmodified planes before applying noise

Luma output plane is used during chroma film grain. Fixes an use of
uninitialized value in iclip/apply_to_row_uv with
clusterfuzz-testcase-minimized-dav1d_fuzzer_mt-5636143299690496. Credits
to oss-fuzz.
parent 70fb01d8
Pipeline #3215 passed with stages
in 7 minutes and 52 seconds
......@@ -475,23 +475,6 @@ void bitfn(dav1d_apply_grain)(Dav1dPicture *const out,
if (data->num_uv_points[1])
generate_scaling(data->uv_points[1], data->num_uv_points[1], scaling[2]);
// Synthesize grain for the affected planes
int rows = (out->p.h + 31) >> 5;
for (int row = 0; row < rows; row++) {
if (data->num_y_points)
apply_to_row_y(out, in, grain_lut[0], scaling[0], row);
if (data->chroma_scaling_from_luma) {
apply_to_row_uv(out, in, grain_lut[1], scaling[0], 0, row);
apply_to_row_uv(out, in, grain_lut[2], scaling[0], 1, row);
} else {
if (data->num_uv_points[0])
apply_to_row_uv(out, in, grain_lut[1], scaling[1], 0, row);
if (data->num_uv_points[1])
apply_to_row_uv(out, in, grain_lut[2], scaling[2], 1, row);
}
}
// Copy over the non-modified planes
// TODO: eliminate in favor of per-plane refs
if (!data->num_y_points) {
......@@ -509,4 +492,21 @@ void bitfn(dav1d_apply_grain)(Dav1dPicture *const out,
}
}
}
// Synthesize grain for the affected planes
int rows = (out->p.h + 31) >> 5;
for (int row = 0; row < rows; row++) {
if (data->num_y_points)
apply_to_row_y(out, in, grain_lut[0], scaling[0], row);
if (data->chroma_scaling_from_luma) {
apply_to_row_uv(out, in, grain_lut[1], scaling[0], 0, row);
apply_to_row_uv(out, in, grain_lut[2], scaling[0], 1, row);
} else {
if (data->num_uv_points[0])
apply_to_row_uv(out, in, grain_lut[1], scaling[1], 0, row);
if (data->num_uv_points[1])
apply_to_row_uv(out, in, grain_lut[2], scaling[2], 1, row);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment