Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 11/13] avcodec/dcahuff: Replace DCAVLC by ordinary VLCs
Date: Tue, 13 Sep 2022 13:33:08 +0200
Message-ID: <GV1P250MB0737F2B7D1F767D6F3D003C88F479@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <GV1P250MB0737F59A25C260BC89CFE14F8F479@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM>

This is possible now that the offsets are already applied
when creating the VLC.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/dca_core.c | 10 +++++-----
 libavcodec/dcahuff.c  | 13 +++++--------
 libavcodec/dcahuff.h  |  9 ++-------
 3 files changed, 12 insertions(+), 20 deletions(-)

diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c
index 7b23a40df4..c204e41cb7 100644
--- a/libavcodec/dca_core.c
+++ b/libavcodec/dca_core.c
@@ -67,9 +67,9 @@ static const uint8_t block_code_nbits[7] = {
     7, 10, 12, 13, 15, 17, 19
 };
 
-static int dca_get_vlc(GetBitContext *s, DCAVLC *v, int i)
+static int dca_get_vlc(GetBitContext *s, const VLC *vlc)
 {
-    return get_vlc2(s, v->vlc[i].table, v->vlc[i].bits, 2);
+    return get_vlc2(s, vlc->table, vlc->bits, 2);
 }
 
 static void get_array(GetBitContext *s, int32_t *array, int size, int n)
