Skip to content

Commit

Permalink
minivideo: add a few string helpers in minivideo_codecs.h
Browse files Browse the repository at this point in the history
  • Loading branch information
emericg committed Aug 20, 2024
1 parent 47c6b6b commit dcb1d8a
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 14 deletions.
49 changes: 35 additions & 14 deletions minivideo/src/minivideo_avutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ typedef enum StereoMode_e

} StereoMode_e;

/* ************************************************************************** */

//! The color model used by the video
typedef enum ColorModel_e
{
Expand All @@ -165,6 +167,39 @@ typedef enum ColorModel_e

} ColorModel_e;

//! The chroma subsampling format used by the video/pictures
typedef enum ChromaSubSampling_e
{
CHROMA_SS_UNKNOWN = 0, //!< Unknown chroma subsampling

CHROMA_SS_311 = 1, //!< 3:1:1 subsampling
CHROMA_SS_400 = 2, //!< 4:0:0 subsampling (monochrome)
CHROMA_SS_410 = 3, //!< 4:1:0 subsampling
CHROMA_SS_411 = 4, //!< 4:1:1 subsampling
CHROMA_SS_420 = 5, //!< 4:2:0 subsampling
CHROMA_SS_421 = 6, //!< 4:2:1 subsampling
CHROMA_SS_422 = 7, //!< 4:2:2 subsampling
CHROMA_SS_440 = 8, //!< 4:4:0 subsampling
CHROMA_SS_441 = 9, //!< 4:4:1 subsampling
CHROMA_SS_442 = 10, //!< 4:4:2 subsampling
CHROMA_SS_444 = 11, //!< 4:4:4 subsampling

} ChromaSubSampling_e;

//! The chroma subsampling format used by the video/pictures
typedef enum ChromaLocation_e
{
CHROMA_LOC_UNKNOWN = 0, //!< Unknown chroma location

CHROMA_LOC_LEFT = 1, //!<
CHROMA_LOC_CENTER = 2,
CHROMA_LOC_TOPLEFT = 3,
CHROMA_LOC_TOP = 4,
CHROMA_LOC_BOTTOMLEFT = 5,
CHROMA_LOC_BOTTOM = 6,

} ChromaLocation_e;

typedef enum ColorsRec_e
{
COLORS_BT470_6,
Expand Down Expand Up @@ -201,20 +236,6 @@ typedef enum ColorMatrix_e

} ColorMatrix_e;

//! The subsampling format used by the video
typedef enum SubSampling_e
{
SS_UNKNOWN = 0, //!< Unknown subsampling

SS_400 = 1, //!< 4:0:0 monochrome subsampling
SS_411 = 2, //!< 4:1:1 subsampling
SS_420 = 3, //!< 4:2:0 subsampling
SS_422 = 4, //!< 4:2:2 subsampling
SS_444 = 5, //!< 4:4:4 subsampling
SS_4444 = 6 //!< 4:4:4:4 subsampling

} SubSampling_e;

/* ************************************************************************** */

//! Chromaticity coordinates of the source primaries
Expand Down
134 changes: 134 additions & 0 deletions minivideo/src/minivideo_codecs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,140 @@ const char *getCodecProfileString(const CodecProfiles_e profile, const bool long

/* ************************************************************************** */

const char *getScanModeString(const ScanType_e mode)
{
switch (mode)
{
case SCAN_PROGRESSIVE:
return "Progressive";
case SCAN_INTERLACED:
return "Interlaced scan";

default:
return "";
}
}
/* ************************************************************************** */

const char *getStereoModeString(const StereoMode_e mode)
{
switch (mode)
{
case MONOSCOPIC:
return "Monoscopic";

case STEREO_ANAGLYPH_CR:
return "Anaglyph (cyan/red)";
case STEREO_ANAGLYPH_GM:
return "Anaglyph (green/magenta)";

case STEREO_SIDEBYSIDE_LEFT:
return "Side by side (left eye is first)";
case STEREO_SIDEBYSIDE_RIGHT:
return "Side by side (right eye is first)";
case STEREO_TOPBOTTOM_LEFT:
return "Top bottom (left eye is first)";
case STEREO_TOPBOTTOM_RIGHT:
return "Top bottom (right eye is first)";
case STEREO_CHECKBOARD_LEFT:
return "Checkerboard (left eye is first)";
case STEREO_CHECKBOARD_RIGHT:
return "Checkerboard (right eye is first)";
case STEREO_ROWINTERLEAVED_LEFT:
return "Row interleaved (left eye is first)";
case STEREO_ROWINTERLEAVED_RIGHT:
return "Row interleaved (right eye is first)";
case STEREO_COLUMNINTERLEAVED_LEFT:
return "Column interleaved (left eye is first)";
case STEREO_COLUMNINTERLEAVED_RIGHT:
return "Column interleaved (right eye is first)";

default:
return "";
}
}

/* ************************************************************************** */

const char *getHdrModeString(const HdrMode_e mode)
{
switch (mode)
{
case SDR:
return "SDR";

case HLG:
return "HLG";
case HDR10:
return "HDR10";
case HDR10plus:
return "HDR10+";
case DolbyVision:
return "Dolby Vision";

default:
return "";
}
}

/* ************************************************************************** */

const char *getChromaSubsamplingString(const ChromaSubSampling_e subsampling)
{
switch (subsampling)
{
case CHROMA_SS_311:
return "3:1:1";
case CHROMA_SS_400:
return "4:0:0";
case CHROMA_SS_410:
return "4:1:0";
case CHROMA_SS_411:
return "4:1:1";
case CHROMA_SS_420:
return "4:2:0+";
case CHROMA_SS_421:
return "4:2:1";
case CHROMA_SS_422:
return "4:2:2";
case CHROMA_SS_440:
return "4:4:0";
case CHROMA_SS_441:
return "4:4:1";
case CHROMA_SS_442:
return "4:4:2";
case CHROMA_SS_444:
return "4:4:4";

default:
return "";
}
}

const char *getChromaLocationString(const ChromaLocation_e location)
{
switch (location)
{
case CHROMA_LOC_LEFT:
return "Left";
case CHROMA_LOC_CENTER:
return "Center";
case CHROMA_LOC_TOPLEFT:
return "Top left";
case CHROMA_LOC_TOP:
return "Top";
case CHROMA_LOC_BOTTOMLEFT:
return "Bottom left";
case CHROMA_LOC_BOTTOM:
return "Bottom";

default:
return "";
}
}

/* ************************************************************************** */

const char *getColorPrimariesString(const ColorPrimaries_e primaries)
{
switch (primaries)
Expand Down
7 changes: 7 additions & 0 deletions minivideo/src/minivideo_codecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,13 @@ minivideo_EXPORT const char *getPictureString(const Pictures_e picture, const bo

/* ************************************************************************** */

minivideo_EXPORT const char *getScanModeString(const ScanType_e mode);
minivideo_EXPORT const char *getStereoModeString(const StereoMode_e mode);
minivideo_EXPORT const char *getHdrModeString(const HdrMode_e mode);

minivideo_EXPORT const char *getChromaSubsamplingString(const ChromaSubSampling_e subsampling);
minivideo_EXPORT const char *getChromaLocationString(const ChromaLocation_e location);

minivideo_EXPORT const char *getColorPrimariesString(const ColorPrimaries_e primaries);
minivideo_EXPORT const char *getColorTransferCharacteristicString(const ColorTransferCharacteristic_e transfert);
minivideo_EXPORT const char *getColorMatrixString(const ColorSpace_e space);
Expand Down

0 comments on commit dcb1d8a

Please sign in to comment.