From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 04/17] avcodec/mpeg12: Avoid indirection when accessing rl_vlc tables Date: Sun, 23 Oct 2022 21:35:57 +0200 Message-ID: <AS8P250MB0744C3F58B759E1BA539FFE58F2F9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <AS8P250MB07449FCA4121B15E497ED55D8F2F9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/eamad.c | 3 +-- libavcodec/mdec.c | 3 +-- libavcodec/mpeg12.c | 19 +++++++++++-------- libavcodec/mpeg12dec.c | 28 ++++++++++++---------------- libavcodec/mpeg12vlc.h | 14 +++++++------- libavcodec/speedhqdec.c | 6 ++++-- 6 files changed, 36 insertions(+), 37 deletions(-) diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c index 2a5aac912d..20f347f0ab 100644 --- a/libavcodec/eamad.c +++ b/libavcodec/eamad.c @@ -134,7 +134,6 @@ static inline void idct_put(MadContext *t, AVFrame *frame, int16_t *block, static inline int decode_block_intra(MadContext *s, int16_t * block) { int level, i, j, run; - RLTable *rl = &ff_rl_mpeg1; const uint8_t *scantable = s->scantable.permutated; int16_t *quant_matrix = s->quant_matrix; @@ -148,7 +147,7 @@ static inline int decode_block_intra(MadContext *s, int16_t * block) /* now quantify & encode AC coefficients */ for (;;) { UPDATE_CACHE(re, &s->gb); - GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0); + GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0); if (level == 127) { break; diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index f27cf84122..7116b73b8e 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -63,7 +63,6 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n) { int level, diff, i, j, run; int component; - RLTable *rl = &ff_rl_mpeg1; uint8_t * const scantable = a->scantable.permutated; const uint16_t *quant_matrix = a->quant_matrix; const int qscale = a->qscale; @@ -84,7 +83,7 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n) /* now quantify & encode AC coefficients */ for (;;) { UPDATE_CACHE(re, &a->gb); - GET_RL_VLC(level, run, re, &a->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0); + GET_RL_VLC(level, run, re, &a->gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0); if (level == 127) { break; diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index df6aba9d74..351ebf420f 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -63,7 +63,8 @@ static const uint8_t table_mb_btype[11][2] = { { 2, 5 }, // 0x1E MB_QUANT|MB_FOR|MB_BACK|MB_PAT }; -av_cold void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags) +av_cold void ff_init_2d_vlc_rl(const RLTable *rl, RL_VLC_ELEM rl_vlc[], + unsigned static_size, int flags) { int i; VLCElem table[680] = { 0 }; @@ -94,9 +95,9 @@ av_cold void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags) level = rl->table_level[code]; } } - rl->rl_vlc[0][i].len = len; - rl->rl_vlc[0][i].level = level; - rl->rl_vlc[0][i].run = run; + rl_vlc[i].len = len; + rl_vlc[i].level = level; + rl_vlc[i].run = run; } } @@ -122,6 +123,9 @@ VLC ff_mb_ptype_vlc; VLC ff_mb_btype_vlc; VLC ff_mb_pat_vlc; +RL_VLC_ELEM ff_mpeg1_rl_vlc[680]; +RL_VLC_ELEM ff_mpeg2_rl_vlc[674]; + static av_cold void mpeg12_init_vlcs(void) { INIT_VLC_STATIC(&ff_dc_lum_vlc, DC_VLC_BITS, 12, @@ -147,8 +151,8 @@ static av_cold void mpeg12_init_vlcs(void) &table_mb_btype[0][1], 2, 1, &table_mb_btype[0][0], 2, 1, 64); - INIT_2D_VLC_RL(ff_rl_mpeg1, 680, 0); - INIT_2D_VLC_RL(ff_rl_mpeg2, 674, 0); + INIT_2D_VLC_RL(ff_rl_mpeg1, ff_mpeg1_rl_vlc, 0); + INIT_2D_VLC_RL(ff_rl_mpeg2, ff_mpeg2_rl_vlc, 0); } av_cold void ff_mpeg12_init_vlcs(void) @@ -231,7 +235,6 @@ int ff_mpeg1_decode_block_intra(GetBitContext *gb, int16_t *block, int index, int qscale) { int dc, diff, i = 0, component; - RLTable *rl = &ff_rl_mpeg1; /* DC coefficient */ component = index <= 3 ? 0 : index - 4 + 1; @@ -256,7 +259,7 @@ int ff_mpeg1_decode_block_intra(GetBitContext *gb, while (1) { int level, run, j; - GET_RL_VLC(level, run, re, gb, rl->rl_vlc[0], + GET_RL_VLC(level, run, re, gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0); if (level != 0) { diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index c942be158e..914516bbd9 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -152,7 +152,6 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s, int16_t *block, int n) { int level, i, j, run; - RLTable *rl = &ff_rl_mpeg1; uint8_t *const scantable = s->intra_scantable.permutated; const uint16_t *quant_matrix = s->inter_matrix; const int qscale = s->qscale; @@ -175,7 +174,7 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s, } /* now quantify & encode AC coefficients */ for (;;) { - GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], + GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0); if (level != 0) { @@ -241,7 +240,6 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, int16_t *block, int n) { int level, i, j, run; - RLTable *rl = &ff_rl_mpeg1; uint8_t *const scantable = s->intra_scantable.permutated; const int qscale = s->qscale; @@ -264,7 +262,7 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, /* now quantify & encode AC coefficients */ for (;;) { - GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], + GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0); if (level != 0) { @@ -326,7 +324,6 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, int16_t *block, int n) { int level, i, j, run; - RLTable *rl = &ff_rl_mpeg1; uint8_t *const scantable = s->intra_scantable.permutated; const uint16_t *quant_matrix; const int qscale = s->qscale; @@ -358,7 +355,7 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, /* now quantify & encode AC coefficients */ for (;;) { - GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], + GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0); if (level != 0) { @@ -416,7 +413,6 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s, int16_t *block, int n) { int level, i, j, run; - RLTable *rl = &ff_rl_mpeg1; uint8_t *const scantable = s->intra_scantable.permutated; const int qscale = s->qscale; OPEN_READER(re, &s->gb); @@ -437,7 +433,7 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s, /* now quantify & encode AC coefficients */ for (;;) { - GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0); + GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0); if (level != 0) { i += run; @@ -489,7 +485,7 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, { int level, dc, diff, i, j, run; int component; - RLTable *rl; + const RL_VLC_ELEM *rl_vlc; uint8_t *const scantable = s->intra_scantable.permutated; const uint16_t *quant_matrix; const int qscale = s->qscale; @@ -512,16 +508,16 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, mismatch = block[0] ^ 1; i = 0; if (s->intra_vlc_format) - rl = &ff_rl_mpeg2; + rl_vlc = ff_mpeg2_rl_vlc; else - rl = &ff_rl_mpeg1; + rl_vlc = ff_mpeg1_rl_vlc; { OPEN_READER(re, &s->gb); /* now quantify & encode AC coefficients */ for (;;) { UPDATE_CACHE(re, &s->gb); - GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], + GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0); if (level == 127) { @@ -575,7 +571,7 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, { int level, dc, diff, i, j, run; int component; - RLTable *rl; + const RL_VLC_ELEM *rl_vlc; uint8_t *const scantable = s->intra_scantable.permutated; const uint16_t *quant_matrix; const int qscale = s->qscale; @@ -595,16 +591,16 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, block[0] = dc * (1 << (3 - s->intra_dc_precision)); i = 0; if (s->intra_vlc_format) - rl = &ff_rl_mpeg2; + rl_vlc = ff_mpeg2_rl_vlc; else - rl = &ff_rl_mpeg1; + rl_vlc = ff_mpeg1_rl_vlc; { OPEN_READER(re, &s->gb); /* now quantify & encode AC coefficients */ for (;;) { UPDATE_CACHE(re, &s->gb); - GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], + GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0); if (level >= 64 || i > 63) { diff --git a/libavcodec/mpeg12vlc.h b/libavcodec/mpeg12vlc.h index 4fb19371f0..d0083f1124 100644 --- a/libavcodec/mpeg12vlc.h +++ b/libavcodec/mpeg12vlc.h @@ -50,17 +50,17 @@ extern VLC ff_mv_vlc; void ff_mpeg12_init_vlcs(void); -#define INIT_2D_VLC_RL(rl, static_size, flags)\ -{\ - static RL_VLC_ELEM rl_vlc_table[static_size];\ - rl.rl_vlc[0] = rl_vlc_table;\ - ff_init_2d_vlc_rl(&rl, static_size, flags);\ -} +#define INIT_2D_VLC_RL(rl, rl_vlc, flags)\ + ff_init_2d_vlc_rl(&rl, rl_vlc, FF_ARRAY_ELEMS(rl_vlc), flags) extern RLTable ff_rl_mpeg1; extern RLTable ff_rl_mpeg2; -void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags); +extern RL_VLC_ELEM ff_mpeg1_rl_vlc[]; +extern RL_VLC_ELEM ff_mpeg2_rl_vlc[]; + +void ff_init_2d_vlc_rl(const RLTable *rl, RL_VLC_ELEM rl_vlc[], + unsigned static_size, int flags); void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len); diff --git a/libavcodec/speedhqdec.c b/libavcodec/speedhqdec.c index acca437bd5..7cb5ff03cc 100644 --- a/libavcodec/speedhqdec.c +++ b/libavcodec/speedhqdec.c @@ -77,6 +77,8 @@ static VLC dc_chroma_vlc_le; static VLC dc_alpha_run_vlc_le; static VLC dc_alpha_level_vlc_le; +static RL_VLC_ELEM speedhq_rl_vlc[674]; + static inline int decode_dc_le(GetBitContext *gb, int component) { int code, diff; @@ -154,7 +156,7 @@ static inline int decode_dct_block(const SHQContext *s, GetBitContext *gb, int l for ( ;; ) { int level, run; UPDATE_CACHE_LE(re, gb); - GET_RL_VLC(level, run, re, gb, ff_rl_speedhq.rl_vlc[0], + GET_RL_VLC(level, run, re, gb, speedhq_rl_vlc, TEX_VLC_BITS, 2, 0); if (level == 127) { break; @@ -564,7 +566,7 @@ static av_cold void speedhq_static_init(void) ff_mpeg12_vlc_dc_chroma_code, 2, 2, INIT_VLC_OUTPUT_LE, 514); - INIT_2D_VLC_RL(ff_rl_speedhq, 674, INIT_VLC_LE); + INIT_2D_VLC_RL(ff_rl_speedhq, speedhq_rl_vlc, INIT_VLC_LE); compute_alpha_vlcs(); } -- 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:[~2022-10-23 19:36 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt 2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 02/17] avformat/mux: Don't call ff_toupper4() unnecessarily Andreas Rheinhardt 2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 03/17] avformat/mux: Constify validate_codec_tag() Andreas Rheinhardt 2022-10-23 19:35 ` Andreas Rheinhardt [this message] 2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 05/17] avcodec/mpeg12enc: Avoid unnecessary indirection Andreas Rheinhardt 2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 06/17] avcodec/speedhqenc: " Andreas Rheinhardt 2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 07/17] avcodec/mpeg12enc: Pass tables explicitly in ff_mpeg1_init_uni_ac_vlc Andreas Rheinhardt 2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 08/17] avcodec/mpeg12enc: Don't initialize ff_rl_mpeg2 unnecessarily Andreas Rheinhardt 2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 09/17] avcodec/mpeg12: Pass parameters explicitly in ff_init_2d_vlc_rl() Andreas Rheinhardt 2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 10/17] avcodec/mpeg12data: Remove unused ff_rl_mpeg2 Andreas Rheinhardt 2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 11/17] avcodec/mpeg12: Use ff_rl_mpeg1.table_(run|level) directly Andreas Rheinhardt 2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 12/17] avcodec/speedhqdec: Use ff_rl_speedhq.table_(run|level) directly Andreas Rheinhardt 2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 13/17] avcodec/rl: Add analogue for ff_rl_init() without RLTable Andreas Rheinhardt 2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 14/17] avcodec/mpeg12enc: Don't initialize unused parts of RLTable Andreas Rheinhardt 2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 15/17] avcodec/mpeg12data: Remove ff_rl_mpeg1 Andreas Rheinhardt 2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 16/17] avcodec/speedhqenc: Don't initialize unused parts of RLTable Andreas Rheinhardt 2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 17/17] avcodec/speedhq: Remove unused ff_rl_speedhq Andreas Rheinhardt 2022-10-25 21:39 ` [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call 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=AS8P250MB0744C3F58B759E1BA539FFE58F2F9@AS8P250MB0744.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