Sunshine latest
Self-hosted game stream host for Moonlight.
vaapi.cpp File Reference

Definitions for VA-API hardware accelerated capture. More...

#include <fcntl.h>
#include <sstream>
#include <string>
#include <libavcodec/avcodec.h>
#include <libavutil/pixdesc.h>
#include <va/va.h>
#include <va/va_drm.h>
#include "graphics.h"
#include "misc.h"
#include "src/config.h"
#include "src/logging.h"
#include "src/platform/common.h"
#include "src/utility.h"
#include "src/video.h"
Include dependency graph for vaapi.cpp:

Classes

struct  va::AVVAAPIDeviceContext
 
struct  va::DRMPRIMESurfaceDescriptor
 
class  va::va_ram_t
 
class  va::va_t
 
class  va::va_vram_t
 
struct  va::VAAPIDevicePriv
 

Typedefs

typedef struct va::AVVAAPIDeviceContext va::AVVAAPIDeviceContext
 
using va::display_t = util::safe_ptr_v2<void, VAStatus, vaTerminate>
 
typedef struct va::VAAPIDevicePriv va::VAAPIDevicePriv
 
using va::VADisplay = void *
 
using va::VAGenericID = unsigned int
 
using va::VAStatus = int
 
using va::VASurfaceID = VAGenericID
 

Functions

std::unique_ptr< platf::avcodec_encode_device_tva::make_avcodec_encode_device (int width, int height, bool vram)
 
std::unique_ptr< platf::avcodec_encode_device_tva::make_avcodec_encode_device (int width, int height, file_t &&card, int offset_x, int offset_y, bool vram)
 
std::unique_ptr< platf::avcodec_encode_device_tva::make_avcodec_encode_device (int width, int height, int offset_x, int offset_y, bool vram)
 
int va::vaapi_init_avcodec_hardware_input_buffer (platf::avcodec_encode_device_t *encode_device, AVBufferRef **hw_device_buf)
 
bool va::validate (int fd)
 
VAStatus vaSyncBuffer (VADisplay dpy, VABufferID buf_id, uint64_t timeout_ns)
 

Variables

constexpr auto va::EXPORT_SURFACE_SEPARATE_LAYERS = 0x0004
 
constexpr auto va::EXPORT_SURFACE_WRITE_ONLY = 0x0002
 
constexpr auto va::SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 = 0x40000000
 

Detailed Description

Definitions for VA-API hardware accelerated capture.

Typedef Documentation

◆ AVVAAPIDeviceContext

typedef struct va::AVVAAPIDeviceContext va::AVVAAPIDeviceContext

VAAPI connection details.

Allocated as AVHWDeviceContext.hwctx

◆ VAAPIDevicePriv

typedef struct va::VAAPIDevicePriv va::VAAPIDevicePriv

This is a private structure of FFmpeg, I need this to manually create a VAAPI hardware context

xdisplay will not be used internally by FFmpeg

Function Documentation

◆ make_avcodec_encode_device()

std::unique_ptr< platf::avcodec_encode_device_t > va::make_avcodec_encode_device ( int width,
int height,
bool vram )

Width --> Width of the image Height --> Height of the image offset_x --> Horizontal offset of the image in the texture offset_y --> Vertical offset of the image in the texture file_t card --> The file descriptor of the render device used for encoding