[FFmpeg-devel] [PATCH 26/30] avcodec/mpc7, mpc7data: Avoid gaps in array

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Tue Sep 15 23:34:15 EEST 2020


Paul B Mahol:
> On Tue, Sep 15, 2020 at 09:39:56AM +0200, Andreas Rheinhardt wrote:
>> The Musepack decoder uses static VLC tables to parse the bitstream.
>> There are 14 different quant tables VLCs and each of them has a varying
>> number of codes. The maximum number is 63, the average number is 25.3.
>> Up until now, the array containing the raw data was of type
>> uint16_t [7][2][64 * 2] (the 14 tables come in pairs of two, hence [7][2]
>> instead of [14]) and from this it follows that there were large gaps in
>> said array. This commit changes this by making it a continuous array
>> instead. Doing so saves about 2KB.
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
>> ---
>>  libavcodec/mpc7.c     | 17 ++++++----
>>  libavcodec/mpc7data.h | 76 +++++++++++++------------------------------
>>  2 files changed, 32 insertions(+), 61 deletions(-)
> 
> Should be fine if there is full coverage of code with samples covering those vlcs.
> 
This code is covered by the musepack7 FATE-test. I just added a few
counters to it in order to check whether all VLC tables are used. They
indeed are:
Counter for quant[0][0]: 1478
Counter for quant[0][1]: 2021
Counter for quant[1][0]: 2628
Counter for quant[1][1]: 3500
Counter for quant[2][0]: 1061
Counter for quant[2][1]: 2355
Counter for quant[3][0]: 367
Counter for quant[3][1]: 1048
Counter for quant[4][0]: 598
Counter for quant[4][1]: 1000
Counter for quant[5][0]: 274
Counter for quant[5][1]: 771
Counter for quant[6][0]: 229
Counter for quant[6][1]: 232

Just to be sure I have also calculated the CRCs (AV_CRC_32_IEEE) of the
tables. They are unchanged:
CRC for quant table 0 0 3BDAC345
CRC for quant table 0 1 F97ACD5D
CRC for quant table 1 0 2EBC08F1
CRC for quant table 1 1 FA19B798
CRC for quant table 2 0 16C9A42B
CRC for quant table 2 1 B3DF7046
CRC for quant table 3 0 D4162F07
CRC for quant table 3 1 DA23BC68
CRC for quant table 4 0 16D7D50F
CRC for quant table 4 1 433F7CB
CRC for quant table 5 0 2511392D
CRC for quant table 5 1 60C43D91
CRC for quant table 6 0 31C9B671
CRC for quant table 6 1 563EFA5D

I have therefore pushed this and the other musepack patch; I have also
incorporated a fix for 1e40dc920a838e35f1483b20bfcd417437e68741 in the
latter (the topic fits).

- Andreas


More information about the ffmpeg-devel mailing list