ref: 564d3d9119da13b6fd288329a734813aa08e11a7
parent: fc968cc90e509c187bfca6035bb9a52873dcccf4
author: Ronald S. Bultje <rsbultje@gmail.com>
date: Fri Nov 15 17:33:43 EST 2019
Don't run film grain generation beyond visible luma border Fixes #309.
--- a/src/fg_apply.h
+++ b/src/fg_apply.h
@@ -36,6 +36,6 @@
bitfn_decls(void dav1d_apply_grain, const Dav1dFilmGrainDSPContext *const dsp,
Dav1dPicture *const out,
- const Dav1dPicture *const in);
+ Dav1dPicture *const in);
#endif /* DAV1D_SRC_FG_APPLY_H */
--- a/src/fg_apply_tmpl.c
+++ b/src/fg_apply_tmpl.c
@@ -91,7 +91,7 @@
#ifndef UNIT_TEST
void bitfn(dav1d_apply_grain)(const Dav1dFilmGrainDSPContext *const dsp,
Dav1dPicture *const out,
- const Dav1dPicture *const in)
+ Dav1dPicture *const in)
{
const Dav1dFilmGrainData *const data = &out->frame_hdr->film_grain.data;
@@ -143,7 +143,7 @@
const int cpw = (out->p.w + ss_x) >> ss_x;
const int is_id = out->seq_hdr->mtrx == DAV1D_MC_IDENTITY;
for (int row = 0; row < rows; row++) {
- const pixel *const luma_src =
+ pixel *const luma_src =
((pixel *) in->data[0]) + row * BLOCK_SIZE * PXSTRIDE(in->stride[0]);
if (data->num_y_points) {
@@ -153,7 +153,23 @@
out->p.w, scaling[0], grain_lut[0], bh, row HIGHBD_TAIL_SUFFIX);
}
+ if (!data->num_uv_points[0] && !data->num_uv_points[1] &&
+ !data->chroma_scaling_from_luma)
+ {
+ continue;
+ }
+
const int bh = (imin(out->p.h - row * BLOCK_SIZE, BLOCK_SIZE) + ss_y) >> ss_y;
+
+ // extend padding pixels
+ if (out->p.w & ss_x) {
+ pixel *ptr = luma_src;
+ for (int y = 0; y < bh; y++) {
+ ptr[out->p.w] = ptr[out->p.w - 1];
+ ptr += PXSTRIDE(in->stride[0]) << ss_y;
+ }
+ }
+
const ptrdiff_t uv_off = row * BLOCK_SIZE * PXSTRIDE(out->stride[1]) >> ss_y;
if (data->chroma_scaling_from_luma) {
for (int pl = 0; pl < 2; pl++)
--- a/src/mc_tmpl.c
+++ b/src/mc_tmpl.c
@@ -905,7 +905,6 @@
src_x += mx >> 14;
mx &= 0x3fff;
}
- if (dst_w & 1) dst[dst_w] = dst[dst_w - 1];
dst += PXSTRIDE(dst_stride);
src += PXSTRIDE(src_stride);