12 Prefiltered Pixel Reconstruction Workflow
Ronald S. Bultje edited this page 2026-04-07 13:45:38 +00:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Prefiltered Pixel Reconstruction Workflow

This page explains how to extract pre-filtered pixel reconstructions (the decoder output before any in-loop post-filters) from both avmdec and dav2d. These reconstructions act as a stable, filter-independent reference for verifying decoder correctness.

This workflow is useful when identifying and isolating pixel-level mismatch without the noise introduced by inloop filters like deblocking, CDEF, loop restoration, CCSO, or GDF.

This guide covers:

  1. Applying the necessary dav2d patches to AVM
  2. Building the patched avmdec
  3. Generating prefiltered Y4M outputs from both decoders
  4. Comparing their luma planes (MD5 or YUV Viewer)

Prefiltered Pixel Reconstruction in AVM

Step 1: Apply the dav2d patches to AVM

The dav2d repository provides several patches for AVM under:

dav2d/patches/

For prefiltered reconstruction, the key patch is:

0005-Add-loopfilters-to-enable-disable-loopfilters.patch

However, since youre already here, simply apply all patches:

cd /path/to/avm
git am ${DAV2D}/patches/*.patch

where ${DAV2D} is the path to your dav2d repository.

This gives avmdec the --inloopfilters= flag that allows disabling all postfilters.

Step 2: Build the patched version of avmdec

We typically build AVM in a dedicated x86-64 directory and disable unused components (encoder + tests) for faster builds:

mkdir x86-64
cd x86-64
cmake .. -DENABLE_TESTS=0 -DCONFIG_AV1_ENCODER=0 -DCMAKE_BUILD_TYPE=Debug
make -j$(nproc) avmdec

Step 3: Run avmdec with in-loop filters disabled

To extract the prefiltered pixels, run:

./avmdec "$file" -o avm.y4m --limit=1 --inloopfilters=none

This disables:

  • Deblocking
  • CDEF
  • Loop restoration
  • CCSO
  • GDF

The resulting avm.y4m contains only unfiltered reconstructed pixels.

Prefiltered Pixel Reconstruction in Dav2d

dav2d already supports disabling in-loop filters via the same flag. From the dav2d build directory, run:

./tools/dav1d -i "$file" -o dav1d.y4m --limit=1 --inloopfilters=none --threads=1 --quiet

The output dav1d.y4m now contains dav2ds prefiltered reconstruction.

Note: Currently, dav2d only decodes luma reconstructed samples.

Comparing the AVM and dav2d Prefiltered Outputs (MD5)

To quickly check whether the two reconstructions match, compute an MD5 of the luma plane only.

Using ffmpeg:

a_md5=$(ffmpeg -loglevel error -i avm.y4m -f rawvideo -pix_fmt gray - | md5sum | cut -d' ' -f1)
d_md5=$(ffmpeg -loglevel error -i dav1d.y4m -f rawvideo -pix_fmt gray - | md5sum | cut -d' ' -f1)
diff <(echo "$a_md5") <(echo "$d_md5")

If diff prints nothing, the luma planes match.

Visual Comparison in a YUV Viewer

To investigate mismatches more closely, open the Y4M files in a YUV viewer such as YUVview

When using YUVView:

  • Load both avm.y4m and dav1d.y4m.
  • Select “Luma (Y) Only” in the Color Component menu.
  • You can use the Difference View to visually inspect mismatches.

Screenshot_from_2025-11-28_15-03-44