Skip to content

Commit d045571

Browse files
committed
test: cover sinc resampling directions
1 parent 625a8f1 commit d045571

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

memory-bank/coverage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ submodule checkout cannot build `AvsCore` reliably.
177177
| `Overlay` | Public masked overlay filter and format conversion behavior | Public `Overlay` class for YV12, YV16, and YUVA420 with forced 4:4:4 and native subsampled `Blend` working formats, plus YV24/RGBP16/YUV444PS/RGBPS `Add`/`Subtract` modes | Direct constructor with strict two-frame sources and a full-scale mask; independent omitted-mask/full-mask active-plane equivalence, native YV12/YV16/YUVA420 blend plane geometry, YV24 full-opacity endpoint equivalence, 4:2:0/4:2:2 conversion, alpha output coverage, YV24 8-bit full/half-opacity YUV overshoot and underflow chroma compensation, RGBP16 16-bit full/half-opacity channel rounding and saturation, YUV444PS float full/half-opacity add/subtract with luma-driven chroma compensation, RGBPS float unsaturated per-channel arithmetic, YV24 blend base-frame property selection for `_ChromaLocation`/`_ColorRange`/`_FieldBased`, source full-pitch immutability, cache hints, frame requests, and output memory checks. Other modes and script conversion remain separate gaps |
178178
| `VerticalReduceBy2` | Public vertical 2:1 reduction filter | Public `VerticalReduceBy2` class for 8-bit YV24 | Direct constructor with a fixed six-row input; independent 1:2:1 interior and 1:3 final-row references across Y/U/V, source full-pitch immutability, frame requests, and output memory checks |
179179
| `HorizontalReduceBy2` | Public horizontal 2:1 reduction filter | Public `HorizontalReduceBy2` class for 8-bit YV24 | Direct constructor with a fixed eight-pixel input; independent 1:2:1 interior and 1:1 final-column references across Y/U/V, source full-pitch immutability, frame requests, and output memory checks |
180-
| `FilteredResizeH/V` | Public point and coefficient-based resampling filters | Public `FilteredResizeH` and `FilteredResizeV` classes with `PointFilter` for 8-bit YV24; `TriangleFilter` for 8-bit YV12/YV16/YUVA420, 16-bit RGBP16, and packed BGR24/BGR64; `MitchellNetravaliFilter` and `LanczosFilter(3)` for 8-bit YV24; `Spline36Filter` for 8-bit YV24 and 16-bit RGBP16 | Direct constructors with full-frame crops; independent nearest-coordinate, triangle, Mitchell-Netravali, Lanczos, and Spline36 coefficient references including long-support edge folding, 8-/16-bit fixed-point rounding, explicit chroma placement, 4:2:0/4:2:2 plane geometry, planar alpha, GBR planes, packed bottom-up row order, direct horizontal/vertical propagation of `_ChromaLocation`/`_ColorRange`/`_FieldBased`, source full-pitch immutability, cache hints, frame requests, output geometry, and output memory checks. Property-selected factory placement and other resampling filters remain separate gaps |
180+
| `FilteredResizeH/V` | Public point and coefficient-based resampling filters | Public `FilteredResizeH` and `FilteredResizeV` classes with `PointFilter` for 8-bit YV24; `TriangleFilter` for 8-bit YV12/YV16/YUVA420, 16-bit RGBP16, and packed BGR24/BGR64; `MitchellNetravaliFilter` and `LanczosFilter(3)` for 8-bit YV24; `Spline36Filter` for 8-bit YV24 and 16-bit RGBP16; `SincFilter(4)` for 8-bit YV24 | Direct constructors with full-frame crops; independent nearest-coordinate, triangle, Mitchell-Netravali, Lanczos, Spline36, and Sinc coefficient references including long-support edge folding, 8-/16-bit fixed-point rounding, explicit chroma placement, 4:2:0/4:2:2 plane geometry, planar alpha, GBR planes, packed bottom-up row order, direct horizontal/vertical propagation of `_ChromaLocation`/`_ColorRange`/`_FieldBased`, source full-pitch immutability, cache hints, frame requests, output geometry, and output memory checks. Property-selected factory placement and other resampling filters remain separate gaps |
181181
| `FlipVertical` | Public vertical flip filter | Public `FlipVertical` class for 8-bit YV24, YV12, YUVA420, BGR24, BGR64, and 16-bit planar RGB | Direct constructors with independent row-reversal references across full-resolution, subsampled, alpha, packed bottom-up, and planar GBR planes; source full-pitch immutability, cache hints, frame requests, and output memory checks |
182182
| `FlipHorizontal` | Public horizontal flip filter | Public `FlipHorizontal` class for 8-bit YV24, YV12, BGR24, BGR64, and 16-bit planar RGB | Direct constructors with independent per-row reversal references across full-resolution, subsampled, packed bottom-up, and planar GBR planes; YUVA420 double-flip restoration invariant; source full-pitch immutability, cache hints, frame requests, and output memory checks |
183183
| `Crop` | Public crop filter | Public `Crop` class for 8-bit YV24, YV12, YV16, YUVA420, BGR24, and 16-bit planar RGB | Direct constructors with explicit subrectangles; independent luma/chroma and alpha coordinate references, Mod2 subsampled offsets, packed logical rows, `_ChromaLocation`/`_ColorRange`/`_FieldBased` preservation on planar subframes, output geometry, source full-pitch immutability, frame requests, and output memory checks |

