MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ to_image_format()

std::optional< Portal::Graphics::ImageFormat > MayaFlux::IO::to_image_format ( int  av_pixel_format)

Map an AVPixelFormat to the Portal ImageFormat backing it.

Covers the formats a container can store. Returns nullopt for anything without a direct equivalent, including planar YUV and packed 24-bit layouts that swscale must convert before a container sees them.

Parameters
av_pixel_formatAVPixelFormat as int; negative means RGBA.

Definition at line 489 of file VideoStreamContext.cpp.

490{
492
493 if (av_pixel_format < 0)
494 return ImageFormat::RGBA8;
495
496 switch (static_cast<AVPixelFormat>(av_pixel_format)) {
497 case AV_PIX_FMT_RGBA:
498 return ImageFormat::RGBA8;
499 case AV_PIX_FMT_BGRA:
500 return ImageFormat::BGRA8;
501 case AV_PIX_FMT_RGBA64LE:
502 return ImageFormat::RGBA16;
503 case AV_PIX_FMT_GRAYF32LE:
504 return ImageFormat::R32F;
505 case AV_PIX_FMT_RGB24:
506 return ImageFormat::RGB8;
507 case AV_PIX_FMT_GRAY8:
508 return ImageFormat::R8;
509 case AV_PIX_FMT_GRAY16LE:
510 return ImageFormat::R16;
511 default:
512 return std::nullopt;
513 }
514}
ImageFormat
User-friendly image format enum.

Referenced by MayaFlux::IO::CameraReader::create_container(), and MayaFlux::IO::VideoFileReader::load_into_container().

+ Here is the caller graph for this function: