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

◆ to_image_format()

MAYAFLUX_API 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 490 of file VideoStreamContext.cpp.

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

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

+ Here is the caller graph for this function: