aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mpc7.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-15 05:23:07 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-15 22:14:43 +0200
commit158f7df5e6de8c917c679c639758e9ee1d739900 (patch)
tree93988cb9242949ff559f032893fd85ade975268e /libavcodec/mpc7.c
parentbec4e158596bbb5af0eb2e9582cbc28961e6c068 (diff)
downloadffmpeg-158f7df5e6de8c917c679c639758e9ee1d739900.tar.gz
avcodec/mpc7, mpc7data: Avoid gaps in array
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. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/mpc7.c')
-rw-r--r--libavcodec/mpc7.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c
index 3c9ef6a600..6482029efc 100644
--- a/libavcodec/mpc7.c
+++ b/libavcodec/mpc7.c
@@ -38,10 +38,9 @@
static VLC scfi_vlc, dscf_vlc, hdr_vlc, quant_vlc[MPC7_QUANT_VLC_TABLES][2];
-static const uint16_t quant_offsets[MPC7_QUANT_VLC_TABLES*2 + 1] =
+static const uint16_t quant_sizes[MPC7_QUANT_VLC_TABLES*2] =
{
- 0, 512, 1024, 1536, 2052, 2564, 3076, 3588, 4100, 4612, 5124,
- 5636, 6164, 6676, 7224
+ 512, 512, 512, 516, 512, 512, 512, 512, 512, 512, 512, 528, 512, 548
};
@@ -54,6 +53,8 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx)
static int vlc_initialized = 0;
static VLC_TYPE quant_tables[7224][2];
+ VLC_TYPE (*quant_table)[2] = quant_tables;
+ const uint16_t *raw_quant_table = mpc7_quant_vlcs;
/* Musepack SV7 is always stereo */
if (avctx->channels != 2) {
@@ -103,11 +104,13 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx)
&mpc7_hdr[0], 2, 1, 1 << MPC7_HDR_BITS);
for(i = 0; i < MPC7_QUANT_VLC_TABLES; i++){
for(j = 0; j < 2; j++){
- quant_vlc[i][j].table = &quant_tables[quant_offsets[i*2 + j]];
- quant_vlc[i][j].table_allocated = quant_offsets[i*2 + j + 1] - quant_offsets[i*2 + j];
+ quant_vlc[i][j].table = quant_table;
+ quant_vlc[i][j].table_allocated = quant_sizes[i * 2 + j];
+ quant_table += quant_sizes[i * 2 + j];
init_vlc(&quant_vlc[i][j], 9, mpc7_quant_vlc_sizes[i],
- &mpc7_quant_vlc[i][j][1], 4, 2,
- &mpc7_quant_vlc[i][j][0], 4, 2, INIT_VLC_USE_NEW_STATIC);
+ raw_quant_table + 1, 4, 2,
+ raw_quant_table, 4, 2, INIT_VLC_USE_NEW_STATIC);
+ raw_quant_table += 2 * mpc7_quant_vlc_sizes[i];
}
}
vlc_initialized = 1;