xine-lib 1.2.11
Data Structures | Macros | Functions | Variables
video_out_opengl2.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#include <errno.h>
#include <ctype.h>
#include <pthread.h>
#include <xine.h>
#include <xine/video_out.h>
#include <xine/vo_scale.h>
#include <xine/xine_internal.h>
#include <xine/xineutils.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include "opengl/xine_gl.h"
#include "color_matrix.c"

Data Structures

struct  opengl2_frame_t
 
struct  opengl2_overlay_t
 
struct  opengl2_program_t
 
struct  opengl2_yuvtex_t
 
struct  opengl2_driver_t
 
struct  opengl2_class_t
 
struct  opengl2_rect_t
 

Macros

#define LOG_MODULE   "video_out_opengl2"
 
#define GL_GLEXT_PROTOTYPES
 
#define MAX_EXIT_TARGETS   8
 
#define CM_LUT
 
#define CM_HAVE_YCGCO_SUPPORT   1
 
#define CM_DRIVER_T   opengl2_driver_t
 
#define LUTWIDTH   1000
 
#define N_SPLINES   2
 
#define CATMULLROM_SPLINE   0
 
#define COS_SPLINE   1
 
#define INITWIDTH   720
 
#define INITHEIGHT   576
 

Functions

static void opengl2_exit (void)
 
static void opengl2_exit_unregister (opengl2_driver_t *this)
 
static void opengl2_exit_register (opengl2_driver_t *this)
 
static float compute_cos_spline (float x)
 
static float compute_catmullrom_spline (float x)
 
static int create_lut_texture (opengl2_driver_t *that)
 
static void load_csc_matrix (GLuint prog, float *cf)
 
static int opengl2_build_program (opengl2_driver_t *this, opengl2_program_t *prog, const char **source, const char *name)
 
static void opengl2_delete_program (opengl2_program_t *prog)
 
static int opengl2_check_textures_size (opengl2_driver_t *this_gen, int w, int h)
 
static void opengl2_upload_overlay (opengl2_driver_t *this, opengl2_overlay_t *o, vo_overlay_t *overlay)
 
static void opengl2_overlay_begin (vo_driver_t *this_gen, vo_frame_t *frame_gen, int changed)
 
static void opengl2_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay)
 
static void opengl2_overlay_end (vo_driver_t *this_gen, vo_frame_t *vo_img)
 
static void opengl2_frame_proc_slice (vo_frame_t *vo_img, uint8_t **src)
 
static void opengl2_frame_field (vo_frame_t *vo_img, int which_field)
 
static void opengl2_frame_dispose (vo_frame_t *vo_img)
 
static vo_frame_topengl2_alloc_frame (vo_driver_t *this_gen)
 
static void opengl2_update_frame_format (vo_driver_t *this_gen, vo_frame_t *frame_gen, uint32_t width, uint32_t height, double ratio, int format, int flags)
 
static int opengl2_redraw_needed (vo_driver_t *this_gen)
 
static void opengl2_update_csc_matrix (opengl2_driver_t *that, opengl2_frame_t *frame)
 
static void opengl2_update_overlays (opengl2_driver_t *that)
 
static void opengl2_rect_set (opengl2_rect_t *r, opengl2_overlay_t *o)
 
static void opengl2_rect_scale (opengl2_rect_t *r, float fx, float fy)
 
static void opengl2_draw_scaled_overlays (opengl2_driver_t *that, opengl2_frame_t *frame)
 
static void opengl2_draw_unscaled_overlays (opengl2_driver_t *that)
 
static GLuint opengl2_swap_textures (opengl2_driver_t *that, GLuint current_dest)
 
static GLuint opengl2_sharpness (opengl2_driver_t *that, opengl2_frame_t *frame, GLuint video_texture)
 
static int opengl2_draw_video_bicubic (opengl2_driver_t *that, int guiw, int guih, GLfloat u, GLfloat v, GLfloat u1, GLfloat v1, GLfloat x, GLfloat y, GLfloat x1, GLfloat y1, GLuint video_texture)
 
static int opengl2_draw_video_cubic_x (opengl2_driver_t *that, int guiw, int guih, GLfloat u, GLfloat v, GLfloat u1, GLfloat v1, GLfloat x, GLfloat y, GLfloat x1, GLfloat y1, GLuint video_texture)
 
static int opengl2_draw_video_cubic_y (opengl2_driver_t *that, int guiw, int guih, GLfloat u, GLfloat v, GLfloat u1, GLfloat v1, GLfloat x, GLfloat y, GLfloat x1, GLfloat y1, GLuint video_texture)
 
