diff mbox series

[FFmpeg-devel,04/35] avcodec/proresenc_anatoliy: move run/lev to codebook LUT to shared proresdata

Message ID 20231211014429.1841681-5-u@pkh.me
State New
Headers show
Series [FFmpeg-devel,01/35] avcodec/proresenc_kostya: remove an unnecessary parenthesis level in MAKE_CODE() macro | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Clément Bœsch Dec. 11, 2023, 1:35 a.m. UTC
This is going to be shared with proresenc_kostya in the upcoming commit.
---
 libavcodec/proresdata.c         | 6 ++++++
 libavcodec/proresdata.h         | 2 ++
 libavcodec/proresenc_anatoliy.c | 9 ++-------
 3 files changed, 10 insertions(+), 7 deletions(-)

Comments

Stefano Sabatini Dec. 12, 2023, 7:02 a.m. UTC | #1
On date Monday 2023-12-11 02:35:05 +0100, Clément Bœsch wrote:
> This is going to be shared with proresenc_kostya in the upcoming commit.
> ---
>  libavcodec/proresdata.c         | 6 ++++++
>  libavcodec/proresdata.h         | 2 ++
>  libavcodec/proresenc_anatoliy.c | 9 ++-------
>  3 files changed, 10 insertions(+), 7 deletions(-)

LGTM.
Stefano Sabatini Dec. 12, 2023, 8:02 a.m. UTC | #2
On date Monday 2023-12-11 02:35:05 +0100, Clément Bœsch wrote:
> This is going to be shared with proresenc_kostya in the upcoming commit.
> ---
>  libavcodec/proresdata.c         | 6 ++++++
>  libavcodec/proresdata.h         | 2 ++
>  libavcodec/proresenc_anatoliy.c | 9 ++-------
>  3 files changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/proresdata.c b/libavcodec/proresdata.c
> index 4787907c71..12ee43bddd 100644
> --- a/libavcodec/proresdata.c
> +++ b/libavcodec/proresdata.c
> @@ -43,3 +43,9 @@ const uint8_t ff_prores_interlaced_scan[64] = {
>      30, 23, 31, 38, 45, 52, 60, 53,
>      46, 39, 47, 54, 61, 62, 55, 63
>  };
> +
> +const uint8_t ff_prores_run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29,
> +        0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C };
> +

> +const uint8_t ff_prores_lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28,
> +        0x28, 0x28, 0x28, 0x4C };

while at it this could employ "lev" => "level" to clarify code and
maybe enable some pattern matching trick

