From: Scott Theisen <scott.the.elm@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Scott Theisen <scott.the.elm@gmail.com> Subject: [FFmpeg-devel] [PATCH 1/2] libavutil: create av_media_type_get_string() Date: Thu, 3 Feb 2022 15:09:29 -0500 Message-ID: <20220203200930.30744-2-scott.the.elm@gmail.com> (raw) In-Reply-To: <20220203200930.30744-1-scott.the.elm@gmail.com> This deprecates av_get_media_type_string() which does return NULL. printf %s with a null pointer is undefined behavior This also matches behavior with avcodec_get_name() which never returns NULL, instead it returns "unknown_codec". --- doc/APIchanges | 3 +++ libavutil/avutil.h | 7 +++++++ libavutil/utils.c | 13 +++++++++++++ 3 files changed, 23 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index 315a04c952..5b2ef724be 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-02-03 - xxxxxxxxxxx - lavu 57.19.100 - avutil.h + Add av_media_type_get_string() which deprecates av_get_media_type_string(). + 2022-01-26 - af94ab7c7c0 - lavu 57.19.100 - tx.h Add AV_TX_FLOAT_RDFT, AV_TX_DOUBLE_RDFT and AV_TX_INT32_RDFT. diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 4d633156d1..6cabeb405a 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -209,9 +209,16 @@ enum AVMediaType { /** * Return a string describing the media_type enum, NULL if media_type * is unknown. + * + * @deprecated Use av_media_type_get_string() instead. */ const char *av_get_media_type_string(enum AVMediaType media_type); +/** + * Return a string describing the media_type enum, never NULL. + */ +const char *av_media_type_get_string(enum AVMediaType media_type); + /** * @defgroup lavu_const Constants * @{ diff --git a/libavutil/utils.c b/libavutil/utils.c index ea9b5097b8..92d242f678 100644 --- a/libavutil/utils.c +++ b/libavutil/utils.c @@ -80,6 +80,19 @@ const char *av_get_media_type_string(enum AVMediaType media_type) } } +const char *av_media_type_get_string(enum AVMediaType media_type) +{ + switch (media_type) { + case AVMEDIA_TYPE_UNKNOWN: return "unknown"; + case AVMEDIA_TYPE_VIDEO: return "video"; + case AVMEDIA_TYPE_AUDIO: return "audio"; + case AVMEDIA_TYPE_DATA: return "data"; + case AVMEDIA_TYPE_SUBTITLE: return "subtitle"; + case AVMEDIA_TYPE_ATTACHMENT: return "attachment"; + default: return "invalid_media_type"; + } +} + char av_get_picture_type_char(enum AVPictureType pict_type) { switch (pict_type) { -- 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-02-03 20:10 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-02-01 22:30 [FFmpeg-devel] [PATCH] lavu: make av_get_media_type_string() never return NULL Scott Theisen 2022-02-01 22:34 ` James Almer 2022-02-02 1:58 ` Scott Theisen 2022-02-02 2:06 ` James Almer 2022-02-02 2:42 ` Scott Theisen 2022-02-02 2:13 ` Andreas Rheinhardt 2022-02-23 7:52 ` Anton Khirnov 2022-02-28 21:06 ` Scott Theisen 2022-02-03 20:09 ` [FFmpeg-devel] [PATCH v2] create av_media_type_get_string() Scott Theisen 2022-02-03 20:09 ` Scott Theisen [this message] 2022-02-03 20:09 ` [FFmpeg-devel] [PATCH 2/2] replace av_get_media_type_string() with av_media_type_get_string() Scott Theisen 2022-02-13 21:52 ` [FFmpeg-devel] [PATCH v3] create av_media_type_get_string() Scott Theisen 2022-02-13 21:52 ` [FFmpeg-devel] [PATCH v3 1/2] libavutil: " Scott Theisen 2022-02-13 21:52 ` [FFmpeg-devel] [PATCH v3 2/2] av_get_media_type_string(): replace with av_media_type_get_string() Scott Theisen 2022-05-15 19:55 ` [FFmpeg-devel] [Patch v4 0/2] create av_media_type_get_string() Scott Theisen 2022-05-15 19:55 ` [FFmpeg-devel] [PATCH v4 1/2] libavutil: " Scott Theisen 2022-05-15 19:55 ` [FFmpeg-devel] [PATCH v4 2/2] av_get_media_type_string(): replace with av_media_type_get_string() Scott Theisen 2022-06-01 19:22 ` [FFmpeg-devel] [PATCH] " Scott Theisen 2022-09-16 17:32 ` [FFmpeg-devel] [PATCH v2] " Scott Theisen
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=20220203200930.30744-2-scott.the.elm@gmail.com \ --to=scott.the.elm@gmail.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