From: Nuo Mi <nuomi2021-at-gmail.com@ffmpeg.org>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: Re: [FFmpeg-devel] [PATCH 2/4] avcodec/vvc/dec: Don't use GetBit-API when byte-aligned
Date: Sun, 6 Jul 2025 10:27:24 +0800
Message-ID: <CAFXK13f3WccTwxHe8u-9xVOkSBmjBdwtj3w-3eb7Xs=OgH7y9A@mail.gmail.com> (raw)
In-Reply-To: <74d4eb18240684d32dda4e8feb689c23387aad86.1751636697.git.ffmpegagent@gmail.com>
LGTM for this.
Thank you, Andreas.
On Fri, Jul 4, 2025 at 9:45 PM Andreas Rheinhardt <
ffmpegagent-at-gmail.com@ffmpeg.org> wrote:
> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/vvc/dec.c | 29 ++++++++++++++++-------------
> 1 file changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
> index 7930d64a05..90fff3a03f 100644
> --- a/libavcodec/vvc/dec.c
> +++ b/libavcodec/vvc/dec.c
> @@ -20,6 +20,8 @@
> * License along with FFmpeg; if not, write to the Free Software
> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> */
> +
> +#include "libavcodec/bytestream.h"
> #include "libavcodec/codec_internal.h"
> #include "libavcodec/decode.h"
> #include "libavcodec/hwaccel_internal.h"
> @@ -509,13 +511,14 @@ static int slices_realloc(VVCFrameContext *fc)
> return 0;
> }
>
> -static int get_ep_size(const H266RawSliceHeader *rsh, GetBitContext *gb,
> const H2645NAL *nal, const int header_size, const int ep_index)
> +static int get_ep_size(const H266RawSliceHeader *rsh, const
> GetByteContext *gb,
> + const H2645NAL *nal, const int header_size, const
> int ep_index)
> {
> int size;
>
> if (ep_index < rsh->num_entry_points) {
> int skipped = 0;
> - int64_t start = (gb->index >> 3);
> + int64_t start = bytestream2_tell(gb);
> int64_t end = start + rsh->sh_entry_point_offset_minus1[ep_index]
> + 1;
> while (skipped < nal->skipped_bytes &&
> nal->skipped_bytes_pos[skipped] <= start + header_size) {
> skipped++;
> @@ -525,26 +528,27 @@ static int get_ep_size(const H266RawSliceHeader
> *rsh, GetBitContext *gb, const H
> skipped++;
> }
> size = end - start;
> - size = av_clip(size, 0, get_bits_left(gb) / 8);
> + size = av_clip(size, 0, bytestream2_get_bytes_left(gb));
> } else {
> - size = get_bits_left(gb) / 8;
> + size = bytestream2_get_bytes_left(gb);
> }
> return size;
> }
>
> -static int ep_init_cabac_decoder(EntryPoint *ep, GetBitContext *gb, const
> int size)
> +static int ep_init_cabac_decoder(EntryPoint *ep, GetByteContext *gb,
> const int size)
> {
> int ret;
>
> - av_assert0(gb->buffer + get_bits_count(gb) / 8 + size <=
> gb->buffer_end);
> - ret = ff_init_cabac_decoder (&ep->cc, gb->buffer + get_bits_count(gb)
> / 8, size);
> + av_assert0(size <= bytestream2_get_bytes_left(gb));
> + ret = ff_init_cabac_decoder(&ep->cc, gb->buffer, size);
> if (ret < 0)
> return ret;
> - skip_bits(gb, size * 8);
> + bytestream2_skipu(gb, size);
> return 0;
> }
>
> -static int ep_init(EntryPoint *ep, const int ctu_addr, const int ctu_end,
> GetBitContext *gb, const int size)
> +static int ep_init(EntryPoint *ep, const int ctu_addr, const int ctu_end,
> + GetByteContext *gb, const int size)
> {
> const int ret = ep_init_cabac_decoder(ep, gb, size);
>
> @@ -567,7 +571,7 @@ static int slice_init_entry_points(SliceContext *sc,
> const H266RawSlice *slice = unit->content_ref;
> int nb_eps = sh->r->num_entry_points + 1;
> int ctu_addr = 0;
> - GetBitContext gb;
> + GetByteContext gb;
> int ret;
>
> if (sc->nb_eps != nb_eps) {
> @@ -578,9 +582,8 @@ static int slice_init_entry_points(SliceContext *sc,
> sc->nb_eps = nb_eps;
> }
>
> - ret = init_get_bits8(&gb, slice->data, slice->data_size);
> - if (ret < 0)
> - return ret;
> + bytestream2_init(&gb, slice->data, slice->data_size);
> +
> for (int i = 0; i < sc->nb_eps; i++)
> {
> const int size = get_ep_size(sc->sh.r, &gb, nal,
> slice->header_size, i);
> --
> ffmpeg-codebot
>
> _______________________________________________
> 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".
>
_______________________________________________
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:[~2025-07-06 2:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-04 13:44 [FFmpeg-devel] [PATCH 0/4] Get bits buffer end ffmpegagent
2025-07-04 13:44 ` [FFmpeg-devel] [PATCH 1/4] avcodec/bytestream: Add const where appropriate Andreas Rheinhardt
2025-07-04 13:44 ` [FFmpeg-devel] [PATCH 2/4] avcodec/vvc/dec: Don't use GetBit-API when byte-aligned Andreas Rheinhardt
2025-07-06 2:27 ` Nuo Mi [this message]
2025-07-04 13:44 ` [FFmpeg-devel] [PATCH 3/4] avcodec/get_bits: Add get_bits_bytesize() Andreas Rheinhardt
2025-07-04 13:44 ` [FFmpeg-devel] [PATCH 4/4] avcodec/get_bits: Remove GetBitContext.buffer_end 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='CAFXK13f3WccTwxHe8u-9xVOkSBmjBdwtj3w-3eb7Xs=OgH7y9A@mail.gmail.com' \
--to=nuomi2021-at-gmail.com@ffmpeg.org \
--cc=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