diff mbox series

[FFmpeg-devel,6/7] proresdec2: remove a useless DC codebook entry

Message ID 20230908081508.510-6-christophe.gisquet@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/7] proresdec2: port and fix for cached reader | expand

Checks

Context Check Description
andriy/make_x86 fail Make failed

Commit Message

Christophe Gisquet Sept. 8, 2023, 8:15 a.m. UTC
---
 libavcodec/proresdec2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Andreas Rheinhardt Sept. 8, 2023, 9:08 a.m. UTC | #1
Christophe Gisquet:
> ---
>  libavcodec/proresdec2.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c
> index 02e1d82d00..b20021c622 100644
> --- a/libavcodec/proresdec2.c
> +++ b/libavcodec/proresdec2.c
> @@ -534,9 +534,9 @@ static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, cons
>  
>  #define FIRST_DC_CB 0xB8
>  
> -static const char dc_codebook[7][4] = {
> +static const char dc_codebook[6][4] = {

You would not need this change if you omitted the length.

>      { 0, 0, 1, -1 }, { 0, 1, 2, -2 }, { 0, 1, 2, -2 },
> -    { 1, 2, 2,  0 }, { 1, 2, 2,  0 }, { 0, 3, 4, -8 }, { 0, 3, 4, -8 }
> +    { 1, 2, 2,  0 }, { 1, 2, 2,  0 }, { 0, 3, 4, -8 }
>  };
>  
>  static av_always_inline int decode_dc_coeffs(GetBitContext *gb, int16_t *out,
> @@ -553,7 +553,7 @@ static av_always_inline int decode_dc_coeffs(GetBitContext *gb, int16_t *out,
>      code = 5;
>      sign = 0;
>      for (i = 1; i < blocks_per_slice; i++, out += 64) {
> -        unsigned int dccb = FFMIN(code, 6U);
> +        unsigned int dccb = FFMIN(code, 5U);

You wouldn't need this change if you used FF_ARRAY_ELEMS(dc_codebook) -
1 here.

Btw: Why is this codebook entry useless? Can code never be 6?

>          DECODE_CODEWORD2(code, dc_codebook[dccb][0], dc_codebook[dccb][1],
>                                 dc_codebook[dccb][2], dc_codebook[dccb][3]);
>          if(code) sign ^= -(code & 1);
diff mbox series

Patch

diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c
index 02e1d82d00..b20021c622 100644
--- a/libavcodec/proresdec2.c
+++ b/libavcodec/proresdec2.c
@@ -534,9 +534,9 @@  static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, cons
 
 #define FIRST_DC_CB 0xB8
 
-static const char dc_codebook[7][4] = {
+static const char dc_codebook[6][4] = {
     { 0, 0, 1, -1 }, { 0, 1, 2, -2 }, { 0, 1, 2, -2 },
-    { 1, 2, 2,  0 }, { 1, 2, 2,  0 }, { 0, 3, 4, -8 }, { 0, 3, 4, -8 }
+    { 1, 2, 2,  0 }, { 1, 2, 2,  0 }, { 0, 3, 4, -8 }
 };
 
 static av_always_inline int decode_dc_coeffs(GetBitContext *gb, int16_t *out,
@@ -553,7 +553,7 @@  static av_always_inline int decode_dc_coeffs(GetBitContext *gb, int16_t *out,
     code = 5;
     sign = 0;
     for (i = 1; i < blocks_per_slice; i++, out += 64) {
-        unsigned int dccb = FFMIN(code, 6U);
+        unsigned int dccb = FFMIN(code, 5U);
         DECODE_CODEWORD2(code, dc_codebook[dccb][0], dc_codebook[dccb][1],
                                dc_codebook[dccb][2], dc_codebook[dccb][3]);
         if(code) sign ^= -(code & 1);