From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id D290E4C1FE for ; Wed, 6 Aug 2025 02:53:11 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 7418B68BDE5; Wed, 6 Aug 2025 05:53:07 +0300 (EEST) Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.2]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 93D65687D15 for ; Wed, 6 Aug 2025 05:52:59 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=tV gH0MaJZCIm4Sp7emyZtnkreOqGvDAA+LXO5GqDMFM=; b=OmTg4KPpZkr8lczsRV OX66AvZ1b59IPD6f4TxyFBDCEIUCvSgRLTTJGu/DtIqb888mpaNga1bny8cNi0r4 vIg4Ak5KTDfO7+kyXNXXFUpBDoCPd8q6YZgf2ksjVKxBSbaEPs2hYItbxP6yQXMt 68hD8lc5LM3sF1Boe4iysWynM= Received: from renjg-ThinkCentre-M760t.mioffice.cn (unknown []) by gzga-smtp-mtada-g0-0 (Coremail) with SMTP id _____wD3XVuCw5JoDDoTAA--.2176S2; Wed, 06 Aug 2025 10:52:52 +0800 (CST) From: 17607086963@163.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 6 Aug 2025 10:52:48 +0800 Message-Id: <20250806025248.109755-1-17607086963@163.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CM-TRANSID: _____wD3XVuCw5JoDDoTAA--.2176S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxKw4kXrykWrW7Kw4DJF43KFg_yoW3XF4kpF 48CFZ8Gry7XFya9a97Jr18ZF45ZanaqFyakrWkWw4DJFn8JF18XFyagrWUZryfW34I9Fyj qF4DZFy2kay7J3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRLjjhUUUUU= X-Originating-IP: [2408:8607:1b00:a:da43:aeff:fee2:89be] X-CM-SenderInfo: bprxliqxqylmiwt6il2tof0z/1tbipRGhPGiSwDBtbAAAsi Subject: [FFmpeg-devel] [PATCH 1/1] avutil/pixdesc: reduce the size of symbols in pixdesc to optimize code size. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: renjg <17607086963@163.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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 +#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".