Sunshine master
Self-hosted game stream host for Moonlight.
video_colorspace.cpp File Reference

Definitions for colorspace functions. More...

#include "video_colorspace.h"
#include "logging.h"
#include "video.h"
#include <libswscale/swscale.h>
Include dependency graph for video_colorspace.cpp:

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_tvideo::color_vectors_from_colorspace (const sunshine_colorspace_t &colorspace, bool unorm_output)
 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.
 
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.
 

Detailed Description

Definitions for colorspace functions.

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 )

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.

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.