2019-04-17 11:37 GMT+02:00, Simone Donadini <simone.donad...@avolites.com>:

> 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
Libav-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to