Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* Re: [FFmpeg-devel] [PATCH] WIP: avutil/pixdesc: reduce the size of symbols in pixdesc to optimize code size. (PR #20154)
       [not found] <20250807101828.85FC768CF28@ffbox0-bg.ffmpeg.org>
@ 2025-08-07 10:24 ` Nicolas George
  2025-08-07 10:27   ` [FFmpeg-devel] Replies on the mailing-list (was: [PATCH] WIP: avutil/pixdesc: reduce the size of symbols in pixdesc to optimize code size. (PR #20154)) Nicolas George
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas George @ 2025-08-07 10:24 UTC (permalink / raw)
  To: Renjianguang-mi; +Cc: ffmpeg-devel

Renjianguang-mi (HE12025-08-07):
> PR #20154 opened by Renjianguang-mi
> URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20154
> Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20154.patch
> 
> Functions and arrays in pixdesc will cause the code size to be larger (about 30KB or more).
> For some products that only care about audio,you can use the audio_only switch to
> reduce the size of pixdesc symbols.
> You can enable optimization by using the command line --enable-audio-only
> Signed-off-by: renjianguang <renjianguang@xiaomi.com>

I do not like that it bloats the public headers and creates a
binary-incompatible version of the library.

And IIRC you cannot use CONFIG_SOMETHING in public headers anyway.

Better leave the function as stubs in the libraries.

Regards,

-- 
  Nicolas George
_______________________________________________
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] Replies on the mailing-list (was: [PATCH] WIP: avutil/pixdesc: reduce the size of symbols in pixdesc to optimize code size. (PR #20154))
  2025-08-07 10:24 ` [FFmpeg-devel] [PATCH] WIP: avutil/pixdesc: reduce the size of symbols in pixdesc to optimize code size. (PR #20154) Nicolas George
@ 2025-08-07 10:27   ` Nicolas George
  0 siblings, 0 replies; 3+ messages in thread
From: Nicolas George @ 2025-08-07 10:27 UTC (permalink / raw)
  To: Renjianguang-mi; +Cc: ffmpeg-devel

Nicolas George (HE12025-08-07):
> > URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20154
> > Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20154.patch

> I do not like that it bloats the public headers and creates a
> binary-incompatible version of the library.
> 
> And IIRC you cannot use CONFIG_SOMETHING in public headers anyway.
> 
> Better leave the function as stubs in the libraries.

My comment did not reach the web monster, even though I overrode the
reply-to header to include code@ffmpeg.org in the reply.

Still a lot of details to fix to get this thing anywhere remotely
usable.

-- 
  Nicolas George
_______________________________________________
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] WIP: avutil/pixdesc: reduce the size of symbols in pixdesc to optimize code size. (PR #20154)
@ 2025-08-07 10:18 Renjianguang-mi
  0 siblings, 0 replies; 3+ messages in thread
From: Renjianguang-mi @ 2025-08-07 10:18 UTC (permalink / raw)
  To: ffmpeg-devel

PR #20154 opened by Renjianguang-mi
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20154
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20154.patch

Functions and arrays in pixdesc will cause the code size to be larger (about 30KB or more).
For some products that only care about audio,you can use the audio_only switch to
reduce the size of pixdesc symbols.
You can enable optimization by using the command line --enable-audio-only
Signed-off-by: renjianguang <renjianguang@xiaomi.com>


From d296d86cab30f7d0d27e7e1986baa8e9f967fc7f Mon Sep 17 00:00:00 2001
From: renjianguang <renjianguang@xiaomi.com>
Date: Tue, 5 Aug 2025 18:38:20 +0800
Subject: [PATCH] avutil/pixdesc: reduce the size of symbols in pixdesc to
 optimize code size.

Functions and arrays in pixdesc will cause the code size to be larger (about 30KB or more).
For some products that only care about audio,you can use the audio_only switch to
reduce the size of pixdesc symbols.
You can enable optimization by using the command line --enable-audio-only
Signed-off-by: renjianguang <renjianguang@xiaomi.com>
---
 configure           |   1 +
 libavutil/Makefile  |   2 +-
 libavutil/pixdesc.h | 151 +++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 143 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index 30e61c5bb5..55b08d0c87 100755
--- a/configure
+++ b/configure
@@ -2057,6 +2057,7 @@ DOCUMENT_LIST="
 "
 
 FEATURE_LIST="
+    audio_only
     ftrapv
     gray
     hardcoded_tables
diff --git a/libavutil/Makefile b/libavutil/Makefile
index ee77e51c08..0edaaebfba 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -166,7 +166,6 @@ OBJS = adler32.o                                                        \
        murmur3.o                                                        \
        opt.o                                                            \
        parseutils.o                                                     \
-       pixdesc.o                                                        \
        pixelutils.o                                                     \
        random_seed.o                                                    \
        rational.o                                                       \
@@ -203,6 +202,7 @@ OBJS = adler32.o                                                        \
        video_hint.o                                                     \
 
 
+OBJS-$(!CONFIG_AUDIO_ONLY)              += pixdesc.o
 OBJS-$(CONFIG_CUDA)                     += hwcontext_cuda.o
 OBJS-$(CONFIG_D3D11VA)                  += hwcontext_d3d11va.o
 OBJS-$(CONFIG_D3D12VA)                  += hwcontext_d3d12va.o
diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h
index ba2f632814..3d6c378eee 100644
--- a/libavutil/pixdesc.h
+++ b/libavutil/pixdesc.h
@@ -24,6 +24,7 @@
 
 #include <inttypes.h>
 
+#include "config.h"
 #include "attributes.h"
 #include "pixfmt.h"
 
@@ -162,6 +163,16 @@ typedef struct AVPixFmtDescriptor {
  */
 #define AV_PIX_FMT_FLAG_XYZ          (1 << 10)
 
+#define FF_LOSS_RESOLUTION        0x0001 /**< loss due to resolution change */
+#define FF_LOSS_DEPTH             0x0002 /**< loss due to color depth change */
+#define FF_LOSS_COLORSPACE        0x0004 /**< loss due to color space conversion */
+#define FF_LOSS_ALPHA             0x0008 /**< loss of alpha bits */
+#define FF_LOSS_COLORQUANT        0x0010 /**< loss due to color quantization */
+#define FF_LOSS_CHROMA            0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
+#define FF_LOSS_EXCESS_RESOLUTION 0x0040 /**< loss due to unneeded extra resolution */
+#define FF_LOSS_EXCESS_DEPTH      0x0080 /**< loss due to unneeded extra color depth */
+
+#if !CONFIG_AUDIO_ONLY
 /**
  * Return the number of bits per pixel used by the pixel format
  * described by pixdesc. Note that this is not the same as the number
@@ -384,16 +395,6 @@ void av_write_image_line(const uint16_t *src, uint8_t *data[4],
  */
 enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt);
 
-#define FF_LOSS_RESOLUTION        0x0001 /**< loss due to resolution change */
-#define FF_LOSS_DEPTH             0x0002 /**< loss due to color depth change */
-#define FF_LOSS_COLORSPACE        0x0004 /**< loss due to color space conversion */
-#define FF_LOSS_ALPHA             0x0008 /**< loss of alpha bits */
-#define FF_LOSS_COLORQUANT        0x0010 /**< loss due to color quantization */
-#define FF_LOSS_CHROMA            0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
-#define FF_LOSS_EXCESS_RESOLUTION 0x0040 /**< loss due to unneeded extra resolution */
-#define FF_LOSS_EXCESS_DEPTH      0x0080 /**< loss due to unneeded extra color depth */
-
-
 /**
  * Compute what kind of losses will occur when converting from one specific
  * pixel format to another.
@@ -436,5 +437,135 @@ int av_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt,
  */
 enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
                                              enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
+#else
+static inline int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc) {
+    return 0;
+}
+
+static inline int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc) {
+    return 0;
+}
+
+static inline const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt) {
+    static const AVPixFmtDescriptor av_pix_fmt_descriptors = {
+        NULL, 0, 0, 0, 0, {  { 0, 0, 0, 0, 0 },  { 0, 0, 0, 0, 0 },  { 0, 0, 0, 0, 0 },  },  0
+    };
+    return &av_pix_fmt_descriptors;
+}
+
+static inline const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev) {
+    return NULL;
+}
+
+static inline enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc) {
+    return AV_PIX_FMT_NONE;
+}
+
+static inline int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,
+                                                   int *h_shift, int *v_shift) {
+    return 0;
+}
+
+static inline int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt) {
+    return 0;
+}
+
+static inline const char *av_color_range_name(enum AVColorRange range) {
+    return NULL;
+}
+
+static inline int av_color_range_from_name(const char *name) {
+    return 0;
+}
+
+static inline const char *av_color_primaries_name(enum AVColorPrimaries primaries) {
+    return NULL;
+}
+
+static inline int av_color_primaries_from_name(const char *name) {
+    return 0;
+}
+
+static inline const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer) {
+    return NULL;
+}
+
+static inline int av_color_transfer_from_name(const char *name) {
+    return 0;
+}
+
+static inline const char *av_color_space_name(enum AVColorSpace space) {
+    return 0;
+}
+
+static inline int av_color_space_from_name(const char *name) {
+    return 0;
+}
+
+static inline const char *av_chroma_location_name(enum AVChromaLocation location) {
+    return NULL;
+}
+
+static inline int av_chroma_location_from_name(const char *name) {
+    return 0;
+}
+
+static inline int av_chroma_location_enum_to_pos(int *xpos, int *ypos, enum AVChromaLocation pos) {
+    return 0;
+}
+
+static inline enum AVChromaLocation av_chroma_location_pos_to_enum(int xpos, int ypos) {
+    return AVCHROMA_LOC_UNSPECIFIED;
+}
+
+static inline enum AVPixelFormat av_get_pix_fmt(const char *name) {
+    return AV_PIX_FMT_NONE;
+}
+
+static inline const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt) {
+    return NULL;
+}
+
+static inline char *av_get_pix_fmt_string(char *buf, int buf_size,
+                                          enum AVPixelFormat pix_fmt) {
+    return NULL;
+}
+
+static inline void av_read_image_line2(void *dst, const uint8_t *data[4],
+                                       const int linesize[4], const AVPixFmtDescriptor *desc,
+                                       int x, int y, int c, int w, int read_pal_component,
+                                       int dst_element_size) {
+}
+
+static inline void av_read_image_line(uint16_t *dst, const uint8_t *data[4],
+                                      const int linesize[4], const AVPixFmtDescriptor *desc,
+                                      int x, int y, int c, int w, int read_pal_component) {
+}
+
+static inline void av_write_image_line2(const void *src, uint8_t *data[4],
+                                        const int linesize[4], const AVPixFmtDescriptor *desc,
+                                        int x, int y, int c, int w, int src_element_size) {
+}
+
+static inline void av_write_image_line(const uint16_t *src, uint8_t *data[4],
+                                       const int linesize[4], const AVPixFmtDescriptor *desc,
+                                       int x, int y, int c, int w) {
+}
+
+static inline enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt) {
+    return AV_PIX_FMT_NONE;
+}
+
+static inline int av_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt,
+                                      enum AVPixelFormat src_pix_fmt,
+                                      int has_alpha) {
+    return 0;
+}
+
+static inline enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
+                                                           enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr) {
+    return AV_PIX_FMT_NONE;
+}
+#endif
 
 #endif /* AVUTIL_PIXDESC_H */
-- 
2.49.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

end of thread, other threads:[~2025-08-07 10:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20250807101828.85FC768CF28@ffbox0-bg.ffmpeg.org>
2025-08-07 10:24 ` [FFmpeg-devel] [PATCH] WIP: avutil/pixdesc: reduce the size of symbols in pixdesc to optimize code size. (PR #20154) Nicolas George
2025-08-07 10:27   ` [FFmpeg-devel] Replies on the mailing-list (was: [PATCH] WIP: avutil/pixdesc: reduce the size of symbols in pixdesc to optimize code size. (PR #20154)) Nicolas George
2025-08-07 10:18 [FFmpeg-devel] [PATCH] WIP: avutil/pixdesc: reduce the size of symbols in pixdesc to optimize code size. (PR #20154) Renjianguang-mi

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