Is there any way to get pixel's bit count from codecContext.pix_fmt of type PixelFormat? I do it manually using switch:
switch (OUT_IMAGE_FORMAT)
{
case PIX_FMT_RGB24:
pVideoInfo->bmiHeader.biBitCount = 24;
do_something();
break;
//etc
}
but this requires manual updates every time libav will add or delete some pixel formats. Or if I will need to add some pixel format that wasn't supported earlier.
P.S. I need it to fill CMediaType for DirectShow filters, so bits_per_raw_sample isn't appropriate since it's for internal libav usage as I know.
Try using
#include "libavutil/pixdesc.h"
pVideoInfo->bmiHeader.biBitCount = av_get_bits_per_pixel(&av_pix_fmt_descriptors[OUT_IMAGE_FORMAT]);