From patchwork Wed Oct 30 01:22:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 16025 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 60E4E44A27C for ; Wed, 30 Oct 2019 03:30:05 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4C98668B05C; Wed, 30 Oct 2019 03:30:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CF28768B028 for ; Wed, 30 Oct 2019 03:29:58 +0200 (EET) Received: by mail-pg1-f194.google.com with SMTP id f19so294784pgn.13 for ; Tue, 29 Oct 2019 18:29:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kt++6V+FI8jx9IJXXa7i13xK004udpleuxXO6JxR5bI=; b=h40hwZMHLimaLvmgAkqgEkNHjq7jXneYxYkRuby26AZi+C4FaxKXSdKS7kXQpsrN4z OYkNgNm2iTTRPhTn6zyLG1hbIuxQ6Y/ql5NeEpjX4+8eSEc+PZhcq7w3z4HRpg1CBBLi mFNU+Kgd0DDHbyb4DoZfjzqlPqFEA+QsOJ2YnZCF/DRg/bXw2ho9kg788qH82i0ugjRA QVJyBRUB6+NXMzuk4R3tV9AcFA4jPI6d4H16h0OdVPkQ6ftJJ3NTzoRI/MqEN8JkR0Ku Pu62+XgQKCeX6YGducaunAQxCcmOfE0L1uCFJ1vQ6tu+IOq9cq9XQ0sKLNIK3kfujSFc HfsA== 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:in-reply-to :references; bh=kt++6V+FI8jx9IJXXa7i13xK004udpleuxXO6JxR5bI=; b=dxCcBrNk6VG3kTWMHSm8H5epPoXYBteeDCFQGEETuVLcYDwD6iKWMMmJS8ajCEV3n3 zvx580Z2HF5J8gOdYp0PPfL3yUf3HP/pplD1YTr9CQApJzKZA1jGGWLrp+GQ+1TEfl5N 74uvtfzvAeZ4ov5Qr1ByerYUfAjG/rdQxN383WdxMYsGRAL1GvG5XnPsgTN0oslg+QQq g4+1GE+RRRf97aji3F9ncHoqT6qUQbc+AKEnhYp0dgh9Isw6h5tgbrT9S04LKtj1K2Z2 9l0d+UiPtdt1WJv3v5ISaOBX18fJXJCWRH2KYg1IdGtO63Mw34ftmNEqhneN8+bsox2V qmxw== X-Gm-Message-State: APjAAAUiiXZGTDNCiUiOBLKMoDtrSYFm/wZO4fJxEbZNjuPPf0+rM3Zd GJPVBX0xUy7TJ65XW+17qq7/Ye+ZPKg= X-Google-Smtp-Source: APXvYqyGZ6sdy1gtq3IocDB08EhCOxZpdsPPYC2dV/ZwoSnLwW1RD60gvu3xZcimjkayg851DCHgFw== X-Received: by 2002:a17:90a:23e2:: with SMTP id g89mr10108146pje.127.1572398598341; Tue, 29 Oct 2019 18:23:18 -0700 (PDT) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id j126sm340924pfb.186.2019.10.29.18.23.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Oct 2019 18:23:17 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 30 Oct 2019 09:22:54 +0800 Message-Id: <20191030012254.21976-3-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20191030012254.21976-1-lance.lmwang@gmail.com> References: <20191030012254.21976-1-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v1 3/3] avfilter/vf_lut: simplify code 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavfilter/vf_lut.c | 60 ++++++++------------------------------------ 1 file changed, 11 insertions(+), 49 deletions(-) diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c index 1fdc5e1812..3aed4ccc2c 100644 --- a/libavfilter/vf_lut.c +++ b/libavfilter/vf_lut.c @@ -220,6 +220,10 @@ static int config_props(AVFilterLink *inlink) int min[4], max[4]; int val, color, ret; + s->is_yuv = !(desc->flags & AV_PIX_FMT_FLAG_RGB) && + (desc->flags & AV_PIX_FMT_FLAG_PLANAR) && + desc->nb_components >= 3; + s->is_rgb = ff_fill_rgba_map(rgba_map, inlink->format) >= 0; s->hsub = desc->log2_chroma_w; s->vsub = desc->log2_chroma_h; @@ -227,42 +231,7 @@ static int config_props(AVFilterLink *inlink) s->var_values[VAR_H] = inlink->h; s->is_16bit = desc->comp[0].depth > 8; - switch (inlink->format) { - case AV_PIX_FMT_YUV410P: - case AV_PIX_FMT_YUV411P: - case AV_PIX_FMT_YUV420P: - case AV_PIX_FMT_YUV422P: - case AV_PIX_FMT_YUV440P: - case AV_PIX_FMT_YUV444P: - case AV_PIX_FMT_YUVA420P: - case AV_PIX_FMT_YUVA422P: - case AV_PIX_FMT_YUVA444P: - case AV_PIX_FMT_YUV420P9LE: - case AV_PIX_FMT_YUV422P9LE: - case AV_PIX_FMT_YUV444P9LE: - case AV_PIX_FMT_YUVA420P9LE: - case AV_PIX_FMT_YUVA422P9LE: - case AV_PIX_FMT_YUVA444P9LE: - case AV_PIX_FMT_YUV420P10LE: - case AV_PIX_FMT_YUV422P10LE: - case AV_PIX_FMT_YUV440P10LE: - case AV_PIX_FMT_YUV444P10LE: - case AV_PIX_FMT_YUVA420P10LE: - case AV_PIX_FMT_YUVA422P10LE: - case AV_PIX_FMT_YUVA444P10LE: - case AV_PIX_FMT_YUV420P12LE: - case AV_PIX_FMT_YUV422P12LE: - case AV_PIX_FMT_YUV440P12LE: - case AV_PIX_FMT_YUV444P12LE: - case AV_PIX_FMT_YUV420P14LE: - case AV_PIX_FMT_YUV422P14LE: - case AV_PIX_FMT_YUV444P14LE: - case AV_PIX_FMT_YUV420P16LE: - case AV_PIX_FMT_YUV422P16LE: - case AV_PIX_FMT_YUV444P16LE: - case AV_PIX_FMT_YUVA420P16LE: - case AV_PIX_FMT_YUVA422P16LE: - case AV_PIX_FMT_YUVA444P16LE: + if (s->is_yuv) { min[Y] = 16 * (1 << (desc->comp[0].depth - 8)); min[U] = 16 * (1 << (desc->comp[1].depth - 8)); min[V] = 16 * (1 << (desc->comp[2].depth - 8)); @@ -271,24 +240,17 @@ static int config_props(AVFilterLink *inlink) max[U] = 240 * (1 << (desc->comp[1].depth - 8)); max[V] = 240 * (1 << (desc->comp[2].depth - 8)); max[A] = (1 << desc->comp[0].depth) - 1; - break; - case AV_PIX_FMT_RGB48LE: - case AV_PIX_FMT_RGBA64LE: - min[0] = min[1] = min[2] = min[3] = 0; - max[0] = max[1] = max[2] = max[3] = 65535; - break; - default: + } else { min[0] = min[1] = min[2] = min[3] = 0; - max[0] = max[1] = max[2] = max[3] = 255 * (1 << (desc->comp[0].depth - 8)); + if (inlink->format == AV_PIX_FMT_RGB48LE || + inlink->format == AV_PIX_FMT_RGBA64LE) + max[0] = max[1] = max[2] = max[3] = 65535; + else + max[0] = max[1] = max[2] = max[3] = 255 * (1 << (desc->comp[0].depth - 8)); } - s->is_yuv = s->is_rgb = 0; s->is_planar = desc->flags & AV_PIX_FMT_FLAG_PLANAR; - if (ff_fmt_is_in(inlink->format, yuv_pix_fmts)) s->is_yuv = 1; - else if (ff_fmt_is_in(inlink->format, rgb_pix_fmts)) s->is_rgb = 1; - if (s->is_rgb) { - ff_fill_rgba_map(rgba_map, inlink->format); s->step = av_get_bits_per_pixel(desc) >> 3; if (s->is_16bit) { s->step = s->step >> 1;