[FFmpeg-devel] [PATCH 4/4] avfilter/avfiltergraph, avutil/pixdesc: use av_pix_fmt_desc_has_alpha()

Marton Balint cus at passwd.hu
Thu Apr 19 22:32:21 EEST 2018


Signed-off-by: Marton Balint <cus at passwd.hu>
---
 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; i<link->in_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;
     }
-- 
2.13.6



More information about the ffmpeg-devel mailing list