static int opengl2_draw_video_simple (opengl2_driver_t *that, int guiw, int guih, GLfloat u, GLfloat v, GLfloat u1, GLfloat v1, GLfloat x, GLfloat y, GLfloat x1, GLfloat y1, GLuint video_texture)
 
static void opengl2_draw_video_bilinear (opengl2_driver_t *that, int guiw, int guih, GLfloat u, GLfloat v, GLfloat u1, GLfloat v1, GLfloat x, GLfloat y, GLfloat x1, GLfloat y1, GLuint video_texture)
 
static void opengl2_draw (opengl2_driver_t *that, opengl2_frame_t *frame)
 
static void opengl2_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen)
 
static int opengl2_get_property (vo_driver_t *this_gen, int property)
 
static int opengl2_set_property (vo_driver_t *this_gen, int property, int value)
 
static void opengl2_get_property_min_max (vo_driver_t *this_gen, int property, int *min, int *max)
 
static int opengl2_gui_data_exchange (vo_driver_t *this_gen, int data_type, void *data)
 
static uint32_t opengl2_get_capabilities (vo_driver_t *this_gen)
 
static void opengl2_set_bicubic (void *this_gen, xine_cfg_entry_t *entry)
 
static void opengl2_dispose (vo_driver_t *this_gen)
 
static vo_driver_topengl2_open_plugin (video_driver_class_t *class_gen, const void *visual_gen)
 
static int opengl2_check_platform (xine_t *xine, unsigned visual_type, const void *visual)
 
static void * opengl2_init_class (xine_t *xine, unsigned visual_type, const void *visual_gen)
 
static void * opengl2_init_class_x11 (xine_t *xine, const void *visual_gen)
 
static void * opengl2_init_class_wl (xine_t *xine, const void *visual_gen)
 

Variables

opengl2_driver_topengl2_exit_vector [8]
 
static const char * bicubic_pass1_frag
 
static const char * bicubic_pass2_frag
 
static const char * blur_sharpen_frag
 
static const char * yuv420_frag
 
static const char * yuv422_frag
 
static const vo_info_t vo_info_opengl2
 
static const vo_info_t vo_info_opengl2_wl
 
const plugin_info_t xine_plugin_info[] EXPORTED
 

Macro Definition Documentation

◆ CATMULLROM_SPLINE

#define CATMULLROM_SPLINE   0

◆ CM_DRIVER_T

#define CM_DRIVER_T   opengl2_driver_t

◆ CM_HAVE_YCGCO_SUPPORT

#define CM_HAVE_YCGCO_SUPPORT   1

◆ CM_LUT

#define CM_LUT

◆ COS_SPLINE

#define COS_SPLINE   1

◆ GL_GLEXT_PROTOTYPES

#define GL_GLEXT_PROTOTYPES

◆ INITHEIGHT

#define INITHEIGHT   576

◆ INITWIDTH

#define INITWIDTH   720

◆ LOG_MODULE

#define LOG_MODULE   "video_out_opengl2"

◆ LUTWIDTH

#define LUTWIDTH   1000

◆ MAX_EXIT_TARGETS

#define MAX_EXIT_TARGETS   8

◆ N_SPLINES

#define N_SPLINES   2

Function Documentation

◆ compute_catmullrom_spline()

static float compute_catmullrom_spline ( float  x)
static

Referenced by create_lut_texture().

◆ compute_cos_spline()

static float compute_cos_spline ( float  x)
static

Referenced by create_lut_texture().

◆ create_lut_texture()

static int create_lut_texture ( opengl2_driver_t that)
static

◆ load_csc_matrix()

static void load_csc_matrix ( GLuint  prog,
float *  cf 
)
static

Referenced by opengl2_draw().

◆ opengl2_alloc_frame()

static vo_frame_t * opengl2_alloc_frame ( vo_driver_t this_gen)
static

◆ opengl2_build_program()

static int opengl2_build_program ( opengl2_driver_t this,
opengl2_program_t prog,
const char **  source,
const char *  name 
)
static

◆ opengl2_check_platform()

static int opengl2_check_platform ( xine_t xine,
unsigned  visual_type,
const void *  visual 
)
static

◆ opengl2_check_textures_size()

static int opengl2_check_textures_size ( opengl2_driver_t this_gen,
int  w,
int  h 
)
static

◆ opengl2_delete_program()

