From patchwork Fri Nov 22 15:54:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 16391 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 68B9444A913 for ; Fri, 22 Nov 2019 17:54:52 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 39323689A59; Fri, 22 Nov 2019 17:54:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A30C96898EE for ; Fri, 22 Nov 2019 17:54:45 +0200 (EET) Received: by mail-pj1-f68.google.com with SMTP id t103so3208643pjb.6 for ; Fri, 22 Nov 2019 07:54:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=SHhlKrbsUPdZm4LphVLDy0OLAHp2G+lqDCQUxde063U=; b=F0ctkqysiztEowfvKVqJ0HM15ICMGwVy9qDq3h3HhnilSTkNUU9mhI7f8KICm2GkSv ddosUevUaH0yfh2cMFIJlH9WIusUW76ZcvD2dA8U+27C5gR6DodNhY2pGp1SgrhucSed K9m4QAd6AJo9MAiqLrUH1UMFe608DX7wxf70TNbAga209emuV2c/xm8igMDVmWAoYaTn aQdTccRjjqpdFfW7Kaceg3+Rt9jsDrGfv6ZKtVQn4SWo/Xxu0RLazjpDP64qfyj02JwS xPRk1yKjyw+w2wSFjzbIbEqjToRzcjuAzkbwFR0Dc/CDUMdXGS6unhYLAvK28r9WKKWn dy9Q== 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=SHhlKrbsUPdZm4LphVLDy0OLAHp2G+lqDCQUxde063U=; b=Hc/gQPbp2DM5mcoqp5TIrSyWH4ZMkbm2aevZjn3ehQPh3uappldefwaSSGW2E22xJ3 C8IpDWshpfAtN/p+13xS9Onhk7THEjweXsfgZXvKomsmms14V8eR3Lv35zjyV+LLO6kB JarNjRXKwXEqvKgrE7oJImcsT8WUStbuhR69xEwb/8pmV589hOwXsdMQTFJn2vDc9PbB 94+vZC2oftZvX0LIgsF/8vcxYq1hpTeAsshz2vre8AAA4OG4lQmznkcgmwUW27UyWcTk jBycTPNp44pe9rMESnUCYXXh6EC0oruIUpGTVh4jU78MhP7h569ObEoOACyb0V0Lnrdk zIPQ== X-Gm-Message-State: APjAAAV488DegyZs5pQgh7lAhBnWI8fGf2AuGFXsT8h68988fmNtoF2D OGv+Etd7aYYTHjL1M0YG4clexSFM X-Google-Smtp-Source: APXvYqy02euttl8Vp64XOIAkQmJASFXT4NfF6QTcE4UAal6AWTGnhKVihbm1YhV967cDLevtH5eq1g== X-Received: by 2002:a17:902:ac97:: with SMTP id h23mr8588271plr.237.1574438083578; Fri, 22 Nov 2019 07:54:43 -0800 (PST) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id i13sm7655479pfo.39.2019.11.22.07.54.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Nov 2019 07:54:42 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Nov 2019 23:54:19 +0800 Message-Id: <20191122155419.16253-1-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 Subject: [FFmpeg-devel] [PATCH v3] 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 --- have pass fate testing for fate-filter-pixfmts-lut libavfilter/vf_lut.c | 67 ++++++++++------------------------------------------ 1 file changed, 12 insertions(+), 55 deletions(-) diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c index 1fdc5e1..328c64d 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,29 +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; - } - } + s->step = av_get_padded_bits_per_pixel(desc) >> (3 + s->is_16bit) ; for (color = 0; color < desc->nb_components; color++) { double res;