From patchwork Sun Mar 21 09:47:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26511 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 95082449A95 for ; Sun, 21 Mar 2021 11:48:00 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8027768A995; Sun, 21 Mar 2021 11:48:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7699368A867 for ; Sun, 21 Mar 2021 11:47:54 +0200 (EET) Received: by mail-wr1-f48.google.com with SMTP id o16so13561037wrn.0 for ; Sun, 21 Mar 2021 02:47:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=ZGEILQYRUMdCjSlcEmOO6cxBJd7DTG5hcHUWT3UpQIw=; b=rDEaGggBiPjUW5hCiJ8NjfYT8GRXjjtXruGzoIqIcUXBMDa4bsZFCkcQ66/K9lgnjH e1GM6YKv5WiA/XCh6N5AbOotJNLyiiHuoDUY7ZLXdPdWdxldH5tjPUFl4saXZXL68S+X EAoYb0NTB7Se4PpoGcRqr8tf5H6KjJ2a6zM0TYZfFXqkREgYCyh+6VES/nA01KVXsJVu nsYMaRip25yr3CS8EFcpwKN1EjEw3NjmzQLQWIFLLe/CZQs5WZ/K/Q2Nkzj3n8eKmSfp nUT7Y430jBCn8rCHFwwsfNYbOh3dltFZiVUFuxcqvWM6pDRAzSjCFfDg+uVfQzi9g3Gm U0Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=ZGEILQYRUMdCjSlcEmOO6cxBJd7DTG5hcHUWT3UpQIw=; b=Ik+nTyvpZIX7tDS4IZ/Pk1hFcGmpyA0vbp5h7R8yDV0QVAf2lcLr0ZIVFcS0JeLlnc TpQsUCMl4tOSe7ElrRVeCJd+kxNa7BWwvWc2bmPe351uLLd8kCmpf9TPtBS7fQeuVqvM ShL4mou757gD9ymAjve9vkq7nQeijXsu30OPgzbMpNw+OzUvOJlMpGW3LNQBcSI3r6pD x4JHf5mFTA3JteAstoPIuTvK9TH28xhIYHh2RQWxjRlbvP8I+mf+RFwYrk7MbRYMD5lY sqCSnDB60KNjDa6n3JE+9//Lc2gdBwTgz3ZU85TpkboZU+McK6iRAp39PSm849uurngs WgmA== X-Gm-Message-State: AOAM5321VoXU+NJ9w5RWd2mQmUVyWIdj9OVdT6nDnFxNopBZRj+Zsmvp 9QmK35MVJxr2vFKgMKIjgoMoiJeQhCnmKA== X-Google-Smtp-Source: ABdhPJx8B1Kn7ArNPF+GqrNaFrftcRmr2TQQMRKin/y43JlP2avTgaQOw2WClCC0ZECN9nOTgjIaOA== X-Received: by 2002:adf:fb05:: with SMTP id c5mr13434550wrr.302.1616320073614; Sun, 21 Mar 2021 02:47:53 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id m14sm11649387wmi.27.2021.03.21.02.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Mar 2021 02:47:53 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 21 Mar 2021 10:47:20 +0100 Message-Id: <20210321094722.447294-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210321094722.447294-1-andreas.rheinhardt@gmail.com> References: <20210321094722.447294-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/5] avcodec/avcodec: Update check for identical colorspace/primaries/trc names X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" If the numerical constants for colorspace, transfer characteristics and color primaries coincide, the current code presumes the corresponding names to be identical and prints only one of them obtained via av_get_colorspace_name(). There are two issues with this: The first is that the underlying assumption is wrong: The names only coincide in the 0-7 range, they differ for more recent additions. The second is that av_get_colorspace_name() is outdated itself; it has not been updated with the names of the newly defined colorspaces. Fix both of this by using the names from av_color_(space|primaries|transfer)_name() and comparing them via strcmp; don't use av_get_colorspace_name() at all. Signed-off-by: Andreas Rheinhardt --- This was our last internal user of av_get_colorspace_name(). libavcodec/avcodec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 93383dc9fb..68a3179b07 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -655,15 +655,15 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) if (enc->colorspace != AVCOL_SPC_UNSPECIFIED || enc->color_primaries != AVCOL_PRI_UNSPECIFIED || enc->color_trc != AVCOL_TRC_UNSPECIFIED) { - if (enc->colorspace != (int)enc->color_primaries || - enc->colorspace != (int)enc->color_trc) { + const char *col = av_x_if_null(av_color_space_name(enc->colorspace), "unknown"); + const char *pri = av_x_if_null(av_color_primaries_name(enc->color_primaries), "unknown"); + const char *trc = av_x_if_null(av_color_transfer_name(enc->color_trc), "unkown"); + if (strcmp(col, pri) || strcmp(col, trc)) { new_line = 1; av_strlcatf(detail, sizeof(detail), "%s/%s/%s, ", - av_x_if_null(av_color_space_name(enc->colorspace), "unknown"), - av_x_if_null(av_color_primaries_name(enc->color_primaries), "unknown"), - av_x_if_null(av_color_transfer_name(enc->color_trc), "unkown")); - } else if (str = av_get_colorspace_name(enc->colorspace)) - av_strlcatf(detail, sizeof(detail), "%s, ", str); + col, pri, trc); + } else + av_strlcatf(detail, sizeof(detail), "%s, ", col); } if (enc->field_order != AV_FIELD_UNKNOWN) {