3.1.8.1.7.2 RLGR3
The core RLGR algorithm [ARLGR] switches between the Run-Length and the Golomb-Rice mode as a stream of data is encoded, based on the Run-Length parameter, k, as shown in figure "Adaptation rule for RLGR1/RLGR3 main parameter k" in section 3.1.8.1.7.2. The Golomb-Rice mode in the RLGR algorithm [ARLGR], operates by encoding one coefficient at a time and updating the Golomb-Rice parameter, kR, as shown in figure "Adaptation rule for RLGR1/RLGR3 parameter kR" in section 3.1.8.1.7.2. In RLGR3, the Run-Length mode parameter, k, and the Golomb-Rice parameter, kR, are updated exactly as in RLGR1, but the Golomb-Rice mode is processed differently. Once the algorithm enters into the Golomb-Rice mode, RLGR3 takes the sum of the next two coefficients and Golomb-Rice encodes the sum and updates the parameters k and kR as with RLGR1. After the sum is encoded, the value of the first coefficient is emitted as binary code in the exact number of bits it takes to represent the sum. Pseudocode for Golomb-Rice mode in RLGR3 encode follows.
-
ENCODER GOLOMB-RICE MODE: SUM = COEFF[n] + COEFF[n+1] // sum of the next two coefficients in the input stream GOLOMB_RICE_ENCODE(SUM) // Golomb-Rice encode the value of SUM BINARY_ENCODE(COEFF[n]) // using LOG2(SUM) bits UPDATE_RLGR_PARAMETERS(SUM) // update RLGR parameters (k,kR) based on SUM
The decoder follows the same sequence of steps as the encoder, as it decodes the encoded data. The pseudocode for the decoder in Golomb-Rice mode is given below.
-
DECODER GOLOMB-RICE MODE: SUM = GOLOMB_RICE_DECODE() // decode the next value from the encoded stream NBS = LOG2(SUM) // number of bits in binary representation of SUM COEFF[n] = BINARY_DECODE(NBS) // read next NBS bits from input stream as COEFF[n] COEFF[n+1] = SUM – COEFF[n] // compute COEFF[n+1] UPDATE_RLGR_PARAMETERS(SUM) // update RLGR parameters (k,kR) based on SUM
In general, RLGR3 encodes faster than RLGR1 but is marginally worse in terms of compression ratio.