Skip to content

Commit

Permalink
{source, rtc_source, cpu_source}/source.cpp: fix temporal padding for…
Browse files Browse the repository at this point in the history
… `VAggregate()`

related issue: WolframRhodium/VapourSynth-WNNM#4
  • Loading branch information
WolframRhodium committed Jul 15, 2022
1 parent b489dcb commit c15ec0d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion cpu_source/source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,11 @@ static const VSFrameRef *VS_CC VAggregateGetFrame(
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->src_vi->numFrames + 1 + d->radius, n + d->radius)
* 2 * plane_height + y) * plane_stride;
for (int x = 0; x < plane_width; ++x) {
buffer[x] += agg_src[x];
}
Expand Down
6 changes: 5 additions & 1 deletion rtc_source/source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,11 @@ static const VSFrameRef *VS_CC VAggregateGetFrame(
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->src_vi->numFrames + 1 + d->radius, n + d->radius)
* 2 * plane_height + y) * plane_stride;
for (int x = 0; x < plane_width; ++x) {
buffer[x] += agg_src[x];
}
Expand Down
6 changes: 5 additions & 1 deletion source/source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,11 @@ static const VSFrameRef *VS_CC VAggregateGetFrame(
memset(buffer, 0, 2 * plane_width * sizeof(float));
for (int i = 0; i < 2 * d->radius + 1; ++i) {
const float * 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->src_vi->numFrames + 1 + d->radius, n + d->radius)
* 2 * plane_height + y) * plane_stride;
for (int x = 0; x < plane_width; ++x) {
buffer[x] += agg_src[x];
}
Expand Down

0 comments on commit c15ec0d

Please sign in to comment.