Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] avcodec/leaddec: Remove unnecessary VLC structures
@ 2024-01-31  9:27 Andreas Rheinhardt
  2024-01-31  9:31 ` [FFmpeg-devel] [PATCH 2/2] avcodec/vlc: Remove unused macros Andreas Rheinhardt
  2024-02-02 11:30 ` [FFmpeg-devel] [PATCH 1/2] avcodec/leaddec: Remove unnecessary VLC structures Andreas Rheinhardt
  0 siblings, 2 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2024-01-31  9:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

One only needs the VLCElem[].

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/leaddec.c | 48 ++++++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/libavcodec/leaddec.c b/libavcodec/leaddec.c
index 4e97479b03..489fe501b6 100644
--- a/libavcodec/leaddec.c
+++ b/libavcodec/leaddec.c
@@ -38,29 +38,29 @@
 #define LUMA_AC_BITS 10
 #define CHROMA_AC_BITS 10
 
-static VLC luma_dc_vlc;
-static VLC chroma_dc_vlc;
-static VLC luma_ac_vlc;
-static VLC chroma_ac_vlc;
+static VLCElem luma_dc_vlc[1 << LUMA_DC_BITS];
+static VLCElem chroma_dc_vlc[1 << CHROMA_DC_BITS];
+static VLCElem luma_ac_vlc[1160];
+static VLCElem chroma_ac_vlc[1160];
 
 static av_cold void lead_init_static_data(void)
 {
-    VLC_INIT_STATIC_FROM_LENGTHS(&luma_dc_vlc, LUMA_DC_BITS, FF_ARRAY_ELEMS(luma_dc_len),
-                                 luma_dc_len, 1,
-                                 0, 0, 0,
-                                 0, 0, 1 << LUMA_DC_BITS);
-    VLC_INIT_STATIC_FROM_LENGTHS(&chroma_dc_vlc, CHROMA_DC_BITS, FF_ARRAY_ELEMS(chroma_dc_len),
-                                 chroma_dc_len, 1,
-                                 0, 0, 0,
-                                 0, 0, 1 << CHROMA_DC_BITS);
-    VLC_INIT_STATIC_FROM_LENGTHS(&luma_ac_vlc, LUMA_AC_BITS, FF_ARRAY_ELEMS(luma_ac_len),
-                                 luma_ac_len, 1,
-                                 ff_mjpeg_val_ac_luminance, 1, 1,
-                                 0, 0, 1160);
-    VLC_INIT_STATIC_FROM_LENGTHS(&chroma_ac_vlc, CHROMA_AC_BITS, FF_ARRAY_ELEMS(chroma_ac_len),
-                                 chroma_ac_len, 1,
-                                 ff_mjpeg_val_ac_chrominance, 1, 1,
-                                 0, 0, 1160);
+    VLC_INIT_STATIC_TABLE_FROM_LENGTHS(luma_dc_vlc, LUMA_DC_BITS, FF_ARRAY_ELEMS(luma_dc_len),
+                                       luma_dc_len, 1,
+                                       NULL, 0, 0,
+                                       0, 0);
+    VLC_INIT_STATIC_TABLE_FROM_LENGTHS(chroma_dc_vlc, CHROMA_DC_BITS, FF_ARRAY_ELEMS(chroma_dc_len),
+                                       chroma_dc_len, 1,
+                                       NULL, 0, 0,
+                                       0, 0);
+    VLC_INIT_STATIC_TABLE_FROM_LENGTHS(luma_ac_vlc, LUMA_AC_BITS, FF_ARRAY_ELEMS(luma_ac_len),
+                                       luma_ac_len, 1,
+                                       ff_mjpeg_val_ac_luminance, 1, 1,
+                                       0, 0);
+    VLC_INIT_STATIC_TABLE_FROM_LENGTHS(chroma_ac_vlc, CHROMA_AC_BITS, FF_ARRAY_ELEMS(chroma_ac_len),
+                                       chroma_ac_len, 1,
+                                       ff_mjpeg_val_ac_chrominance, 1, 1,
+                                       0, 0);
 }
 
 typedef struct LeadContext {
@@ -199,9 +199,9 @@ static int lead_decode_frame(AVCodecContext *avctx, AVFrame * frame,
             for (int mb_x = 0; mb_x < avctx->width / 16; mb_x++)
                 for (int b = 0; b < (yuv20p_half ? 4 : 6); b++) {
                     int luma_block = yuv20p_half ? 2 : 4;
-                    const VLCElem * dc_vlc = b < luma_block ? luma_dc_vlc.table : chroma_dc_vlc.table;
+                    const VLCElem * dc_vlc = b < luma_block ? luma_dc_vlc : chroma_dc_vlc;
                     int dc_bits            = b < luma_block ? LUMA_DC_BITS : CHROMA_DC_BITS;
-                    const VLCElem * ac_vlc = b < luma_block ? luma_ac_vlc.table : chroma_ac_vlc.table;
+                    const VLCElem * ac_vlc = b < luma_block ? luma_ac_vlc : chroma_ac_vlc;
                     int ac_bits            = b < luma_block ? LUMA_AC_BITS : CHROMA_AC_BITS;
                     int plane              = b < luma_block ? 0 : b - (yuv20p_half ? 1 : 3);
                     int x, y;
@@ -231,9 +231,9 @@ static int lead_decode_frame(AVCodecContext *avctx, AVFrame * frame,
             for (int j = 0; j < avctx->height / fields / 8; j++)
                 for (int i = 0; i < avctx->width / 8; i++)
                     for (int plane = 0; plane < 3; plane++) {
-                        const VLCElem * dc_vlc = !plane ? luma_dc_vlc.table : chroma_dc_vlc.table;
+                        const VLCElem * dc_vlc = !plane ? luma_dc_vlc : chroma_dc_vlc;
                         int dc_bits            = !plane ? LUMA_DC_BITS : CHROMA_DC_BITS;
-                        const VLCElem * ac_vlc = !plane ? luma_ac_vlc.table : chroma_ac_vlc.table;
+                        const VLCElem * ac_vlc = !plane ? luma_ac_vlc : chroma_ac_vlc;
                         int ac_bits            = !plane ? LUMA_AC_BITS : CHROMA_AC_BITS;
 
                         ret = decode_block(s, &gb, dc_vlc, dc_bits, ac_vlc, ac_bits,
-- 
2.34.1

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] avcodec/vlc: Remove unused macros
  2024-01-31  9:27 [FFmpeg-devel] [PATCH 1/2] avcodec/leaddec: Remove unnecessary VLC structures Andreas Rheinhardt
@ 2024-01-31  9:31 ` Andreas Rheinhardt
  2024-02-02 11:30 ` [FFmpeg-devel] [PATCH 1/2] avcodec/leaddec: Remove unnecessary VLC structures Andreas Rheinhardt
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2024-01-31  9:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
1. This has already been sent months ago, but I didn't apply it
because Peter Ross has sent patches that make use of them and
I did not want to force him to adapt.
2. I do not rule out that there might be scenarios in the future where
creating a static VLC (and not only VLCElem[]) would be useful,
but this zoo of macros is nevertheless too much. There should
be only two macros: One with symbols (i.e. "sparse") and one without,
both having options for flags.

 libavcodec/vlc.h | 41 -----------------------------------------
 1 file changed, 41 deletions(-)

diff --git a/libavcodec/vlc.h b/libavcodec/vlc.h
index 679666801a..0cc106c499 100644
--- a/libavcodec/vlc.h
+++ b/libavcodec/vlc.h
@@ -185,47 +185,6 @@ void ff_vlc_free(VLC *vlc);
 #define VLC_INIT_OUTPUT_LE      8
 #define VLC_INIT_LE             (VLC_INIT_INPUT_LE | VLC_INIT_OUTPUT_LE)
 
-#define VLC_INIT_CUSTOM_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g,      \
-                                      h, i, j, flags, static_size)         \
-    do {                                                                   \
-        static VLCElem table[static_size];                                 \
-        (vlc)->table           = table;                                    \
-        (vlc)->table_allocated = static_size;                              \
-        ff_vlc_init_sparse(vlc, bits, a, b, c, d, e, f, g, h, i, j,        \
-                           flags | VLC_INIT_USE_STATIC);                   \
-    } while (0)
-
-#define VLC_INIT_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, h, i, j, static_size) \
-    VLC_INIT_CUSTOM_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g,          \
-                                  h, i, j, 0, static_size)
-
-#define VLC_INIT_LE_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, h, i, j, static_size) \
-    VLC_INIT_CUSTOM_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g,          \
-                                  h, i, j, VLC_INIT_LE, static_size)
-
-#define VLC_INIT_CUSTOM_STATIC(vlc, bits, a, b, c, d, e, f, g, flags, static_size) \
-    VLC_INIT_CUSTOM_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g,          \
-                                  NULL, 0, 0, flags, static_size)
-
-#define VLC_INIT_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)       \
-    VLC_INIT_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, NULL, 0, 0, static_size)
-
-#define VLC_INIT_LE_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size) \
-    VLC_INIT_LE_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, NULL, 0, 0, static_size)
-
-#define VLC_INIT_STATIC_FROM_LENGTHS(vlc, bits, nb_codes, lens, len_wrap,  \
-                                     symbols, symbols_wrap, symbols_size,  \
-                                     offset, flags, static_size)           \
-    do {                                                                   \
-        static VLCElem table[static_size];                                 \
-        (vlc)->table           = table;                                    \
-        (vlc)->table_allocated = static_size;                              \
-        ff_vlc_init_from_lengths(vlc, bits, nb_codes, lens, len_wrap,      \
-                                 symbols, symbols_wrap, symbols_size,      \
-                                 offset, flags | VLC_INIT_USE_STATIC,      \
-                                 NULL);                                    \
-    } while (0)
-
 /**
  * For static VLCs, the number of bits can often be hardcoded
  * at each get_vlc2() callsite. Then using a full VLC would be uneconomical,
-- 
2.34.1

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/leaddec: Remove unnecessary VLC structures
  2024-01-31  9:27 [FFmpeg-devel] [PATCH 1/2] avcodec/leaddec: Remove unnecessary VLC structures Andreas Rheinhardt
  2024-01-31  9:31 ` [FFmpeg-devel] [PATCH 2/2] avcodec/vlc: Remove unused macros Andreas Rheinhardt
@ 2024-02-02 11:30 ` Andreas Rheinhardt
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2024-02-02 11:30 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt:
> One only needs the VLCElem[].
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/leaddec.c | 48 ++++++++++++++++++++++----------------------
>  1 file changed, 24 insertions(+), 24 deletions(-)
> 
> diff --git a/libavcodec/leaddec.c b/libavcodec/leaddec.c
> index 4e97479b03..489fe501b6 100644
> --- a/libavcodec/leaddec.c
> +++ b/libavcodec/leaddec.c
> @@ -38,29 +38,29 @@
>  #define LUMA_AC_BITS 10
>  #define CHROMA_AC_BITS 10
>  
> -static VLC luma_dc_vlc;
> -static VLC chroma_dc_vlc;
> -static VLC luma_ac_vlc;
> -static VLC chroma_ac_vlc;
> +static VLCElem luma_dc_vlc[1 << LUMA_DC_BITS];
> +static VLCElem chroma_dc_vlc[1 << CHROMA_DC_BITS];
> +static VLCElem luma_ac_vlc[1160];
> +static VLCElem chroma_ac_vlc[1160];
>  
>  static av_cold void lead_init_static_data(void)
>  {
> -    VLC_INIT_STATIC_FROM_LENGTHS(&luma_dc_vlc, LUMA_DC_BITS, FF_ARRAY_ELEMS(luma_dc_len),
> -                                 luma_dc_len, 1,
> -                                 0, 0, 0,
> -                                 0, 0, 1 << LUMA_DC_BITS);
> -    VLC_INIT_STATIC_FROM_LENGTHS(&chroma_dc_vlc, CHROMA_DC_BITS, FF_ARRAY_ELEMS(chroma_dc_len),
> -                                 chroma_dc_len, 1,
> -                                 0, 0, 0,
> -                                 0, 0, 1 << CHROMA_DC_BITS);
> -    VLC_INIT_STATIC_FROM_LENGTHS(&luma_ac_vlc, LUMA_AC_BITS, FF_ARRAY_ELEMS(luma_ac_len),
> -                                 luma_ac_len, 1,
> -                                 ff_mjpeg_val_ac_luminance, 1, 1,
> -                                 0, 0, 1160);
> -    VLC_INIT_STATIC_FROM_LENGTHS(&chroma_ac_vlc, CHROMA_AC_BITS, FF_ARRAY_ELEMS(chroma_ac_len),
> -                                 chroma_ac_len, 1,
> -                                 ff_mjpeg_val_ac_chrominance, 1, 1,
> -                                 0, 0, 1160);
> +    VLC_INIT_STATIC_TABLE_FROM_LENGTHS(luma_dc_vlc, LUMA_DC_BITS, FF_ARRAY_ELEMS(luma_dc_len),
> +                                       luma_dc_len, 1,
> +                                       NULL, 0, 0,
> +                                       0, 0);
> +    VLC_INIT_STATIC_TABLE_FROM_LENGTHS(chroma_dc_vlc, CHROMA_DC_BITS, FF_ARRAY_ELEMS(chroma_dc_len),
> +                                       chroma_dc_len, 1,
> +                                       NULL, 0, 0,
> +                                       0, 0);
> +    VLC_INIT_STATIC_TABLE_FROM_LENGTHS(luma_ac_vlc, LUMA_AC_BITS, FF_ARRAY_ELEMS(luma_ac_len),
> +                                       luma_ac_len, 1,
> +                                       ff_mjpeg_val_ac_luminance, 1, 1,
> +                                       0, 0);
> +    VLC_INIT_STATIC_TABLE_FROM_LENGTHS(chroma_ac_vlc, CHROMA_AC_BITS, FF_ARRAY_ELEMS(chroma_ac_len),
> +                                       chroma_ac_len, 1,
> +                                       ff_mjpeg_val_ac_chrominance, 1, 1,
> +                                       0, 0);
>  }
>  
>  typedef struct LeadContext {
> @@ -199,9 +199,9 @@ static int lead_decode_frame(AVCodecContext *avctx, AVFrame * frame,
>              for (int mb_x = 0; mb_x < avctx->width / 16; mb_x++)
>                  for (int b = 0; b < (yuv20p_half ? 4 : 6); b++) {
>                      int luma_block = yuv20p_half ? 2 : 4;
> -                    const VLCElem * dc_vlc = b < luma_block ? luma_dc_vlc.table : chroma_dc_vlc.table;
> +                    const VLCElem * dc_vlc = b < luma_block ? luma_dc_vlc : chroma_dc_vlc;
>                      int dc_bits            = b < luma_block ? LUMA_DC_BITS : CHROMA_DC_BITS;
> -                    const VLCElem * ac_vlc = b < luma_block ? luma_ac_vlc.table : chroma_ac_vlc.table;
> +                    const VLCElem * ac_vlc = b < luma_block ? luma_ac_vlc : chroma_ac_vlc;
>                      int ac_bits            = b < luma_block ? LUMA_AC_BITS : CHROMA_AC_BITS;
>                      int plane              = b < luma_block ? 0 : b - (yuv20p_half ? 1 : 3);
>                      int x, y;
> @@ -231,9 +231,9 @@ static int lead_decode_frame(AVCodecContext *avctx, AVFrame * frame,
>              for (int j = 0; j < avctx->height / fields / 8; j++)
>                  for (int i = 0; i < avctx->width / 8; i++)
>                      for (int plane = 0; plane < 3; plane++) {
> -                        const VLCElem * dc_vlc = !plane ? luma_dc_vlc.table : chroma_dc_vlc.table;
> +                        const VLCElem * dc_vlc = !plane ? luma_dc_vlc : chroma_dc_vlc;
>                          int dc_bits            = !plane ? LUMA_DC_BITS : CHROMA_DC_BITS;
> -                        const VLCElem * ac_vlc = !plane ? luma_ac_vlc.table : chroma_ac_vlc.table;
> +                        const VLCElem * ac_vlc = !plane ? luma_ac_vlc : chroma_ac_vlc;
>                          int ac_bits            = !plane ? LUMA_AC_BITS : CHROMA_AC_BITS;
>  
>                          ret = decode_block(s, &gb, dc_vlc, dc_bits, ac_vlc, ac_bits,

Will apply this patchset tomorrow unless there are objections.

- Andreas

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-02 11:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-31  9:27 [FFmpeg-devel] [PATCH 1/2] avcodec/leaddec: Remove unnecessary VLC structures Andreas Rheinhardt
2024-01-31  9:31 ` [FFmpeg-devel] [PATCH 2/2] avcodec/vlc: Remove unused macros Andreas Rheinhardt
2024-02-02 11:30 ` [FFmpeg-devel] [PATCH 1/2] avcodec/leaddec: Remove unnecessary VLC structures Andreas Rheinhardt

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