From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 40E11410BA for ; Sun, 13 Feb 2022 21:53:14 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9C6CF68B2CF; Sun, 13 Feb 2022 23:53:04 +0200 (EET) Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1CD4368B2B0 for ; Sun, 13 Feb 2022 23:52:56 +0200 (EET) Received: by mail-qv1-f44.google.com with SMTP id o5so13433631qvm.3 for ; Sun, 13 Feb 2022 13:52:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8P0eKRUDesX1DJn8YqQxqM/smJpewaQOmBB5lLkZiPc=; b=VwdoF/raEm5PJsim9ZtW96UQaqkk47hrhAXHX80xqRZhhAgVUIj247bGtDfOHCqcjW 0J7J824kdC4vrV7LwNK9M7rWEm+Hp0DDQBDghaTDn+q7LEKwq/S58kUk+yne+w2AZJN6 tATGXirfgyMM0hOXx2jCa/KOWLHXhnbmJUcQ5RM4+hccsXierLcZQkI22/I0aT+PgRsZ dwrsjDCRTPo51AUOMakMsX7LQGUdNXEa1rg2c08A/Nf8a1d8Sw4CBILD4epfjhYCgQqs W0qicCiyEcH6VUa4u20e9wOku9VPA5AlsGxLfAW8BeGVGmWIdesISw8FwltYnEL0Fw+X XGyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8P0eKRUDesX1DJn8YqQxqM/smJpewaQOmBB5lLkZiPc=; b=CykHvmkOidur9WJa1e+lMRiyooODTZ8hdI20honU3RF5Q+NOeg7hoxapB0ayRtGl/n EJ0yltM0rA0m7disLNNLFfR5gW5s19NB+NCEpsj1L53rz81zeOQ3rYAy/88lS+s9Q19o UgfJhs8Ogx7gI3QZpCtk2g3lOv65QYHwAD6Ad8Ri4VlF857ymTrhen5DGsSfaIP9EZAC yPKZy0Feepbz1hO/gEKP8Y9CMFlT7ldXzs9dNeqZKxLzb+c/CiJDvOgi7K3keGce8di7 G/cL7TvJfYAmzLddyttw8yfJD3+KqQPtFdVcSgCeHc3Qo1nxhKjRKl4jLX9D45qN6/pY zJCw== X-Gm-Message-State: AOAM533Kzm4TTxawwGxSXJHPf/l1Z3xsEVQZI46y3UEwd5vhIaWWvvOa g/J6MnYiwk5ujaa6cV7chzWPGULsMAekxw== X-Google-Smtp-Source: ABdhPJxPEyIs/6CujnMFU+ggBbIq//P7jxB/2PCLfHkFztI51bZ5RKMOqWMOqOzAtMgpZTK25kMHrQ== X-Received: by 2002:ad4:5ba6:: with SMTP id 6mr7851424qvq.112.1644789174082; Sun, 13 Feb 2022 13:52:54 -0800 (PST) Received: from localhost.localdomain ([151.200.235.219]) by smtp.gmail.com with ESMTPSA id b21sm2946108qkc.87.2022.02.13.13.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Feb 2022 13:52:53 -0800 (PST) From: Scott Theisen To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Feb 2022 16:52:29 -0500 Message-Id: <20220213215230.101828-2-scott.the.elm@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220213215230.101828-1-scott.the.elm@gmail.com> References: <20220201223058.31090-1-scott.the.elm@gmail.com> <20220213215230.101828-1-scott.the.elm@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 1/2] libavutil: create av_media_type_get_string() 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: Scott Theisen 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: 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 ea402f6118..7733de8dea 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-02-XX - xxxxxxxxxxx - lavu 57.19.100 - avutil.h + Add av_media_type_get_string() which deprecates av_get_media_type_string(). + 2022-02-07 - xxxxxxxxxx - lavu 57.21.100 - fifo.h Deprecate AVFifoBuffer and the API around it, namely av_fifo_alloc(), av_fifo_alloc_array(), av_fifo_free(), av_fifo_freep(), av_fifo_reset(), 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".