From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 14/61] avcodec/rv40: Avoid superfluous VLC structures
Date: Wed, 27 Sep 2023 00:16:45 +0200
Message-ID: <GV1P250MB0737A8D7ECF8992C44C419CC8FC3A@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <GV1P250MB073754E215A199E7219CC13A8FC3A@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM>
Of all these VLCs here, only VLC.table was really used
after init, so use the ff_vlc_init_tables API
to get rid of them.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/rv40.c | 69 ++++++++++++++++++++++-------------------------
1 file changed, 32 insertions(+), 37 deletions(-)
diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c
index d2f8ef9f5a..3ee405f33c 100644
--- a/libavcodec/rv40.c
+++ b/libavcodec/rv40.c
@@ -40,22 +40,16 @@
#include "rv40vlc2.h"
#include "rv40data.h"
-static VLC aic_top_vlc;
-static VLC aic_mode1_vlc[AIC_MODE1_NUM], aic_mode2_vlc[AIC_MODE2_NUM];
-static VLC ptype_vlc[NUM_PTYPE_VLCS], btype_vlc[NUM_BTYPE_VLCS];
+static VLCElem aic_top_vlc[23590];
+static const VLCElem *aic_mode1_vlc[AIC_MODE1_NUM], *aic_mode2_vlc[AIC_MODE2_NUM];
+static const VLCElem *ptype_vlc[NUM_PTYPE_VLCS], *btype_vlc[NUM_BTYPE_VLCS];
-static av_cold void rv40_init_table(VLC *vlc, unsigned *offset, int nb_bits,
- int nb_codes, const uint8_t (*tab)[2])
+static av_cold const VLCElem *rv40_init_table(VLCInitState *state, int nb_bits,
+ int nb_codes, const uint8_t (*tab)[2])
{
- static VLCElem vlc_buf[11776];
-
- vlc->table = &vlc_buf[*offset];
- vlc->table_allocated = 1 << nb_bits;
- *offset += 1 << nb_bits;
-
- ff_vlc_init_from_lengths(vlc, nb_bits, nb_codes,
- &tab[0][1], 2, &tab[0][0], 2, 1,
- 0, VLC_INIT_USE_STATIC, NULL);
+ return ff_vlc_init_tables_from_lengths(state, nb_bits, nb_codes,
+ &tab[0][1], 2, &tab[0][0], 2, 1,
+ 0, 0);
}
/**
@@ -63,18 +57,19 @@ static av_cold void rv40_init_table(VLC *vlc, unsigned *offset, int nb_bits,
*/
static av_cold void rv40_init_tables(void)
{
- int i, offset = 0;
- static VLCElem aic_mode2_table[11814];
+ VLCInitState state = VLC_INIT_STATE(aic_top_vlc);
+ int i;
- rv40_init_table(&aic_top_vlc, &offset, AIC_TOP_BITS, AIC_TOP_SIZE,
+ rv40_init_table(&state, AIC_TOP_BITS, AIC_TOP_SIZE,
rv40_aic_top_vlc_tab);
for(i = 0; i < AIC_MODE1_NUM; i++){
// Every tenth VLC table is empty
if((i % 10) == 9) continue;
- rv40_init_table(&aic_mode1_vlc[i], &offset, AIC_MODE1_BITS,
- AIC_MODE1_SIZE, aic_mode1_vlc_tabs[i]);
+ aic_mode1_vlc[i] =
+ rv40_init_table(&state, AIC_MODE1_BITS,
+ AIC_MODE1_SIZE, aic_mode1_vlc_tabs[i]);
}
- for (unsigned i = 0, offset = 0; i < AIC_MODE2_NUM; i++){
+ for (unsigned i = 0; i < AIC_MODE2_NUM; i++){
uint16_t syms[AIC_MODE2_SIZE];
for (int j = 0; j < AIC_MODE2_SIZE; j++) {
@@ -85,20 +80,20 @@ static av_cold void rv40_init_tables(void)
else
syms[j] = first | (second << 8);
}
- aic_mode2_vlc[i].table = &aic_mode2_table[offset];
- aic_mode2_vlc[i].table_allocated = FF_ARRAY_ELEMS(aic_mode2_table) - offset;
- ff_vlc_init_from_lengths(&aic_mode2_vlc[i], AIC_MODE2_BITS, AIC_MODE2_SIZE,
- aic_mode2_vlc_bits[i], 1,
- syms, 2, 2, 0, VLC_INIT_STATIC_OVERLONG, NULL);
- offset += aic_mode2_vlc[i].table_size;
+ aic_mode2_vlc[i] =
+ ff_vlc_init_tables_from_lengths(&state, AIC_MODE2_BITS, AIC_MODE2_SIZE,
+ aic_mode2_vlc_bits[i], 1,
+ syms, 2, 2, 0, 0);
}
for(i = 0; i < NUM_PTYPE_VLCS; i++){
- rv40_init_table(&ptype_vlc[i], &offset, PTYPE_VLC_BITS, PTYPE_VLC_SIZE,
- ptype_vlc_tabs[i]);
+ ptype_vlc[i] =
+ rv40_init_table(&state, PTYPE_VLC_BITS, PTYPE_VLC_SIZE,
+ ptype_vlc_tabs[i]);
}
for(i = 0; i < NUM_BTYPE_VLCS; i++){
- rv40_init_table(&btype_vlc[i], &offset, BTYPE_VLC_BITS, BTYPE_VLC_SIZE,
- btype_vlc_tabs[i]);
+ btype_vlc[i] =
+ rv40_init_table(&state, BTYPE_VLC_BITS, BTYPE_VLC_SIZE,
+ btype_vlc_tabs[i]);
}
}
@@ -178,7 +173,7 @@ static int rv40_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int8_t
for(i = 0; i < 4; i++, dst += r->intra_types_stride){
if(!i && s->first_slice_line){
- pattern = get_vlc2(gb, aic_top_vlc.table, AIC_TOP_BITS, 1);
+ pattern = get_vlc2(gb, aic_top_vlc, AIC_TOP_BITS, 1);
dst[0] = (pattern >> 2) & 2;
dst[1] = (pattern >> 1) & 2;
dst[2] = pattern & 2;
@@ -201,12 +196,12 @@ static int rv40_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int8_t
if(pattern == rv40_aic_table_index[k])
break;
if(j < 3 && k < MODE2_PATTERNS_NUM){ //pattern is found, decoding 2 coefficients
- AV_WN16(ptr, get_vlc2(gb, aic_mode2_vlc[k].table, AIC_MODE2_BITS, 2));
+ AV_WN16(ptr, get_vlc2(gb, aic_mode2_vlc[k], AIC_MODE2_BITS, 2));
ptr += 2;
j++;
}else{
if(B != -1 && C != -1)
- v = get_vlc2(gb, aic_mode1_vlc[B + C*10].table, AIC_MODE1_BITS, 1);
+ v = get_vlc2(gb, aic_mode1_vlc[B + C*10], AIC_MODE1_BITS, 1);
else{ // tricky decoding
v = 0;
switch(C){
@@ -270,17 +265,17 @@ static int rv40_decode_mb_info(RV34DecContext *r)
if(s->pict_type == AV_PICTURE_TYPE_P){
prev_type = block_num_to_ptype_vlc_num[prev_type];
- q = get_vlc2(gb, ptype_vlc[prev_type].table, PTYPE_VLC_BITS, 1);
+ q = get_vlc2(gb, ptype_vlc[prev_type], PTYPE_VLC_BITS, 1);
if(q < PBTYPE_ESCAPE)
return q;
- q = get_vlc2(gb, ptype_vlc[prev_type].table, PTYPE_VLC_BITS, 1);
+ q = get_vlc2(gb, ptype_vlc[prev_type], PTYPE_VLC_BITS, 1);
av_log(s->avctx, AV_LOG_ERROR, "Dquant for P-frame\n");
}else{
prev_type = block_num_to_btype_vlc_num[prev_type];
- q = get_vlc2(gb, btype_vlc[prev_type].table, BTYPE_VLC_BITS, 1);
+ q = get_vlc2(gb, btype_vlc[prev_type], BTYPE_VLC_BITS, 1);
if(q < PBTYPE_ESCAPE)
return q;
- q = get_vlc2(gb, btype_vlc[prev_type].table, BTYPE_VLC_BITS, 1);
+ q = get_vlc2(gb, btype_vlc[prev_type], BTYPE_VLC_BITS, 1);
av_log(s->avctx, AV_LOG_ERROR, "Dquant for B-frame\n");
}
return 0;
--
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".
next prev parent reply other threads:[~2023-09-26 22:18 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-26 22:12 [FFmpeg-devel] [PATCH 01/61] avcodec/vlc: Add functions to init static VLCElem[] without VLC Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 02/61] avcodec/vp3: Make VLC tables static where possible Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 03/61] avcodec/vp3: Increase some VLC tables Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 04/61] avcodec/h264_cavlc: Avoid superfluous VLC structures Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 05/61] avcodec/h264_cavlc: Avoid indirection for coefficient table VLCs Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 06/61] avcodec/h264_cavlc: Remove code duplication Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 07/61] avcodec/asvdec: Avoid superfluous VLC structures Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 08/61] avcodec/faxcompr: " Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 09/61] avcodec/h261dec: " Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 10/61] avcodec/ituh263dec: " Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 11/61] avcodec/msmpeg4_vc1_data: " Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 12/61] avcodec/svq1dec: " Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 13/61] avcodec/svq1dec: Increase size of VLC Andreas Rheinhardt
2023-09-26 22:16 ` Andreas Rheinhardt [this message]
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 15/61] avcodec/mpc7: Avoid superfluous VLC structures Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 16/61] avcodec/intrax8: " Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 17/61] avcodec/clearvideo: " Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 18/61] avcodec/atrac9dec: " Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 19/61] avcodec/imc: " Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 20/61] avcodec/refstruct: Add simple API for refcounted objects Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 21/61] avcodec/vp3: Share coefficient VLCs between threads Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 22/61] avcodec/vp3: Avoid complete VLC struct, only use VLCElem* Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 23/61] avcodec/vp3: Reindent after the previous commits Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 24/61] avcodec/rv34: Avoid superfluous VLC structures Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 25/61] avcodec/rv34: Constify pointer to static object Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 26/61] avcodec/wnv1: Avoid unnecessary VLC structure Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 27/61] avcodec/mv30: " Andreas Rheinhardt
2023-09-26 22:16 ` [FFmpeg-devel] [PATCH 28/61] avcodec/vqcdec: " Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 29/61] avcodec/mobiclip: " Andreas Rheinhardt
2023-09-27 23:20 ` Michael Niedermayer
2023-09-27 23:44 ` Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 30/61] avcodec/mimic: " Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 31/61] avcodec/imm4: " Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 32/61] avcodec/lagarith: " Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 33/61] avcodec/speedhqdec: " Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 34/61] avcodec/vc1: Avoid superfluous VLC structures Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 35/61] avcodec/4xm: Avoid unnecessary " Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 36/61] avcodec/indeo2: Avoid unnecessary VLC structure Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 37/61] avcodec/mss4: Partially inline max_depth and nb_bits of VLC Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 38/61] avcodec/mpeg4videodec: Avoid superfluous VLC structures Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 39/61] avcodec/msmpeg4dec: " Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 40/61] avcodec/aacps: Remove unused AVCodecContext* parameter from ff_ps_apply Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 41/61] avcodec/aacps: Pass logctx as void* instead of AVCodecContext* Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 42/61] avcodec/aacdectab: Deduplicate common decoder tables Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 43/61] avcodec/aacdec_template: Deduplicate VLCs Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 44/61] avcodec/aacdec_template: Don't init unused table for fixed-point decoder Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 45/61] avcodec/aactab: Improve included headers Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 46/61] avcodec/aacdec_common: Avoid superfluous VLC structures Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 47/61] avcodec/aacsbr_template: Deduplicate VLCs Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 48/61] avcodec/aacdec_common: Avoid superfluous VLC structures for SBR VLCs Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 49/61] avcodec/aacdec_common: Switch to ff_vlc_init_tables_from_lengths() Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 50/61] avcodec/aacdec_common: Combine huffman tabs Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 51/61] avcodec/aacdec_common: Apply offset for SBR VLCs during init Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 52/61] avcodec/aacps: Move initializing common stuff to aacdec_common.c Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 53/61] avcodec/aacps_common: Avoid superfluous VLC structures Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 54/61] avcodec/aacps_common: Switch to ff_vlc_init_tables_from_lengths() Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 55/61] avcodec/aacps_common: Combine huffman tabels Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 56/61] avcodec/aacps_common: Apply offset for VLCs during init Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 57/61] avcodec/mpegaudiodec_common: Avoid superfluous VLC structures Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 58/61] avcodec/mpeg12: Avoid unnecessary " Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 59/61] avcodec/wmaprodec: Avoid superfluous " Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 60/61] avcodec/wmavoice: Avoid unnecessary VLC structure Andreas Rheinhardt
2023-09-26 22:17 ` [FFmpeg-devel] [PATCH 61/61] avcodec/vlc: Remove unused macros Andreas Rheinhardt
2023-10-30 23:08 ` [FFmpeg-devel] [PATCH 01/61] avcodec/vlc: Add functions to init static VLCElem[] without VLC 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=GV1P250MB0737A8D7ECF8992C44C419CC8FC3A@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