Thank you for the explanation Carl.
Actually i can not deduce from your answer if the first method is correct, but i will definitely not use the macro one.
Bye,
Simone.
From: "Carl Eugen Hoyos" <[email protected]>
Date: 17/04/2019 at 23:30:48
To: "This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter." <[email protected]>
Subject: Re: [Libav-user] Cheking for an alpha channel / using AVPixFmtDescriptor
2019-04-17 11:37 GMT+02:00, Simone Donadini :
> When opening a media i need to check if the pixel format holds an alpha
> channel.
> I can check for the alpha flag in the pixel format description, like this:
> const AVPixFmtDescriptor *pixDesc = av_pix_fmt_desc_get(pix_format);
> bool has_alpha = pixDesc->flags & AV_PIX_FMT_FLAG_ALPHA;
>
> But i noticed that inside libavutil/pixdesc.c there is a function for
> checking for an alpha channel, which is defined like this:
> #define pixdesc_has_alpha(pixdesc) ((pixdesc)->nb_components == 2 ||
> (pixdesc)->nb_components == 4 || (pixdesc)->flags & AV_PIX_FMT_FLAG_PAL)
> I understand the use of AV_PIX_FMT_FLAG_PAL as it is an exception, but could
> a pixel format with alpha have a number of components different from 2 and
> 4?
>
> So, which one of the two methods is more reliable?
For you as a user, only one method exist, the macro
is not exported.
If you plan to copy the macro: It is not correct as FFmpeg
contains several formats with four components where
alpha should be ignored, it is meaningless (RGB0 and friends).
Carl Eugen
_______________________________________________
Libav-user mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/libav-user
To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".
_______________________________________________ Libav-user mailing list [email protected] https://ffmpeg.org/mailman/listinfo/libav-user
To unsubscribe, visit link above, or email [email protected] with subject "unsubscribe".
