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 3B2F343F9C for ; Thu, 22 Sep 2022 13:20:43 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AEA9168BBBB; Thu, 22 Sep 2022 16:20:41 +0300 (EEST) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8E52068B8F2 for ; Thu, 22 Sep 2022 16:20:35 +0300 (EEST) Received: by mail-wm1-f45.google.com with SMTP id t4so2838326wmj.5 for ; Thu, 22 Sep 2022 06:20:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date; bh=UPerj9PBx8sJrPo7EOEtI/ErcOIDz5QQuGfaEaFqzpQ=; b=AzJnJJLCI8KizXZLzmtcedwZtpPaMFbVQTYuQaZDTmfSHLUg2nGvZgIHJhfclW7KBk iFwnWljgnZ2C7Jh17EfZ0Ebn6Cv7lycAHk37LIWx1HW/0ZXHgKVHCXMJzBgy4gX0a1ra L5D3qDQdL4Zo1WAfw/3QTc4SPuIXFIOZRxQoeRerH1+qW25Brgn6LztUO3XDoh0WhSBg /uQPn5ROiNJdPWINOIzZowpuU9fzF02OcpAohm+sTbCs39od6yi1PXzZSDmDsoC1ESXP rDaw7OXcuXCjmckxSeeQ/yryCOQ13e7HcH6JQfIEHhr0Wag7YDhmQDQ0cmCWkF+EfoQA bDjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date; bh=UPerj9PBx8sJrPo7EOEtI/ErcOIDz5QQuGfaEaFqzpQ=; b=P9iDZz82oncbb+RlO4pmT0pr+xQGbDL80nvZLAOrDjFaKbJDVA/zmX/8z62ExtNNeY 441N+eNAa2fnd7twBJD2CZx05MTe9WVv3AqLpBcuTQFaye4I6MRoT0gtI1Tnen5x3gGY rOw/Tty69S1aaEorRZR78hnxXDQgpIlti7Ue4Ep5DSqep3GrTKls7+wEildbEX1mT/rt ZLSg6JDtSXtQ9l7rqcVcZJGjDds3tgK6H2eE1BPV0Se1KS6UGDyQGtIFHh6uM+ffdJB1 MxjoGYcNWooWn0DHcw95S3tWIg+1ZGwUYd/ITG5iIiaBUvLwd3qr4+BhpV4NEH2+x1cr qbTA== X-Gm-Message-State: ACrzQf2dyC+oUeu0Sx+j8J2W8VLTgrWqYnT2IULRPFH4zMpHQd7zifM7 prfIaFyAH7jHwwtNp5EWVrsDzXE1HMU= X-Google-Smtp-Source: AMsMyM5VE4JQRbQwdGGTTNmIrv1LAXMhA7TYjHBG8glAVNG+jcxf1QO4ahYfZbMWe/uA4UKKXyP0Yw== X-Received: by 2002:a05:600c:524d:b0:3b4:91ee:933c with SMTP id fc13-20020a05600c524d00b003b491ee933cmr9055810wmb.100.1663852834427; Thu, 22 Sep 2022 06:20:34 -0700 (PDT) Received: from localhost.localdomain ([149.12.10.163]) by smtp.gmail.com with ESMTPSA id j3-20020a05600c300300b003b4868eb6bbsm6710368wmh.23.2022.09.22.06.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 06:20:33 -0700 (PDT) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Sep 2022 14:20:23 +0100 Message-Id: <20220922132023.240086-1-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] ffprobe: Check for invalid matrix error when printing rotation 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 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: av_display_rotation_get will return NAN when the display matrix is invalid, which would end up printing NAN as an integer in the rotation field. This is poor for multiple reasons: * Users of ffprobe have no way of discerning "valid but ugly rotation from display matrix" from "invalid display matrix". * It can have unintended consequences on some platforms, such as Linux x86_64, where NAN is equal to INT64_MIN, which, for example, when printed as JSON, which uses floating point for all numbers, can end up as invalid JSON or wit a number that cannot be reserialized as an integer at all. Since NAN is av_display_rotation_get's error case, just print 0 (no rotation) when that happens. Signed-off-by: Derek Buitenhuis --- I could have also changed av_display_rotation_get to return 0, but I didn't want to make an API change. Arguably, though, returning NAN on error isn't an amazing API to begin with. --- fftools/ffprobe.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 8ee1b1036c..915ed0fb9c 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -2282,8 +2282,11 @@ static void print_pkt_side_data(WriterContext *w, writer_print_section_header(w, id_data); print_str("side_data_type", name ? name : "unknown"); if (sd->type == AV_PKT_DATA_DISPLAYMATRIX && sd->size >= 9*4) { + double rotation = av_display_rotation_get((int32_t *)sd->data); + if (rotation == NAN) + rotation = 0; writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1); - print_int("rotation", av_display_rotation_get((int32_t *)sd->data)); + print_int("rotation", 0); } else if (sd->type == AV_PKT_DATA_STEREO3D) { const AVStereo3D *stereo = (AVStereo3D *)sd->data; print_str("type", av_stereo3d_type_name(stereo->type)); @@ -2639,8 +2642,11 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream, name = av_frame_side_data_name(sd->type); print_str("side_data_type", name ? name : "unknown"); if (sd->type == AV_FRAME_DATA_DISPLAYMATRIX && sd->size >= 9*4) { + double rotation = av_display_rotation_get((int32_t *)sd->data); + if (rotation == NAN) + rotation = 0; writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1); - print_int("rotation", av_display_rotation_get((int32_t *)sd->data)); + print_int("rotation", rotation); } else if (sd->type == AV_FRAME_DATA_AFD && sd->size > 0) { print_int("active_format", *sd->data); } else if (sd->type == AV_FRAME_DATA_GOP_TIMECODE && sd->size >= 8) { -- 2.37.2 _______________________________________________ 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".