This testbench was tested with GNU Octave v4.2.1

The main entry is qmat_test, which compares scaling_list_data bit counts with different encoding methods:
- HEVC with HEVC test set
- JVET-N0847 (same as VVC draft 6), JVET-O0223, and current proposal with VVC test set

Test execution can take several minutes.
For JVET-O0223 and related, unused high-frequency coefficients of size-64 QMs may be optimized, which is indicated in the report by [+x*] symbols (+: INTRA, x:INTER, *:both). When a tolerance is specified, average error is also reported.

To enable direct comparison between HEVC and VVC, the VVC test set is automatically generated from the HEVC one present in testset-hevc folder. VVC matrices are derived by extending HEVC ones using qmat_test_extend (see also make_testset_hevc2vvc).

Custom test matrices can be added to testset-hevc folder, and referred to in the "testset" variable of qmat_test.m.
VVC test set should then be regenerated by calling make_testset_hevc2vvc.
If adding custom matrices directly in VVC format in testset-vvc folder, then corresponding HEVC matrices should be generated by calling make_testset_vvc2hevc (drops size-2 and size-16 QMs then squeezes the result).

Note: make_testset_vvc("hard"), not used by default, generates an harder-to-code VVC test set by making an average of size-8 and size-32 QM for size-16 instead of copies of size-32, so that all matrices are potentially different.

Other features can be adjusted in qmat_test.m:
- 'verbose' enables bit count report for each QM of each test
- 'check_decode' enables actual encode/decode instead of just bit count, and verifies match (reported by [OK] or [failed])
- 'use_default' enables use of default QMs as predictors (see qmat_default.m for definition, which can be customized)
- 'TOL' can be used to repeat the test with different error tolerance values, and observe the impact on bit count. Residual (when available) is truncated to the number of coefficients needed to comply with the tolerance.

Digging further and executing separately qmat_compress_xxx with a single entry in "testset" provides more details about QM encoding, like how they are modified by error tolerance, and what references, coefficients numbers, scales, were chosen for each QM.

---
Changes in version 2
- P0110-*: bug fix when using custom default matrices (were forced to all-16)
- Provide a variant for default matrices (either flat or ramp)
- Lossy mode: aligned tolerance restriction algorithm for all variants, and added a control parameter
- Restricted tolerance means:
  - force lossless for 1st matrixId or flat prediction
  - prevent propagation of optimized-out size-64 HF coefficients
- Changed error metric to give more weight to DC error
  - from (SAD(QM)+abs(DC_diff))/n to max(MAD(QM),abs(DC_diff))

Changes in version 1b
- O0223 & P0110-*: bug fix in decoded Qm cache at encode side (caused sporadic encode/decode mismatches in lossy mode)
- P0110-*: bug fix in error estimation for automatic coefNum, lacking proper 8-bit wrap-around (caused sporadic tolerance violation in lossy mode for P0110_1)

---
Copyright (c) 2019-Present InterDigital R&D France. All rights reserved.
This project is made available under the Clear BSD license found in the LICENSE.md file in the root directory of this package.

