Repository navigation
Conversation
The arithmetic decoder keeps the interval as a 9-bit range and a 32-bit window of the bitstream, refilled 16 bits at a time, instead of the draft's shift counts and 8-bit remainders (rS1/rT1, valueS/valueT): the form AVS3 decoders use, one comparison per bin and a leading-zero count to renormalise. The probability models and their updates are unchanged. Decisions, two-model decisions and bypass bins are inline, so the patch parser no longer calls out for every bin. Bits consumed (for bytes_used and the overrun check) come from the window's marker bit. The two forms give the same bins for any AEC data an encoder can write. tests/aec_ref.c keeps the draft's engine, and test_aec runs both over random valid data with random sequences of decisions, two-model decisions, bypass bins (both the normative definition, a decision with lgPmps 1024, and Annex M's shortcut) and stuffing bits: every bin and model agrees, and so do the bits consumed at each patch end. Data whose first nine bits are all 1, which no encoder writes, is excluded: the engines part there, as garbage in either. Also: the coefficient-context history of SRCC (the last five levels) as bit masks with a popcount, pos_class() as per-block row and column zones, and the dequantisation skips the zero coefficients.
PR Summary by QodoSpeed up SVAC3 entropy decoding without changing decoded bins
AI Description
Diagram
High-Level Assessment
Files changed (8)
|
Code Review by Qodo
1.
|
A bypass 1 early in a stream was taken for a stuffing bit and ended it, and a two-model decision's second model went unchecked. Each operation now compares all the models, and only a stuffing bit of 1 ends a stream: 36.7 million bins in 5000 streams, 3390 patch ends.
|
Thanks, both valid; both fixed in the latest commit (test only, no decoder change). 1. Bypass bits prematurely end test streams: fixed. The end-of-patch condition now depends on the stuffing branch having actually run ( 2. Weighted model errors escape the test: fixed. After every operation all 24 models are compared, so the second model of a two-model decision is checked as soon as it is updated. Also, for the speed table: on the idle Core Ultra 5 245K, pinned to one P-core, this branch decodes faster single-threaded than the vendor decoder (
Our times are wall-clock and include process start and file reading. The vendor's 4-thread figure is ahead because libsvac3d decodes on one thread. |
After #8 and #9, high-bitrate streams are bound by entropy decoding, which is serial. This PR makes it cheaper per bin without changing any bin.
Engine
rS1/rT1,valueS/valueT, 5.3.3.2.2). The decoder now keeps a 9-bit range and a 32-bit window of the bitstream, refilled 16 bits at a time with a marker bit under the unread bits. That is the form AVS3 decoders use (cf. uavs3d'slbac_dec_bin).sFlagas a 0/1 shift, and one leading-zero count to renormalise.svac3_aec.h, so the patch parser no longer makes a call per bin.bytes_usedand the overrun/CORRUPT check, are recovered exactly from the marker bit (8 × bytes loaded − 16 + ctz(low)).Smaller changes
pos_class()is now per-block row and column zones plus a table.Equivalence
tests/aec_ref.ckeeps the previous, draft-shaped engine.test_aec: runs both engines over random valid AEC data, with random sequences of decisions on a model pool, two-model decisions, bypass bins and stuffing bits, MAEC on and off, I and P thresholds, and zero runs up to just under the 254-bit bound. Bypass is exercised in both forms: the normative decision and Annex M's shortcut.Speed: one core, best of 5,
masteragainst this branch, on two idle machines:On the x86 machine, too:
test_dspandtest_aecagree, ctest is 26/26 bit-exact. (The earlier x86 figures came from a shared, loaded host and are replaced by these.)