tests/resize_filter/resize_filter_tests.cpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct TriangleTap {
4343
int coefficient;
4444
};
4545

46-
enum class ExtraResizeKernel { MitchellNetravali, Lanczos3, Spline36 };
46+
enum class ExtraResizeKernel { MitchellNetravali, Lanczos3, Spline36, Sinc4 };
4747

4848
double mitchell_netravali_value(double value) {
4949
constexpr double b = 1.0 / 3.0;
@@ -90,6 +90,16 @@ double spline36_value(double value) {
9090
return 0.0;
9191
}
9292

93+
double sinc4_value(double value) {
94+
constexpr double pi = 3.14159265358979323846;
95+
value = std::abs(value);
96+
if (value > 0.000001) {
97+
value *= pi;
98+
return std::sin(value) / value;
99+
}
100+
return 1.0;
101+
}
102+
93103
double extra_resize_kernel_value(ExtraResizeKernel kernel, double value) {
94104
switch (kernel) {
95105
case ExtraResizeKernel::MitchellNetravali:
@@ -98,12 +108,17 @@ double extra_resize_kernel_value(ExtraResizeKernel kernel, double value) {
98108
return lanczos3_value(value);
99109
case ExtraResizeKernel::Spline36:
100110
return spline36_value(value);
111+
case ExtraResizeKernel::Sinc4:
112+
return sinc4_value(value);
101113
}
102114
return 0.0;
103115
}
104116

105117
double extra_resize_kernel_support(ExtraResizeKernel kernel) {
106-
return kernel == ExtraResizeKernel::MitchellNetravali ? 2.0 : 3.0;
118+
if (kernel == ExtraResizeKernel::MitchellNetravali) {
119+
return 2.0;
120+
}
121+
return kernel == ExtraResizeKernel::Sinc4 ? 4.0 : 3.0;
107122
}
108123

109124
std::vector<TriangleTap> extra_resize_taps(ExtraResizeKernel kernel, int source_size,
@@ -650,6 +665,9 @@ void run_extra_resize_case(const ExtraResizeCase& test_case) {
650665
case ExtraResizeKernel::Spline36:
651666
filter_function = std::make_unique<Spline36Filter>();
652667
break;
668+
case ExtraResizeKernel::Sinc4:
669+
filter_function = std::make_unique<SincFilter>(4);
670+
break;
653671
}
654672
if (horizontal) {
655673
FilteredResizeH filter(clip, 0.0, static_cast<double>(source_width), target_width,
@@ -707,7 +725,11 @@ INSTANTIATE_TEST_SUITE_P(
707725
ExtraResizeCase{ExtraResizeKernel::Spline36, ResizeDirection::Horizontal,
708726
"Spline36Horizontal"},
709727
ExtraResizeCase{ExtraResizeKernel::Spline36, ResizeDirection::Vertical,
710-
"Spline36Vertical"}),
728+
"Spline36Vertical"},
729+
ExtraResizeCase{ExtraResizeKernel::Sinc4, ResizeDirection::Horizontal,
730+
"Sinc4Horizontal"},
731+
ExtraResizeCase{ExtraResizeKernel::Sinc4, ResizeDirection::Vertical,
732+
"Sinc4Vertical"}),
711733
[](const ::testing::TestParamInfo<ExtraResizeCase>& info) { return info.param.name; });
712734

713735
struct Spline36Rgb16Case {

0 commit comments

Comments
 (0)