From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 8/8] avcodec/codec_internal: Include codec_tags only when they are needed Date: Fri, 18 Mar 2022 11:52:54 +0100 Message-ID: <AS1PR01MB9564A756D9A92805D2F8C0088F139@AS1PR01MB9564.eurprd01.prod.exchangelabs.com> (raw) In-Reply-To: <AS1PR01MB9564621E92A6F42E563B74A38F119@AS1PR01MB9564.eurprd01.prod.exchangelabs.com> They are only needed for the fuzzer, so check for CONFIG_OSSFUZZ. This decreases sizeof(FFCodec), which is important given that FFCodecs reside in .data.rel.ro in case of ELF with position-independent code which is always loaded and can't be shared between processes. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/bitpacked_dec.c | 5 +---- libavcodec/codec_internal.h | 10 ++++++++++ libavcodec/hapdec.c | 13 +++++-------- tools/target_dec_fuzzer.c | 2 ++ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/libavcodec/bitpacked_dec.c b/libavcodec/bitpacked_dec.c index 419550dfe0..b62d88fa8f 100644 --- a/libavcodec/bitpacked_dec.c +++ b/libavcodec/bitpacked_dec.c @@ -151,9 +151,6 @@ const FFCodec ff_bitpacked_decoder = { .init = bitpacked_init_decoder, .decode = bitpacked_decode, .p.capabilities = AV_CODEC_CAP_FRAME_THREADS, - .codec_tags = (const uint32_t []){ - MKTAG('U', 'Y', 'V', 'Y'), - FF_CODEC_TAGS_END, - }, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, + FF_CODEC_TAGS(MKTAG('U', 'Y', 'V', 'Y')) }; diff --git a/libavcodec/codec_internal.h b/libavcodec/codec_internal.h index 596cdbebd2..b6b5b05b44 100644 --- a/libavcodec/codec_internal.h +++ b/libavcodec/codec_internal.h @@ -21,6 +21,7 @@ #include <stdint.h> +#include "config.h" #include "libavutil/attributes.h" #include "codec.h" @@ -74,10 +75,16 @@ */ #define FF_CODEC_CAP_SETS_FRAME_PROPS (1 << 8) +#if CONFIG_OSSFUZZ /** * FFCodec.codec_tags termination value */ #define FF_CODEC_TAGS_END -1 +#define FF_CODEC_TAGS(...) \ + .codec_tags = (const uint32_t[]){ __VA_ARGS__, FF_CODEC_TAGS_END }, +#else +#define FF_CODEC_TAGS(...) +#endif typedef struct FFCodecDefault { const char *key; @@ -196,10 +203,13 @@ typedef struct FFCodec { */ const struct AVCodecHWConfigInternal *const *hw_configs; +#if CONFIG_OSSFUZZ /** * List of supported codec_tags, terminated by FF_CODEC_TAGS_END. + * Should be defined with the FF_CODEC_TAGS() macro. */ const uint32_t *codec_tags; +#endif } FFCodec; static av_always_inline const FFCodec *ffcodec(const AVCodec *codec) diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c index 4a7ac15a8e..72f922bc5b 100644 --- a/libavcodec/hapdec.c +++ b/libavcodec/hapdec.c @@ -486,12 +486,9 @@ const FFCodec ff_hap_decoder = { AV_CODEC_CAP_DR1, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, - .codec_tags = (const uint32_t []){ - MKTAG('H','a','p','1'), - MKTAG('H','a','p','5'), - MKTAG('H','a','p','Y'), - MKTAG('H','a','p','A'), - MKTAG('H','a','p','M'), - FF_CODEC_TAGS_END, - }, + FF_CODEC_TAGS(MKTAG('H','a','p','1'), + MKTAG('H','a','p','5'), + MKTAG('H','a','p','Y'), + MKTAG('H','a','p','A'), + MKTAG('H','a','p','M')) }; diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index 288aa63313..77f4bb8dd8 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -279,12 +279,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { ctx->sample_rate = bytestream2_get_le32(&gbc) & 0x7FFFFFFF; ctx->ch_layout.nb_channels = (unsigned)bytestream2_get_le32(&gbc) % FF_SANE_NB_CHANNELS; ctx->block_align = bytestream2_get_le32(&gbc) & 0x7FFFFFFF; +#if CONFIG_OSSFUZZ ctx->codec_tag = bytestream2_get_le32(&gbc); if (c->codec_tags) { int n; for (n = 0; c->codec_tags[n] != FF_CODEC_TAGS_END; n++); ctx->codec_tag = c->codec_tags[ctx->codec_tag % n]; } +#endif keyframes = bytestream2_get_le64(&gbc); request_channel_layout = bytestream2_get_le64(&gbc); -- 2.32.0 _______________________________________________ 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".
next prev parent reply other threads:[~2022-03-18 10:53 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-03-16 21:45 [FFmpeg-devel] [PATCH 1/3] avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.h Andreas Rheinhardt 2022-03-16 21:47 ` [FFmpeg-devel] [PATCH 2/3] avcodec/codec_internal: Add FFCodec, hide internal part of AVCodec Andreas Rheinhardt 2022-03-16 21:47 ` [FFmpeg-devel] [PATCH 3/3] avcodec/codec_internal: Rename AVCodecDefault->FFCodecDefault Andreas Rheinhardt 2022-03-17 12:43 ` [FFmpeg-devel] [PATCH 4/7] avcodec/mathops: Move bitswap_32() to its only user Andreas Rheinhardt 2022-03-17 12:43 ` [FFmpeg-devel] [PATCH 5/7] avcodec/bitstream: Move code for initializing VLCs to file of its own Andreas Rheinhardt 2022-03-17 12:43 ` [FFmpeg-devel] [PATCH 6/7] avcodec/internal: Move FF_SIGNBIT and ff_log2_run to mathops.h Andreas Rheinhardt 2022-03-17 12:43 ` [FFmpeg-devel] [PATCH 7/7] avcodec/internal: Move FF_DEFAULT_QUANT_BIAS to mpegvideoenc.h Andreas Rheinhardt 2022-03-18 10:52 ` Andreas Rheinhardt [this message] 2022-03-18 13:13 ` [FFmpeg-devel] [PATCH 8/8] avcodec/codec_internal: Include codec_tags only when they are needed Michael Niedermayer 2022-03-18 13:31 ` Michael Niedermayer 2022-03-18 13:39 ` Andreas Rheinhardt 2022-03-18 13:37 ` Andreas Rheinhardt 2022-03-31 8:26 ` Andreas Rheinhardt
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=AS1PR01MB9564A756D9A92805D2F8C0088F139@AS1PR01MB9564.eurprd01.prod.exchangelabs.com \ --to=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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