From: Anton Khirnov <anton@khirnov.net> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 4/5] lavc/bitstream: make skip_remaining() public Date: Fri, 17 Jun 2022 15:32:05 +0200 Message-ID: <20220617133206.23643-4-anton@khirnov.net> (raw) In-Reply-To: <20220617133206.23643-1-anton@khirnov.net> Also rename it to bitstream_skip_cache(), which is more descriptive and follows the naming conventions of tis API. --- libavcodec/bitstream.h | 1 + libavcodec/bitstream_template.h | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/libavcodec/bitstream.h b/libavcodec/bitstream.h index 3fa63695d3..364245453b 100644 --- a/libavcodec/bitstream.h +++ b/libavcodec/bitstream.h @@ -116,6 +116,7 @@ static inline void bitstream_unget(BitstreamContext *bc, uint64_t value, #define bitstream_peek bitstream_peek_be #define bitstream_peek_signed bitstream_peek_signed_be #define bitstream_skip bitstream_skip_be +#define bitstream_skip_cache bitstream_skip_cache_be #define bitstream_seek bitstream_seek_be #define bitstream_align bitstream_align_be #define bitstream_read_xbits bitstream_read_xbits_be diff --git a/libavcodec/bitstream_template.h b/libavcodec/bitstream_template.h index 14a420139c..717473ca40 100644 --- a/libavcodec/bitstream_template.h +++ b/libavcodec/bitstream_template.h @@ -225,7 +225,12 @@ static inline int BS_FUNC(bitstream_peek_signed)(BitstreamContext *bc, unsigned return sign_extend(BS_FUNC(bitstream_peek)(bc, n), n); } -static inline void BS_FUNC(skip_remaining)(BitstreamContext *bc, unsigned int n) +/** + * Skip n bits from the cache. This may only be called if at least n bits are + * guaranteed to be in the cache, e.g. right after bitstream_peek(n). + * Otherwise use bitstream_skip(). + */ +static inline void BS_FUNC(bitstream_skip_cache)(BitstreamContext *bc, unsigned int n) { #ifdef BITSTREAM_LE bc->bits >>= n; @@ -241,7 +246,7 @@ static inline void BS_FUNC(skip_remaining)(BitstreamContext *bc, unsigned int n) static inline void BS_FUNC(bitstream_skip)(BitstreamContext *bc, unsigned int n) { if (n < bc->bits_left) - BS_FUNC(skip_remaining)(bc, n); + BS_FUNC(bitstream_skip_cache)(bc, n); else { n -= bc->bits_left; bc->bits = 0; @@ -255,7 +260,7 @@ static inline void BS_FUNC(bitstream_skip)(BitstreamContext *bc, unsigned int n) } BS_FUNC(refill_64)(bc); if (n) - BS_FUNC(skip_remaining)(bc, n); + BS_FUNC(bitstream_skip_cache)(bc, n); } } @@ -291,7 +296,7 @@ static inline int BS_FUNC(bitstream_read_xbits)(BitstreamContext *bc, unsigned i { int32_t cache = BS_FUNC(bitstream_peek)(bc, 32); int sign = ~cache >> 31; - BS_FUNC(skip_remaining)(bc, n); + BS_FUNC(bitstream_skip_cache)(bc, n); return ((((uint32_t)(sign ^ cache)) >> (32 - n)) ^ sign) - sign; } @@ -374,14 +379,14 @@ static inline int BS_FUNC(bitstream_read_vlc)(BitstreamContext *bc, VLC_TYPE (*t int n = table[idx][1]; if (max_depth > 1 && n < 0) { - BS_FUNC(skip_remaining)(bc, bits); + BS_FUNC(bitstream_skip_cache)(bc, bits); code = BS_FUNC(set_idx)(bc, code, &n, &nb_bits, table); if (max_depth > 2 && n < 0) { - BS_FUNC(skip_remaining)(bc, nb_bits); + BS_FUNC(bitstream_skip_cache)(bc, nb_bits); code = BS_FUNC(set_idx)(bc, code, &n, &nb_bits, table); } } - BS_FUNC(skip_remaining)(bc, n); + BS_FUNC(bitstream_skip_cache)(bc, n); return code; } -- 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-06-17 13:32 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-06-17 13:32 [FFmpeg-devel] [PATCH 1/5] get_bits: move check_marker() to mpegvideodec.h Anton Khirnov 2022-06-17 13:32 ` [FFmpeg-devel] [PATCH 2/5] lavc: add standalone cached bitstream reader Anton Khirnov 2022-06-17 15:00 ` Paul B Mahol 2022-06-17 13:32 ` [FFmpeg-devel] [PATCH 3/5] lavc/bitstream: templatize for BE/LE Anton Khirnov 2022-06-17 13:32 ` Anton Khirnov [this message] 2022-06-20 11:39 ` [FFmpeg-devel] [PATCH 4/5] lavc/bitstream: make skip_remaining() public Andreas Rheinhardt 2022-06-17 13:32 ` [FFmpeg-devel] [PATCH 5/5] lavc/get_bits: add a compat wrapper for the cached bitstream reader Anton Khirnov 2022-06-17 15:00 ` Paul B Mahol 2022-06-17 15:00 ` James Almer 2022-06-17 15:26 ` Paul B Mahol 2022-06-18 14:31 ` Jean-Baptiste Kempf 2022-06-18 15:40 ` Paul B Mahol 2022-06-23 12:01 ` Anton Khirnov 2022-06-23 11:57 ` Anton Khirnov
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=20220617133206.23643-4-anton@khirnov.net \ --to=anton@khirnov.net \ --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