From patchwork Sat Aug 12 16:47:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Rice X-Patchwork-Id: 4699 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.46.211 with SMTP id u202csp2284946vsu; Sat, 12 Aug 2017 09:48:06 -0700 (PDT) X-Received: by 10.28.92.143 with SMTP id q137mr1325145wmb.167.1502556486635; Sat, 12 Aug 2017 09:48:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502556486; cv=none; d=google.com; s=arc-20160816; b=EKrDxYYJp5JkKL+coLhTSUmMXcBrjFqCC1H9ClAg+I20wosZmItdN24a3aJ38llNXm h3OIMVwrVqrM+1ra8qYxfPioZX6dYydYKFpwEx5esvBs57xY4+5cB+z6mcK+JcHDwIM4 76DN/qTU90NduzInfNKUaILOWlyqIzNxWlvSuUbUu17J1ifcMqObYr1WI3g9kxsjlgzt bU1m436t/ZtLNROpsnxaEFg77TsLPxNBBJShUnqMi3xLEiAvNdOdH792lP8W/0PmHQen x9FclxmMVLoTKwmnCz/2tC1/w+lmN9Eh09vaNLmlAuBMXwkdhoEyE6lSYszY3a00PDcz vNeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:to:date:message-id:mime-version:from :delivered-to:arc-authentication-results; bh=pnNLeRvYi2eDEKJUV5dmW0klZ75r/bM1qzIDpaldp1E=; b=O/v7DBSDw4zZY30qij+MAW3lV99tlK3XcVyRQPT1D1M+a9LxkKVxZx4Ih61DZyXjkx GuGFt2SGXt1ceNNSoZiu6EbctWW6kiTc1LoGLpm5d6OZEFhoe7N1w4GQbY4ZJoVjjPAy bgFKRe0u9mIPoyCscRGLTcVA4KJZ+HrUZknWegmfqMV2FUCStplp3RGuXcZcPxm5kaFO qXMOt7uH/Athx8DdZzmrWpN+YfBdnsGQu/fxYuI+Lt3BcYBCRFLMAa70efes1hhJiSaX gpRUbkTxDAp0RLicqSSVSIjkuhPomqMIaWApDjPk70M7FbCRuZx0YT/vnc4GRaDNcAAS XsuQ== 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r3si1201168wme.259.2017.08.12.09.48.05; Sat, 12 Aug 2017 09:48:06 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 090FE689811; Sat, 12 Aug 2017 19:47:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from server172-2.web-hosting.com (server172-2.web-hosting.com [68.65.122.110]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AF1B06883D5 for ; Sat, 12 Aug 2017 19:47:52 +0300 (EEST) Received: from cpe-104-162-94-162.nyc.res.rr.com ([104.162.94.162]:36977 helo=[10.0.1.3]) by server172.web-hosting.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dgZZo-0006Ii-3P for ffmpeg-devel@ffmpeg.org; Sat, 12 Aug 2017 12:47:53 -0400 From: Dave Rice Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Message-Id: Date: Sat, 12 Aug 2017 12:47:49 -0400 To: FFmpeg development discussions and patches X-Mailer: Apple Mail (2.3273) X-OutGoing-Spam-Status: No, score=-2.9 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server172.web-hosting.com X-AntiAbuse: Original Domain - ffmpeg.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - dericed.com X-Get-Message-Sender-Via: server172.web-hosting.com: authenticated_id: dave@dericed.com X-Authenticated-Sender: server172.web-hosting.com: dave@dericed.com X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched Subject: [FFmpeg-devel] [PATCH] libavcodec: fix field_order labelling 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" Hello all, This issue originated in this thread https://github.com/amiaopensource/vrecord/issues/170. On Field Order, in the QuickTime specification at https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html (and similarly in the Matroska specification which adopted similar language) it states the following meanings for field order values: > 9 – B is displayed earliest, T is stored first in the file. 14 – T is displayed earliest, B is stored first in the file. This definition is contradicted by other Apple documentation such as https://developer.apple.com/library/content/technotes/tn2162/_index.html#//apple_ref/doc/uid/DTS40013070-CH1-TNTAG10-THE__FIEL__IMAGEDESCRIPTION_EXTENSION__FIELD_FRAME_INFORMATION. An Apple engineer confirmed that the QuickTime specification’s definitions for those Field Order values is wrong and does not match Apple’s (of FFmpeg’s) practice, see https://github.com/amiaopensource/vrecord/issues/170#issuecomment-321937668. However I think that some of the commenting in ffmpeg is based upon the inaccurate definitions from Apple. For instance, in that thread David Singer confirms: > Ah, not quite. 1 and 6 are indeed 'planar' (all of one field before all of the other). They don't concern us. Both 9 and 14 are stored in spatial order (i.e. you could do terrible de-interlacing by simply displaying the buffer as a frame), and the 9 or 14 value tells you which field is to be displayed first. > > 9 – T is earlier than B. 14 – B is earlier than T mov.c associates AV_FIELD_TB with 9 and AV_FIELD_BT with 14 (similar associations in matroska.h), but avcodec.h states: > AV_FIELD_TB, //< Top coded first, bottom displayed first > AV_FIELD_BT, //< Bottom coded first, bottom displayed first IMHO in both cases of AV_FIELD_TB and AV_FIELD_BT the coding should be referred as interleaved rather than ‘bottom coded first’ or ‘top coded first’. In the case of AV_FIELD_TT and AV_FIELD_BB the fields are stored as planar images where storage order is notable, but with TB and BT the fields are interleaved. Also utils.c associates these field order values with the following labels: > AV_FIELD_TB -> "top coded first (swapped)"; > AV_FIELD_BT -> "bottom coded first (swapped)"; From my reading, I infer that "top coded first (swapped)” means "top coded first, bottom displayed first”; however in practice from files generated by QuickTime and FFmpeg files with a value of TB have the top field displayed first, so I think the labels are swapped. In the patch below I suggest using “top first (interleaved)” for TB and “bottom first (interleaved)” for BT. Comments? From de871b3fa891fa0ae6856461c1f8305cc889cde7 Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Sat, 12 Aug 2017 12:30:43 -0400 Subject: [PATCH] libavcodec: fix field_order labelling --- libavcodec/avcodec.h | 4 ++-- libavcodec/utils.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index c594993766..37c39072b3 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1726,8 +1726,8 @@ enum AVFieldOrder { AV_FIELD_PROGRESSIVE, AV_FIELD_TT, //< Top coded_first, top displayed first AV_FIELD_BB, //< Bottom coded first, bottom displayed first - AV_FIELD_TB, //< Top coded first, bottom displayed first - AV_FIELD_BT, //< Bottom coded first, top displayed first + AV_FIELD_TB, //< Interleaved coding, top displayed first + AV_FIELD_BT, //< Interleaved coding, bottom displayed first }; /** diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 1336e921c9..926c964846 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1406,9 +1406,9 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) else if (enc->field_order == AV_FIELD_BB) field_order = "bottom first"; else if (enc->field_order == AV_FIELD_TB) - field_order = "top coded first (swapped)"; + field_order = "top first (interleaved)"; else if (enc->field_order == AV_FIELD_BT) - field_order = "bottom coded first (swapped)"; + field_order = "bottom first (interleaved)"; av_strlcatf(detail, sizeof(detail), "%s, ", field_order); }