@@ -435,7 +435,7 @@ static int parse_subframe_header(DCACoreDecoder *s, int sf,
             int abits;
 
             if (sel < 5)
-                abits = dca_get_vlc(&s->gb, &ff_dca_vlc_bit_allocation, sel);
+                abits = dca_get_vlc(&s->gb, &ff_dca_vlc_bit_allocation[sel]);
             else
                 abits = get_bits(&s->gb, sel - 1);
 
@@ -570,7 +570,7 @@ static inline int parse_huffman_codes(DCACoreDecoder *s, int32_t *audio, int abi
 
     // Extract Huffman codes from the bit stream
     for (i = 0; i < DCA_SUBBAND_SAMPLES; i++)
-        audio[i] = dca_get_vlc(&s->gb, &ff_dca_vlc_quant_index[abits - 1], sel);
+        audio[i] = dca_get_vlc(&s->gb, &ff_dca_vlc_quant_index[abits - 1][sel]);
 
     return 1;
 }
@@ -1340,7 +1340,7 @@ static int parse_x96_subframe_header(DCACoreDecoder *s, int xch_base)
         for (band = s->x96_subband_start; band < s->nsubbands[ch]; band++) {
             // If Huffman code was used, the difference of abits was encoded
             if (sel < 7)
-                abits += dca_get_vlc(&s->gb, &ff_dca_vlc_quant_index[5 + 2 * s->x96_high_res], sel);
+                abits += dca_get_vlc(&s->gb, &ff_dca_vlc_quant_index[5 + 2 * s->x96_high_res][sel]);
             else
                 abits = get_bits(&s->gb, 3 + s->x96_high_res);
 
diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c
index a7518aded8..937a87ee05 100644
--- a/libavcodec/dcahuff.c
+++ b/libavcodec/dcahuff.c
@@ -768,10 +768,10 @@ const uint8_t ff_dca_vlc_src_tables[][2] = {
     {   4,   3 }, {   0,   3 }, {   2,   2 }, {   3,   2 },
 };
 
-DCAVLC  ff_dca_vlc_bit_allocation;
+VLC     ff_dca_vlc_bit_allocation[5];
 VLC     ff_dca_vlc_transition_mode[4];
 VLC     ff_dca_vlc_scale_factor[5];
-DCAVLC  ff_dca_vlc_quant_index[DCA_CODE_BOOKS];
+VLC     ff_dca_vlc_quant_index[DCA_CODE_BOOKS][7];
 
 VLC     ff_dca_vlc_tnl_grp[5];
 VLC     ff_dca_vlc_tnl_scf;
@@ -791,7 +791,6 @@ av_cold void ff_dca_init_vlcs(void)
     static VLCElem dca_table[30218];
     const uint8_t (*src_table)[2] = ff_dca_vlc_src_tables;
     unsigned offset = 0;
-    int i;
 
 #define DCA_INIT_VLC(vlc, nb_bits, nb_codes, entry_offset)                  \
     do {                                                                    \
@@ -805,15 +804,13 @@ av_cold void ff_dca_init_vlcs(void)
     } while (0)
 
     for (unsigned i = 0; i < DCA_CODE_BOOKS; i++) {
-        ff_dca_vlc_quant_index[i].max_depth = 1 + (i > 4);
         for (unsigned j = 0; j < ff_dca_quant_index_group_size[i]; j++)
-            DCA_INIT_VLC(ff_dca_vlc_quant_index[i].vlc[j], bitalloc_maxbits[i][j],
+            DCA_INIT_VLC(ff_dca_vlc_quant_index[i][j], bitalloc_maxbits[i][j],
                          ff_dca_bitalloc_sizes[i], ff_dca_bitalloc_offsets[i]);
     }
 
-    ff_dca_vlc_bit_allocation.max_depth = 2;
-    for (i = 0; i < 5; i++)
-        DCA_INIT_VLC(ff_dca_vlc_bit_allocation.vlc[i], bitalloc_12_vlc_bits[i], 12, 1);
+    for (unsigned i = 0; i < FF_ARRAY_ELEMS(ff_dca_vlc_bit_allocation); i++)
+        DCA_INIT_VLC(ff_dca_vlc_bit_allocation[i], bitalloc_12_vlc_bits[i], 12, 1);
 
     for (unsigned i = 0; i < FF_ARRAY_ELEMS(ff_dca_vlc_scale_factor); i++)
         DCA_INIT_VLC(ff_dca_vlc_scale_factor[i], DCA_SCALES_VLC_BITS, 129, -64);
diff --git a/libavcodec/dcahuff.h b/libavcodec/dcahuff.h
index 8663f8ba12..eaae234479 100644
--- a/libavcodec/dcahuff.h
+++ b/libavcodec/dcahuff.h
@@ -35,17 +35,12 @@
                                 3 * (5 + 7 + 9 + 13) \
                                 + 7 * (17 + 25 + 33 + 65 + 129))
 
-typedef struct DCAVLC {
-    int max_depth;      ///< Parameter for get_vlc2()
-    VLC vlc[7];         ///< Actual codes
-} DCAVLC;
-
-extern DCAVLC   ff_dca_vlc_bit_allocation;
+extern VLC  ff_dca_vlc_bit_allocation[5];
 #define DCA_TMODE_VLC_BITS 3
 extern VLC  ff_dca_vlc_transition_mode[4];
 #define DCA_SCALES_VLC_BITS 9
 extern VLC  ff_dca_vlc_scale_factor[5];
-extern DCAVLC   ff_dca_vlc_quant_index[DCA_CODE_BOOKS];
+extern VLC  ff_dca_vlc_quant_index[DCA_CODE_BOOKS][7];
 
 extern VLC  ff_dca_vlc_tnl_grp[5];
 extern VLC  ff_dca_vlc_tnl_scf;
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2022-09-13 11:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13 11:28 [FFmpeg-devel] [PATCH 01/13] avcodec/dolby_e_parser: Remove unnecessary headers Andreas Rheinhardt
2022-09-13 11:32 ` [FFmpeg-devel] [PATCH 02/13] avcodec/dcahuff: Remove unused define Andreas Rheinhardt
2022-09-13 11:33 ` [FFmpeg-devel] [PATCH 03/13] avcodec/dcahuff: Avoid redundant offset table Andreas Rheinhardt
2022-09-13 11:33 ` [FFmpeg-devel] [PATCH 04/13] avcodec/dca_core, dcahuff: Don't use DCAVLC unnecessarily Andreas Rheinhardt
2022-09-13 11:33 ` [FFmpeg-devel] [PATCH 05/13] avcodec/dcahuff: Always use three bits for transition mode VLCs Andreas Rheinhardt
2022-09-13 11:33 ` [FFmpeg-devel] [PATCH 06/13] avcodec/dcaenc: Create encoder-adapted tables Andreas Rheinhardt
2022-09-13 11:33 ` [FFmpeg-devel] [PATCH 07/13] avcodec/dcahuff: Combine tables, use ff_init_vlc_from_lengths() Andreas Rheinhardt
2022-09-13 11:33 ` [FFmpeg-devel] [PATCH 08/13] avcodec/dcahuff, dca_core, dca_lbr: Apply offset during VLC creation Andreas Rheinhardt
2022-09-13 11:33 ` [FFmpeg-devel] [PATCH 09/13] avcodec/dca_core: Inline number of bits of scale factor VLCs Andreas Rheinhardt
2022-09-13 11:33 ` [FFmpeg-devel] [PATCH 10/13] avcodec/dca_core: Don't use too big max_depth in get_vlc2() Andreas Rheinhardt
2022-09-13 11:33 ` Andreas Rheinhardt [this message]
2022-09-13 11:33 ` [FFmpeg-devel] [PATCH 12/13] avcodec/dca_lbr: Hardcode lpc table to save space Andreas Rheinhardt
2022-09-13 11:33 ` [FFmpeg-devel] [PATCH 13/13] avcodec/dca_lbr: Inline nb_bits for VLCs Andreas Rheinhardt
2022-09-15 19:34 ` [FFmpeg-devel] [PATCH 01/13] avcodec/dolby_e_parser: Remove unnecessary headers Andreas Rheinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=GV1P250MB0737F2B7D1F767D6F3D003C88F479@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git