From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH 7/7] prores: use VLC LUTs Date: Fri, 8 Sep 2023 11:20:54 +0200 Message-ID: <AS8P250MB0744A5C037CA9ED3883468BD8FEDA@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <20230908081508.510-7-christophe.gisquet@gmail.com> Christophe Gisquet: > One indirection less, around 1% speedup. > --- > libavcodec/proresdec2.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) > > diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c > index b20021c622..85f81d92d3 100644 > --- a/libavcodec/proresdec2.c > +++ b/libavcodec/proresdec2.c > @@ -561,12 +561,18 @@ static av_always_inline int decode_dc_coeffs(GetBitContext *gb, int16_t *out, > prev_dc += (((code + 1) >> 1) ^ sign) - sign; > out[0] = prev_dc; > } > - return 0; > + return 0; You are adding trailing whitespace. > } > > +#include "libavutil/timer.h" You really need to look over your patches once more before you send them. Both of these changes are obviously not ok to commit. > + > + > static av_always_inline int decode_ac_coeffs(AVCodecContext *avctx, GetBitContext *gb, > int16_t *out, int blocks_per_slice) > { > + static VLC* lvl_vlc[9] = { &ac_vlc[0], &ac_vlc[1], &ac_vlc[2], &ac_vlc[3], &ac_vlc[0], &ac_vlc[4], &ac_vlc[4], &ac_vlc[4], &ac_vlc[4], }; > + static VLC* run_vlc[15] = { &ac_vlc[3], &ac_vlc[3], &ac_vlc[2], &ac_vlc[2], &ac_vlc[0], &ac_vlc[5], &ac_vlc[5], &ac_vlc[5], &ac_vlc[5], > + &ac_vlc[4], &ac_vlc[4], &ac_vlc[4], &ac_vlc[4], &ac_vlc[4], &ac_vlc[4], }; This still incurs an unnecessary indirection. The LUT should not point to the VLC's, but rather to the VLC tables (as this is the only thing needed from them lateron given that the number of bits is a compile-time constant. The LUT should be initialized when the VLCs are initialized. In fact, this is so common that I always pondered adding an explicit function for it. Will probably do so soon. (Apart from that: This could be "static const VLC *const run_vlc[15]".) > const ProresContext *ctx = avctx->priv_data; > int block_mask, sign; > unsigned pos, run, level; > @@ -585,9 +591,7 @@ static av_always_inline int decode_ac_coeffs(AVCodecContext *avctx, GetBitContex > break; > > if (run < 15) { > - static const uint8_t ctx_to_tbl[] = { 3, 3, 2, 2, 0, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4 }; > - const VLC* tbl = ac_vlc + ctx_to_tbl[run]; > - run = get_vlc2(gb, tbl->table, PRORES_LEV_BITS, 3); > + run = get_vlc2(gb, run_vlc[run]->table, PRORES_LEV_BITS, 3); > } else { > unsigned int bits = 21 - 2*av_log2(show_bits(gb, 10)); > run = READ_BITS(gb, bits) - 4; // up to 17 bits > @@ -599,9 +603,7 @@ static av_always_inline int decode_ac_coeffs(AVCodecContext *avctx, GetBitContex > } > > if (level < 9) { > - static const uint8_t ctx_to_tbl[] = { 0, 1, 2, 3, 0, 4, 4, 4, 4 }; > - const VLC* tbl = ac_vlc + ctx_to_tbl[level]; > - level = 1+get_vlc2(gb, tbl->table, PRORES_LEV_BITS, 3); > + level = 1+get_vlc2(gb, lvl_vlc[level]->table, PRORES_LEV_BITS, 3); Seems like these VLCs should be offset by 1 to avoid the "1+". > } else { > unsigned int bits = 25 - 2*av_log2(show_bits(gb, 12)); > level = READ_BITS(gb, bits) - 4 + 1; // up to 21 bits _______________________________________________ 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-08 9:19 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-08 8:15 [FFmpeg-devel] [PATCH 1/7] proresdec2: port and fix for cached reader Christophe Gisquet 2023-09-08 8:15 ` [FFmpeg-devel] [PATCH 2/7] proresdec2: store precomputed EC parameters Christophe Gisquet 2023-09-08 8:39 ` Andreas Rheinhardt 2023-09-08 8:15 ` [FFmpeg-devel] [PATCH 3/7] proresdec2: use VLC for level instead of EC switch Christophe Gisquet 2023-09-08 8:44 ` Andreas Rheinhardt 2023-09-08 9:58 ` Andreas Rheinhardt 2023-09-10 15:28 ` Christophe Gisquet 2023-09-10 15:41 ` Andreas Rheinhardt 2023-09-10 15:56 ` Christophe Gisquet 2023-09-08 8:15 ` [FFmpeg-devel] [PATCH 4/7] proresdec2: offset VLCs by 1 to avoid 1 add Christophe Gisquet 2023-09-08 8:15 ` [FFmpeg-devel] [PATCH 5/7] proresdec2: use VLC for small runs and levels Christophe Gisquet 2023-09-08 8:15 ` [FFmpeg-devel] [PATCH 6/7] proresdec2: remove a useless DC codebook entry Christophe Gisquet 2023-09-08 9:08 ` Andreas Rheinhardt 2023-09-08 8:15 ` [FFmpeg-devel] [PATCH 7/7] prores: use VLC LUTs Christophe Gisquet 2023-09-08 9:20 ` Andreas Rheinhardt [this message] 2023-09-08 9:58 ` Christophe Gisquet 2023-09-08 8:20 ` [FFmpeg-devel] [PATCH 1/7] proresdec2: port and fix for cached reader Christophe Gisquet 2023-09-08 8:30 ` Andreas Rheinhardt 2023-09-08 8:34 ` Andreas Rheinhardt 2023-09-11 20:54 ` Christophe Gisquet 2023-09-08 8:36 ` Andreas Rheinhardt 2023-09-08 21:00 ` Michael Niedermayer
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=AS8P250MB0744A5C037CA9ED3883468BD8FEDA@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