From: Christophe Gisquet <christophe.gisquet@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 2/2] read_xbits: request fewer bits Date: Thu, 7 Sep 2023 21:27:21 +0200 Message-ID: <20230907192721.50459-3-christophe.gisquet@gmail.com> (raw) In-Reply-To: <20230907192721.50459-1-christophe.gisquet@gmail.com> This would have also helped a bitstream reader with a cache of 32 bits. --- libavcodec/bitstream_template.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavcodec/bitstream_template.h b/libavcodec/bitstream_template.h index 3f90fc6a07..c27e8108b2 100644 --- a/libavcodec/bitstream_template.h +++ b/libavcodec/bitstream_template.h @@ -423,8 +423,18 @@ static inline const uint8_t *BS_FUNC(align)(BSCTX *bc) */ static inline int BS_FUNC(read_xbits)(BSCTX *bc, unsigned int n) { - int32_t cache = BS_FUNC(peek)(bc, 32); - int sign = ~cache >> 31; + int32_t cache; + int sign; + + if (n > bc->bits_valid) + BS_FUNC(priv_refill_32)(bc); + +#if defined(BITSTREAM_READER_LE) + cache = bc->bits & 0xFFFFFFFF; +#else + cache = bc->bits >> 32; +#endif + sign = ~cache >> 31; BS_FUNC(skip_remaining)(bc, n); return ((((uint32_t)(sign ^ cache)) >> (32 - n)) ^ sign) - sign; -- 2.42.0 _______________________________________________ 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-07 19:27 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-07 19:27 [FFmpeg-devel] [PATCH 0/2] cached bistream: small improvements Christophe Gisquet 2023-09-07 19:27 ` [FFmpeg-devel] [PATCH 1/2] Expose and start using skip_remaining Christophe Gisquet 2023-09-07 22:40 ` Andreas Rheinhardt 2023-09-11 20:43 ` Christophe Gisquet 2023-09-07 19:27 ` Christophe Gisquet [this message] 2023-09-07 22:48 ` [FFmpeg-devel] [PATCH 2/2] read_xbits: request fewer bits 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=20230907192721.50459-3-christophe.gisquet@gmail.com \ --to=christophe.gisquet@gmail.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