static void opengl2_delete_program ( opengl2_program_t prog)
static

◆ opengl2_display_frame()

static void opengl2_display_frame ( vo_driver_t this_gen,
vo_frame_t frame_gen 
)
static

◆ opengl2_dispose()

static void opengl2_dispose ( vo_driver_t this_gen)
static

◆ opengl2_draw()

static void opengl2_draw ( opengl2_driver_t that,
opengl2_frame_t frame 
)
static

◆ opengl2_draw_scaled_overlays()

static void opengl2_draw_scaled_overlays ( opengl2_driver_t that,
opengl2_frame_t frame 
)
static

◆ opengl2_draw_unscaled_overlays()

static void opengl2_draw_unscaled_overlays ( opengl2_driver_t that)
static

◆ opengl2_draw_video_bicubic()

static int opengl2_draw_video_bicubic ( opengl2_driver_t that,
int  guiw,
int  guih,
GLfloat  u,
GLfloat  v,
GLfloat  u1,
GLfloat  v1,
GLfloat  x,
GLfloat  y,
GLfloat  x1,
GLfloat  y1,
GLuint  video_texture 
)
static

◆ opengl2_draw_video_bilinear()

static void opengl2_draw_video_bilinear ( opengl2_driver_t that,
int  guiw,
int  guih,
GLfloat  u,
GLfloat  v,
GLfloat  u1,
GLfloat  v1,
GLfloat  x,
GLfloat  y,
GLfloat  x1,
GLfloat  y1,
GLuint  video_texture 
)
static

Referenced by opengl2_draw().

◆ opengl2_draw_video_cubic_x()

static int opengl2_draw_video_cubic_x ( opengl2_driver_t that,
int  guiw,
int  guih,
GLfloat  u,
GLfloat  v,
GLfloat  u1,
GLfloat  v1,
GLfloat  x,
GLfloat  y,
GLfloat  x1,
GLfloat  y1,
GLuint  video_texture 
)
static

◆ opengl2_draw_video_cubic_y()

static int opengl2_draw_video_cubic_y ( opengl2_driver_t that,
int  guiw,
int  guih,
GLfloat  u,
GLfloat  v,
GLfloat  u1,
GLfloat  v1,
GLfloat  x,
GLfloat  y,
GLfloat  x1,
GLfloat  y1,
GLuint  video_texture 
)
static

◆ opengl2_draw_video_simple()

static int opengl2_draw_video_simple ( opengl2_driver_t that,
int  guiw,
int  guih,
GLfloat  u,
GLfloat  v,
GLfloat  u1,
GLfloat  v1,
GLfloat  x,
GLfloat  y,
GLfloat  x1,
GLfloat  y1,
GLuint  video_texture 
)
static

Referenced by opengl2_draw().

◆ opengl2_exit()

static void opengl2_exit ( void  )
static

◆ opengl2_exit_register()

static void opengl2_exit_register ( opengl2_driver_t this)
static

◆ opengl2_exit_unregister()

static void opengl2_exit_unregister ( opengl2_driver_t this)
static

References MAX_EXIT_TARGETS, NULL, and opengl2_exit_vector.

Referenced by opengl2_dispose().

◆ opengl2_frame_dispose()

static void opengl2_frame_dispose ( vo_frame_t vo_img)
static

◆ opengl2_frame_field()

static void opengl2_frame_field ( vo_frame_t vo_img,
int  which_field 
)
static

Referenced by opengl2_alloc_frame().

◆ opengl2_frame_proc_slice()

static void opengl2_frame_proc_slice ( vo_frame_t vo_img,
uint8_t **  src 
)
static

References vo_frame_s::proc_called.

Referenced by opengl2_alloc_frame().

◆ opengl2_get_capabilities()

static uint32_t opengl2_get_capabilities ( vo_driver_t this_gen)
static

◆ opengl2_get_property()

static int opengl2_get_property ( vo_driver_t this_gen,
int  property 
)
static

◆ opengl2_get_property_min_max()

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

◆ opengl2_gui_data_exchange()

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

◆ opengl2_init_class()

static void * opengl2_init_class ( xine_t xine,
unsigned  visual_type,
const void *  visual_gen 
)
static

◆ opengl2_init_class_wl()

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

◆ opengl2_init_class_x11()

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

◆ opengl2_open_plugin()

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

◆ opengl2_overlay_begin()

static void opengl2_overlay_begin ( vo_driver_t this_gen,
vo_frame_t frame_gen,
int  changed 
)
static

