[FFmpeg-cvslog] avcodec/aacps_common: Combine huffman tabels
Andreas Rheinhardt
git at videolan.org
Tue Oct 31 23:20:06 EET 2023
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Tue Sep 26 18:14:21 2023 +0200| [40a8cb9e6cdb3d05f5f984ab961a4b077185f8fe] | committer: Andreas Rheinhardt
avcodec/aacps_common: Combine huffman tabels
This allows to avoid the relocations inherent in an array
to individual tables; it also reduces padding.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=40a8cb9e6cdb3d05f5f984ab961a4b077185f8fe
---
libavcodec/aacps_common.c | 27 +++++----------------------
libavcodec/aacpsdata.c | 31 +++----------------------------
2 files changed, 8 insertions(+), 50 deletions(-)
diff --git a/libavcodec/aacps_common.c b/libavcodec/aacps_common.c
index 653fc38da3..7a83cbd7d6 100644
--- a/libavcodec/aacps_common.c
+++ b/libavcodec/aacps_common.c
@@ -288,36 +288,19 @@ err:
return bits_left;
}
-#define PS_VLC_ROW(name) \
- { name ## _tab, FF_ARRAY_ELEMS(name ## _tab) }
-
av_cold void ff_ps_init_common(void)
{
static VLCElem vlc_buf[(1544 + 832 + 1024 + 1036) +
(544 + 544) + (32 + 32 + 32 + 32)];
VLCInitState state = VLC_INIT_STATE(vlc_buf);
- // Syntax initialization
- static const struct {
- const uint8_t (*vlc_tab)[2];
- const unsigned int table_elems;
- } ps_tmp[] = {
- PS_VLC_ROW(huff_iid_df1),
- PS_VLC_ROW(huff_iid_dt1),
- PS_VLC_ROW(huff_iid_df0),
- PS_VLC_ROW(huff_iid_dt0),
- PS_VLC_ROW(huff_icc_df),
- PS_VLC_ROW(huff_icc_dt),
- PS_VLC_ROW(huff_ipd_df),
- PS_VLC_ROW(huff_ipd_dt),
- PS_VLC_ROW(huff_opd_df),
- PS_VLC_ROW(huff_opd_dt),
- };
+ const uint8_t (*tab)[2] = aacps_huff_tabs;
for (int i = 0; i < FF_ARRAY_ELEMS(vlc_ps); i++) {
vlc_ps[i] =
- ff_vlc_init_tables_from_lengths(&state, i <= 5 ? 9 : 5, ps_tmp[i].table_elems,
- &ps_tmp[i].vlc_tab[0][1], 2,
- &ps_tmp[i].vlc_tab[0][0], 2, 1,
+ ff_vlc_init_tables_from_lengths(&state, i <= 5 ? 9 : 5, huff_sizes[i],
+ &tab[0][1], 2,
+ &tab[0][0], 2, 1,
0, 0);
+ tab += huff_sizes[i];
}
}
diff --git a/libavcodec/aacpsdata.c b/libavcodec/aacpsdata.c
index 8241346b0d..6885b386c0 100644
--- a/libavcodec/aacpsdata.c
+++ b/libavcodec/aacpsdata.c
@@ -21,7 +21,9 @@
#include <stdint.h>
-static const uint8_t huff_iid_df1_tab[][2] = {
+static const uint8_t huff_sizes[] = { 61, 61, 29, 29, 15, 15, 8, 8, 8, 8 };
+
+static const uint8_t aacps_huff_tabs[][2] = {
/* huff_iid_df1 - 61 entries */
{ 28, 4 }, { 32, 4 }, { 29, 3 }, { 31, 3 }, { 27, 5 },
{ 33, 5 }, { 26, 6 }, { 34, 6 }, { 25, 7 }, { 35, 7 },
@@ -36,9 +38,6 @@ static const uint8_t huff_iid_df1_tab[][2] = {
{ 57, 18 }, { 58, 18 }, { 0, 18 }, { 1, 18 }, { 10, 18 },
{ 50, 18 }, { 14, 16 }, { 46, 16 }, { 20, 12 }, { 23, 10 },
{ 30, 1 },
-};
-
-static const uint8_t huff_iid_dt1_tab[][2] = {
/* huff_iid_dt1 - 61 entries */
{ 31, 2 }, { 26, 7 }, { 34, 7 }, { 27, 6 }, { 33, 6 },
{ 35, 8 }, { 24, 9 }, { 36, 9 }, { 39, 11 }, { 41, 12 },
@@ -53,9 +52,6 @@ static const uint8_t huff_iid_dt1_tab[][2] = {
{ 14, 15 }, { 46, 15 }, { 50, 16 }, { 51, 16 }, { 19, 13 },
{ 21, 12 }, { 25, 9 }, { 28, 5 }, { 32, 5 }, { 29, 3 },
{ 30, 1 },
-};
-
-static const uint8_t huff_iid_df0_tab[][2] = {
/* huff_iid_df0 - 29 entries */
{ 14, 1 }, { 15, 3 }, { 13, 3 }, { 16, 4 }, { 12, 4 },
{ 17, 5 }, { 11, 5 }, { 10, 6 }, { 18, 6 }, { 19, 6 },
@@ -63,9 +59,6 @@ static const uint8_t huff_iid_df0_tab[][2] = {
{ 22, 13 }, { 6, 13 }, { 23, 14 }, { 24, 14 }, { 5, 15 },
{ 25, 15 }, { 4, 16 }, { 3, 17 }, { 0, 17 }, { 1, 17 },
{ 2, 17 }, { 26, 17 }, { 27, 18 }, { 28, 18 },
-};
-
-static const uint8_t huff_iid_dt0_tab[][2] = {
/* huff_iid_dt0 - 29 entries */
{ 14, 1 }, { 13, 2 }, { 15, 3 }, { 12, 4 }, { 16, 5 },
{ 11, 6 }, { 17, 7 }, { 10, 8 }, { 18, 9 }, { 9, 10 },
@@ -73,41 +66,23 @@ static const uint8_t huff_iid_dt0_tab[][2] = {
{ 22, 17 }, { 6, 17 }, { 23, 19 }, { 0, 19 }, { 1, 19 },
{ 2, 19 }, { 3, 20 }, { 4, 20 }, { 5, 20 }, { 24, 20 },
{ 25, 20 }, { 26, 20 }, { 27, 20 }, { 28, 20 },
-};
-
-static const uint8_t huff_icc_df_tab[][2] = {
/* huff_icc_df - 15 entries */
{ 7, 1 }, { 8, 2 }, { 6, 3 }, { 9, 4 }, { 5, 5 },
{ 10, 6 }, { 4, 7 }, { 11, 8 }, { 12, 9 }, { 3, 10 },
{ 13, 11 }, { 2, 12 }, { 14, 13 }, { 1, 14 }, { 0, 14 },
-};
-
-static const uint8_t huff_icc_dt_tab[][2] = {
/* huff_icc_dt - 15 entries */
{ 7, 1 }, { 8, 2 }, { 6, 3 }, { 9, 4 }, { 5, 5 },
{ 10, 6 }, { 4, 7 }, { 11, 8 }, { 3, 9 }, { 12, 10 },
{ 2, 11 }, { 13, 12 }, { 1, 13 }, { 0, 14 }, { 14, 14 },
-};
-
-static const uint8_t huff_ipd_df_tab[][2] = {
/* huff_ipd_df - 8 entries */
{ 1, 3 }, { 4, 4 }, { 5, 4 }, { 3, 4 }, { 6, 4 },
{ 2, 4 }, { 7, 4 }, { 0, 1 },
-};
-
-static const uint8_t huff_ipd_dt_tab[][2] = {
/* huff_ipd_dt - 8 entries */
{ 5, 4 }, { 4, 5 }, { 3, 5 }, { 2, 4 }, { 6, 4 },
{ 1, 3 }, { 7, 3 }, { 0, 1 },
-};
-
-static const uint8_t huff_opd_df_tab[][2] = {
/* huff_opd_df - 8 entries */
{ 7, 3 }, { 1, 3 }, { 3, 4 }, { 6, 4 }, { 2, 4 },
{ 5, 5 }, { 4, 5 }, { 0, 1 },
-};
-
-static const uint8_t huff_opd_dt_tab[][2] = {
/* huff_opd_dt - 8 entries */
{ 5, 4 }, { 2, 4 }, { 6, 4 }, { 4, 5 }, { 3, 5 },
{ 1, 3 }, { 7, 3 }, { 0, 1 },
More information about the ffmpeg-cvslog
mailing list