* [FFmpeg-devel] [PATCH 1/1] avutil/pixdesc: reduce the size of symbols in pixdesc to optimize code size.
@ 2025-08-06 2:52 17607086963
0 siblings, 0 replies; only message in thread
From: 17607086963 @ 2025-08-06 2:52 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: renjg
From: renjg <17607086963@163.com>
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: renjg <17607086963@163.com>
---
configure | 1 +
libavutil/Makefile | 2 +-
libavutil/pixdesc.h | 151 +++++++++++++++++++++++++++++++++++++++++---
3 files changed, 143 insertions(+), 11 deletions(-)
diff --git a/configure b/configure
index c0a4c3c87c..1ddcd1b21f 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.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] only message in thread
only message in thread, other threads:[~2025-08-06 2:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-06 2:52 [FFmpeg-devel] [PATCH 1/1] avutil/pixdesc: reduce the size of symbols in pixdesc to optimize code size 17607086963
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