Referenced by opengl2_open_plugin().

◆ opengl2_overlay_blend()

static void opengl2_overlay_blend ( vo_driver_t this_gen,
vo_frame_t frame_gen,
vo_overlay_t overlay 
)
static

◆ opengl2_overlay_end()

static void opengl2_overlay_end ( vo_driver_t this_gen,
vo_frame_t vo_img 
)
static

References XINE_VORAW_MAX_OVL.

Referenced by opengl2_open_plugin().

◆ opengl2_rect_scale()

static void opengl2_rect_scale ( opengl2_rect_t r,
float  fx,
float  fy 
)
static

◆ opengl2_rect_set()

static void opengl2_rect_set ( opengl2_rect_t r,
opengl2_overlay_t o 
)
static

◆ opengl2_redraw_needed()

static int opengl2_redraw_needed ( vo_driver_t this_gen)
static

◆ opengl2_set_bicubic()

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

◆ opengl2_set_property()

static int opengl2_set_property ( vo_driver_t this_gen,
int  property,
int  value 
)
static

◆ opengl2_sharpness()

static GLuint opengl2_sharpness ( opengl2_driver_t that,
opengl2_frame_t frame,
GLuint  video_texture 
)
static

◆ opengl2_swap_textures()

static GLuint opengl2_swap_textures ( opengl2_driver_t that,
GLuint  current_dest 
)
static

◆ opengl2_update_csc_matrix()

static void opengl2_update_csc_matrix ( opengl2_driver_t that,
opengl2_frame_t frame 
)
static

◆ opengl2_update_frame_format()

static void opengl2_update_frame_format ( vo_driver_t this_gen,
vo_frame_t frame_gen,
uint32_t  width,
uint32_t  height,
double  ratio,
int  format,
int  flags 
)
static

◆ opengl2_update_overlays()

static void opengl2_update_overlays ( opengl2_driver_t that)
static

◆ opengl2_upload_overlay()

static void opengl2_upload_overlay ( opengl2_driver_t this,
opengl2_overlay_t o,
vo_overlay_t overlay 
)
static

Variable Documentation

◆ bicubic_pass1_frag

const char* bicubic_pass1_frag
static
Initial value:
=
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex, lut;\n"
"uniform float spline;\n"
"void main() {\n"
" vec2 coord = gl_TexCoord[0].xy;\n"
" vec2 TexCoord = vec2( floor( coord.x - 0.5 ) + 0.5, coord.y );\n"
" vec4 wlut = texture2DRect( lut, vec2( ( coord.x - TexCoord.x ) * 1000.0, spline ) );\n"
" vec4 sum = texture2DRect( tex, TexCoord + vec2( -1.0, 0.0) ) * wlut[0];\n"
" sum += texture2DRect( tex, TexCoord ) * wlut[1];\n"
" sum += texture2DRect( tex, TexCoord + vec2( 1.0, 0.0) ) * wlut[2];\n"
" sum += texture2DRect( tex, TexCoord + vec2( 2.0, 0.0) ) * wlut[3];\n"
" gl_FragColor = sum;\n"
"}\n"

Referenced by opengl2_draw_video_bicubic(), and opengl2_draw_video_cubic_x().

◆ bicubic_pass2_frag

const char* bicubic_pass2_frag
static
Initial value:
=
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex, lut;\n"
"uniform float spline;\n"
"void main() {\n"
" vec2 coord = gl_TexCoord[0].xy;\n"
" vec2 TexCoord = vec2( coord.x, floor( coord.y - 0.5 ) + 0.5 );\n"
" vec4 wlut = texture2DRect( lut, vec2( ( coord.y - TexCoord.y ) * 1000.0, spline ) );\n"
" vec4 sum = texture2DRect( tex, TexCoord + vec2( 0.0, -1.0 ) ) * wlut[0];\n"
" sum += texture2DRect( tex, TexCoord ) * wlut[1];\n"
" sum += texture2DRect( tex, TexCoord + vec2( 0.0, 1.0 ) ) * wlut[2];\n"
" sum += texture2DRect( tex, TexCoord + vec2( 0.0, 2.0 ) ) * wlut[3];\n"
" gl_FragColor = sum;\n"
"}\n"

Referenced by opengl2_draw_video_bicubic(), and opengl2_draw_video_cubic_y().

◆ blur_sharpen_frag

