From patchwork Sun Sep 25 23:52:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 721 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp1653519vsd; Sun, 25 Sep 2016 17:04:32 -0700 (PDT) X-Received: by 10.194.161.68 with SMTP id xq4mr2492858wjb.135.1474848272714; Sun, 25 Sep 2016 17:04:32 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id jo2si17133486wjc.103.2016.09.25.17.04.32; Sun, 25 Sep 2016 17:04:32 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E15EC689D7B; Mon, 26 Sep 2016 03:04:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A7D1689A50 for ; Mon, 26 Sep 2016 03:04:07 +0300 (EEST) Received: by mail-wm0-f68.google.com with SMTP id w84so11637682wmg.0 for ; Sun, 25 Sep 2016 17:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7pq2GBH1kXeFqCiv7iEVTm7ybYGKg1ireMGsUdEp8h8=; b=UJBDQJrM+/P2EGyCtTTTgPiXgB8cjU9ojagSe/uo+HEefF+mRNqWwsJ1oprswT2fU2 5KsXMbO7xLaDfgTK8H/KDU8EAfldIJRsrIuBMY44CsnXOtuN7cFY19MCNqbZT+FLoj6U SvZygXbeM8is3zBbW754F5b6aXx8aJY94HzfDfLkfZ6+V4vkRA7uCi/L72qEO1X9bS8R o8qJNUFuF1gcRRjU3weJBP9D7gN1dYoUUELz19bm9gVdRA7JNxqubqERIPF6aJ0yFF60 ROUVSYtufVrwbY6VStKXCBxGRg/8kKH7ytf0MMzK76UNeYN+/J6+Nacxo/9wX98M+S70 phVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7pq2GBH1kXeFqCiv7iEVTm7ybYGKg1ireMGsUdEp8h8=; b=CmOedrYZxf8egWZGuT/8mk63R8SdT9VILea2SX/G7FJztSruAiktiPd/jV5rbkRZVT E3OlqY4/ktRXltB9czUGvgCgqCSUOwhwCGm4WFlCLLZC0SQ7WBYunzTQhpMp39y3x+T+ L1K8UdgbGfH9vMWY+otrkPP4T9Lyo89s0EAP6AfrYowZvGCpHEPzl0wYlEG0rQIoStIT ybOu+RCrq2qk5abJPyeha7FKhr81xcSB1rlYiRTCqv+ZiMS2rQGS++Jog3TJcBNNlqQE AoxnultDHnFUgTzJWcgNx8FZ98DS/r/75CCQFwNHITOPNCN0ejyR7xaDFozZIR5vatvv a/1g== X-Gm-Message-State: AE9vXwPVDJn0v07xudiUOrICg6cCLQFyR7Vr/ZQsQ+++k99B9FlOnumXO8RM86DkP0Waqw== X-Received: by 10.194.29.7 with SMTP id f7mr15163173wjh.99.1474847565340; Sun, 25 Sep 2016 16:52:45 -0700 (PDT) Received: from saten.lan (dsl-hkibrasgw4-50df5e-23.dhcp.inet.fi. [80.223.94.23]) by smtp.gmail.com with ESMTPSA id r8sm19264016wjs.22.2016.09.25.16.52.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Sep 2016 16:52:44 -0700 (PDT) From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 26 Sep 2016 02:52:42 +0300 Message-Id: <1474847562-22945-2-git-send-email-jeebjp@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474847562-22945-1-git-send-email-jeebjp@gmail.com> References: <1474847562-22945-1-git-send-email-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] lavf/mxfdec: begin utilizing the newly parsed widths and heights 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" * Updates the width/height sanity check to check all values against INT_MAX. * Correctly utilizes the stored width or height by default, and if sampled or display values are available they are utilized. Signed-off-by: Jan Ekström --- libavformat/mxfdec.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 54fc6fb..f90a85c 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -2061,15 +2061,39 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) if (st->codecpar->codec_id == AV_CODEC_ID_NONE) st->codecpar->codec_id = container_ul->id; - if (descriptor->stored_width > INT_MAX || descriptor->stored_height > INT_MAX) { + if (descriptor->stored_width > INT_MAX || descriptor->stored_height > INT_MAX || + descriptor->sampled_width > INT_MAX || descriptor->sampled_height > INT_MAX || + descriptor->display_width > INT_MAX || descriptor->display_height > INT_MAX) { av_log(mxf->fc, AV_LOG_ERROR, - "One or both of the descriptor's storage width/height values does not fit within an integer! " - "(width=%"PRIu32", height=%"PRIu32")\n", descriptor->stored_width, descriptor->stored_height); + "One or more of the descriptor's storage width/height values does not fit within an integer:\n" + "(stored_width=%"PRIu32", stored_height=%"PRIu32")\n" + "(sampled_width=%"PRIu32", sampled_height=%"PRIu32")\n" + "(display_width=%"PRIu32", display_height=%"PRIu32")\n", + descriptor->stored_width, descriptor->stored_height, + descriptor->sampled_width, descriptor->sampled_height, + descriptor->display_width, descriptor->display_height); ret = AVERROR(AVERROR_PATCHWELCOME); goto fail_and_free; } st->codecpar->width = descriptor->stored_width; st->codecpar->height = descriptor->stored_height; /* Field height, not frame height */ + + /* + Widths and heights get overridden storage->sampled->display. + In case of an unset value the previous value shall be used. + */ + if (descriptor->sampled_width) + st->codecpar->width = descriptor->sampled_width; + + if (descriptor->display_width) + st->codecpar->width = descriptor->display_width; + + if (descriptor->sampled_height) + st->codecpar->height = descriptor->sampled_height; + + if (descriptor->display_height) + st->codecpar->height = descriptor->display_height; + switch (descriptor->frame_layout) { case FullFrame: st->codecpar->field_order = AV_FIELD_PROGRESSIVE;