Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3128,6 +3128,15 @@ the simple slots are full at four).
- **The Noise Reduction pass's preview radius is per method**
(`NoiseReductionParameters::temporal_radius`): BM3D's Final step re-reads
its basic estimate's neighbours, so it reaches 2r; a fixed 3 was too few.
MCTemporalDenoise's high and very high profiles reach 6-10 frames
(`mctd_reach`: two MDegrain passes, TTempSmooth, and `post`'s FFT3D
window), and their preview was off its encode until task #141. A new
argument that reads more frames must be added there.
- **MCTemporalDenoise has no Sigma** (task #141): havsfunc reads `sigma`
only with `pfMode=0`, which the template never passes. Its strength beyond
the profile is Post-denoise (`mcTemporalPost`, havsfunc's `post`, an
FFT3DFilter pass), off at 0 and left out of the script then
(docs/reports/task-141-mctd-sigma).

### SangNom, NLMeans (CPU) and the vs-jetpack ports (deps 1.16.0, app 1.7.0)

Expand Down Expand Up @@ -4093,7 +4102,8 @@ Rules:
second process did, on some runners. Every template call passes
`measure=0` (FFTW_ESTIMATE: one plan per machine, in every process;
`test_261`), and the patch makes 0 the plugin's default (deps 1.18.0-rc2),
for havsfunc's calls (QTGMC, MCTemporalDenoise), which pass none. Both are
for havsfunc's calls (QTGMC, MCTemporalDenoise's prefilter and its `post`
pass, task #141), which pass none. Both are
needed: FFTW reuses a measured plan made earlier in a process for a later
ESTIMATE request of the same problem, so one measured call undoes the rest
(docs/reports/task-80-fft3dfilter-fftw-estimate).
Expand Down
2 changes: 1 addition & 1 deletion Scripts/probe-plugin-formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def call(key, covers, run):
lambda c: module('removedirt', 'remove_dirt', c, post_denoise=True))
# Noise reduction
call('havsfunc.SMDegrain', ['havsfunc.SMDegrain'], lambda c: haf.SMDegrain(c, tr=2, thSAD=300, thSADC=150, RefineMotion=True, prefilter=2, contrasharp=False))
call('havsfunc.MCTemporalDenoise', ['havsfunc.MCTemporalDenoise'], lambda c: haf.MCTemporalDenoise(c, settings='medium', sigma=4.0, radius=2))
call('havsfunc.MCTemporalDenoise', ['havsfunc.MCTemporalDenoise'], lambda c: haf.MCTemporalDenoise(c, settings='medium', radius=2, post=4.0))
call('dfttest.DFTTest', ['dfttest.DFTTest'], lambda c: core.dfttest.DFTTest(c, sigma=8.0, tbsize=3, sbsize=16))
call('fft3dfilter.FFT3DFilter', ['fft3dfilter.FFT3DFilter'], lambda c: core.fft3dfilter.FFT3DFilter(c, sigma=2.0, bt=3, sharpen=0.0, measure=0))
call('ttmpsm.TTempSmooth', ['ttmpsm.TTempSmooth'], lambda c: core.ttmpsm.TTempSmooth(c, maxr=3, thresh=[4], mdiff=[2], strength=2))
Expand Down
25 changes: 16 additions & 9 deletions app/assets/filters/core/noise_reduction.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"function": "haf.MCTemporalDenoise",
"parameters": [
"mcTemporalProfile",
"mcTemporalSigma",
"mcTemporalPost",
"mcTemporalRadius"
]
},
Expand Down Expand Up @@ -401,19 +401,19 @@
}
}
},
"mcTemporalSigma": {
"mcTemporalPost": {
"type": "number",
"default": 4.0,
"default": 0.0,
"min": 0.0,
"max": 20.0,
"max": 16.0,
"step": 0.5,
"optional": true,
"vapoursynth": {
"name": "sigma"
"name": "post"
},
"sinceAppVersion": "1.8.0",
"ui": {
"label": "Sigma",
"description": "Noise sigma estimate",
"label": "Post-denoise",
"description": "An extra spatial FFT3D pass after the temporal denoise, at this strength (0 = off). For very heavy noise the profile leaves behind; it softens clean pictures and slows the pass",
"widget": "slider",
"precision": 1,
"visibleWhen": {
Expand Down Expand Up @@ -1469,11 +1469,18 @@
"title": "MCTemporalDenoise",
"parameters": [
"mcTemporalProfile",
"mcTemporalSigma",
"mcTemporalRadius"
],
"expanded": true
},
{
"title": "MCTemporalDenoise tuning",
"parameters": [
"mcTemporalPost"
],
"expanded": false,
"advancedOnly": true
},
{
"title": "QTGMC built-in",
"parameters": [
Expand Down
14 changes: 9 additions & 5 deletions app/lib/models/noise_reduction_parameters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,12 @@ class NoiseReductionParameters {

// --- MCTemporalDenoise Parameters ---

/// Denoise strength/sigma.
final double mcTemporalSigma;
/// havsfunc's `post`: an FFT3DFilter pass after the temporal denoise, at
/// this sigma (8-bit units). 0 (the default) leaves it out of the script.
/// It replaced `mcTemporalSigma`, which havsfunc reads only with
/// `pfMode=0` and so changed nothing (task #141); JSON that still carries
/// `mcTemporalSigma` loads, and the key is ignored.
final double mcTemporalPost;

/// Temporal radius for MCTemporalDenoise.
final int mcTemporalRadius;
Expand Down Expand Up @@ -291,7 +295,7 @@ class NoiseReductionParameters {
this.smDegrainPrefilter = 2,
this.smDegrainThSCD1 = 400,
// MCTemporalDenoise defaults
this.mcTemporalSigma = 4.0,
this.mcTemporalPost = 0.0,
this.mcTemporalRadius = 2,
this.mcTemporalProfile = 'medium',
// MCDegrainSharp defaults (Didée's published values)
Expand Down Expand Up @@ -380,7 +384,7 @@ class NoiseReductionParameters {
bool? smDegrainRefine,
int? smDegrainPrefilter,
int? smDegrainThSCD1,
double? mcTemporalSigma,
double? mcTemporalPost,
int? mcTemporalRadius,
String? mcTemporalProfile,
int? mcdsFrames,
Expand Down Expand Up @@ -442,7 +446,7 @@ class NoiseReductionParameters {
smDegrainRefine: smDegrainRefine ?? this.smDegrainRefine,
smDegrainPrefilter: smDegrainPrefilter ?? this.smDegrainPrefilter,
smDegrainThSCD1: smDegrainThSCD1 ?? this.smDegrainThSCD1,
mcTemporalSigma: mcTemporalSigma ?? this.mcTemporalSigma,
mcTemporalPost: mcTemporalPost ?? this.mcTemporalPost,
mcTemporalRadius: mcTemporalRadius ?? this.mcTemporalRadius,
mcTemporalProfile: mcTemporalProfile ?? this.mcTemporalProfile,
mcdsFrames: mcdsFrames ?? this.mcdsFrames,
Expand Down
4 changes: 2 additions & 2 deletions app/lib/models/parameter_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class ParameterConverter {
'smDegrainRefine': params.smDegrainRefine,
'smDegrainPrefilter': params.smDegrainPrefilter,
'smDegrainThSCD1': params.smDegrainThSCD1,
'mcTemporalSigma': params.mcTemporalSigma,
'mcTemporalPost': params.mcTemporalPost,
'mcTemporalRadius': params.mcTemporalRadius,
'mcTemporalProfile': params.mcTemporalProfile,
'mcdsFrames': params.mcdsFrames,
Expand Down Expand Up @@ -1396,7 +1396,7 @@ class ParameterConverter {
smDegrainRefine: v['smDegrainRefine'] as bool? ?? true,
smDegrainPrefilter: v['smDegrainPrefilter'] as int? ?? 2,
smDegrainThSCD1: v['smDegrainThSCD1'] as int? ?? 400,
mcTemporalSigma: (v['mcTemporalSigma'] as num?)?.toDouble() ?? 4.0,
mcTemporalPost: (v['mcTemporalPost'] as num?)?.toDouble() ?? 0.0,
mcTemporalRadius: v['mcTemporalRadius'] as int? ?? 2,
mcdsFrames: _asInt(v['mcdsFrames']) ?? 2,
mcdsBlur: (v['mcdsBlur'] as num?)?.toDouble() ?? 0.3,
Expand Down
26 changes: 25 additions & 1 deletion app/test/integration_fft3dfilter_determinism_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
// Task #80: a preview and its encode are two processes, and FFT3DFilter's
// old default (measure=1) let FFTW time a different plan in each. The
// templates pass measure=0; havsfunc's QTGMC call passes nothing and relies
// on the patched default (deps 1.18.0-rc2 on), checked by the QTGMC case.
// on the patched default (deps 1.18.0-rc2 on), checked by the QTGMC case,
// as does MCTemporalDenoise's `post` pass (task #141, the mctd_post case).
// docs/reports/task-80-fft3dfilter-fftw-estimate.
@Tags(['heavy'])
@Timeout(Duration(minutes: 30))
Expand Down Expand Up @@ -124,6 +125,29 @@ void main() {
deint: noDeint,
since: '1.18.0-rc1',
),
// Task #141: MCTD's Post-denoise is havsfunc's own FFT3DFilter call (bt 3
// at high, 4 at very high), which passes no measure and so relies on the
// patched default, like QTGMC's. These two profiles also read past the
// preview's old window of 3 (two MDegrain passes and TTempSmooth): before
// `mctd_reach`, high's preview was up to 2 levels off its encode.
'mctd_high_post': (
nr: NoiseReductionParameters(
enabled: true,
method: NoiseReductionMethod.mcTemporalDenoise,
mcTemporalProfile: 'high',
mcTemporalPost: 4.0),
deint: noDeint,
since: '1.18.0-rc2',
),
'mctd_very_high_post': (
nr: NoiseReductionParameters(
enabled: true,
method: NoiseReductionMethod.mcTemporalDenoise,
mcTemporalProfile: 'very high',
mcTemporalPost: 6.0),
deint: noDeint,
since: '1.18.0-rc2',
),
// havsfunc's FFT3DFilter call (NoiseTR 1: bt 3) takes the plugin's
// default; single rate, so output frame n is source frame n.
'qtgmc_fft3dfilter': (
Expand Down
26 changes: 25 additions & 1 deletion app/test/integration_filter_parameters_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,30 @@ void main() {
// that fails silently: a name mismatch anywhere and the filter runs with
// its defaults while the UI shows the user's values.

// Task #141: Sigma did nothing (havsfunc reads it only with pfMode=0)
// and is gone; Post-denoise passes `post`, off (absent) at its default.
test('noise reduction: MCTemporalDenoise post, no sigma', () async {
final schema = loadSchema('noise_reduction');
expect(schema.parameters.containsKey('mcTemporalSigma'), isFalse);
expect(schema.parameters['mcTemporalPost']!.defaultValue, 0.0);
for (final (post, expected) in [(0.0, null), (6.0, '6.0'), (2.5, '2.5')]) {
// Through the panel's path: the converter's dynamic values.
final dyn = ParameterConverter.fromNoiseReduction(const NoiseReductionParameters(
enabled: true,
method: NoiseReductionMethod.mcTemporalDenoise,
mcTemporalProfile: 'high',
)).withValue('mcTemporalPost', post);
final typed = ParameterConverter.toNoiseReduction(dyn);
final job = buildJob(testName: 'nr_mctd_post_$post', noiseReduction: typed);
final script = await generateScriptViaWorker(job);
expect(script, contains('haf.MCTemporalDenoise('));
final actual = parseFilterParams(script, 'haf.MCTemporalDenoise(');
expect(actual['settings'], '"high"');
expect(actual.containsKey('sigma'), isFalse, reason: 'post=$post');
expect(actual['post'], expected, reason: 'post=$post');
}
}, timeout: const Timeout(Duration(minutes: 2)));

test('noise reduction: DFTTest params', () async {
loadSchema('noise_reduction');
final typed = const NoiseReductionParameters(
Expand Down Expand Up @@ -2297,7 +2321,7 @@ void main() {
group('Strength steps (issue #177)', () {
const keywords = {
'smDegrainTr': 'tr', 'smDegrainThSAD': 'thSAD',
'mcTemporalProfile': 'settings', 'mcTemporalSigma': 'sigma', 'mcTemporalRadius': 'radius',
'mcTemporalProfile': 'settings', 'mcTemporalPost': 'post', 'mcTemporalRadius': 'radius',
'qtgmcEzDenoise': 'EZDenoise',
'mcleanStrength': 'strength', 'mcleanThsad': 'thSAD', 'mcleanRn': 'rn', 'mcleanSharp': 'sharp',
'strength': 'strength', 'overshoot': 'overshoot', 'undershoot': 'undershoot',
Expand Down
2 changes: 0 additions & 2 deletions app/test/integration_filter_pipeline_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,6 @@ void main() {
noiseReduction: const NoiseReductionParameters(
enabled: true,
method: NoiseReductionMethod.mcTemporalDenoise,
mcTemporalSigma: 4.0,
mcTemporalRadius: 2,
),
),
Expand Down Expand Up @@ -1584,7 +1583,6 @@ void main() {
noiseReduction: NoiseReductionParameters(
enabled: true,
method: NoiseReductionMethod.mcTemporalDenoise,
mcTemporalSigma: 4.0,
mcTemporalRadius: 2,
),
),
Expand Down
21 changes: 21 additions & 0 deletions app/test/integration_strength_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,25 @@ void main() {
});
}
}

// Task #141: MCTD's Sigma did nothing and was replaced by Post-denoise
// (havsfunc's `post`). At sigma 6 the medium profile barely denoises
// (34.5 dB from 32.6 in the report); post 6 takes it most of the way to
// clean (42.5). Preview = encode for it is checked in
// integration_fft3dfilter_determinism_test.dart.
test('noise_reduction mc_temporal_denoise: Post-denoise acts on heavy noise', () async {
Future<String> encode(double post) => _run(
_job(noisy, 'mctd_post_$post', ProcessingPipeline(
deinterlace: const QTGMCParameters(enabled: false),
noiseReduction: NoiseReductionParameters(
enabled: true,
method: NoiseReductionMethod.mcTemporalDenoise,
mcTemporalPost: post))),
'MCTD post $post');
final off = await _psnrY(await encode(0), clean);
final on = await _psnrY(await encode(6), clean);
// ignore: avoid_print
print('MCTD medium at sigma 6: post 0 $off dB, post 6 $on dB');
expect(on, greaterThan(off + 3.0), reason: 'post 6 should remove clearly more noise');
});
}
4 changes: 2 additions & 2 deletions app/test/parameter_converter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ void main() {
const params = NoiseReductionParameters(
enabled: true,
method: NoiseReductionMethod.mcTemporalDenoise,
mcTemporalSigma: 5.0,
mcTemporalPost: 5.0,
mcTemporalRadius: 3,
);
final dynamic = ParameterConverter.fromNoiseReduction(params);

expect(dynamic.values['method'], 'mc_temporal_denoise');
expect(dynamic.values['mcTemporalSigma'], 5.0);
expect(dynamic.values['mcTemporalPost'], 5.0);
expect(dynamic.values['mcTemporalRadius'], 3);
});
});
Expand Down
12 changes: 6 additions & 6 deletions app/test/schema_converter_integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ void main() {
const original = NoiseReductionParameters(
enabled: true,
method: NoiseReductionMethod.mcTemporalDenoise,
mcTemporalSigma: 6.0,
mcTemporalPost: 6.0,
mcTemporalRadius: 3,
mcTemporalProfile: 'high',
);
Expand All @@ -688,7 +688,7 @@ void main() {
final restored = ParameterConverter.toNoiseReduction(dynamic);

expect(restored.method, original.method);
expect(restored.mcTemporalSigma, original.mcTemporalSigma);
expect(restored.mcTemporalPost, original.mcTemporalPost);
expect(restored.mcTemporalRadius, original.mcTemporalRadius);
expect(restored.mcTemporalProfile, original.mcTemporalProfile);
});
Expand Down Expand Up @@ -977,8 +977,8 @@ void main() {
model.smDegrainRefine);
expect(schema.parameters['smDegrainPrefilter']!.defaultValue,
model.smDegrainPrefilter);
expect(schema.parameters['mcTemporalSigma']!.defaultValue,
model.mcTemporalSigma);
expect(schema.parameters['mcTemporalPost']!.defaultValue,
model.mcTemporalPost);
expect(schema.parameters['mcTemporalRadius']!.defaultValue,
model.mcTemporalRadius);
expect(schema.parameters['mcTemporalProfile']!.defaultValue,
Expand Down Expand Up @@ -1185,8 +1185,8 @@ void main() {
reason: 'smDegrainRefine fallback mismatch');
expect(result.smDegrainPrefilter, model.smDegrainPrefilter,
reason: 'smDegrainPrefilter fallback mismatch');
expect(result.mcTemporalSigma, model.mcTemporalSigma,
reason: 'mcTemporalSigma fallback mismatch');
expect(result.mcTemporalPost, model.mcTemporalPost,
reason: 'mcTemporalPost fallback mismatch');
expect(result.mcTemporalRadius, model.mcTemporalRadius,
reason: 'mcTemporalRadius fallback mismatch');
expect(result.mcTemporalProfile, model.mcTemporalProfile,
Expand Down
39 changes: 37 additions & 2 deletions docs/ENGINEERING_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7164,8 +7164,8 @@ What it found beyond the steps:
Strong and Very strong.
- **MCTemporalDenoise's Sigma is inert**: havsfunc reads it only for pfMode 0
or `post` > 0, which VapourBox never passes. Every sigma from 2 to 12 gave
identical output. Strength sets MCTD's own profile instead; the dead control
is task #141.
identical output. Strength sets MCTD's own profile instead; task #141 then
replaced the control with Post-denoise (`post`, entry below).
- **QTGMC built-in's default did nothing** (EZDenoise 0). Its default is now
the measured Medium, 5.
- **SMDegrain's default is 3.6 dB short of its best at sigma 4** (38.8 vs
Expand Down Expand Up @@ -7210,3 +7210,38 @@ sync queue (0.13 s before the fix). Only the layout was measured, on macOS
arm64; no player was tested.

Report: [docs/reports/issue-266-subtitle-interleave](reports/issue-266-subtitle-interleave/index.html).

### MCTemporalDenoise's Sigma replaced by Post-denoise (task #141, 2026-11-28)

The Sigma slider of the Noise Reduction pass's MCTemporalDenoise method was
passed as `sigma=` to havsfunc r31, which reads it only for its `pfMode=0`
prefilter; VapourBox passes no `pfMode` (havsfunc's 3, DFTTest), so every sigma
gave the same picture (spread 0.0000 dB over 45 cells). Measured on issue
#177's fixtures through the worker:

- **Sigma and `mcTemporalSigma` are gone.** Old JSON that carries the key
still loads (serde and json_serializable ignore it); a default job's script
loses only `sigma=4.0,`, and its output is unchanged.
- **Post-denoise (`mcTemporalPost`, advanced only, default 0 = off) is
havsfunc's `post`**: an FFT3DFilter pass after the temporal denoise. It
acts in order (medium at noise sigma 6: 34.5 -> 43.1 dB at post 8), but it
is spatial: 1.3-10.7 dB lost on a clean picture, 1.3-1.8x the time. Left
out of the script at 0, clamped to 16. `pfMode=0` would also make sigma act,
but it replaces the prefilter for every job (default output changes) and
recovers less at heavy noise.
- **The Strength steps don't set it**: at Strong's and Very strong's own noise
levels it adds at most 0.5 dB and costs 1.3-3.4 dB on clean pictures.
- **Issue #177's guess about low/medium on heavy noise is wrong for MCTD.**
`thSCD1` 800-2000 gains at most 0.7 dB, `thSAD` 600/1200 0.15, `limit=0`
about 3 dB at sigma 6 (2-5 dB lost on clean) and nothing at sigma 9. Low and
medium are light-noise profiles; high and very high are the heavy-noise ones.
At a real hard cut every `thSCD1` gives the default's output.
- **MCTD's preview reach was short.** High and very high run MDegrain twice
and a stabilizing TTempSmooth, reaching 6 frames each side (7-8 with
`post`, 10 at radius 4); the preview decoded 3, and high's preview was up to
2 levels off the lossless encode. `NoiseReductionParameters::mctd_reach`
declares it from havsfunc's per-profile defaults; previews now match
sample for sample (`integration_fft3dfilter_determinism_test.dart`, which
also checks `post` keeps FFT3DFilter's patched `measure=0` default).

Report: [docs/reports/task-141-mctd-sigma](reports/task-141-mctd-sigma/index.html).
Loading
Loading