#include "media/gpu/chromeos/fourcc.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "media/gpu/macros.h"
#if BUILDFLAG(USE_V4L2_CODEC)
#include <linux/videodev2.h>
#elif BUILDFLAG(USE_VAAPI)
#include <va/va.h>
#endif
namespace media {
std::optional<Fourcc> Fourcc::FromUint32(uint32_t fourcc) { … }
std::optional<Fourcc> Fourcc::FromVideoPixelFormat(
VideoPixelFormat pixel_format,
bool single_planar) { … }
VideoPixelFormat Fourcc::ToVideoPixelFormat() const { … }
#if BUILDFLAG(USE_V4L2_CODEC)
std::optional<Fourcc> Fourcc::FromV4L2PixFmt(uint32_t v4l2_pix_fmt) {
return FromUint32(v4l2_pix_fmt);
}
uint32_t Fourcc::ToV4L2PixFmt() const {
return static_cast<uint32_t>(value_);
}
#elif BUILDFLAG(USE_VAAPI)
std::optional<Fourcc> Fourcc::FromVAFourCC(uint32_t va_fourcc) { … }
std::optional<uint32_t> Fourcc::ToVAFourCC() const { … }
#endif
std::optional<Fourcc> Fourcc::ToSinglePlanar() const { … }
bool operator!=(const Fourcc& lhs, const Fourcc& rhs) { … }
bool Fourcc::IsMultiPlanar() const { … }
std::string Fourcc::ToString() const { … }
#if BUILDFLAG(USE_V4L2_CODEC)
static_assert(Fourcc::YU12 == V4L2_PIX_FMT_YUV420, "Mismatch Fourcc");
static_assert(Fourcc::YV12 == V4L2_PIX_FMT_YVU420, "Mismatch Fourcc");
static_assert(Fourcc::YM12 == V4L2_PIX_FMT_YUV420M, "Mismatch Fourcc");
static_assert(Fourcc::YM21 == V4L2_PIX_FMT_YVU420M, "Mismatch Fourcc");
static_assert(Fourcc::YUYV == V4L2_PIX_FMT_YUYV, "Mismatch Fourcc");
static_assert(Fourcc::NV12 == V4L2_PIX_FMT_NV12, "Mismatch Fourcc");
static_assert(Fourcc::NV21 == V4L2_PIX_FMT_NV21, "Mismatch Fourcc");
static_assert(Fourcc::NM12 == V4L2_PIX_FMT_NV12M, "Mismatch Fourcc");
static_assert(Fourcc::NM21 == V4L2_PIX_FMT_NV21M, "Mismatch Fourcc");
static_assert(Fourcc::YU16 == V4L2_PIX_FMT_YUV422P, "Mismatch Fourcc");
static_assert(Fourcc::YM16 == V4L2_PIX_FMT_YUV422M, "Mismatch Fourcc");
static_assert(Fourcc::MM21 == V4L2_PIX_FMT_MM21, "Mismatch Fourcc");
static_assert(Fourcc::MT21 == V4L2_PIX_FMT_MT21C, "Mismatch Fourcc");
static_assert(Fourcc::AR24 == V4L2_PIX_FMT_ABGR32, "Mismatch Fourcc");
static_assert(Fourcc::P010 == V4L2_PIX_FMT_P010, "Mismatch Fourcc");
#ifdef V4L2_PIX_FMT_MT2T
static_assert(Fourcc::MT2T == V4L2_PIX_FMT_MT2T, "Mismatch Fourcc");
#endif
#ifdef V4L2_PIX_FMT_QC08C
static_assert(Fourcc::Q08C == V4L2_PIX_FMT_QC08C, "Mismatch Fourcc");
#endif
#ifdef V4L2_PIX_FMT_QC10C
static_assert(Fourcc::Q10C == V4L2_PIX_FMT_QC10C, "Mismatch Fourcc");
#endif
#endif
}