From patchwork Tue Apr 24 19:05:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 8635 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp2190433jad; Tue, 24 Apr 2018 12:06:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/12Qo5cueNC5bTsa9cQdrQd5qdygwQ0cfAzqYZS9mNW5XztoOFxHpRrG4nAsyWg4zxdANm X-Received: by 2002:adf:d0d0:: with SMTP id z16-v6mr17990813wrh.152.1524596763100; Tue, 24 Apr 2018 12:06:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524596763; cv=none; d=google.com; s=arc-20160816; b=aBVBDMbuDvbuGWkIQqUW1PhENE/37V0SJa3Xsp8AdK1VfUGAYq+RFO/JiG1X6bBbaW RX3c4iz6Xw45L+LtGemuOmEjQE6lfmA3RjqBkqV/Zvz6W6yKKK9Xc84h6jEL1I1TnJns ixtcIyyMQ9wyy5i53Xm9EsKUnnTo7HkgbHEcIt4YRpJGlZ7Kz7DdZ+9t5LXVIeSNU5+n 6ahGnmAlx0cwbfUve3Dhrg+kZvo8rTiy+GlKOdXzabU7nJgCExRFSga7LYRgRV2wdLJd FRyE7rad1JmSP4CGCxn1eP5uxPlQ/5berxgGcYX/QgW9RTInaPW4zTqi5bYUgnhr2B79 shXA== 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=5Vitr6qfUEUVre11ON61i4JmS94TYFI3bgBxtOXYMu4=; b=ZYAdKMA2oDv/udNx9zqkiWI2oIwnwVuPFt5FbsZIIv+lMQ+5vBcBHnz6aLhaYvRTLc A+E16sMsygW4zXhIpBvapXYaXZ8ktAuYRZMVgwO2qjgl0USnKiYtKuHgnyXT7awiktyX C60RE2EcH4dAO7l7JM0lCUJr7PRHFFCuTEOi9ZSEmCqT2jJOwnl/7lMjwOD6znFRGgLk 13o6FxPG1+bJmdphP7eGEuG2fgEtN+dzmtmAsW5nGfkb93YR6UXI7NnnhHREflBAJpQi 91ZS7NjdBe+y0xf5/XW0hN+RicpfF905OnIgq9DKYQ7fiUkOGNSPwy5qZ3DIvrR6FIOd jpeg== 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 4-v6si7655049wrp.215.2018.04.24.12.06.02; Tue, 24 Apr 2018 12:06:03 -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 E2F8B68A2C6; Tue, 24 Apr 2018 22:05:10 +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 2810A689F0F for ; Tue, 24 Apr 2018 22:05:04 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id E8A40E1069; Tue, 24 Apr 2018 21:05:33 +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 Zv-5h2KoNn6Y; Tue, 24 Apr 2018 21:05:32 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 45862E0742; Tue, 24 Apr 2018 21:05:32 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 24 Apr 2018 21:05:01 +0200 Message-Id: <20180424190501.23908-5-cus@passwd.hu> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180424190501.23908-1-cus@passwd.hu> References: <20180424190501.23908-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 5/5] Use AV_PIX_FMT_FLAG_ALPHA for detecting transparency where nb_components was used 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" Temporarily keep the old method for ffmpeg_filters.c choose_pix_fmt and avfiltergraph.c pick_format() until a paletted pixel format without alpha is introduced. Signed-off-by: Marton Balint --- fftools/ffmpeg_filter.c | 1 + libavcodec/ffv1enc.c | 4 ++-- libavfilter/avfiltergraph.c | 1 + libavutil/pixdesc.c | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 877fd670e6..068f499e0b 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -65,6 +65,7 @@ enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx, AVCod if (codec && codec->pix_fmts) { const enum AVPixelFormat *p = codec->pix_fmts; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(target); + //FIXME: This should check for AV_PIX_FMT_FLAG_ALPHA after PAL8 pixel format without alpha is implemented int has_alpha = desc ? desc->nb_components % 2 == 0 : 0; enum AVPixelFormat best= AV_PIX_FMT_NONE; diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 23e8d3dfa4..e6f4422fa1 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -624,7 +624,7 @@ FF_ENABLE_DEPRECATION_WARNINGS case AV_PIX_FMT_YUVA420P: s->chroma_planes = desc->nb_components < 3 ? 0 : 1; s->colorspace = 0; - s->transparency = desc->nb_components == 4 || desc->nb_components == 2; + s->transparency = !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA); if (!avctx->bits_per_raw_sample && !s->bits_per_raw_sample) s->bits_per_raw_sample = 8; else if (!s->bits_per_raw_sample) @@ -676,7 +676,7 @@ FF_ENABLE_DEPRECATION_WARNINGS s->bits_per_raw_sample = 16; else if (!s->bits_per_raw_sample) s->bits_per_raw_sample = avctx->bits_per_raw_sample; - s->transparency = desc->nb_components == 4 || desc->nb_components == 2; + s->transparency = !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA); s->colorspace = 1; s->chroma_planes = 1; if (s->bits_per_raw_sample >= 16) { diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 4cc6892404..a149f8fb6d 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -679,6 +679,7 @@ static int pick_format(AVFilterLink *link, AVFilterLink *ref) if (link->type == AVMEDIA_TYPE_VIDEO) { if(ref && ref->type == AVMEDIA_TYPE_VIDEO){ + //FIXME: This should check for AV_PIX_FMT_FLAG_ALPHA after PAL8 pixel format without alpha is implemented int has_alpha= av_pix_fmt_desc_get(ref->format)->nb_components % 2 == 0; enum AVPixelFormat best= AV_PIX_FMT_NONE; int i; diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index a8be7b66e6..df03b3372d 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2482,7 +2482,7 @@ enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt) #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) + ((pixdesc)->flags & AV_PIX_FMT_FLAG_ALPHA) static int get_color_type(const AVPixFmtDescriptor *desc) {