Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
vaapi.cpp File Reference

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

#include <algorithm>
#include <fcntl.h>
#include <format>
#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:

Go to the source code of this file.

Classes

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

Typedefs

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

Functions

VAStatus vaSyncBuffer (VADisplay dpy, VABufferID buf_id, uint64_t timeout_ns)
int va::vaapi_init_avcodec_hardware_input_buffer (platf::avcodec_encode_device_t *encode_device, AVBufferRef **hw_device_buf)
bool va::validate (int fd)
int va::encode_capability (int fd)
 Rank what the GPU behind fd can encode, for choosing between GPUs.
std::unique_ptr< platf::avcodec_encode_device_t > va::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_t > va::make_avcodec_encode_device (int width, int height, int offset_x, int offset_y, bool vram)
std::unique_ptr< platf::avcodec_encode_device_t > va::make_avcodec_encode_device (int width, int height, bool vram)

Variables

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

Detailed Description

Definitions for VA-API hardware accelerated capture.

Definition in file vaapi.cpp.

Typedef Documentation

◆ AVVAAPIDeviceContext

typedef struct va::AVVAAPIDeviceContext va::AVVAAPIDeviceContext

VAAPI connection details.

Allocated as AVHWDeviceContext.hwctx

◆ display_t

using va::display_t = util::safe_ptr_v2<void, VAStatus, vaTerminate>

Definition at line 95 of file vaapi.cpp.

◆ 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

◆ VADisplay

using va::VADisplay = void *

Definition at line 48 of file vaapi.cpp.

◆ VAGenericID

using va::VAGenericID = unsigned int

Definition at line 50 of file vaapi.cpp.

◆ VAStatus

using va::VAStatus = int

Definition at line 49 of file vaapi.cpp.

◆ VASurfaceID

using va::VASurfaceID = VAGenericID

Definition at line 51 of file vaapi.cpp.

Function Documentation

◆ encode_capability()

int va::encode_capability ( int fd)

Rank what the GPU behind fd can encode, for choosing between GPUs.

Returns
0 when it cannot encode H.264 through VAAPI at all; otherwise 1 for H.264, plus 2 for HEVC, 4 for HEVC Main10 and 8 for AV1. Nothing is logged: this is asked of every GPU, including ones that are not meant to encode.

Definition at line 634 of file vaapi.cpp.

◆ make_avcodec_encode_device() [1/3]

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

Definition at line 707 of file vaapi.cpp.

◆ make_avcodec_encode_device() [2/3]

std::unique_ptr< platf::avcodec_encode_device_t > va::make_avcodec_encode_device ( int width,
int height,
file_t && card,
int offset_x,
int offset_y,
bool vram )

Definition at line 677 of file vaapi.cpp.

◆ make_avcodec_encode_device() [3/3]

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

Definition at line 697 of file vaapi.cpp.

◆ vaapi_init_avcodec_hardware_input_buffer()

int va::vaapi_init_avcodec_hardware_input_buffer ( platf::avcodec_encode_device_t * encode_device,
AVBufferRef ** hw_device_buf )

Definition at line 524 of file vaapi.cpp.

◆ validate()

bool va::validate ( int fd)

Definition at line 599 of file vaapi.cpp.

◆ vaSyncBuffer()

VAStatus vaSyncBuffer ( VADisplay dpy,
VABufferID buf_id,
uint64_t timeout_ns )

Definition at line 20 of file vaapi.cpp.

Variable Documentation

◆ EXPORT_SURFACE_SEPARATE_LAYERS

auto va::EXPORT_SURFACE_SEPARATE_LAYERS = 0x0004
constexpr

Definition at line 46 of file vaapi.cpp.

◆ EXPORT_SURFACE_WRITE_ONLY

auto va::EXPORT_SURFACE_WRITE_ONLY = 0x0002
constexpr

Definition at line 45 of file vaapi.cpp.

◆ SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2

auto va::SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 = 0x40000000
constexpr

Definition at line 44 of file vaapi.cpp.