From patchwork Thu Apr 19 19:32:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 8508 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp1044195jad; Thu, 19 Apr 2018 12:33:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZod8s8+SHr9LSSjNJBKzBEmN1cFPQkL+woKiHRbaQTrfaI9xMr5lPWumARUK6C7pfMrHwcc X-Received: by 10.28.88.195 with SMTP id m186mr37783wmb.113.1524166382354; Thu, 19 Apr 2018 12:33:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524166382; cv=none; d=google.com; s=arc-20160816; b=qkVoeYNofIpSHx3urjqdOLEy4lTaxQu0pHGi0dx6zEZsQarVx/OTO4mOORGUJTQODo yWPhhgaWkg7xgb8JJSq7nhfYpOl7Bquf7IjRVRsJXGXDTMX5c1Et/79hPXsODgGyO/cd 8zQIEWG0HEbmqFclRSNfr2p+ZFB7CKaoCVBKRwWtDoi09vO1ntLbL2Fdxpm19D8VPkHS vmSul9BXs9YJC9PLMJUqwZbFf7ULqd6TxgmOyWle2lSre+EWJRkh6Moryov36UOvZ+VV 5mOj7rpjmGAvBw9D3N7uC31+JKdXt6ATqYjh1OylZAg4jhiRA4o4yMTAEs6hD0heoUbw I0Mw== 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:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=0w7vEt7fk704LwD0A9DsiCRlP8GkBwxNlIwl+a8WtJU=; b=ymdzrdsyqEUwhz+iuitF561wQ5Rtl8foME5j7jSg/snuSXJnAZP1Ky8/qcvyL3uCRz lGC2R27zf1Wi5o2HFXdFeOU3123qNYL+InEV6/k/vcxNQYiOuzBEFHyEcMfciVgmzRRy BKqow1sCIbJva3qy9lINm1kastElWyqPf5BR4Zy8VU/GCGKKM/zAG8dMm1OS40K6eqEe XCjuriKGo3FlYy32Yw98Ds1cmwO8yBwlNR5bAqjiw8JGdHRRGyNh4Gjf96QKSVQd1tFW aQIuCiglg4X4sP3OevYDCTTFM2NPoQgnvHFNQRQqzxfrMJT5zcpreYpjm6cYdngz9Ei1 gbcQ== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 35-v6si3144170wrd.224.2018.04.19.12.33.02; Thu, 19 Apr 2018 12:33:02 -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 ECD34689FC8; Thu, 19 Apr 2018 22:32:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 37E6F689FC4 for ; Thu, 19 Apr 2018 22:32:08 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D8F6EE1050; Thu, 19 Apr 2018 21:32:35 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2nNSjWZ8pSmf; Thu, 19 Apr 2018 21:32:34 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 9BAB0E052A; Thu, 19 Apr 2018 21:32:34 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 19 Apr 2018 21:32:21 +0200 Message-Id: <20180419193221.21712-4-cus@passwd.hu> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180419193221.21712-1-cus@passwd.hu> References: <20180419193221.21712-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 4/4] avfilter/avfiltergraph, avutil/pixdesc: use av_pix_fmt_desc_has_alpha() 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: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- libavfilter/avfiltergraph.c | 2 +- libavutil/pixdesc.c | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index e18f733e23..1e77cc8495 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -679,7 +679,7 @@ static int pick_format(AVFilterLink *link, AVFilterLink *ref) if (link->type == AVMEDIA_TYPE_VIDEO) { if(ref && ref->type == AVMEDIA_TYPE_VIDEO){ - int has_alpha= av_pix_fmt_desc_get(ref->format)->nb_components % 2 == 0 || (av_pix_fmt_desc_get(ref->format)->flags & AV_PIX_FMT_FLAG_PAL); + int has_alpha = av_pix_fmt_desc_has_alpha(av_pix_fmt_desc_get(ref->format)); enum AVPixelFormat best= AV_PIX_FMT_NONE; int i; for (i=0; iin_formats->nb_formats; i++) { diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 8ed52751c1..ee5d77d46b 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2482,10 +2482,6 @@ enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt) #define FF_COLOR_YUV_JPEG 3 /**< YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */ #define FF_COLOR_XYZ 4 -#define pixdesc_has_alpha(pixdesc) \ - ((pixdesc)->nb_components == 2 || (pixdesc)->nb_components == 4 || (pixdesc)->flags & AV_PIX_FMT_FLAG_PAL) - - static int get_color_type(const AVPixFmtDescriptor *desc) { if (desc->flags & AV_PIX_FMT_FLAG_PAL) return FF_COLOR_RGB; @@ -2625,12 +2621,12 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt, loss |= FF_LOSS_CHROMA; score -= 2 * 65536; } - if (!pixdesc_has_alpha(dst_desc) && (pixdesc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA))) { + if (!av_pix_fmt_desc_has_alpha(dst_desc) && (av_pix_fmt_desc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA))) { loss |= FF_LOSS_ALPHA; score -= 65536; } if (dst_pix_fmt == AV_PIX_FMT_PAL8 && (consider & FF_LOSS_COLORQUANT) && - (src_pix_fmt != AV_PIX_FMT_PAL8 && (src_color != FF_COLOR_GRAY || (pixdesc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA))))) { + (src_pix_fmt != AV_PIX_FMT_PAL8 && (src_color != FF_COLOR_GRAY || (av_pix_fmt_desc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA))))) { loss |= FF_LOSS_COLORQUANT; score -= 65536; }