From patchwork Sun Oct 30 07:07:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vittorio Giovara X-Patchwork-Id: 1230 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.133 with SMTP id o127csp1810251vsd; Sun, 30 Oct 2016 00:25:21 -0700 (PDT) X-Received: by 10.195.17.165 with SMTP id gf5mr17264953wjd.114.1477812321303; Sun, 30 Oct 2016 00:25:21 -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 z13si18449224wmz.143.2016.10.30.00.25.20; Sun, 30 Oct 2016 00:25:21 -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 6C721689A5C; Sun, 30 Oct 2016 09:25:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f195.google.com (mail-qk0-f195.google.com [209.85.220.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 634D1680CA2 for ; Sun, 30 Oct 2016 09:25:09 +0200 (EET) Received: by mail-qk0-f195.google.com with SMTP id o68so4807354qkf.1 for ; Sun, 30 Oct 2016 00:25:12 -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; bh=at8I00YmntsVbxjggtDb+MMDDI/Nqf4lQdf3VCj4m1k=; b=dHo8bHzSIFN4FS5AskC1wnnKXLpbxRQ0WYSUI0MEYm6+jDiN+8sqM7JiRpObU0CyOc uNcgnMZLOzy2XukuDxY6+k0XegkgHQ1u9eVZlpPr6Psw8NuNB68jawj25gNkDGAyItoT Fl1pDCUetVeIpplLjUdUcYy97Tq/+kDy58Wv5j7m3Nt/7QdHn2ZXE7jDgdZYAtYwW2hL wxIPLzKPOt706LXHZ7swOP3O7rXwm2LZi6oI/2zGegK3+9DKR290FWb/kjgBPsc8H8ix M+dCf2TNL7h1OKizljh5Ea+p3ERMkum0ceqq6G5h5CYqMsJW7NVh600ELh+MHVuraNMu I/AQ== 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; bh=at8I00YmntsVbxjggtDb+MMDDI/Nqf4lQdf3VCj4m1k=; b=Hraq9MB2AmygVTEA192Hi7F/xp0wmSy04oQGHYjdYx9rPxXutysYPL43ettZWhmLLC tAP1/H7D5PUYLr4M76/A4vDnvsstV1qaYVUyyIkXxNlMNEagXgevhDfrE0gzU8ASMATK 9fwA7wGkD+z8895mkzhjAlpQm5Gu0d13QF8BTv1MC4EAjHOAq8S8VzHtllWzsCG9zrhc 5fw9K8LEYJFbabNAwkmotyC6yx2Qpf2JQq0/3bBByrBT+NudbrGCJTINNFBTlXqmoRoF uMIgfioNovsMI3vPP1hEfCbI0HlZR3InOQQFWDl9uRoHZDTqvH2Uhr4wrSxVm9djOX4P 73DA== X-Gm-Message-State: ABUngvcgycMx3ML/ZdaFD0yaW8IRNQq6wvEJO/SlGJm5oYrHHsGMxOq7LVf+FezjbB2oUQ== X-Received: by 10.55.96.194 with SMTP id u185mr12682382qkb.140.1477811269132; Sun, 30 Oct 2016 00:07:49 -0700 (PDT) Received: from vimacbookpro.vimeows.com (cpe-24-193-79-62.nyc.res.rr.com. [24.193.79.62]) by smtp.gmail.com with ESMTPSA id d127sm10467457qkf.24.2016.10.30.00.07.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 30 Oct 2016 00:07:48 -0700 (PDT) From: Vittorio Giovara To: ffmpeg-devel@ffmpeg.org Date: Sun, 30 Oct 2016 03:07:45 -0400 Message-Id: <20161030070746.37115-2-vittorio.giovara@gmail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161030070746.37115-1-vittorio.giovara@gmail.com> References: <20161030070746.37115-1-vittorio.giovara@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/3] vf_colorspace: Add support for ycgco color space 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Vittorio Giovara --- This is a little hackish, not sure how to represent the matrix otherwise. Please CC. Vittorio libavfilter/vf_colorspace.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c index d26f658..7e0bafa 100644 --- a/libavfilter/vf_colorspace.c +++ b/libavfilter/vf_colorspace.c @@ -175,6 +175,13 @@ typedef struct ColorSpaceContext { // FIXME dithering if bitdepth goes down? // FIXME bitexact for fate integration? +static const double ycgco_matrix[3][3] = +{ + { 0.25, 0.5, 0.25 }, + { -0.25, 0.5, -0.25 }, + { 0.5, 0, -0.5 }, +}; + /* * All constants explained in e.g. https://linuxtv.org/downloads/v4l-dvb-apis/ch02s06.html * The older ones (bt470bg/m) are also explained in their respective ITU docs @@ -187,6 +194,7 @@ static const struct LumaCoefficients luma_coefficients[AVCOL_SPC_NB] = { [AVCOL_SPC_SMPTE170M] = { 0.299, 0.587, 0.114 }, [AVCOL_SPC_BT709] = { 0.2126, 0.7152, 0.0722 }, [AVCOL_SPC_SMPTE240M] = { 0.212, 0.701, 0.087 }, + [AVCOL_SPC_YCOCG] = { 0.25, 0.5, 0.25 }, [AVCOL_SPC_BT2020_NCL] = { 0.2627, 0.6780, 0.0593 }, [AVCOL_SPC_BT2020_CL] = { 0.2627, 0.6780, 0.0593 }, }; @@ -209,6 +217,12 @@ static void fill_rgb2yuv_table(const struct LumaCoefficients *coeffs, { double bscale, rscale; + // special ycgco matrix + if (coeffs->cr == 0.25 && coeffs->cg == 0.5 && coeffs->cb == 0.25) { + memcpy(rgb2yuv, ycgco_matrix, sizeof(double) * 9); + return; + } + rgb2yuv[0][0] = coeffs->cr; rgb2yuv[0][1] = coeffs->cg; rgb2yuv[0][2] = coeffs->cb; @@ -1047,6 +1061,7 @@ static const AVOption colorspace_options[] = { ENUM("bt470bg", AVCOL_SPC_BT470BG, "csp"), ENUM("smpte170m", AVCOL_SPC_SMPTE170M, "csp"), ENUM("smpte240m", AVCOL_SPC_SMPTE240M, "csp"), + ENUM("ycgco", AVCOL_SPC_YCGCO, "csp"), ENUM("bt2020ncl", AVCOL_SPC_BT2020_NCL, "csp"), { "range", "Output color range",