Skip to content

VP9 VDPU381 patch v9: Two bugs causing decode artifacts at 2K+ #73

@dongioia

Description

@dongioia

Summary

Your v9 VP9 VDPU381 patch (3564-media-rockchip-rkvdec-vdpu381-add-vp9-support-v9.patch) inherits two bugs from dvab-sarma's original code that cause visual artifacts at resolutions above 1080p.

We tested on RK3588 (Rock 5B+, kernel 7.0-rc3+) with Chromium V4L2 stateless decode. VP9 works perfectly at 720p/1080p but shows corruption at 2K+.

I also reported this upstream to dvab-sarma: dvab-sarma/android_kernel_rk_opi#3

Bug #1 (CRITICAL): Altref vertical scale copy-paste error

In config_registers(), at the scale calculation loop:

case 2:
    regs->vp9_param.reg92.vp9_aref_hor_scale = hscale;
    regs->vp9_param.reg93.vp9_aref_ver_scale = hscale;  // BUG: should be vscale
    break;

Cases 0 and 1 correctly use vscale for vertical. Case 2 (altref) copies hscale instead. This causes incorrect reference frame scaling when the altref has different dimensions from the current frame.

One-line fix:

-    regs->vp9_param.reg93.vp9_aref_ver_scale = hscale;
+    regs->vp9_param.reg93.vp9_aref_ver_scale = vscale;

Bug #2: Segmap buffer overflow at 4K

#define RKVDEC_VP9_MAX_SEGMAP_SIZE 73728

Segmap size = ceil(w/64) * ceil(h/64) * 64. At 4K this is 130,560 bytes, exceeding 73728. This causes buffer overflow and potential memory corruption.

Fix: Increase to 524288 for 8K safety.

NOT bugs (we investigated these too)

  • Missing yuv_virstride: VDPU381 doesn't have this register (confirmed by checking H.264/HEVC backends)
  • Missing lastref_yuv_virstride: Same — hardware design difference from VDPU2

Test setup

  • Rock 5B+ (RK3588), kernel 7.0-rc3+, Mesa 26.0.3, Chromium 148 V4L2 zero-copy
  • Beryllium OS (ex-BredOS)

— Sav (dongioia @ beryllium-org)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions