xine-lib 1.2.13-20230125hg15249
Data Structures | Macros | Typedefs | Functions | Variables
video_out_vaapi.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/time.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <time.h>
#include <unistd.h>
#include "xine.h"
#include <xine/video_out.h>
#include <xine/xine_internal.h>
#include <xine/xineutils.h>
#include <xine/vo_scale.h>
#include <va/va_x11.h>
#include "vaapi/vaapi_util.h"
#include "vaapi/vaapi_frame.h"
#include "vaapi/xine_va_display.h"
#include <pthread.h>
#include "color_matrix.c"

Data Structures

struct  vaapi_rect_t
 
struct  va_property_t
 
struct  vaapi_driver_s
 
struct  vaapi_class_t
 

Macros

#define LOG_MODULE   "video_out_vaapi"
 
#define LOG_VERBOSE
 
#define vaCreateSurfaces(d, f, w, h, s, ns, a, na)    vaCreateSurfaces(d, w, h, f, ns, s)
 
#define MIN_SURFACES   22
 
#define SOFT_SURFACES   3
 
#define SW_WIDTH   1920
 
#define SW_HEIGHT   1080
 
#define STABLE_FRAME_COUNTER   4
 
#define SW_CONTEXT_INIT_FORMAT   -1
 
#define USE_VAAPI_COLORSPACE   0
 
#define FOVY   60.0f
 
#define ASPECT   1.0f
 
#define Z_NEAR   0.1f
 
#define Z_FAR   100.0f
 
#define Z_CAMERA   0.869f
 
#define GLAPIENTRY
 
#define LOCK_DISPLAY(_this)   XLockDisplay (_this->display)
 
#define UNLOCK_DISPLAY(_this)   XUnlockDisplay (_this->display)
 
#define RECT_IS_EQ(a, b)   ((a).x1 == (b).x1 && (a).y1 == (b).y1 && (a).x2 == (b).x2 && (a).y2 == (b).y2)
 
#define CSC_MODE_USER_MATRIX   0
 
#define CSC_MODE_FLAGS   1
 
#define CSC_MODE_FLAGS_FULLRANGE2   2
 
#define CSC_MODE_FLAGS_FULLRANGE3   3
 
#define CM_LUT
 
#define CM_HAVE_YCGCO_SUPPORT   1
 
#define CM_HAVE_BT2020_SUPPORT   1
 
#define CM_DRIVER_T   vaapi_driver_t
 
#define UMAX(a, b)   ((a) > (uint32_t)(b) ? (a) : (uint32_t)(b))
 

Typedefs

typedef struct vaapi_driver_s vaapi_driver_t
 

Functions

static void vaapi_destroy_subpicture (vaapi_driver_t *this)
 
static int vaapi_ovl_associate (vaapi_driver_t *this, int format, int bShow)
 
static VAStatus vaapi_destroy_soft_surfaces (vaapi_driver_t *this)
 
static int vaapi_set_property (vo_driver_t *this_gen, int property, int value)
 
static int vaapi_check_status (vaapi_driver_t *this, VAStatus vaStatus, const char *msg)
 
static int vaapi_lock_decode_guarded (vo_frame_t *frame_gen)
 
static void vaapi_unlock_decode_guarded (vo_frame_t *frame_gen)
 
static void vaapi_x11_wait_event (Display *dpy, Window w, int type)
 
static int vaapi_x11_error_handler (Display *dpy, XErrorEvent *error)
 
static void vaapi_x11_trap_errors (void)
 
static int vaapi_x11_untrap_errors (void)
 
static uint32_t vaapi_get_capabilities (vo_driver_t *this_gen)
 
static void vaapi_init_subpicture (vaapi_driver_t *this)
 
static void vaapi_close (vaapi_driver_t *this)
 
static VAStatus vaapi_create_subpicture (vaapi_driver_t *this, int width, int height)
 
static void vaapi_set_csc_mode (vaapi_driver_t *this, int new_mode)
 
static float vaapi_normalized_prop (vaapi_driver_t *this, int prop)
 
static void vaapi_update_csc (vaapi_driver_t *that, mem_frame_t *frame)
 
static void vaapi_property_callback (void *property_gen, xine_cfg_entry_t *entry)
 
static void vaapi_check_capability (vaapi_driver_t *this, int property, VADisplayAttribute attr, const char *config_name, const char *config_desc, const char *config_help)
 
static void vaapi_display_attribs (vaapi_driver_t *this)
 
static void vaapi_set_background_color (vaapi_driver_t *this)
 
static VAStatus vaapi_init_soft_surfaces (vaapi_driver_t *this, int width, int height)
 
static int _flush_recent_frames (vaapi_driver_t *this)
 
static VAStatus vaapi_init_internal (vaapi_driver_t *this, int va_profile, int width, int height)
 
static VAStatus vaapi_init (vo_frame_t *frame_gen, int va_profile, int width, int height)
 
static vo_frame_tvaapi_alloc_frame (vo_driver_t *this_gen)
 
static void vaapi_overlay_begin (vo_driver_t *this_gen, vo_frame_t *frame_gen, int changed)
 
static void vaapi_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay)
 
static void _merge_rects (vaapi_rect_t *rect, const vo_overlay_t *ovl)
 
static void vaapi_overlay_end (vo_driver_t *this_gen, vo_frame_t *frame_gen)
 
static int vaapi_redraw_needed (vo_driver_t *this_gen)
 
static VAStatus vaapi_software_render_frame (vaapi_driver_t *this, mem_frame_t *frame, VAImage *va_image, int is_bound, VASurfaceID va_surface_id)
 
static VAStatus vaapi_hardware_render_frame (vaapi_driver_t *this, mem_frame_t *frame, VASurfaceID va_surface_id)
 
static void _add_recent_frame (vaapi_driver_t *this, vo_frame_t *vo_frame)
 
static void vaapi_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen)
 
static int vaapi_get_property (vo_driver_t *this_gen, int property)
 
static void vaapi_get_property_min_max (vo_driver_t *this_gen, int property, int *min, int *max)
 
static int vaapi_gui_data_exchange (vo_driver_t *this_gen, int data_type, void *data)
 
static void vaapi_dispose_locked (vaapi_driver_t *this)
 
static void vaapi_dispose (vo_driver_t *this_gen)
 
static void vaapi_vdr_osd_width_flag (void *this_gen, xine_cfg_entry_t *entry)
 
static void vaapi_vdr_osd_height_flag (void *this_gen, xine_cfg_entry_t *entry)
 
static void vaapi_deinterlace_flag (void *this_gen, xine_cfg_entry_t *entry)
 
static void vaapi_scaling_level (void *this_gen, xine_cfg_entry_t *entry)
 
static void vaapi_swap_uv_planes (void *this_gen, xine_cfg_entry_t *entry)
 
static void vaapi_csc_mode (void *this_gen, xine_cfg_entry_t *entry)
 
static int vaapi_init_x11 (vaapi_driver_t *this)
 
static int vaapi_initialize (vaapi_driver_t *this, int visual_type, const void *visual)
 
static vo_driver_tvaapi_open_plugin (video_driver_class_t *class_gen, const void *visual_gen)
 
static void * vaapi_init_class (xine_t *xine, const void *visual_gen)
 

Variables

static const char *const scaling_level_enum_names []
 
static const int scaling_level_enum_values []
 
static int vaapi_x11_error_code = 0
 
static int(* vaapi_x11_old_error_handler )(Display *, XErrorEvent *)
 
static const char *const vaapi_csc_mode_labels []
 
static const vo_info_t vo_info_vaapi
 
const plugin_info_t xine_plugin_info[] EXPORTED
 

Macro Definition Documentation

◆ ASPECT

#define ASPECT   1.0f

◆ CM_DRIVER_T

#define CM_DRIVER_T   vaapi_driver_t

◆ CM_HAVE_BT2020_SUPPORT

#define CM_HAVE_BT2020_SUPPORT   1

◆ CM_HAVE_YCGCO_SUPPORT

#define CM_HAVE_YCGCO_SUPPORT   1

◆ CM_LUT

#define CM_LUT

◆ CSC_MODE_FLAGS

#define CSC_MODE_FLAGS   1

◆ CSC_MODE_FLAGS_FULLRANGE2

#define CSC_MODE_FLAGS_FULLRANGE2   2

Referenced by vaapi_update_csc().

◆ CSC_MODE_FLAGS_FULLRANGE3

#define CSC_MODE_FLAGS_FULLRANGE3   3

Referenced by vaapi_update_csc().

◆ CSC_MODE_USER_MATRIX

#define CSC_MODE_USER_MATRIX   0

◆ FOVY

#define FOVY   60.0f

◆ GLAPIENTRY

#define GLAPIENTRY

◆ LOCK_DISPLAY

#define LOCK_DISPLAY ( _this)    XLockDisplay (_this->display)

◆ LOG_MODULE

#define LOG_MODULE   "video_out_vaapi"

◆ LOG_VERBOSE

#define LOG_VERBOSE

◆ MIN_SURFACES

#define MIN_SURFACES   22

Referenced by vaapi_open_plugin().

◆ RECT_IS_EQ

#define RECT_IS_EQ ( a,
b )   ((a).x1 == (b).x1 && (a).y1 == (b).y1 && (a).x2 == (b).x2 && (a).y2 == (b).y2)

Referenced by vaapi_overlay_end().

◆ SOFT_SURFACES

#define SOFT_SURFACES   3

◆ STABLE_FRAME_COUNTER

#define STABLE_FRAME_COUNTER   4

◆ SW_CONTEXT_INIT_FORMAT

#define SW_CONTEXT_INIT_FORMAT   -1

◆ SW_HEIGHT

#define SW_HEIGHT   1080

Referenced by vaapi_initialize().

◆ SW_WIDTH

#define SW_WIDTH   1920

Referenced by vaapi_initialize().

◆ UMAX

#define UMAX ( a,
b )   ((a) > (uint32_t)(b) ? (a) : (uint32_t)(b))

◆ UNLOCK_DISPLAY

#define UNLOCK_DISPLAY ( _this)    XUnlockDisplay (_this->display)

◆ USE_VAAPI_COLORSPACE

#define USE_VAAPI_COLORSPACE   0

◆ vaCreateSurfaces

#define vaCreateSurfaces ( d,
f,
w,
h,
s,
ns,
a,
na )    vaCreateSurfaces(d, w, h, f, ns, s)

◆ Z_CAMERA

#define Z_CAMERA   0.869f

◆ Z_FAR

#define Z_FAR   100.0f

◆ Z_NEAR

#define Z_NEAR   0.1f

Typedef Documentation

◆ vaapi_driver_t

Function Documentation

◆ _add_recent_frame()

static void _add_recent_frame ( vaapi_driver_t * this,
vo_frame_t * vo_frame )
static

◆ _flush_recent_frames()

static int _flush_recent_frames ( vaapi_driver_t * this)
static

◆ _merge_rects()

static void _merge_rects ( vaapi_rect_t * rect,
const vo_overlay_t * ovl )
static

◆ vaapi_alloc_frame()

static vo_frame_t * vaapi_alloc_frame ( vo_driver_t * this_gen)
static

◆ vaapi_check_capability()

static void vaapi_check_capability ( vaapi_driver_t * this,
int property,
VADisplayAttribute attr,
const char * config_name,
const char * config_desc,
const char * config_help )
static

◆ vaapi_check_status()

static int vaapi_check_status ( vaapi_driver_t * this,
VAStatus vaStatus,
const char * msg )
static

◆ vaapi_close()

static void vaapi_close ( vaapi_driver_t * this)
static

◆ vaapi_create_subpicture()

static VAStatus vaapi_create_subpicture ( vaapi_driver_t * this,
int width,
int height )
static

◆ vaapi_csc_mode()

static void vaapi_csc_mode ( void * this_gen,
xine_cfg_entry_t * entry )
static

◆ vaapi_deinterlace_flag()

static void vaapi_deinterlace_flag ( void * this_gen,
xine_cfg_entry_t * entry )
static

◆ vaapi_destroy_soft_surfaces()

static VAStatus vaapi_destroy_soft_surfaces ( vaapi_driver_t * this)
static

◆ vaapi_destroy_subpicture()

static void vaapi_destroy_subpicture ( vaapi_driver_t * this)
static

◆ vaapi_display_attribs()

static void vaapi_display_attribs ( vaapi_driver_t * this)
static

◆ vaapi_display_frame()

static void vaapi_display_frame ( vo_driver_t * this_gen,
vo_frame_t * frame_gen )
static

◆ vaapi_dispose()

static void vaapi_dispose ( vo_driver_t * this_gen)
static

References lprintf, and vaapi_dispose_locked().

Referenced by vaapi_open_plugin().

◆ vaapi_dispose_locked()

static void vaapi_dispose_locked ( vaapi_driver_t * this)
static

◆ vaapi_get_capabilities()

static uint32_t vaapi_get_capabilities ( vo_driver_t * this_gen)
static

Referenced by vaapi_open_plugin().

◆ vaapi_get_property()

static int vaapi_get_property ( vo_driver_t * this_gen,
int property )
static

◆ vaapi_get_property_min_max()

static void vaapi_get_property_min_max ( vo_driver_t * this_gen,
int property,
int * min,
int * max )
static

Referenced by vaapi_open_plugin().

◆ vaapi_gui_data_exchange()

static int vaapi_gui_data_exchange ( vo_driver_t * this_gen,
int data_type,
void * data )
static

◆ vaapi_hardware_render_frame()

static VAStatus vaapi_hardware_render_frame ( vaapi_driver_t * this,
mem_frame_t * frame,
VASurfaceID va_surface_id )
static

◆ vaapi_init()

static VAStatus vaapi_init ( vo_frame_t * frame_gen,
int va_profile,
int width,
int height )
static

◆ vaapi_init_class()

static void * vaapi_init_class ( xine_t * xine,
const void * visual_gen )
static

◆ vaapi_init_internal()

static VAStatus vaapi_init_internal ( vaapi_driver_t * this,
int va_profile,
int width,
int height )
static

◆ vaapi_init_soft_surfaces()

static VAStatus vaapi_init_soft_surfaces ( vaapi_driver_t * this,
int width,
int height )
static

◆ vaapi_init_subpicture()

static void vaapi_init_subpicture ( vaapi_driver_t * this)
static

References NULL.

Referenced by vaapi_open_plugin().

◆ vaapi_init_x11()

static int vaapi_init_x11 ( vaapi_driver_t * this)
static

◆ vaapi_initialize()

static int vaapi_initialize ( vaapi_driver_t * this,
int visual_type,
const void * visual )
static

◆ vaapi_lock_decode_guarded()

static int vaapi_lock_decode_guarded ( vo_frame_t * frame_gen)
static

References vo_frame_s::driver.

Referenced by vaapi_alloc_frame().

◆ vaapi_normalized_prop()

static float vaapi_normalized_prop ( vaapi_driver_t * this,
int prop )
static

Referenced by vaapi_update_csc().

◆ vaapi_open_plugin()

static vo_driver_t * vaapi_open_plugin ( video_driver_class_t * class_gen,
const void * visual_gen )
static

◆ vaapi_overlay_begin()

static void vaapi_overlay_begin ( vo_driver_t * this_gen,
vo_frame_t * frame_gen,
int changed )
static

◆ vaapi_overlay_blend()

static void vaapi_overlay_blend ( vo_driver_t * this_gen,
vo_frame_t * frame_gen,
vo_overlay_t * overlay )
static

◆ vaapi_overlay_end()

static void vaapi_overlay_end ( vo_driver_t * this_gen,
vo_frame_t * frame_gen )
static

◆ vaapi_ovl_associate()

static int vaapi_ovl_associate ( vaapi_driver_t * this,
int format,
int bShow )
static

◆ vaapi_property_callback()

static void vaapi_property_callback ( void * property_gen,
xine_cfg_entry_t * entry )
static

◆ vaapi_redraw_needed()

static int vaapi_redraw_needed ( vo_driver_t * this_gen)
static

◆ vaapi_scaling_level()

static void vaapi_scaling_level ( void * this_gen,
xine_cfg_entry_t * entry )
static

◆ vaapi_set_background_color()

static void vaapi_set_background_color ( vaapi_driver_t * this)
static

◆ vaapi_set_csc_mode()

static void vaapi_set_csc_mode ( vaapi_driver_t * this,
int new_mode )
static

◆ vaapi_set_property()

static int vaapi_set_property ( vo_driver_t * this_gen,
int property,
int value )
static

◆ vaapi_software_render_frame()

static VAStatus vaapi_software_render_frame ( vaapi_driver_t * this,
mem_frame_t * frame,
VAImage * va_image,
int is_bound,
VASurfaceID va_surface_id )
static

◆ vaapi_swap_uv_planes()

static void vaapi_swap_uv_planes ( void * this_gen,
xine_cfg_entry_t * entry )
static

◆ vaapi_unlock_decode_guarded()

static void vaapi_unlock_decode_guarded ( vo_frame_t * frame_gen)
static

References vo_frame_s::driver.

Referenced by vaapi_alloc_frame().

◆ vaapi_update_csc()

static void vaapi_update_csc ( vaapi_driver_t * that,
mem_frame_t * frame )
static

◆ vaapi_vdr_osd_height_flag()

static void vaapi_vdr_osd_height_flag ( void * this_gen,
xine_cfg_entry_t * entry )
static

◆ vaapi_vdr_osd_width_flag()

static void vaapi_vdr_osd_width_flag ( void * this_gen,
xine_cfg_entry_t * entry )
static

◆ vaapi_x11_error_handler()

static int vaapi_x11_error_handler ( Display * dpy,
XErrorEvent * error )
static

References vaapi_x11_error_code.

Referenced by vaapi_x11_trap_errors().

◆ vaapi_x11_trap_errors()

static void vaapi_x11_trap_errors ( void )
static

◆ vaapi_x11_untrap_errors()

static int vaapi_x11_untrap_errors ( void )
static

◆ vaapi_x11_wait_event()

static void vaapi_x11_wait_event ( Display * dpy,
Window w,
int type )
static

References type, and xine_usec_sleep().

Referenced by vaapi_init_x11().

Variable Documentation

◆ EXPORTED

const plugin_info_t xine_plugin_info [] EXPORTED
Initial value:
= {
{ PLUGIN_NONE, 0, NULL, 0, NULL, NULL }
}
static void * vaapi_init_class(xine_t *xine, const void *visual_gen)
Definition video_out_vaapi.c:3027
static const vo_info_t vo_info_vaapi
Definition video_out_vaapi.c:3045
#define XINE_VERSION_CODE
Definition xine_internal.h:57
NULL
Definition xine_plugin.c:78
#define PLUGIN_NONE
Definition xine_plugin.h:29
#define PLUGIN_VIDEO_OUT
Definition xine_plugin.h:36

◆ scaling_level_enum_names

const char* const scaling_level_enum_names[]
static
Initial value:
= {
"default",
"fast",
"hq",
"nla",
}

Referenced by vaapi_init_internal(), and vaapi_open_plugin().

◆ scaling_level_enum_values

const int scaling_level_enum_values[]
static
Initial value:
= {
VA_FILTER_SCALING_DEFAULT,
VA_FILTER_SCALING_FAST,
VA_FILTER_SCALING_HQ,
VA_FILTER_SCALING_NL_ANAMORPHIC
}

Referenced by vaapi_open_plugin().

◆ vaapi_csc_mode_labels

const char* const vaapi_csc_mode_labels[]
static
Initial value:
= {
"user_matrix", "simple", "simple+2", "simple+3", NULL
}

Referenced by vaapi_update_csc().

◆ vaapi_x11_error_code

int vaapi_x11_error_code = 0
static

◆ vaapi_x11_old_error_handler

int(* vaapi_x11_old_error_handler) (Display *, XErrorEvent *) ( Display * ,
XErrorEvent *  )
static

◆ vo_info_vaapi

const vo_info_t vo_info_vaapi
static
Initial value:
= {
.priority = 9,
.visual_type = XINE_VISUAL_TYPE_X11,
}
#define XINE_VISUAL_TYPE_X11
Definition xine.h:154