Sunshine master
Self-hosted game stream host for Moonlight.
egl::sws_t Class Reference

EGL/OpenGL scaler and colorspace conversion pipeline. More...

#include <src/platform/linux/graphics.h>

Collaboration diagram for egl::sws_t:
[legend]

Public Member Functions

void apply_colorspace (const video::sunshine_colorspace_t &colorspace, bool is_yuv444)
 Apply the configured colorspace metadata to the active frame.
 
int blank (gl::frame_buf_t &fb, int offsetX_, int offsetY_, int width, int height, bool is_yuv444)
 Clear the render target to a blank frame.
 
int convert_nv12 (gl::frame_buf_t &fb)
 Convert the loaded source image into NV12 output planes.
 
int convert_yuv444 (gl::frame_buf_t &fb)
 Convert the loaded source image into YUV444 output planes.
 
int draw_programs_to_buffers (GLenum attachments[], gl::frame_buf_t &fb, int count, bool is_yuv444)
 Render the loaded source texture into output framebuffers.
 
void load_ram (platf::img_t &img)
 Load ram data from the backing API or store.
 
void load_vram (img_descriptor_t &img, int offset_x, int offset_y, int texture, bool is_yuv444)
 Load vram data from the backing API or store.
 

Static Public Member Functions

static std::optional< sws_tmake (int in_width, int in_height, int out_width, int out_height, AVPixelFormat format, bool is_yuv444)
 Allocate the underlying object and wrap it in the owning handle.
 
static std::optional< sws_tmake_nv12 (int in_width, int in_height, int out_width, int out_height, gl::tex_t &&tex)
 Create a software-scaling pipeline that renders to NV12 planes.
 
static std::optional< sws_tmake_yuv444 (int in_width, int in_height, int out_width, int out_height, gl::tex_t &&tex)
 Create a software-scaling pipeline that renders to YUV444 planes.
 

Public Attributes

gl::buffer_t color_matrix
 Color matrix.
 
gl::frame_buf_t copy_framebuffer
 Copy framebuffer.
 
gl::frame_buf_t cursor_framebuffer
 Cursor framebuffer.
 
int in_height
 In height.
 
int in_width
 In width.
 
int loaded_texture
 Loaded texture.
 
int offsetX
 Offset x.
 
int offsetY
 Offset y.
 
int out_height
 Out height.
 
int out_width
 Out width.
 
std::array< gl::program_t, 4 > program
 Program.
 
std::uint64_t serial
 Serial.
 
gl::tex_t tex
 Source and cursor textures used by the conversion pipeline.
 

Detailed Description

EGL/OpenGL scaler and colorspace conversion pipeline.

Member Function Documentation

◆ apply_colorspace()

void egl::sws_t::apply_colorspace ( const video::sunshine_colorspace_t & colorspace,
bool is_yuv444 )

Apply the configured colorspace metadata to the active frame.

Parameters
colorspaceColorimetry information used for conversion or encoding.
is_yuv444Is YUV444.

◆ blank()

int egl::sws_t::blank ( gl::frame_buf_t & fb,
int offsetX_,
int offsetY_,
int width,
int height,
bool is_yuv444 )

Clear the render target to a blank frame.

Parameters
fbFramebuffer object to bind or update.
offsetX_Offset x.
offsetY_Offset y.
widthFrame or display width in pixels.
heightFrame or display height in pixels.
is_yuv444Is YUV444.
Returns
0 when the target area is cleared; nonzero on OpenGL failure.

◆ convert_nv12()

int egl::sws_t::convert_nv12 ( gl::frame_buf_t & fb)

Convert the loaded source image into NV12 output planes.

Parameters
fbFramebuffer object to bind or update.
Returns
Conversion status.

◆ convert_yuv444()

int egl::sws_t::convert_yuv444 ( gl::frame_buf_t & fb)

Convert the loaded source image into YUV444 output planes.

Parameters
fbFramebuffer object to bind or update.
Returns
Conversion status.

◆ draw_programs_to_buffers()

int egl::sws_t::draw_programs_to_buffers ( GLenum attachments[],
gl::frame_buf_t & fb,
int count,
bool is_yuv444 )

Render the loaded source texture into output framebuffers.

Parameters
attachmentsFramebuffer attachments to bind.
fbFramebuffer object to bind or update.
countNumber of output planes to draw.
is_yuv444Whether to render three YUV444 planes instead of NV12 planes.
Returns
0 when all draw calls complete; nonzero on OpenGL failure.

◆ load_ram()

void egl::sws_t::load_ram ( platf::img_t & img)

Load ram data from the backing API or store.

Parameters
imgImage or frame object to read from or populate.

◆ load_vram()

void egl::sws_t::load_vram ( img_descriptor_t & img,
int offset_x,
int offset_y,
int texture,
bool is_yuv444 )

Load vram data from the backing API or store.

Parameters
imgImage or frame object to read from or populate.
offset_xOffset x.
offset_yOffset y.
textureTexture resource to bind, update, or attach.
is_yuv444Is YUV444.

◆ make()

std::optional< sws_t > egl::sws_t::make ( int in_width,
int in_height,
int out_width,
int out_height,
AVPixelFormat format,
bool is_yuv444 )
static

Allocate the underlying object and wrap it in the owning handle.

Parameters
in_widthSource frame width in pixels.
in_heightSource frame height in pixels.
out_widthDestination frame width in pixels.
out_heightDestination frame height in pixels.
formatDestination FFmpeg pixel format.
is_yuv444Whether the destination uses three full-resolution planes.
Returns
Created backend object, or null when creation fails.

◆ make_nv12()

std::optional< sws_t > egl::sws_t::make_nv12 ( int in_width,
int in_height,
int out_width,
int out_height,
gl::tex_t && tex )
static

Create a software-scaling pipeline that renders to NV12 planes.

Parameters
in_widthSource frame width in pixels.
in_heightSource frame height in pixels.
out_widthDestination frame width in pixels.
out_heightDestination frame height in pixels.
texTexture resource used by the converter.
Returns
Constructed NV12 object.

◆ make_yuv444()

std::optional< sws_t > egl::sws_t::make_yuv444 ( int in_width,
int in_height,
int out_width,
int out_height,
gl::tex_t && tex )
static

Create a software-scaling pipeline that renders to YUV444 planes.

Parameters
in_widthSource frame width in pixels.
in_heightSource frame height in pixels.
out_widthDestination frame width in pixels.
out_heightDestination frame height in pixels.
texTexture resource used by the converter.
Returns
Constructed YUV444 object.

The documentation for this class was generated from the following files: