Hi,


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?

Any advice would be much appreciated.
Thank you,

Simone.

_______________________________________________
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".

Reply via email to