diff --git a/source/wnnm.cpp b/source/wnnm.cpp index b458b78..db8ab05 100644 --- a/source/wnnm.cpp +++ b/source/wnnm.cpp @@ -1537,7 +1537,11 @@ static const VSFrameRef *VS_CC VAggregateGetFrame( std::memset(buffer, 0, 2 * plane_width * sizeof(float)); for (int i = 0; i < 2 * d->radius + 1; ++i) { auto agg_src = srcps[i]; - agg_src += ((2 * d->radius - i) * 2 * plane_height + y) * plane_stride; + // bm3d.VAggregate implements zero padding in temporal dimension + // here we implements replication padding + agg_src += ( + std::clamp(2 * d->radius - i, n + d->radius, n - d->src_vi->numFrames + 1 + d->radius) + * 2 * plane_height + y) * plane_stride; for (int x = 0; x < plane_width; ++x) { buffer[x] += agg_src[x]; }