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