fix(graphics): mirror decoder GR-mode adaptation in RLGR1 encoder#1370
fix(graphics): mirror decoder GR-mode adaptation in RLGR1 encoder#1370Rocco De Angelis (rdeangel) wants to merge 1 commit into
Conversation
In the GR-mode zero branch the RLGR1 encoder updated kp with UP_GR (+4) while the decoder (compute_rlgr1_magnitude) uses UQ_GR (+3). The asymmetric adaptation makes the adaptive k parameter diverge between the two sides, after which the bitstream is misinterpreted: a randomized encode->decode round-trip failed on 1877 of 2000 inputs before this change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Nice catch. The One note for merge ordering: elmarco's draft #1179 fixes this same Good to see this one fixed regardless. It's on the RemoteFX Progressive encode path that #1199's round-trip tests cover. |
|
Thanks for flagging the overlap with #1179. If this lands first, elmarco can drop the overlapping hunk on rebase, otherwise happy to wait, whatever you prefer. |
Problem
In
rlgr::encode, the RLGR1 GR-mode zero branch updateskpwithUP_GR(+4), while the decoder's corresponding branch (compute_rlgr1_magnitude) usesUQ_GR(+3), which is the value MS-RDPRFX 3.1.8.1.7.2 and FreeRDP'srfx_rlgr.cprescribe for GR mode. Because RLGR adaptation is implicit, encoder and decoder must updatekidentically from the coded symbols alone; with this mismatch the two sides'kdiverges as soon as a zero value is coded in GR mode, and the remainder of the bitstream is misinterpreted (mode selection and run lengths depend onk).Evidence
A randomized encode→decode round-trip (deterministic LCG, mostly-zero inputs with small magnitudes, i.e. the shape of quantized wavelet coefficients) failed on 1877 of 2000 inputs before this change. Example:
The divergence starts right after the first GR-mode zero. With the one-line fix, all 2000 round-trips pass.
Changes
UQ_GRin the GR-mode zero branch of the RLGR1 encoder, mirroring the decoder.rlgr1_round_trip_randomizedregression test (rlgr.rspreviously had no tests).Found while debugging RemoteFX Progressive (EGFX) interop against xrdp in an IronRDP-based client.
🤖 Generated with Claude Code