xine-lib 1.2.11
xxmc.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2000-2020 the xine project
3 * Copyright (C) 2004 the unichrome project
4 *
5 * This file is part of xine, a free video player.
6 *
7 * xine is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * xine is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20 *
21 * video_out_xxmc.c, X11 decoding accelerated video extension interface for xine
22 *
23 * based on mpeg2dec code from
24 * Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
25 *
26 * Xv image support by Gerd Knorr <kraxel@goldbach.in-berlin.de>
27 *
28 * xine-specific code by Guenter Bartsch <bartscgr@studbox.uni-stuttgart.de>
29 *
30 * overlay support by James Courtier-Dutton <James@superbug.demon.co.uk> - July 2001
31 * X11 unscaled overlay support by Miguel Freitas - Nov 2003
32 * XxMC implementation by Thomas Hellström - August 2004
33 */
34
35#ifndef _XXMC_H
36#define _XXMC_H
37
38#define XVMC_THREAD_SAFE
39
40/*
41 * some implementations are not aware of the display having been locked
42 * already before calling the xvmc function and may therefore deadlock.
43 */
44/*
45#define XVMC_LOCKDISPLAY_SAFE
46*/
47
48#if defined(HAVE_CONFIG_H) && !defined(__XINE_LIB_CONFIG_H__)
49# error config.h not included
50#endif
51
52#include <stdio.h>
53#include <stdlib.h>
54#include <string.h>
55#include <errno.h>
56#include <math.h>
57
58#if defined (__SVR4) && defined (__sun)
59# include <sys/int_types.h>
60#else
61# include <stdint.h>
62#endif
63
64#include <sys/types.h>
65#if defined(__FreeBSD__)
66#include <machine/param.h>
67#endif
68#include <sys/ipc.h>
69#include <sys/shm.h>
70#include <sys/time.h>
71
72#include <X11/Xlib.h>
73#include <X11/Xutil.h>
74#include <X11/cursorfont.h>
75#include <X11/extensions/XShm.h>
76#include <X11/extensions/Xv.h>
77#include <X11/extensions/Xvlib.h>
78#include <X11/extensions/XvMClib.h>
79#ifdef HAVE_VLDXVMC
80 #include <X11/extensions/vldXvMC.h>
81#endif
82
83#define LOG_MODULE "video_out_xxmc"
84#define LOG_VERBOSE
85/*
86#define LOG
87*/
88
89#include "xine.h"
90#include <xine/video_out.h>
91#include <xine/xine_internal.h>
92#include <xine/xineutils.h>
93#include <xine/vo_scale.h>
94#include "x11osd.h"
95#include "accel_xvmc.h"
96
97#define FOURCC_IA44 0x34344149
98#define FOURCC_AI44 0x34344941
99#define XVMC_MAX_SURFACES 16
100#define XVMC_MAX_SUBPICTURES 4
101
103
104typedef struct {
106 XvMCBlockArray blocks; /* pointer to memory for dct block array */
108 XvMCMacroBlock *macroblockptr; /* pointer to current macro block */
109 XvMCMacroBlock *macroblockbaseptr; /* pointer to base MacroBlock in MB array */
110 XvMCMacroBlockArray macro_blocks; /* pointer to memory for macroblock array */
113
114
115typedef struct {
116 int value;
117 int min;
118 int max;
119 Atom atom;
120
122
125
126typedef struct {
128
130 double ratio;
131
132 XvImage *image;
133 XShmSegmentInfo shminfo;
134
135 /* XvMC specific stuff */
136
137 XvMCSurface *xvmc_surf;
141
142typedef struct{
143 unsigned int mpeg_flags;
144 unsigned int accel_flags;
145 unsigned int max_width;
146 unsigned int max_height;
147 unsigned int sub_max_width;
148 unsigned int sub_max_height;
150 XvImageFormatValues subPicType;
151 int flags;
153
161 pthread_mutex_t mutex;
163
164typedef struct context_lock_s {
165 pthread_mutex_t mutex;
166 pthread_cond_t cond;
169
170#define LOCK_AND_SURFACE_VALID(driver, surface) \
171 xvmc_context_reader_lock( &(driver)->xvmc_lock ); \
172 if (!xxmc_xvmc_surface_valid((driver),(surface))) { \
173 xvmc_context_reader_unlock( &(driver)->xvmc_lock ); \
174 return; \
175 }
176
177#if defined(XVMC_THREAD_SAFE) && defined(XVMC_LOCKDISPLAY_SAFE)
178#define XVMCLOCKDISPLAY(display)
179#define XVMCUNLOCKDISPLAY(display)
180#else
181#define XVMCLOCKDISPLAY(display) XLockDisplay(display)
182#define XVMCUNLOCKDISPLAY(display) XUnlockDisplay(display)
183#endif
184
187
189
190 /* X11 / Xv related stuff */
191 Display *display;
193 Drawable drawable;
194 unsigned int xv_format_yv12;
195 unsigned int xv_format_yuy2;
196 XVisualInfo vinfo;
197 GC gc;
198 XvPortID xv_port;
199 XColor black;
200
204 uint32_t capabilities;
208 int bob;
216
217 /* all scaling information goes here */
221 uint32_t colorkey;
222 int (*x11_old_error_handler) (Display *, XErrorEvent *);
224
225 /* XvMC related stuff here */
228 unsigned xvmc_num_cap;
229 unsigned int xvmc_max_subpic_x;
230 unsigned int xvmc_max_subpic_y;
234 XvMCSubpicture *old_subpic,*new_subpic;
241
242 /*
243 * These variables are protected by the context lock:
244 */
245
246 unsigned xvmc_cur_cap;
248 XvMCContext context;
251 unsigned xvmc_mpeg;
252 unsigned xvmc_accel;
254 unsigned xvmc_width;
255 unsigned xvmc_height;
259
260 /*
261 * Only creation and destruction of the below.
262 */
263
265 XvImage *subImage;
266 XShmSegmentInfo subShmInfo;
267
268 /*
269 * The mutex below is needed since XlockDisplay wasn't really enough
270 * to protect the XvMC Calls.
271 */
273
275};
276
277typedef struct {
279
282
285extern int xxmc_xvmc_surface_valid(xxmc_driver_t *this, XvMCSurface *surf);
286
287extern void xvmc_vld_slice(vo_frame_t *this_gen);
288extern void xvmc_vld_frame(struct vo_frame_s *this_gen);
289
290extern void xxmc_xvmc_proc_macro_block(int x, int y, int mb_type, int motion_type,
291 int (*mv_field_sel)[2], int *dmvector,
292 int cbp,
293 int dct_type, vo_frame_t *current_frame,
294 vo_frame_t *forward_ref_frame,
295 vo_frame_t *backward_ref_frame,
296 int picture_structure,
297 int second_field, int (*f_mot_pmv)[2],
298 int (*b_mot_pmv)[2]);
299
300#endif
unsigned int height
Definition: gfontrle.c:5
unsigned int width
Definition: gfontrle.c:4
#define VO_NUM_RECENT_FRAMES
Definition: video_out.h:288
#define VO_NUM_PROPERTIES
Definition: video_out.h:275
Definition: alphablend.h:30
Definition: configfile.h:46
Definition: configfile.h:83
Definition: xxmc.h:164
int num_readers
Definition: xxmc.h:167
pthread_cond_t cond
Definition: xxmc.h:166
pthread_mutex_t mutex
Definition: xxmc.h:165
Definition: video_out.h:426
Definition: video_out.h:50
Definition: video_out.h:59
Definition: vo_scale.h:39
Definition: x11osd.c:60
Definition: accel_xvmc.h:34
Definition: xine_internal.h:80
Definition: accel_xvmc.h:77
Definition: xxmc.h:142
XvImageFormatValues subPicType
Definition: xxmc.h:150
unsigned int accel_flags
Definition: xxmc.h:144
int type_id
Definition: xxmc.h:149
unsigned int sub_max_height
Definition: xxmc.h:148
unsigned int max_width
Definition: xxmc.h:145
int flags
Definition: xxmc.h:151
unsigned int max_height
Definition: xxmc.h:146
unsigned int sub_max_width
Definition: xxmc.h:147
unsigned int mpeg_flags
Definition: xxmc.h:143
Definition: xxmc.h:104
int num_blocks
Definition: xxmc.h:107
int slices
Definition: xxmc.h:111
XvMCMacroBlock * macroblockbaseptr
Definition: xxmc.h:109
XvMCBlockArray blocks
Definition: xxmc.h:106
xine_macroblocks_t xine_mc
Definition: xxmc.h:105
XvMCMacroBlockArray macro_blocks
Definition: xxmc.h:110
XvMCMacroBlock * macroblockptr
Definition: xxmc.h:108
Definition: xxmc.h:154
XvMCSubpicture subpictures[4]
Definition: xxmc.h:158
pthread_mutex_t mutex
Definition: xxmc.h:161
int subValid[4]
Definition: xxmc.h:160
int subInUse[4]
Definition: xxmc.h:159
int surfValid[16]
Definition: xxmc.h:157
int surfInUse[16]
Definition: xxmc.h:156
XvMCSurface surfaces[16]
Definition: xxmc.h:155
Definition: alphablend.h:55
Definition: xxmc.h:277
xine_t * xine
Definition: xxmc.h:280
video_driver_class_t driver_class
Definition: xxmc.h:278
Definition: xxmc.h:185
int reverse_nvidia_palette
Definition: xxmc.h:239
int use_pitch_alignment
Definition: xxmc.h:202
XvMCSubpicture * new_subpic
Definition: xxmc.h:234
float cpu_saver
Definition: xxmc.h:237
unsigned last_accel_request
Definition: xxmc.h:253
int bob
Definition: xxmc.h:208
uint32_t capabilities
Definition: xxmc.h:204
xvmc_surface_handler_t xvmc_surf_handler
Definition: xxmc.h:250
int xvmc_eventbase
Definition: xxmc.h:231
x11osd * xoverlay
Definition: xxmc.h:212
int xvmc_errbase
Definition: xxmc.h:232
int disable_bob_for_scaled_osd
Definition: xxmc.h:210
xvmc_capabilities_t * xvmc_cap
Definition: xxmc.h:227
xxmc_property_t props[VO_NUM_PROPERTIES]
Definition: xxmc.h:203
unsigned xvmc_cur_cap
Definition: xxmc.h:246
int screen
Definition: xxmc.h:192
int(* x11_old_error_handler)(Display *, XErrorEvent *)
Definition: xxmc.h:222
unsigned xvmc_mpeg
Definition: xxmc.h:251
xine_t * xine
Definition: xxmc.h:223
int use_shm
Definition: xxmc.h:201
int xoverlay_type
Definition: xxmc.h:214
int contextActive
Definition: xxmc.h:249
int cur_field
Definition: xxmc.h:207
int disable_bob_for_progressive_frames
Definition: xxmc.h:209
int have_xvmc_autopaint
Definition: xxmc.h:256
unsigned int xvmc_max_subpic_x
Definition: xxmc.h:229
int xvmc_xoverlay_type
Definition: xxmc.h:257
int deinterlace_enabled
Definition: xxmc.h:219
xxmc_frame_t * cur_frame
Definition: xxmc.h:206
vo_scale_t sc
Definition: xxmc.h:218
int use_colorkey
Definition: xxmc.h:220
xx44_palette_t palette
Definition: xxmc.h:235
int first_overlay
Definition: xxmc.h:236
unsigned int xvmc_max_subpic_y
Definition: xxmc.h:230
XVisualInfo vinfo
Definition: xxmc.h:196
int cpu_save_enabled
Definition: xxmc.h:238
int context_flags
Definition: xxmc.h:240
int scaled_osd_active
Definition: xxmc.h:211
unsigned xvmc_height
Definition: xxmc.h:255
int ovl_changed
Definition: xxmc.h:215
unsigned int xv_format_yv12
Definition: xxmc.h:194
XvMCSubpicture * old_subpic
Definition: xxmc.h:234
int unsigned_intra
Definition: xxmc.h:258
xxmc_frame_t * recent_frames[VO_NUM_RECENT_FRAMES]
Definition: xxmc.h:205
XColor black
Definition: xxmc.h:199
int xv_xoverlay_type
Definition: xxmc.h:213
unsigned xvmc_width
Definition: xxmc.h:254
char * xvmc_palette
Definition: xxmc.h:264
XvMCContext context
Definition: xxmc.h:248
unsigned int xv_format_yuy2
Definition: xxmc.h:195
uint32_t colorkey
Definition: xxmc.h:221
XShmSegmentInfo subShmInfo
Definition: xxmc.h:266
context_lock_t xvmc_lock
Definition: xxmc.h:272
unsigned xvmc_accel
Definition: xxmc.h:252
config_values_t * config
Definition: xxmc.h:188
unsigned xvmc_num_cap
Definition: xxmc.h:228
xvmc_macroblocks_t macroblocks
Definition: xxmc.h:226
XvImage * subImage
Definition: xxmc.h:265
alphablend_t alphablend_extra_data
Definition: xxmc.h:274
Display * display
Definition: xxmc.h:191
int hwSubpictures
Definition: xxmc.h:233
XvPortID xv_port
Definition: xxmc.h:198
GC gc
Definition: xxmc.h:197
vo_driver_t vo_driver
Definition: xxmc.h:186
Drawable drawable
Definition: xxmc.h:193
int xvmc_backend_subpic
Definition: xxmc.h:247
Definition: xxmc.h:126
int format
Definition: xxmc.h:129
XvMCSurface * xvmc_surf
Definition: xxmc.h:137
XvImage * image
Definition: xxmc.h:132
XShmSegmentInfo shminfo
Definition: xxmc.h:133
double ratio
Definition: xxmc.h:130
xine_xxmc_t xxmc_data
Definition: xxmc.h:138
vo_frame_t vo_frame
Definition: xxmc.h:127
int last_sw_format
Definition: xxmc.h:139
Definition: xxmc.h:115
int max
Definition: xxmc.h:118
Atom atom
Definition: xxmc.h:119
cfg_entry_t * entry
Definition: xxmc.h:121
int value
Definition: xxmc.h:116
int min
Definition: xxmc.h:117
#define XVMC_MAX_SUBPICTURES
Definition: xxmc.h:100
int xxmc_xvmc_surface_valid(xxmc_driver_t *this, XvMCSurface *surf)
Definition: video_out_xxmc.c:269
void xvmc_vld_slice(vo_frame_t *this_gen)
void xvmc_context_reader_unlock(context_lock_t *c)
Definition: video_out_xxmc.c:102
struct xvmc_surface_handler_s xvmc_surface_handler_t
void xxmc_xvmc_proc_macro_block(int x, int y, int mb_type, int motion_type, int(*mv_field_sel)[2], int *dmvector, int cbp, int dct_type, vo_frame_t *current_frame, vo_frame_t *forward_ref_frame, vo_frame_t *backward_ref_frame, int picture_structure, int second_field, int(*f_mot_pmv)[2], int(*b_mot_pmv)[2])
Definition: xvmc_mocomp.c:103
void xvmc_vld_frame(struct vo_frame_s *this_gen)
void xvmc_context_reader_lock(context_lock_t *c)
Definition: video_out_xxmc.c:93
struct context_lock_s context_lock_t
#define XVMC_MAX_SURFACES
Definition: xxmc.h:99