Skip to content

Commit 207ba1e

Browse files
Fix run-to-run non-determinism in non-separable Wiener filter (#5034)
Fix encoder run-to-run non-determinism caused by uninitialized memory in the non-separable Wiener filter restoration search path (av2/encoder/pickrst.c). Multiple runs of the same encoding with identical inputs produce different chroma (U/V) results while luma (Y) is always identical. Reproduced with 4:2:2 12-bit content (SolLevanteFace) at QP 135, cpu-used=0, threads=2, described in issue #1500 , and r2r issue still occurs for some inter frame occasionally before this fix.
1 parent a5f7c81 commit 207ba1e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

av2/encoder/pickrst.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2049,6 +2049,7 @@ static void gather_stats_wienerns(const RestorationTileLimits *limits,
20492049
rui.cm = rsc->cm;
20502050
// Calculate and save this RU's stats.
20512051
RstUnitStats unit_stats;
2052+
memset(&unit_stats, 0, sizeof(unit_stats));
20522053
RestUnitSearchInfo *rusi = &rsc->rusi[rest_unit_idx];
20532054
unit_stats.real_sse = 0;
20542055
if (!rusi->bru_unit_skipped) {
@@ -3796,7 +3797,7 @@ void av2_pick_filter_restoration(const YV12_BUFFER_CONFIG *src, AV2_COMP *cpi) {
37963797
// left uninitialised when we reach copy_unit_info(...). This is not a
37973798
// problem, as these elements are ignored later, but in order to quiet
37983799
// Valgrind's warnings we initialise the array below.
3799-
memset(rusi, 0, sizeof(*rusi) * ntiles[0]);
3800+
memset(rusi, 0, sizeof(*rusi) * max_ntile);
38003801
x->rdmult = cpi->rd.RDMULT;
38013802

38023803
Vector unit_stack;

0 commit comments

Comments
 (0)