From patchwork Sat Jan 14 15:48:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Martinez X-Patchwork-Id: 40000 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bb05:b0:b6:a58c:cef with SMTP id fc5csp444040pzb; Sat, 14 Jan 2023 07:48:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXuSUE9JkA2lBu3upTb0Pp+gumHyluh8JbBctcX8kZxcptt5YfGX/8I86j8dOuMtuiQDxWsm X-Received: by 2002:a17:906:5289:b0:82b:61db:92b8 with SMTP id c9-20020a170906528900b0082b61db92b8mr65218423ejm.57.1673711309931; Sat, 14 Jan 2023 07:48:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673711309; cv=none; d=google.com; s=arc-20160816; b=rkFT4fPNZeNYLN685G6lWoAF2vksB/wg4KIiuw7AWPfi7rcTaFo1KhRRfd8CCFZVbw HF2QeQHUk5oW++raLotSfr0jzjcpKOA+ZZitKzMFJV0NNvjU2oL23xLh8O5M2O9njbgM R9Q/bfEKS8MyWutjKtYmKtOU6LqmWdhsSxYlhNw3tJLtKLf1iXlaDboQx19cTda7Ci+O 5ggjm46RkZnIMuiQkKbLNIODFR7wUe3C8EBVgqd6JNTrN6qj7ZKpD9XTW8yPWfWFAc02 jv8+MV7KWReUKU00II5qGdZcQSvR43lpX7fpOZR4s3xmQC1uQfvXp3nRVd4bDPoWVGEw qc4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to:from :content-language:user-agent:mime-version:date:message-id :delivered-to; bh=fU2jTxa7rQ1NBMiY9Wb21YCIZ5gZRinx4lSpFfvpUGo=; b=z36mCbAycgOw6f4UfA2UsNC84nwxDLVj8JFMyU1Cp0I0C3xdM3RF6+LatUuyLCQoX2 /EnrMHFLRkTbb1eKJHRs64e/XFQnLnQuDqRanHxlAZudhGFF80G5RGgeupTJ+mkYmFmJ ZAHxX1OnqFszyxi88HSfMHRDRaxoK4sh6NL2qPx6OD9JVDF1XyYMtN0ZhTqr+TxneehG r+WHzSjoaEKXnasaeiplkdCtNqG8N7NwmRea3p6S+ahJcCeKqT6e8zWoGnmH1DIGCB7M JnCFPBAgPeL3hw4ThHOEOmpU9VzXS0t+w9hM46wWCFMtLittWkAzRHOztHNOea5x38VR Rjtg== ARC-Authentication-Results: i=1; mx.google.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 sp=NONE dis=NONE) header.from=mediaarea.net Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q13-20020a170906770d00b0084b9ac8f893si17895123ejm.976.2023.01.14.07.48.21; Sat, 14 Jan 2023 07:48:29 -0800 (PST) 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; 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 sp=NONE dis=NONE) header.from=mediaarea.net Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0AF4A68B929; Sat, 14 Jan 2023 17:48:19 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from 1.mo560.mail-out.ovh.net (1.mo560.mail-out.ovh.net [46.105.63.121]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AE70A6898F6 for ; Sat, 14 Jan 2023 17:48:12 +0200 (EET) Received: from director8.ghost.mail-out.ovh.net (unknown [10.108.4.60]) by mo560.mail-out.ovh.net (Postfix) with ESMTP id BF21D22B5B for ; Sat, 14 Jan 2023 15:48:11 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-vcj6j (unknown [10.110.115.159]) by director8.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 7E1D91FED9 for ; Sat, 14 Jan 2023 15:48:11 +0000 (UTC) Received: from mediaarea.net ([37.59.142.99]) by ghost-submission-6684bf9d7b-vcj6j with ESMTPSA id SKaxGLvOwmM6zh8AanWh3Q (envelope-from ) for ; Sat, 14 Jan 2023 15:48:11 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-99G003909b1fe1-7f1e-415d-9b28-e7f20c46874f, 531310C571D3E7C8BE5E63E303B7EE8DB87128E6) smtp.auth=jerome@mediaarea.net X-OVh-ClientIp: 84.143.156.21 Message-ID: <0af7e930-9ec7-dc81-95bc-939eb21e2da0@mediaarea.net> Date: Sat, 14 Jan 2023 16:48:10 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US From: Jerome Martinez To: FFmpeg development discussions and patches X-Ovh-Tracer-Id: 14896500194274412793 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedruddttddgkedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurheptgfkffggfgfhuffvsehmtderredtfeejnecuhfhrohhmpeflvghrohhmvgcuofgrrhhtihhnvgiiuceojhgvrhhomhgvsehmvgguihgrrghrvggrrdhnvghtqeenucggtffrrghtthgvrhhnpeduueffudefudejueeggfdthedtteefiedvudeluedtgeeftdefuefgleegheehveenucfkphepuddvjedrtddrtddruddpfeejrdehledrudegvddrleelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeojhgvrhhomhgvsehmvgguihgrrghrvggrrdhnvghtqedpnhgspghrtghpthhtohepuddprhgtphhtthhopehffhhmphgvghdquggvvhgvlhesfhhfmhhpvghgrdhorhhgpdfovfetjfhoshhtpehmohehiedtpdhmohguvgepshhmthhpohhuth Subject: [FFmpeg-devel] avformat/mxfenc: fix stored/sampled/displayed width/height 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: wJXPstfynKku Before the patch: - stored values were rounded to upper 16 multiple also for formats not using macroblocks (should be st->codecpar->width and st->codecpar->height when not MPEG formats; note that I found no other muxer doing the rounding for AVC, only for MPEG-2 Video, but I find no reason in specs for doing the difference so I kept the rounding for AVC) - sampled and displayed widths were stored width (should be st->codecpar->width like it is already done for height, with the DV50/100 exception) Could be tested with e.g. - fixed stored width (1912 instead of 1920) and height (1080 instead of 1088) not multiple of 16 : ffmpeg -f lavfi -i testsrc=duration=1:size=1912x1080 -c:v jpeg2000 test_prores.mxf - fixed sampled/displayed width (1912 instead of 1920): ffmpeg -f lavfi -i testsrc=duration=1:size=1912x1080 -c:v mpeg2video test_mpeg2video.mxf From cda353059886182aab2e258023c4d027c448344b Mon Sep 17 00:00:00 2001 From: Jerome Martinez Date: Sat, 14 Jan 2023 13:32:36 +0100 Subject: [PATCH] avformat/mxfenc: fix stored/sampled/displayed width/height Stored values are rounded to upper 16 multiple only for MPEG related formats Sampled and displayed widths are codecpar ones (with DV exception) --- libavformat/mxfenc.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 58c551c83c..0b7e83ba4d 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1109,8 +1109,9 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID { MXFStreamContext *sc = st->priv_data; AVIOContext *pb = s->pb; - int stored_width = 0; - int stored_height = (st->codecpar->height+15)/16*16; + int stored_width = st->codecpar->width; + int stored_height = st->codecpar->height; + int display_width; int display_height; int f1, f2; const MXFCodecUL *color_primaries_ul; @@ -1129,12 +1130,25 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID else if (st->codecpar->height == 720) stored_width = 1280; } - if (!stored_width) - stored_width = (st->codecpar->width+15)/16*16; + display_width = stored_width; + switch (st->codecpar->codec_id) { + case AV_CODEC_ID_MPEG2VIDEO: + case AV_CODEC_ID_DVVIDEO: + case AV_CODEC_ID_H264: + //Based on 16x16 macroblocks + stored_width = (stored_width+15)/16*16; + stored_height = (stored_height+15)/16*16; + break; + default: + break; + } + + //Stored width mxf_write_local_tag(s, 4, 0x3203); avio_wb32(pb, stored_width); + //Stored height mxf_write_local_tag(s, 4, 0x3202); avio_wb32(pb, stored_height>>sc->interlaced); @@ -1154,7 +1168,7 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID //Sampled width mxf_write_local_tag(s, 4, 0x3205); - avio_wb32(pb, stored_width); + avio_wb32(pb, display_width); //Samples height mxf_write_local_tag(s, 4, 0x3204); @@ -1168,8 +1182,9 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID mxf_write_local_tag(s, 4, 0x3207); avio_wb32(pb, 0); + //Display width mxf_write_local_tag(s, 4, 0x3209); - avio_wb32(pb, stored_width); + avio_wb32(pb, display_width); if (st->codecpar->height == 608) // PAL + VBI display_height = 576; @@ -1178,6 +1193,7 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID else display_height = st->codecpar->height; + //Display height mxf_write_local_tag(s, 4, 0x3208); avio_wb32(pb, display_height>>sc->interlaced);