diff mbox series

[FFmpeg-devel,v2,2/3] avcodec/vvc/cabac: remove vvc_refill2

Message ID OS3PR01MB99447B96CD3A32B4D5149471CAB92@OS3PR01MB9944.jpnprd01.prod.outlook.com
State New
Headers show
Series [FFmpeg-devel,v2,1/3] avcodec/vvc_parser: move avctx->has_b_frames initialization to dec | expand

Checks

Context Check Description
yinshiyou/make_fate_loongarch64 success Make fate finished
yinshiyou/make_loongarch64 warning New warnings during build

Commit Message

Wu Jianhua Aug. 8, 2024, 7:13 p.m. UTC
From: Wu Jianhua <toqsxw@outlook.com>

See https://github.com/ffvvc/FFmpeg/issues/178

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 libavcodec/cabac_functions.h |  2 +-
 libavcodec/vvc/cabac.c       | 28 +---------------------------
 2 files changed, 2 insertions(+), 28 deletions(-)

Comments

Andreas Rheinhardt Aug. 8, 2024, 8:19 p.m. UTC | #1
toqsxw@outlook.com:
> From: Wu Jianhua <toqsxw@outlook.com>
> 
> See https://github.com/ffvvc/FFmpeg/issues/178

This link only sends one to a patchwork thread to read. The commit
message should instead explain why this is done on its own (and may
refer to the mailing list thread for a more detailed explanation).

Same for the next patch.

> 
> Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
> ---
>  libavcodec/cabac_functions.h |  2 +-
>  libavcodec/vvc/cabac.c       | 28 +---------------------------
>  2 files changed, 2 insertions(+), 28 deletions(-)
> 
> diff --git a/libavcodec/cabac_functions.h b/libavcodec/cabac_functions.h
> index c3f08d3410..9bee401f2c 100644
> --- a/libavcodec/cabac_functions.h
> +++ b/libavcodec/cabac_functions.h
> @@ -85,7 +85,7 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){
>  }
>  #endif
>  
> -#ifndef get_cabac_inline
> +#if !defined(get_cabac_inline) || !defined(refill2)
>  static void refill2(CABACContext *c){
>      int i;
>      unsigned x;
> diff --git a/libavcodec/vvc/cabac.c b/libavcodec/vvc/cabac.c
> index 0d45eec751..c9b6f9bf3e 100644
> --- a/libavcodec/vvc/cabac.c
> +++ b/libavcodec/vvc/cabac.c
> @@ -856,32 +856,6 @@ int ff_vvc_cabac_init(VVCLocalContext *lc,
>      return ret;
>  }
>  
> -//fixme
> -static void vvc_refill2(CABACContext* c) {
> -    int i;
> -    unsigned x;
> -#if !HAVE_FAST_CLZ
> -    x = c->low ^ (c->low - 1);
> -    i = 7 - ff_h264_norm_shift[x >> (CABAC_BITS - 1)];
> -#else
> -    i = ff_ctz(c->low) - CABAC_BITS;
> -#endif
> -
> -    x = -CABAC_MASK;
> -
> -#if CABAC_BITS == 16
> -    x += (c->bytestream[0] << 9) + (c->bytestream[1] << 1);
> -#else
> -    x += c->bytestream[0] << 1;
> -#endif
> -
> -    c->low += x << i;
> -#if !UNCHECKED_BITSTREAM_READER
> -    if (c->bytestream < c->bytestream_end)
> -#endif
> -        c->bytestream += CABAC_BITS / 8;
> -}
> -
>  static int inline vvc_get_cabac(CABACContext *c, VVCCabacState* base, const int ctx)
>  {
>      VVCCabacState *s = base + ctx;
> @@ -904,7 +878,7 @@ static int inline vvc_get_cabac(CABACContext *c, VVCCabacState* base, const int
>      c->low  <<= lps_mask;
>  
>      if (!(c->low & CABAC_MASK))
> -        vvc_refill2(c);
> +        refill2(c);
>      s->state[0] = s->state[0] - (s->state[0] >> s->shift[0]) + (1023 * bit >> s->shift[0]);
>      s->state[1] = s->state[1] - (s->state[1] >> s->shift[1]) + (16383 * bit >> s->shift[1]);
>      return bit;
Wu Jianhua Aug. 10, 2024, 8:20 p.m. UTC | #2
From Andreas Rheinhardt:
> 发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> 发送时间: 2024年8月8日 13:19
> 收件人: ffmpeg-devel@ffmpeg.org
> 主题: Re: [FFmpeg-devel] [PATCH v2 2/3] avcodec/vvc/cabac: remove vvc_refill2
> 
> toqsxw@outlook.com:
>> From: Wu Jianhua <toqsxw@outlook.com>
>>
>> See https://github.com/ffvvc/FFmpeg/issues/178
> 
> This link only sends one to a patchwork thread to read. The commit
> message should instead explain why this is done on its own (and may
> refer to the mailing list thread for a more detailed explanation).
> 
> Same for the next patch.
> 
>

No problem. I will send a new patchset.

Thanks,
Jianhua
diff mbox series

Patch

diff --git a/libavcodec/cabac_functions.h b/libavcodec/cabac_functions.h
index c3f08d3410..9bee401f2c 100644
--- a/libavcodec/cabac_functions.h
+++ b/libavcodec/cabac_functions.h
@@ -85,7 +85,7 @@  static inline void renorm_cabac_decoder_once(CABACContext *c){
 }
 #endif
 
-#ifndef get_cabac_inline
+#if !defined(get_cabac_inline) || !defined(refill2)
 static void refill2(CABACContext *c){
     int i;
     unsigned x;
diff --git a/libavcodec/vvc/cabac.c b/libavcodec/vvc/cabac.c
index 0d45eec751..c9b6f9bf3e 100644
--- a/libavcodec/vvc/cabac.c
+++ b/libavcodec/vvc/cabac.c
@@ -856,32 +856,6 @@  int ff_vvc_cabac_init(VVCLocalContext *lc,
     return ret;
 }
 
-//fixme
-static void vvc_refill2(CABACContext* c) {
-    int i;
-    unsigned x;
-#if !HAVE_FAST_CLZ
-    x = c->low ^ (c->low - 1);
-    i = 7 - ff_h264_norm_shift[x >> (CABAC_BITS - 1)];
-#else
-    i = ff_ctz(c->low) - CABAC_BITS;
-#endif
-
-    x = -CABAC_MASK;
-
-#if CABAC_BITS == 16
-    x += (c->bytestream[0] << 9) + (c->bytestream[1] << 1);
-#else
-    x += c->bytestream[0] << 1;
-#endif
-
-    c->low += x << i;
-#if !UNCHECKED_BITSTREAM_READER
-    if (c->bytestream < c->bytestream_end)
-#endif
-        c->bytestream += CABAC_BITS / 8;
-}
-
 static int inline vvc_get_cabac(CABACContext *c, VVCCabacState* base, const int ctx)
 {
     VVCCabacState *s = base + ctx;
@@ -904,7 +878,7 @@  static int inline vvc_get_cabac(CABACContext *c, VVCCabacState* base, const int
     c->low  <<= lps_mask;
 
     if (!(c->low & CABAC_MASK))
-        vvc_refill2(c);
+        refill2(c);
     s->state[0] = s->state[0] - (s->state[0] >> s->shift[0]) + (1023 * bit >> s->shift[0]);
     s->state[1] = s->state[1] - (s->state[1] >> s->shift[1]) + (16383 * bit >> s->shift[1]);
     return bit;