diff mbox series

[FFmpeg-devel,1/2] mpeg2: Renaming functions around init_uni_ac_vlc

Message ID 20200713111619.226490-1-jb@videolan.org
State New
Headers show
Series [FFmpeg-devel,1/2] mpeg2: Renaming functions around init_uni_ac_vlc
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Jean-Baptiste Kempf July 13, 2020, 11:16 a.m. UTC
We need to export init_uni_ac_vlc to init_uni_ac_vlc and therefore need
renaming ff_init_uni_ac_vlc to ff_init_uni_ac_huffman for the following
patch.
---
 libavcodec/mjpegenc.c        | 4 ++--
 libavcodec/mjpegenc_common.c | 6 +++---
 libavcodec/mjpegenc_common.h | 2 +-
 libavcodec/mpeg12.h          | 2 ++
 libavcodec/mpeg12enc.c       | 6 +++---
 libavcodec/speedhq.c         | 2 +-
 6 files changed, 12 insertions(+), 10 deletions(-)

Comments

Michael Niedermayer July 13, 2020, 9:49 p.m. UTC | #1
On Mon, Jul 13, 2020 at 01:16:18PM +0200, Jean-Baptiste Kempf wrote:
> We need to export init_uni_ac_vlc to init_uni_ac_vlc and therefore need
> renaming ff_init_uni_ac_vlc to ff_init_uni_ac_huffman for the following
> patch.
> ---
>  libavcodec/mjpegenc.c        | 4 ++--
>  libavcodec/mjpegenc_common.c | 6 +++---
>  libavcodec/mjpegenc_common.h | 2 +-
>  libavcodec/mpeg12.h          | 2 ++
>  libavcodec/mpeg12enc.c       | 6 +++---
>  libavcodec/speedhq.c         | 2 +-
>  6 files changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
> index 56ccbc5fb1..eaa739306a 100644
> --- a/libavcodec/mjpegenc.c
> +++ b/libavcodec/mjpegenc.c
> @@ -106,8 +106,8 @@ av_cold int ff_mjpeg_encode_init(MpegEncContext *s)
>                                   avpriv_mjpeg_bits_ac_chrominance,
>                                   avpriv_mjpeg_val_ac_chrominance);
>  
> -    ff_init_uni_ac_vlc(m->huff_size_ac_luminance,   m->uni_ac_vlc_len);
> -    ff_init_uni_ac_vlc(m->huff_size_ac_chrominance, m->uni_chroma_ac_vlc_len);
> +    ff_init_uni_ac_huffman(m->huff_size_ac_luminance,   m->uni_ac_vlc_len);
> +    ff_init_uni_ac_huffman(m->huff_size_ac_chrominance, m->uni_chroma_ac_vlc_len);
>      s->intra_ac_vlc_length      =
>      s->intra_ac_vlc_last_length = m->uni_ac_vlc_len;
>      s->intra_chroma_ac_vlc_length      =
> diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
> index 3038ebde6e..fed32efc67 100644
> --- a/libavcodec/mjpegenc_common.c
> +++ b/libavcodec/mjpegenc_common.c
> @@ -36,7 +36,7 @@
>  #include "mjpegenc_huffman.h"
>  #include "mjpeg.h"
>  
> -av_cold void ff_init_uni_ac_vlc(const uint8_t huff_size_ac[256], uint8_t *uni_ac_vlc_len)
> +av_cold void ff_init_uni_ac_huffman(const uint8_t huff_size_ac[256], uint8_t *uni_ac_vlc_len)
>  {
>      int i;
>  

Maybe its nitpicking but huffman != vlc
huffman is a specific type of vlc code
and specifically, huffman codes are optimal and have no unused parts while
this here can have unused parts so huffman may be a suboptimal term

also isnt this jpeg specific here ?
if so adding a "jpeg" in the name might work better

thx

[...]
Moritz Barsnick July 14, 2020, 12:38 p.m. UTC | #2
On Mon, Jul 13, 2020 at 13:16:18 +0200, Jean-Baptiste Kempf wrote:
> We need to export init_uni_ac_vlc to init_uni_ac_vlc and therefore need

"to ff_init_uni_ac_vlc"?

Moritz
diff mbox series

Patch

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 56ccbc5fb1..eaa739306a 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -106,8 +106,8 @@  av_cold int ff_mjpeg_encode_init(MpegEncContext *s)
                                  avpriv_mjpeg_bits_ac_chrominance,
                                  avpriv_mjpeg_val_ac_chrominance);
 
-    ff_init_uni_ac_vlc(m->huff_size_ac_luminance,   m->uni_ac_vlc_len);
-    ff_init_uni_ac_vlc(m->huff_size_ac_chrominance, m->uni_chroma_ac_vlc_len);
+    ff_init_uni_ac_huffman(m->huff_size_ac_luminance,   m->uni_ac_vlc_len);
+    ff_init_uni_ac_huffman(m->huff_size_ac_chrominance, m->uni_chroma_ac_vlc_len);
     s->intra_ac_vlc_length      =
     s->intra_ac_vlc_last_length = m->uni_ac_vlc_len;
     s->intra_chroma_ac_vlc_length      =
diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 3038ebde6e..fed32efc67 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -36,7 +36,7 @@ 
 #include "mjpegenc_huffman.h"
 #include "mjpeg.h"
 
-av_cold void ff_init_uni_ac_vlc(const uint8_t huff_size_ac[256], uint8_t *uni_ac_vlc_len)
+av_cold void ff_init_uni_ac_huffman(const uint8_t huff_size_ac[256], uint8_t *uni_ac_vlc_len)
 {
     int i;
 
@@ -551,8 +551,8 @@  int ff_mjpeg_encode_stuffing(MpegEncContext *s)
 
         // Replace the VLCs with the optimal ones.
         // The default ones may be used for trellis during quantization.
-        ff_init_uni_ac_vlc(m->huff_size_ac_luminance,   m->uni_ac_vlc_len);
-        ff_init_uni_ac_vlc(m->huff_size_ac_chrominance, m->uni_chroma_ac_vlc_len);
+        ff_init_uni_ac_huffman(m->huff_size_ac_luminance,   m->uni_ac_vlc_len);
+        ff_init_uni_ac_huffman(m->huff_size_ac_chrominance, m->uni_chroma_ac_vlc_len);
         s->intra_ac_vlc_length      =
         s->intra_ac_vlc_last_length = m->uni_ac_vlc_len;
         s->intra_chroma_ac_vlc_length      =
diff --git a/libavcodec/mjpegenc_common.h b/libavcodec/mjpegenc_common.h
index e8698d18c6..c24fee0b4e 100644
--- a/libavcodec/mjpegenc_common.h
+++ b/libavcodec/mjpegenc_common.h
@@ -41,6 +41,6 @@  void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4
 void ff_mjpeg_encode_dc(PutBitContext *pb, int val,
                         uint8_t *huff_size, uint16_t *huff_code);
 
-av_cold void ff_init_uni_ac_vlc(const uint8_t huff_size_ac[256], uint8_t *uni_ac_vlc_len);
+av_cold void ff_init_uni_ac_huffman(const uint8_t huff_size_ac[256], uint8_t *uni_ac_vlc_len);
 
 #endif /* AVCODEC_MJPEGENC_COMMON_H */
diff --git a/libavcodec/mpeg12.h b/libavcodec/mpeg12.h
index 1ec99f17e1..f01d7197ff 100644
--- a/libavcodec/mpeg12.h
+++ b/libavcodec/mpeg12.h
@@ -77,4 +77,6 @@  void ff_mpeg12_find_best_frame_rate(AVRational frame_rate,
                                     int *code, int *ext_n, int *ext_d,
                                     int nonstandard);
 
+void ff_init_uni_ac_vlc(RLTable *rl, uint8_t *uni_ac_vlc_len);
+
 #endif /* AVCODEC_MPEG12_H */
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 9fbbcef607..c33e20604e 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -64,7 +64,7 @@  static int8_t  mpeg1_max_level[2][64];
 
 #define A53_MAX_CC_COUNT 0x1f
 
-static av_cold void init_uni_ac_vlc(RLTable *rl, uint8_t *uni_ac_vlc_len)
+av_cold void ff_init_uni_ac_vlc(RLTable *rl, uint8_t *uni_ac_vlc_len)
 {
     int i;
 
@@ -1054,9 +1054,9 @@  av_cold void ff_mpeg1_encode_init(MpegEncContext *s)
             mpeg1_index_run[0][i] = ff_rl_mpeg1.index_run[0][i];
         }
 
-        init_uni_ac_vlc(&ff_rl_mpeg1, uni_mpeg1_ac_vlc_len);
+        ff_init_uni_ac_vlc(&ff_rl_mpeg1, uni_mpeg1_ac_vlc_len);
         if (s->intra_vlc_format)
-            init_uni_ac_vlc(&ff_rl_mpeg2, uni_mpeg2_ac_vlc_len);
+            ff_init_uni_ac_vlc(&ff_rl_mpeg2, uni_mpeg2_ac_vlc_len);
 
         /* build unified dc encoding tables */
         for (i = -255; i < 256; i++) {
diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c
index b834b79f28..86eb725398 100644
--- a/libavcodec/speedhq.c
+++ b/libavcodec/speedhq.c
@@ -132,7 +132,7 @@  static const uint8_t speedhq_run[121] = {
     31,
 };
 
-static RLTable ff_rl_speedhq = {
+RLTable ff_rl_speedhq = {
     121,
     121,
     (const uint16_t (*)[])speedhq_vlc,