const char* blur_sharpen_frag
static
Initial value:
=
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;\n"
"uniform float value;\n"
"void main() {\n"
" vec2 pos = gl_TexCoord[0].xy;\n"
" vec4 c1;\n"
" float K;\n"
" if ( value < 0.0 )\n"
" K = value / 8.0;\n"
" else\n"
" K = value / 4.0;\n"
" c1 = texture2DRect( tex, pos ) * (1.0 + (8.0 * K));\n"
" c1 -= texture2DRect( tex, pos + vec2( 1.0, 0.0 ) ) * K;\n"
" c1 -= texture2DRect( tex, pos + vec2( -1.0, 0.0 ) ) * K;\n"
" c1 -= texture2DRect( tex, pos + vec2( 0.0, 1.0 ) ) * K;\n"
" c1 -= texture2DRect( tex, pos + vec2( 0.0, -1.0 ) ) * K;\n"
" c1 -= texture2DRect( tex, pos + vec2( 1.0, 1.0 ) ) * K;\n"
" c1 -= texture2DRect( tex, pos + vec2( -1.0, 1.0 ) ) * K;\n"
" c1 -= texture2DRect( tex, pos + vec2( -1.0, -1.0 ) ) * K;\n"
" c1 -= texture2DRect( tex, pos + vec2( 1.0, -1.0 ) ) * K;\n"
" gl_FragColor = c1 ;\n"
"}\n"

Referenced by opengl2_sharpness().

◆ EXPORTED

const plugin_info_t xine_plugin_info [] EXPORTED
Initial value:
= {
{ PLUGIN_NONE, 0, NULL, 0, NULL, NULL }
}
static void * opengl2_init_class_x11(xine_t *xine, const void *visual_gen)
Definition: video_out_opengl2.c:2036
static void * opengl2_init_class_wl(xine_t *xine, const void *visual_gen)
Definition: video_out_opengl2.c:2041
static const vo_info_t vo_info_opengl2
Definition: video_out_opengl2.c:2047
static const vo_info_t vo_info_opengl2_wl
Definition: video_out_opengl2.c:2052
#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

◆ opengl2_exit_vector

opengl2_driver_t* opengl2_exit_vector[8]

◆ vo_info_opengl2

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

◆ vo_info_opengl2_wl

const vo_info_t vo_info_opengl2_wl
static
Initial value:
= {
.priority = 8,
.visual_type = XINE_VISUAL_TYPE_WAYLAND,
}
#define XINE_VISUAL_TYPE_WAYLAND
Definition: xine.h:166

◆ yuv420_frag

const char* yuv420_frag
static
Initial value:
=
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect texY, texU, texV;\n"
"uniform vec4 r_coefs, g_coefs, b_coefs;\n"
"void main(void) {\n"
" vec4 rgb;\n"
" vec4 yuv;\n"
" vec2 ycoord = gl_TexCoord[0].xy;\n"
" vec2 uvcoord = ycoord / 2.0;\n"
" yuv.r = texture2DRect( texY, ycoord ).r;\n"
" yuv.g = texture2DRect( texU, uvcoord ).r;\n"
" yuv.b = texture2DRect( texV, uvcoord ).r;\n"
" yuv.a = 1.0;\n"
" rgb.r = dot( yuv, r_coefs );\n"
" rgb.g = dot( yuv, g_coefs );\n"
" rgb.b = dot( yuv, b_coefs );\n"
" rgb.a = 1.0;\n"
" gl_FragColor = rgb;\n"
"}\n"

Referenced by opengl2_open_plugin().

◆ yuv422_frag

const char* yuv422_frag
static
Initial value:
=
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect texYUV;\n"
"uniform vec4 r_coefs, g_coefs, b_coefs;\n"
"void main(void) {\n"
" vec3 rgb;\n"
" vec4 yuv;\n"
" vec4 coord = gl_TexCoord[0].xyxx;\n"
" coord.z -= step(1.0, mod(coord.x, 2.0));\n"
" coord.w = coord.z + 1.0;\n"
" yuv.r = texture2DRect(texYUV, coord.xy).r;\n"
" yuv.g = texture2DRect(texYUV, coord.zy).a;\n"
" yuv.b = texture2DRect(texYUV, coord.wy).a;\n"
" yuv.a = 1.0;\n"
" rgb.r = dot( yuv, r_coefs );\n"
" rgb.g = dot( yuv, g_coefs );\n"
" rgb.b = dot( yuv, b_coefs );\n"
" gl_FragColor = vec4(rgb, 1.0);\n"
"}\n"

Referenced by opengl2_open_plugin().