From patchwork Wed Aug 17 07:25:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Robertson X-Patchwork-Id: 207 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp106115vsd; Wed, 17 Aug 2016 00:43:57 -0700 (PDT) X-Received: by 10.28.230.205 with SMTP id e74mr25623584wmi.42.1471419837662; Wed, 17 Aug 2016 00:43:57 -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 qu8si29098363wjb.96.2016.08.17.00.43.56; Wed, 17 Aug 2016 00:43:57 -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=@strobe-cc.20150623.gappssmtp.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 AD34C689B97; Wed, 17 Aug 2016 10:43:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pa0-f65.google.com (mail-pa0-f65.google.com [209.85.220.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 02814689B86 for ; Wed, 17 Aug 2016 10:43:23 +0300 (EEST) Received: by mail-pa0-f65.google.com with SMTP id ez1so6505813pab.3 for ; Wed, 17 Aug 2016 00:43:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=strobe-cc.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=El+E8E4Ib3enTjFkGg6qgH/0hnazMGC9uGIK4+AXTfU=; b=hw4KkVA4kTFUSaOOI3ImPx68NKR4NFc7MLRM967p2JKGGyzNYURljuYGQgxwRfVMLj Kg/HpuO5+HIinc8lKsGkpRMsUU8qqxpsykGalBXSIZhPtOnnHH3rn2XXH4XrDHENorDB Pj6btVWTSn6xk8zwA8ZamRiO/v/aOdPw71RPjb5aKGxCh6SWSZvltkFu9NGmqVj5lphH 472VA6W6jm4h2EtwnXAvFTO8qRkp0NRD3ZEKW7yW8RPM9ZBbWlPPkDSQcQVsgaCK8uSu 9QaDmZQ1tZ0k0AyXU3KbrP3tsVhnerh2Q5DEOH1t9irV5W7TsnIDgcUSlewTy1MgAARQ 0ZRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=El+E8E4Ib3enTjFkGg6qgH/0hnazMGC9uGIK4+AXTfU=; b=kXVU7pLR/NNXJ30/XMkIn94oo/dTMTvHKRLc68/eAiCG8KWlbAU8LLuvOyQfj2qsjJ j94Sa8utNbXuPvLWuy0uojxQgVRhzs3+z7bIrjySXHhvTrZFXAGSIAme8lsuYuW1fHT3 yPqpUuEUfAjshcIl2NJj/hNox5PFda/n2m9JPQAmJAeAsTGQtgB2DrLuqKQLAGJMFSV3 f0rGvrAFouJtzHTHe+vGTbL+FFqMhAT6nGaEtG+vGFBGN97J6EUl4ZXPIuHHuzR4uTDJ vct+zjlhz9RYEiszbuua2EopPfe0jOuUve63xyNFvUMF1aStGSz+zYh5Q2jKcQgjrh4q OMEA== X-Gm-Message-State: AEkoous9VNbSr4AqTF+QPa0zd65gi40xkQj1xRr8KBG7uzJOI4agP3u+vC03wNa2YBcfHQ== X-Received: by 10.66.137.107 with SMTP id qh11mr71535334pab.49.1471418766362; Wed, 17 Aug 2016 00:26:06 -0700 (PDT) Received: from localhost.localdomain (199-83-222-145.PUBLIC.monkeybrains.net. [199.83.222.145]) by smtp.gmail.com with ESMTPSA id f3sm44418962pff.26.2016.08.17.00.26.05 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 17 Aug 2016 00:26:05 -0700 (PDT) From: Steven Robertson To: ffmpeg-devel@ffmpeg.org Date: Wed, 17 Aug 2016 00:25:47 -0700 Message-Id: <1471418747-69153-1-git-send-email-steven@strobe.cc> X-Mailer: git-send-email 2.8.0.rc2 Subject: [FFmpeg-devel] [PATCH] libavformat/mov: Accept known codepoints in 'colr' 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: Steven Robertson MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This change relaxes the whitelist on reading color metadata in MOV/BMFF containers. The whitelist on writing values is still in place. As a consequence it also fixes an apparent bug in reading 'nclc' values. The 'nclc' spec [1] is in harmony with ISO 23001-8 for the values it lists, but the code getting removed was remapping 5->6 and 6->7 for primaries, which is incorrect, and was remapping 6->5 for color matrix ("colorspace" in the code), which is equivalent but an unnecessary inconsistency. This logic error doesn't appear in movenc. Removing the whitelist allows proper conversion when the source codec relies on the container for proper signaling of newer codepoints, such as DNxHR and VP9. If converting to a codec or container that has updated its spec to include the new codepoints, the metadata will be preserved. If going back to MOV/BMFF, the output whitelist will still kick in, so this won't result in out-of-spec files being created. [1] https://developer.apple.com/library/mac/technotes/tn2162/_index.html Signed-off-by: Steven Robertson --- libavformat/mov.c | 40 +++++++++------------------------------- 1 file changed, 9 insertions(+), 31 deletions(-) -- 2.8.0.rc2 diff --git a/libavformat/mov.c b/libavformat/mov.c index 7c8f784..6450d52 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1324,38 +1324,16 @@ static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom) st->codecpar->color_range = AVCOL_RANGE_JPEG; else st->codecpar->color_range = AVCOL_RANGE_MPEG; - /* 14496-12 references JPEG XR specs (rather than the more complete - * 23001-8) so some adjusting is required */ - if (color_primaries >= AVCOL_PRI_FILM) - color_primaries = AVCOL_PRI_UNSPECIFIED; - if ((color_trc >= AVCOL_TRC_LINEAR && - color_trc <= AVCOL_TRC_LOG_SQRT) || - color_trc >= AVCOL_TRC_BT2020_10) - color_trc = AVCOL_TRC_UNSPECIFIED; - if (color_matrix >= AVCOL_SPC_BT2020_NCL) - color_matrix = AVCOL_SPC_UNSPECIFIED; - st->codecpar->color_primaries = color_primaries; - st->codecpar->color_trc = color_trc; - st->codecpar->color_space = color_matrix; - } else if (!strncmp(color_parameter_type, "nclc", 4)) { - /* color primaries, Table 4-4 */ - switch (color_primaries) { - case 1: st->codecpar->color_primaries = AVCOL_PRI_BT709; break; - case 5: st->codecpar->color_primaries = AVCOL_PRI_SMPTE170M; break; - case 6: st->codecpar->color_primaries = AVCOL_PRI_SMPTE240M; break; - } - /* color transfer, Table 4-5 */ - switch (color_trc) { - case 1: st->codecpar->color_trc = AVCOL_TRC_BT709; break; - case 7: st->codecpar->color_trc = AVCOL_TRC_SMPTE240M; break; - } - /* color matrix, Table 4-6 */ - switch (color_matrix) { - case 1: st->codecpar->color_space = AVCOL_SPC_BT709; break; - case 6: st->codecpar->color_space = AVCOL_SPC_BT470BG; break; - case 7: st->codecpar->color_space = AVCOL_SPC_SMPTE240M; break; - } } + if (color_primaries >= AVCOL_PRI_NB) + color_primaries = AVCOL_PRI_UNSPECIFIED; + if (color_trc >= AVCOL_TRC_NB) + color_trc = AVCOL_TRC_UNSPECIFIED; + if (color_matrix >= AVCOL_SPC_NB) + color_matrix = AVCOL_SPC_UNSPECIFIED; + st->codecpar->color_primaries = color_primaries; + st->codecpar->color_trc = color_trc; + st->codecpar->color_space = color_matrix; av_log(c->fc, AV_LOG_TRACE, "\n"); return 0;