> diff --git a/libavcodec/proresdata.h b/libavcodec/proresdata.h
> index d8c8786689..4d16992892 100644
> --- a/libavcodec/proresdata.h
> +++ b/libavcodec/proresdata.h
> @@ -29,6 +29,8 @@
>  
>  extern const uint8_t ff_prores_progressive_scan[64];
>  extern const uint8_t ff_prores_interlaced_scan[64];
> +extern const uint8_t ff_prores_run_to_cb[16];
> +extern const uint8_t ff_prores_lev_to_cb[10];
>  
>  #define FIRST_DC_CB 0xB8 // rice_order = 5, exp_golomb_order = 6, switch_bits = 0
>  
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index e7114f1646..6b2e513bed 100644
> --- a/libavcodec/proresenc_anatoliy.c
> +++ b/libavcodec/proresenc_anatoliy.c
> @@ -296,11 +296,6 @@ static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
>      }
>  }
>  
> -static const uint8_t run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29,
> -        0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C };
> -static const uint8_t lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28,
> -        0x28, 0x28, 0x28, 0x4C };
> -
>  static void encode_ac_coeffs(PutBitContext *pb,
>          int16_t *in, int blocks_per_slice, int *qmat, const uint8_t ff_prores_scan[64])
>  {
> @@ -313,14 +308,14 @@ static void encode_ac_coeffs(PutBitContext *pb,
>          for (j = 0; j < blocks_per_slice; j++) {
>              int val = QSCALE(qmat, indp, in[(j << 6) + indp]);
>              if (val) {
> -                encode_codeword(pb, run, run_to_cb[FFMIN(prev_run, 15)]);
> +                encode_codeword(pb, run, ff_prores_run_to_cb[FFMIN(prev_run, 15)]);
>  
>                  prev_run   = run;
>                  run        = 0;
>                  level      = get_level(val);
>                  code       = level - 1;
>  
> -                encode_codeword(pb, code, lev_to_cb[FFMIN(prev_level, 9)]);
> +                encode_codeword(pb, code, ff_prores_lev_to_cb[FFMIN(prev_level, 9)]);
>  
>                  prev_level = level;
>  
> -- 
> 2.43.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".
Clément Bœsch Jan. 8, 2024, 5:06 p.m. UTC | #3
On Tue, Dec 12, 2023 at 09:02:23AM +0100, Stefano Sabatini wrote:
> On date Monday 2023-12-11 02:35:05 +0100, Clément Bœsch wrote:
> > This is going to be shared with proresenc_kostya in the upcoming commit.
> > ---
> >  libavcodec/proresdata.c         | 6 ++++++
> >  libavcodec/proresdata.h         | 2 ++
> >  libavcodec/proresenc_anatoliy.c | 9 ++-------
> >  3 files changed, 10 insertions(+), 7 deletions(-)
> > 
> > diff --git a/libavcodec/proresdata.c b/libavcodec/proresdata.c
> > index 4787907c71..12ee43bddd 100644
> > --- a/libavcodec/proresdata.c
> > +++ b/libavcodec/proresdata.c
> > @@ -43,3 +43,9 @@ const uint8_t ff_prores_interlaced_scan[64] = {
> >      30, 23, 31, 38, 45, 52, 60, 53,
> >      46, 39, 47, 54, 61, 62, 55, 63
> >  };
> > +
> > +const uint8_t ff_prores_run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29,
> > +        0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C };
> > +
> 
> > +const uint8_t ff_prores_lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28,
> > +        0x28, 0x28, 0x28, 0x4C };
> 
> while at it this could employ "lev" => "level" to clarify code and
> maybe enable some pattern matching trick

Renamed locally
diff mbox series

Patch

diff --git a/libavcodec/proresdata.c b/libavcodec/proresdata.c
index 4787907c71..12ee43bddd 100644
--- a/libavcodec/proresdata.c
+++ b/libavcodec/proresdata.c
@@ -43,3 +43,9 @@  const uint8_t ff_prores_interlaced_scan[64] = {
     30, 23, 31, 38, 45, 52, 60, 53,
     46, 39, 47, 54, 61, 62, 55, 63
 };
+
+const uint8_t ff_prores_run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29,
+        0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C };
+
+const uint8_t ff_prores_lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28,
+        0x28, 0x28, 0x28, 0x4C };
diff --git a/libavcodec/proresdata.h b/libavcodec/proresdata.h
index d8c8786689..4d16992892 100644
--- a/libavcodec/proresdata.h
+++ b/libavcodec/proresdata.h
@@ -29,6 +29,8 @@ 
 
 extern const uint8_t ff_prores_progressive_scan[64];
 extern const uint8_t ff_prores_interlaced_scan[64];
+extern const uint8_t ff_prores_run_to_cb[16];
+extern const uint8_t ff_prores_lev_to_cb[10];
 
 #define FIRST_DC_CB 0xB8 // rice_order = 5, exp_golomb_order = 6, switch_bits = 0
 
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index e7114f1646..6b2e513bed 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -296,11 +296,6 @@  static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
     }
 }
 
-static const uint8_t run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29,
-        0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C };
-static const uint8_t lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28,
-        0x28, 0x28, 0x28, 0x4C };
-
 static void encode_ac_coeffs(PutBitContext *pb,
         int16_t *in, int blocks_per_slice, int *qmat, const uint8_t ff_prores_scan[64])
 {
@@ -313,14 +308,14 @@  static void encode_ac_coeffs(PutBitContext *pb,
         for (j = 0; j < blocks_per_slice; j++) {
             int val = QSCALE(qmat, indp, in[(j << 6) + indp]);
             if (val) {
-                encode_codeword(pb, run, run_to_cb[FFMIN(prev_run, 15)]);
+                encode_codeword(pb, run, ff_prores_run_to_cb[FFMIN(prev_run, 15)]);
 
                 prev_run   = run;
                 run        = 0;
                 level      = get_level(val);
                 code       = level - 1;
 
-                encode_codeword(pb, code, lev_to_cb[FFMIN(prev_level, 9)]);
+                encode_codeword(pb, code, ff_prores_lev_to_cb[FFMIN(prev_level, 9)]);
 
                 prev_level = level;