Sunshine0.0.5917
Sunshine 0.0.5917
Self-hosted game stream host for Moonlight.
Loading...
Searching...
No Matches
video_colorspace.h File Reference

Declarations for colorspace functions. More...

#include <array>
#include <libavutil/pixfmt.h>
Include dependency graph for video_colorspace.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  video::avcodec_colorspace_t
 FFmpeg colorimetry values used by AVCodec encoders. More...
struct  video::color_t
 Pair of Sunshine and AVCodec colorimetry descriptions. More...
struct  video::sunshine_colorspace_t
 Sunshine colorimetry values derived from stream configuration. More...

Enumerations

enum class  video::colorspace_e { rec601 , rec709 , bt2020sdr , bt2020 }
 Enumerates supported colorspace options. More...

Functions

avcodec_colorspace_t video::avcodec_colorspace_from_sunshine_colorspace (const sunshine_colorspace_t &sunshine_colorspace)
 Convert Sunshine colorspace metadata to FFmpeg AVCodec fields.
const color_t * video::color_vectors_from_colorspace (const sunshine_colorspace_t &colorspace, bool unorm_output)
 Select static RGB-to-YUV conversion vectors for the requested colorspace and range.
sunshine_colorspace_t video::colorspace_from_client_config (const config_t &config, bool hdr_display)
 Derive Sunshine colorspace metadata from client stream configuration.
bool video::colorspace_is_hdr (const sunshine_colorspace_t &colorspace)
 Check whether a Sunshine colorspace represents HDR video.
const char * video::colorspace_to_string (colorspace_e colorspace)
 Describe a colorspace for encoder diagnostic messages.

Detailed Description

Declarations for colorspace functions.

Enumeration Type Documentation

◆ colorspace_e

enum class video::colorspace_e
strong

Enumerates supported colorspace options.

Enumerator
rec601 

Rec. 601.

rec709 

Rec. 709.

bt2020sdr 

Rec. 2020 SDR.

bt2020 

Rec. 2020 HDR.

Function Documentation

◆ avcodec_colorspace_from_sunshine_colorspace()

avcodec_colorspace_t video::avcodec_colorspace_from_sunshine_colorspace ( const sunshine_colorspace_t & sunshine_colorspace)

Convert Sunshine colorspace metadata to FFmpeg AVCodec fields.

Parameters
sunshine_colorspaceSunshine colorspace.
Returns
FFmpeg color range, primaries, transfer, and software format values.

◆ color_vectors_from_colorspace()

const color_t * video::color_vectors_from_colorspace ( const sunshine_colorspace_t & colorspace,
bool unorm_output )

Select static RGB-to-YUV conversion vectors for the requested colorspace and range.

Get static RGB->YUV color conversion matrix. This matrix expects RGB input in UNORM (0.0 to 1.0) range and doesn't perform any gamut mapping or gamma correction.

Note
Unknown colorspaces fall back to Rec. 709.
Parameters
colorspaceTargeted YUV colorspace.
unorm_outputWhether the matrix should produce output in UNORM or UINT range.
Returns
const color_t* that contains RGB->YUV transformation vectors. Components range_y and range_uv are there for backwards compatibility and can be ignored in the computation.

◆ colorspace_from_client_config()

sunshine_colorspace_t video::colorspace_from_client_config ( const config_t & config,
bool hdr_display )

Derive Sunshine colorspace metadata from client stream configuration.

Derive Sunshine colorspace metadata from the negotiated client config.

Parameters
configConfiguration values to apply.
hdr_displayHDR display.
Returns
Colorspace, range, transfer, and HDR flags used for encoding.

◆ colorspace_is_hdr()

bool video::colorspace_is_hdr ( const sunshine_colorspace_t & colorspace)

Check whether a Sunshine colorspace represents HDR video.

Parameters
colorspaceColorimetry information used for conversion or encoding.
Returns
True when the colorspace values describe the same metadata.

◆ colorspace_to_string()

const char * video::colorspace_to_string ( colorspace_e colorspace)

Describe a colorspace for encoder diagnostic messages.

Parameters
colorspaceColorspace to describe.
Returns
Color coding label, or "unknown" for an unsupported colorspace.