From patchwork Wed Nov 29 00:49:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Robertson X-Patchwork-Id: 6431 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp3876165jah; Tue, 28 Nov 2017 16:56:17 -0800 (PST) X-Google-Smtp-Source: AGs4zMap0pNyipHZnIA1nl8YHtYvDKuu+THkHg6OLEZYjMj2K0iCbdFqHXIT9a9EfxW3fs9flsG9 X-Received: by 10.28.213.143 with SMTP id m137mr956367wmg.67.1511916977834; Tue, 28 Nov 2017 16:56:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511916977; cv=none; d=google.com; s=arc-20160816; b=SqLBGy+GvxFhsGlVskv/kKulMw10rKTdOoje+VgcILfqtAdAMdGBZTAiWBgu8mriDj 3Se/KhWsGKF4OVNvG6Ud4CztrLpxpet6oc6D2EHjPg8iEUx1k8d2gLkGtHSyVdp2E2+8 cQSIIzOuoa3W+3NrQ8Fikc0c7ZDp0igSHm+tqqp4JngVHktw13kcAIAPlHN+5RExLZf6 sK7S1gRTYLf543Kz46seFNmzFsvqMyBg0HCOymoSS5UxaCf2IamyylVbucoCevOlFC9e b5nbIZMuFCBI7hJesbkCtW19PqSNETMf9fquM+sGIYuALMxkSDIA+Tzw4fBVA2TF+hZM KvXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=f+5KTt1+87+vLggsOfI82D11uvAo3ABy4PEstmLGWUM=; b=sW6Q5oDZtgtPeAg0H2/P4XJmcb5FnhldWG3KKU1GajMnP63fyy0vZ1m1dMkFH1UAOC KH6Ht9VdtTIbNikKWrSZsMta1OlL8UzT+qQmSaid5CMzIADxZeYKEQ3sNMqkTA7H4W9C XtOja8+caGtsVajGnEAYcHZECY5eX1DHBS/MW3ZM1P1BQeKRT7JOhTWoWvfW0O6oh7df 5J19KhopEnLXwJcFh+dGcTYSOAcWkm2r09lXUHydh/9i00iMY/a7P7GfjmSBHzaHc2o5 bwT9pvpQ1sTa6Uya4Y7Hlc862IO1NwzVpb5vWhgeftSamdpt8ryAiMT5+GZMy1KsoFn+ 3YYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@strobe-cc.20150623.gappssmtp.com header.s=20150623 header.b=B3UscgcD; 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 r15si288616wrg.494.2017.11.28.16.56.17; Tue, 28 Nov 2017 16:56:17 -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; dkim=neutral (body hash did not verify) header.i=@strobe-cc.20150623.gappssmtp.com header.s=20150623 header.b=B3UscgcD; 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 0FBDD68A0D3; Wed, 29 Nov 2017 02:56:14 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io0-f181.google.com (mail-io0-f181.google.com [209.85.223.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 057F9689982 for ; Wed, 29 Nov 2017 02:56:07 +0200 (EET) Received: by mail-io0-f181.google.com with SMTP id g1so1926744ioc.8 for ; Tue, 28 Nov 2017 16:56:09 -0800 (PST) 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=k1elaG6Q+0W4Ioc3J+jq6Uwa0uWdTsWOC+YuC0mpClE=; b=B3UscgcDzgwNhtGtR6K7yuO02tzYo6YZ8WIUf3OiZB+/DE97a42cYwHLM8PktvO84r 3vKTxPisv2AU3RLWC4bNfjF+GA07jkdMOBtAQN+3FiFfYMs+7OoudCpOdMJgz/YijlQT uWzUZx2AHxKJnyTDcdcND0F7tXiupsH2bSfJOHaWtoWGAaV62cZlG6tf7ejMZLLe1L0U Dm5qGu5lMuvNLuiXO+E5wIXqRK+9ICxVgPEIbVo4QY5UhgaihnA9ccOwqzT70pNNaJS5 hx1c3W5DzT6a9xjgpBGvdXcJi0sGsiQ9zYsdLXOYaV62sY4f881ySkfKDe90Cmx8M5MF peKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=k1elaG6Q+0W4Ioc3J+jq6Uwa0uWdTsWOC+YuC0mpClE=; b=WRfHrKT64oXZ1rDK6tPlZk5kOR3T07bkxnui6ZKpjVsyefEqVyDgQO/ICujL42DMTh qWTfhiXvOAxW3zQt13n1uXPxlP83NGz0wy+NrmzbjV6se7Sq81QUFjAdEjkQWdNNzIc9 k42JjUEf2B70g/mMhAN6sTpqzvLjwZbSsMo4AlZZNpI9Pa5D9XODftjwfUy6qV2jUEQ0 rsTUSzoptHEeTkMzZ8H9o0Neg6JUo/AEpks/lkLAYlDuN2DbXNh4ZXoHwn8cHThQOMRq /uSjFve9qOUoyFyyXphYUD8rLNeKhbtHMB1dMhbk6vqgd1DrQiyXyWLcgsYtNcemqARN Q11A== X-Gm-Message-State: AJaThX7y8qKCepQZTvx5TQ9dXSscDWiAPS/Ew4AfjnFCqf88xRUbRjjk yku52Vxd7+dgW8iXWLo6htQ0FcqWWZA= X-Received: by 10.107.88.7 with SMTP id m7mr1382792iob.65.1511916592247; Tue, 28 Nov 2017 16:49:52 -0800 (PST) Received: from donner.sbo.corp.google.com ([2620:0:1006:1:b5fa:2fa0:9a43:a02f]) by smtp.gmail.com with ESMTPSA id w6sm435154itc.5.2017.11.28.16.49.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Nov 2017 16:49:51 -0800 (PST) From: Steven Robertson To: ffmpeg-devel@ffmpeg.org Date: Tue, 28 Nov 2017 16:49:46 -0800 Message-Id: <20171129004946.28211-1-steven@strobe.cc> X-Mailer: git-send-email 2.15.0.417.g466bffb3ac-goog Subject: [FFmpeg-devel] [PATCH] avcodec/dnxhddec: Do not overwrite colorspace if the container has set it. 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" The existing logic overrides container metadata even in cases where the container metadata must be trusted (e.g. HDR). The original spec had no provision for specifying color volume, so many files rely on the assumption of Rec. 709. An update to the spec included a 'clv' field for explicitly signaling that the container should be trusted in an existing bitfield in the frame header, but the default of 0 from old encoders forces Rec. 709, which would break any HDR stream. Because there is no place in DNxHR for specifying a transfer function, DNxHR HDR files must include container-level color information. This patch maintains the existing behavior of choosing the 709 over the 601 matrix when container-level information is missing, and allows container-level information to win if present. Signed-off-by: Steven Robertson --- libavcodec/dnxhddec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index f46e41a456..6f8c716412 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -93,7 +93,9 @@ static av_cold int dnxhd_decode_init(AVCodecContext *avctx) ctx->avctx = avctx; ctx->cid = -1; - avctx->colorspace = AVCOL_SPC_BT709; + if (avctx->colorspace == AVCOL_SPC_UNSPECIFIED) { + avctx->colorspace = AVCOL_SPC_BT709; + } avctx->coded_width = FFALIGN(avctx->width, 16); avctx->coded_height = FFALIGN(avctx->height, 16);