From patchwork Sun Mar 19 21:37:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgQsWTc2No?= X-Patchwork-Id: 3020 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp1143490vsy; Sun, 19 Mar 2017 14:37:42 -0700 (PDT) X-Received: by 10.28.30.79 with SMTP id e76mr7160889wme.96.1489959462040; Sun, 19 Mar 2017 14:37:42 -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 k22si20242386wrc.333.2017.03.19.14.37.41; Sun, 19 Mar 2017 14:37:42 -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; 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 EA5A9680D52; Sun, 19 Mar 2017 23:37:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from golem.pkh.me (LStLambert-657-1-117-164.w92-154.abo.wanadoo.fr [92.154.28.164]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6D6E7680942 for ; Sun, 19 Mar 2017 23:37:14 +0200 (EET) Received: from golem.pkh.me (localhost.localdomain [127.0.0.1]) by golem.pkh.me (OpenSMTPD) with ESMTPSA id b157f6ef (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO) for ; Sun, 19 Mar 2017 21:37:31 +0000 (UTC) Date: Sun, 19 Mar 2017 22:37:30 +0100 From: =?utf-8?B?Q2zDqW1lbnQgQsWTc2No?= To: FFmpeg development discussions and patches Message-ID: <20170319213729.GB8199@golem.pkh.me> Mail-Followup-To: FFmpeg development discussions and patches References: <20170319143343.7298-1-u@pkh.me> <20170319143343.7298-4-u@pkh.me> <20170319153512.GC5776@nb4> <20170319155023.GB7136@golem.pkh.me> <20170319211337.GG5776@nb4> MIME-Version: 1.0 In-Reply-To: <20170319211337.GG5776@nb4> User-Agent: Mutt/1.8.0 (2017-02-23) Subject: Re: [FFmpeg-devel] [PATCH 3/5] swscale: use a function for isBayer 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" On Sun, Mar 19, 2017 at 10:13:37PM +0100, Michael Niedermayer wrote: [...] > > > > +static av_always_inline int isBayer(enum AVPixelFormat pix_fmt) > > > > +{ > > > > + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); > > > > + av_assert0(desc); > > > > + return !strncmp(desc->name, "bayer_", 6); > > > > > > iam not sure strncmp() is a good idea speed wise > > > > > > > In a non-bayer case, the function will return in the worst case after the > > 2nd character, I have high doubt about this being a speed issue. We can > > introduce a flag for this, but I don't think it's worth. > > i think needing to call libc is a bit ugly here > It's already how we do it in libavutil/pixdesc.c. But anyway, how about the 2 attached patches? From 7faa2be248b5a2cbb54314983e2305b62906e0aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Sun, 19 Mar 2017 15:04:53 +0100 Subject: [PATCH 4/6] swscale: use a function for isBayer --- libswscale/swscale_internal.h | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 6bcb4640ee..c26a1ea418 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -760,20 +760,12 @@ static av_always_inline int isGray(enum AVPixelFormat pix_fmt) || (x) == AV_PIX_FMT_BGR24 \ ) -#define isBayer(x) ( \ - (x)==AV_PIX_FMT_BAYER_BGGR8 \ - || (x)==AV_PIX_FMT_BAYER_BGGR16LE \ - || (x)==AV_PIX_FMT_BAYER_BGGR16BE \ - || (x)==AV_PIX_FMT_BAYER_RGGB8 \ - || (x)==AV_PIX_FMT_BAYER_RGGB16LE \ - || (x)==AV_PIX_FMT_BAYER_RGGB16BE \ - || (x)==AV_PIX_FMT_BAYER_GBRG8 \ - || (x)==AV_PIX_FMT_BAYER_GBRG16LE \ - || (x)==AV_PIX_FMT_BAYER_GBRG16BE \ - || (x)==AV_PIX_FMT_BAYER_GRBG8 \ - || (x)==AV_PIX_FMT_BAYER_GRBG16LE \ - || (x)==AV_PIX_FMT_BAYER_GRBG16BE \ - ) +static av_always_inline int isBayer(enum AVPixelFormat pix_fmt) +{ + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); + av_assert0(desc); + return desc->flags & AV_PIX_FMT_FLAG_BAYER; +} #define isAnyRGB(x) \ ( \ -- 2.12.0