Mercurial > mplayer.hg
annotate libvo/vo_xvmc.c @ 33197:17dba462c48c
Fix compilation with XvMC, only lightly tested.
author | reimar |
---|---|
date | Fri, 22 Apr 2011 07:28:44 +0000 |
parents | 2f560e361175 |
children | 38b1b532c41b |
rev | line source |
---|---|
28446
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
1 /* |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
2 * This file is part of MPlayer. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
3 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
7 * (at your option) any later version. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
8 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
12 * GNU General Public License for more details. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
13 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
17 */ |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28251
diff
changeset
|
18 |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
19 #include <stdlib.h> |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
20 #include <stdio.h> |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
21 #include <string.h> |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
22 #include <unistd.h> |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
23 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
24 #include "config.h" |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
25 #include "mp_msg.h" |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
26 #include "video_out.h" |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
27 #include "video_out_internal.h" |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
28 #include "osdep/timer.h" |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
29 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
30 #include <X11/Xlib.h> |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
31 #include <X11/Xutil.h> |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
32 #include <X11/Xatom.h> |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
33 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
34 #ifdef HAVE_SHM |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
35 #include <sys/ipc.h> |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
36 #include <sys/shm.h> |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
37 #include <X11/extensions/XShm.h> |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
38 #endif |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
39 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
40 #include <X11/extensions/Xv.h> |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
41 #include <X11/extensions/Xvlib.h> |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
42 #include <X11/extensions/XvMClib.h> |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
43 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
44 #include "x11_common.h" |
28640 | 45 #include "libavcodec/avcodec.h" |
28522
fee39b6b62ea
Remove local copy of xvmc_render.h, it is now an installed header in FFmpeg.
diego
parents:
28511
diff
changeset
|
46 #include "libavcodec/xvmc.h" |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
47 |
32467 | 48 #include "sub/sub.h" |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
49 #include "aspect.h" |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
50 |
14742 | 51 #include "subopt-helper.h" |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
52 |
22461
c54ad95f852a
Factor out some duplicated code in vo_xv and vo_xvmc
reimar
parents:
22257
diff
changeset
|
53 #include "libavutil/common.h" |
c54ad95f852a
Factor out some duplicated code in vo_xv and vo_xvmc
reimar
parents:
22257
diff
changeset
|
54 |
24595 | 55 //no chance for xinerama to be supported in the near future |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
56 #undef CONFIG_XINERAMA |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
57 |
28569
fb881ea1a985
whitespace cosmetics: Remove all tabs and trailing whitespace.
diego
parents:
28568
diff
changeset
|
58 #undef NDEBUG |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
59 #include <assert.h> |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
60 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
61 |
22813 | 62 #if LIBAVCODEC_BUILD < ((51<<16)+(40<<8)+2) |
28919 | 63 #error You need at least libavcodec v51.40.2 |
22813 | 64 #endif |
65 | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
66 |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
67 static int benchmark; |
14742 | 68 static int use_sleep; |
15102
1d3ba9fb75cd
incorporate all image drawing in single function and use fixed vo_xv_draw_colorkey() for proper key drawing.
iive
parents:
15060
diff
changeset
|
69 static int first_frame;//draw colorkey on first frame |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
70 static int use_queue; |
14742 | 71 static int xv_port_request = 0; |
28569
fb881ea1a985
whitespace cosmetics: Remove all tabs and trailing whitespace.
diego
parents:
28568
diff
changeset
|
72 static int xv_adaptor = -1; |
20244 | 73 static int bob_deinterlace; |
74 static int top_field_first; | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
75 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
76 static int image_width,image_height; |
22257
f979aa12d8cc
Don't free and then allocate surfaces when config() is called again with same resolution and format.
iive
parents:
22246
diff
changeset
|
77 static int image_format; |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
78 |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
79 #define NO_SUBPICTURE 0 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
80 #define OVERLAY_SUBPICTURE 1 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
81 #define BLEND_SUBPICTURE 2 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
82 #define BACKEND_SUBPICTURE 3 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
83 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
84 static int subpicture_mode; |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
85 static int subpicture_alloc; |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
86 static XvMCSubpicture subpicture; |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
87 static XvImageFormatValues subpicture_info; |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
88 static int subpicture_clear_color;//transparent color for the subpicture or color key for overlay |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
89 |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
90 static XvMCSurfaceInfo surface_info; |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
91 static XvMCContext ctx; |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
92 static XvMCBlockArray data_blocks; |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
93 static XvMCMacroBlockArray mv_blocks; |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
94 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
95 #define MAX_SURFACES 8 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
96 static int number_of_surfaces=0; |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
97 static XvMCSurface surface_array[MAX_SURFACES]; |
33195
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
98 static struct render_info { |
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
99 #define STATE_DISPLAY_PENDING 1 /** the surface should be shown, the video driver manipulates this */ |
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
100 #define STATE_PREDICTION 2 /** the surface is needed for prediction, the codec manipulates this */ |
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
101 #define STATE_OSD_SOURCE 4 /** the surface is needed for subpicture rendering */ |
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
102 int state; |
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
103 void *p_osd_target_surface_render; |
33197 | 104 mp_image_t *mpi; |
33195
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
105 } surface_render_info[MAX_SURFACES]; |
28568
1a90167d9f0e
The xvmc_pixfmt_render structure was renamed to xvmc_pix_fmt in FFmpeg.
diego
parents:
28567
diff
changeset
|
106 static struct xvmc_pix_fmt *surface_render; |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
107 |
28568
1a90167d9f0e
The xvmc_pixfmt_render structure was renamed to xvmc_pix_fmt in FFmpeg.
diego
parents:
28567
diff
changeset
|
108 static struct xvmc_pix_fmt *p_render_surface_to_show = NULL; |
1a90167d9f0e
The xvmc_pixfmt_render structure was renamed to xvmc_pix_fmt in FFmpeg.
diego
parents:
28567
diff
changeset
|
109 static struct xvmc_pix_fmt *p_render_surface_visible = NULL; |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
110 |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
111 //display queue, kinda render ahead |
28568
1a90167d9f0e
The xvmc_pixfmt_render structure was renamed to xvmc_pix_fmt in FFmpeg.
diego
parents:
28567
diff
changeset
|
112 static struct xvmc_pix_fmt *show_queue[MAX_SURFACES]; |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
113 static int free_element; |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
114 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
115 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
116 static void (*draw_osd_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
117 static void (*clear_osd_fnc)(int x0,int y0, int w,int h); |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
118 static void (*init_osd_fnc)(void); |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
119 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
120 static void draw_osd_AI44(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
121 static void draw_osd_IA44(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
122 static void clear_osd_subpic(int x0,int y0, int w,int h); |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
123 static void init_osd_yuv_pal(void); |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
124 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
125 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
126 static const struct{ |
28642 | 127 int id;//id as xvimages or as mplayer RGB|{8,15,16,24,32} |
30933
d3dc11568f7e
Use (void) instead of () to indicate a parameterless function, fixes:
diego
parents:
30612
diff
changeset
|
128 void (* init_func_ptr)(void); |
28642 | 129 void (* draw_func_ptr)(); |
130 void (* clear_func_ptr)(); | |
131 } osd_render[]={ | |
132 {0x34344149,init_osd_yuv_pal,draw_osd_AI44,clear_osd_subpic}, | |
133 {0x34344941,init_osd_yuv_pal,draw_osd_IA44,clear_osd_subpic}, | |
134 {0,NULL,NULL,NULL} | |
135 }; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
136 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
137 static void xvmc_free(void); |
22257
f979aa12d8cc
Don't free and then allocate surfaces when config() is called again with same resolution and format.
iive
parents:
22246
diff
changeset
|
138 static void xvmc_clean_surfaces(void); |
28232
8df85ad26746
Add missing 'void' keyword to parameterless function declarations.
diego
parents:
28202
diff
changeset
|
139 static int count_free_surfaces(void); |
28568
1a90167d9f0e
The xvmc_pixfmt_render structure was renamed to xvmc_pix_fmt in FFmpeg.
diego
parents:
28567
diff
changeset
|
140 static struct xvmc_pix_fmt *find_free_surface(void); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
141 |
25216 | 142 static const vo_info_t info = { |
28642 | 143 "XVideo Motion Compensation", |
144 "xvmc", | |
145 "Ivan Kalvachev <iive@users.sf.net>", | |
146 "" | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
147 }; |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
148 |
25220
c9e9ac2008c2
Mark the vo_functions_t definitions as const where possible.
reimar
parents:
25216
diff
changeset
|
149 const LIBVO_EXTERN(xvmc); |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
150 |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
151 //shm stuff from vo_xv |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
152 #ifdef HAVE_SHM |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
153 static XShmSegmentInfo Shminfo; |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
154 static int Shmem_Flag; |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
155 #endif |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
156 XvImage * xvimage; |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
157 |
33195
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
158 static struct render_info *get_render_info(struct xvmc_pix_fmt *cur_render) |
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
159 { |
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
160 int idx; |
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
161 if (!surface_render || !cur_render) |
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
162 return NULL; |
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
163 idx = cur_render - surface_render; |
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
164 if (idx < 0 || idx >= MAX_SURFACES) |
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
165 return NULL; |
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
166 return surface_render_info + idx; |
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
167 } |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
168 |
33197 | 169 static void add_state(struct xvmc_pix_fmt *cur_render, int flags) |
170 { | |
171 struct render_info *info = get_render_info(cur_render); | |
172 int bit; | |
173 if (info->mpi) { | |
174 for (bit = 1; flags >= bit; bit <<= 1) { | |
175 if (flags & ~info->state & bit) | |
176 info->mpi->usage_count++; | |
177 } | |
178 } | |
179 info->state |= flags; | |
180 } | |
181 | |
182 static void remove_state(struct xvmc_pix_fmt *cur_render, int flags) | |
183 { | |
184 struct render_info *info = get_render_info(cur_render); | |
185 int bit; | |
186 if (info->mpi) { | |
187 for (bit = 1; flags >= bit; bit <<= 1) { | |
188 if (flags & info->state & bit) | |
189 info->mpi->usage_count--; | |
190 } | |
191 } | |
192 info->state &= ~flags; | |
193 } | |
194 | |
195 static int in_use(struct xvmc_pix_fmt *cur_render) | |
196 { | |
197 struct render_info *info = get_render_info(cur_render); | |
198 return info->state || (info->mpi && info->mpi->usage_count); | |
199 } | |
200 | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
201 static void allocate_xvimage(int xvimage_width,int xvimage_height,int xv_format) |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
202 { |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
203 /* |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
204 * allocate XvImages. FIXME: no error checking, without |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
205 * mit-shm this will bomb... trzing to fix ::atmos |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
206 */ |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
207 #ifdef HAVE_SHM |
28642 | 208 if ( mLocalDisplay && XShmQueryExtension( mDisplay ) ) Shmem_Flag = 1; |
209 else | |
210 { | |
211 Shmem_Flag = 0; | |
28645 | 212 mp_msg(MSGT_VO,MSGL_WARN, "Shared memory not supported\nReverting to normal Xv\n" ); |
28642 | 213 } |
214 if ( Shmem_Flag ) | |
215 { | |
216 xvimage = (XvImage *) XvShmCreateImage(mDisplay, xv_port, xv_format, | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
217 NULL, xvimage_width, xvimage_height, &Shminfo); |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
218 |
28642 | 219 Shminfo.shmid = shmget(IPC_PRIVATE, xvimage->data_size, IPC_CREAT | 0777); |
220 Shminfo.shmaddr = (char *) shmat(Shminfo.shmid, 0, 0); | |
221 Shminfo.readOnly = False; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
222 |
28642 | 223 xvimage->data = Shminfo.shmaddr; |
224 XShmAttach(mDisplay, &Shminfo); | |
225 XSync(mDisplay, False); | |
226 shmctl(Shminfo.shmid, IPC_RMID, 0); | |
227 } | |
228 else | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
229 #endif |
28642 | 230 { |
231 xvimage = (XvImage *) XvCreateImage(mDisplay, xv_port, xv_format, NULL, xvimage_width, xvimage_height); | |
232 xvimage->data = malloc(xvimage->data_size); | |
233 XSync(mDisplay,False); | |
234 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
235 // memset(xvimage->data,128,xvimage->data_size); |
28642 | 236 return; |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
237 } |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
238 |
28232
8df85ad26746
Add missing 'void' keyword to parameterless function declarations.
diego
parents:
28202
diff
changeset
|
239 static void deallocate_xvimage(void) |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
240 { |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
241 #ifdef HAVE_SHM |
28642 | 242 if ( Shmem_Flag ) |
243 { | |
244 XShmDetach( mDisplay,&Shminfo ); | |
245 shmdt( Shminfo.shmaddr ); | |
246 } | |
247 else | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
248 #endif |
28642 | 249 { |
250 free(xvimage->data); | |
251 } | |
252 XFree(xvimage); | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
253 |
28642 | 254 XSync(mDisplay, False); |
255 return; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
256 } |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
257 //end of vo_xv shm/xvimage code |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
258 |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
259 static int xvmc_check_surface_format(uint32_t format, XvMCSurfaceInfo * surf_info){ |
28642 | 260 if ( format == IMGFMT_XVMC_IDCT_MPEG2 ){ |
261 if( surf_info->mc_type != (XVMC_IDCT|XVMC_MPEG_2) ) return -1; | |
262 if( surf_info->chroma_format != XVMC_CHROMA_FORMAT_420 ) return -1; | |
263 return 0; | |
264 } | |
265 if ( format == IMGFMT_XVMC_MOCO_MPEG2 ){ | |
266 if(surf_info->mc_type != XVMC_MPEG_2) return -1; | |
267 if(surf_info->chroma_format != XVMC_CHROMA_FORMAT_420) return -1; | |
268 return 0; | |
269 } | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
270 return -1;//fail |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
271 } |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
272 |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
273 //print all info needed to add new format |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
274 static void print_xvimage_format_values(XvImageFormatValues *xifv){ |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
275 int i; |
28930
abdc27586f35
Fix warning: Add forgotten 'int' to variable declaration.
iive
parents:
28919
diff
changeset
|
276 const int msgl=MSGL_DBG4; |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
277 |
28645 | 278 mp_msg(MSGT_VO,msgl,"Format_ID = 0x%X\n",xifv->id); |
28569
fb881ea1a985
whitespace cosmetics: Remove all tabs and trailing whitespace.
diego
parents:
28568
diff
changeset
|
279 |
28645 | 280 mp_msg(MSGT_VO,msgl," type = "); |
281 if(xifv->type == XvRGB) mp_msg(MSGT_VO,msgl,"RGB\n"); | |
282 else if(xifv->type == XvYUV) mp_msg(MSGT_VO,msgl,"YUV\n"); | |
283 else mp_msg(MSGT_VO,msgl,"Unknown\n"); | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
284 |
28645 | 285 mp_msg(MSGT_VO,msgl," byte_order = "); |
286 if(xifv->byte_order == LSBFirst) mp_msg(MSGT_VO,msgl,"LSB First\n"); | |
287 else if(xifv->type == MSBFirst) mp_msg(MSGT_VO,msgl,"MSB First\n"); | |
288 else mp_msg(MSGT_VO,msgl,"Unknown\n");//yes Linux support other types too | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
289 |
28645 | 290 mp_msg(MSGT_VO,msgl," guid = "); |
28642 | 291 for(i=0;i<16;i++) |
28645 | 292 mp_msg(MSGT_VO,msgl,"%02X ",(unsigned char)xifv->guid[i]); |
293 mp_msg(MSGT_VO,msgl,"\n"); | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
294 |
28645 | 295 mp_msg(MSGT_VO,msgl," bits_per_pixel = %d\n",xifv->bits_per_pixel); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
296 |
28645 | 297 mp_msg(MSGT_VO,msgl," format = "); |
298 if(xifv->format == XvPacked) mp_msg(MSGT_VO,msgl,"XvPacked\n"); | |
299 else if(xifv->format == XvPlanar) mp_msg(MSGT_VO,msgl,"XvPlanar\n"); | |
300 else mp_msg(MSGT_VO,msgl,"Unknown\n"); | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
301 |
28645 | 302 mp_msg(MSGT_VO,msgl," num_planes = %d\n",xifv->num_planes); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
303 |
28642 | 304 if(xifv->type == XvRGB){ |
28645 | 305 mp_msg(MSGT_VO,msgl," red_mask = %0X\n", xifv->red_mask); |
306 mp_msg(MSGT_VO,msgl," green_mask = %0X\n",xifv->green_mask); | |
307 mp_msg(MSGT_VO,msgl," blue_mask = %0X\n", xifv->blue_mask); | |
28642 | 308 } |
309 if(xifv->type == XvYUV){ | |
28645 | 310 mp_msg(MSGT_VO,msgl," y_sample_bits = %d\n u_sample_bits = %d\n v_sample_bits = %d\n", |
28642 | 311 xifv->y_sample_bits,xifv->u_sample_bits,xifv->v_sample_bits); |
28645 | 312 mp_msg(MSGT_VO,msgl," horz_y_period = %d\n horz_u_period = %d\n horz_v_period = %d\n", |
28642 | 313 xifv->horz_y_period,xifv->horz_u_period,xifv->horz_v_period); |
28645 | 314 mp_msg(MSGT_VO,msgl," vert_y_period = %d\n vert_u_period = %d\n vert_v_period = %d\n", |
28642 | 315 xifv->vert_y_period,xifv->vert_u_period,xifv->vert_v_period); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
316 |
28645 | 317 mp_msg(MSGT_VO,msgl," component_order = "); |
28642 | 318 for(i=0;i<32;i++) |
319 if(xifv->component_order[i]>=32) | |
28645 | 320 mp_msg(MSGT_VO,msgl,"%c",xifv->component_order[i]); |
321 mp_msg(MSGT_VO,msgl,"\n"); | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
322 |
28645 | 323 mp_msg(MSGT_VO,msgl," scanline = "); |
324 if(xifv->scanline_order == XvTopToBottom) mp_msg(MSGT_VO,msgl,"XvTopToBottom\n"); | |
325 else if(xifv->scanline_order == XvBottomToTop) mp_msg(MSGT_VO,msgl,"XvBottomToTop\n"); | |
326 else mp_msg(MSGT_VO,msgl,"Unknown\n"); | |
28642 | 327 } |
28645 | 328 mp_msg(MSGT_VO,msgl,"\n"); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
329 } |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
330 |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
331 // WARNING This function may changes xv_port and surface_info! |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
332 static int xvmc_find_surface_by_format(int format,int width,int height, |
28642 | 333 XvMCSurfaceInfo * surf_info,int query){ |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
334 int rez; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
335 XvAdaptorInfo * ai; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
336 int num_adaptors,i; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
337 unsigned long p; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
338 int s,mc_surf_num; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
339 XvMCSurfaceInfo * mc_surf_list; |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
340 |
28642 | 341 rez = XvQueryAdaptors(mDisplay,DefaultRootWindow(mDisplay),&num_adaptors,&ai); |
342 if( rez != Success ) return -1; | |
28644 | 343 mp_msg(MSGT_VO,MSGL_DBG3,"vo_xvmc: Querying %d adaptors\n",num_adaptors); |
28642 | 344 for(i=0; i<num_adaptors; i++) |
345 { | |
346 /* check if adaptor number has been specified */ | |
347 if (xv_adaptor != -1 && xv_adaptor != i) | |
348 continue; | |
31834
64ba1daa147a
various spelling fixes, found by the Debian QA tool 'lintian'
siretart
parents:
31316
diff
changeset
|
349 mp_msg(MSGT_VO,MSGL_DBG3,"vo_xvmc: Querying adaptor #%d\n",i); |
28642 | 350 if( ai[i].type == 0 ) continue;// we need at least dummy type! |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
351 //probing ports |
28642 | 352 for(p=ai[i].base_id; p<ai[i].base_id+ai[i].num_ports; p++) |
353 { | |
28644 | 354 mp_msg(MSGT_VO,MSGL_DBG3,"vo_xvmc: probing port #%ld\n",p); |
28642 | 355 mc_surf_list = XvMCListSurfaceTypes(mDisplay,p,&mc_surf_num); |
356 if( mc_surf_list == NULL || mc_surf_num == 0){ | |
28644 | 357 mp_msg(MSGT_VO,MSGL_DBG3,"vo_xvmc: No XvMC supported. \n"); |
28642 | 358 continue; |
359 } | |
28644 | 360 mp_msg(MSGT_VO,MSGL_DBG3,"vo_xvmc: XvMC list have %d surfaces\n",mc_surf_num); |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
361 //we have XvMC list! |
28642 | 362 for(s=0; s<mc_surf_num; s++) |
363 { | |
364 if( width > mc_surf_list[s].max_width ) continue; | |
365 if( height > mc_surf_list[s].max_height ) continue; | |
366 if( xvmc_check_surface_format(format,&mc_surf_list[s])<0 ) continue; | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
367 //we have match! |
28642 | 368 /* respect the users wish */ |
369 if ( xv_port_request != 0 && xv_port_request != p ) | |
370 { | |
371 continue; | |
372 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
373 |
28642 | 374 if(!query){ |
375 rez = XvGrabPort(mDisplay,p,CurrentTime); | |
376 if(rez != Success){ | |
28644 | 377 mp_msg(MSGT_VO,MSGL_DBG3,"vo_xvmc: Fail to grab port %ld\n",p); |
28642 | 378 continue; |
379 } | |
28645 | 380 mp_msg(MSGT_VO,MSGL_INFO,"vo_xvmc: Using Xv Adaptor #%d (%s)\n", i, ai[i].name); |
381 mp_msg(MSGT_VO,MSGL_INFO,"vo_xvmc: Port %ld grabed\n",p); | |
28642 | 382 xv_port = p; |
383 } | |
384 goto surface_found; | |
385 }//for mc surf | |
386 XFree(mc_surf_list);//if mc_surf_num==0 is list==NULL ? | |
387 }//for ports | |
388 }//for adaptors | |
389 XvFreeAdaptorInfo(ai); | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
390 |
28645 | 391 if(!query) mp_msg(MSGT_VO,MSGL_ERR,"vo_xvmc: Could not find free matching surface. Sorry.\n"); |
28642 | 392 return 0; |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
393 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
394 // somebody know cleaner way to escape from 3 internal loops? |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
395 surface_found: |
28642 | 396 XvFreeAdaptorInfo(ai); |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
397 |
28642 | 398 memcpy(surf_info,&mc_surf_list[s],sizeof(XvMCSurfaceInfo)); |
28644 | 399 mp_msg(MSGT_VO, query?MSGL_INFO:MSGL_DBG3, |
400 "vo_xvmc: Found matching surface with id=%X on %ld port at %d adapter\n", | |
28642 | 401 mc_surf_list[s].surface_type_id,p,i); |
402 return mc_surf_list[s].surface_type_id; | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
403 } |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
404 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
405 static uint32_t xvmc_draw_image(mp_image_t *mpi){ |
28642 | 406 struct xvmc_pix_fmt *rndr; |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
407 |
28642 | 408 assert(mpi!=NULL); |
409 assert(mpi->flags &MP_IMGFLAG_DIRECT); | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
410 // assert(mpi->flags &MP_IMGFLAGS_DRAWBACK); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
411 |
28642 | 412 rndr = (struct xvmc_pix_fmt*)mpi->priv; //there is copy in plane[2] |
413 assert( rndr != NULL ); | |
414 assert( rndr->xvmc_id == AV_XVMC_ID ); | |
28644 | 415 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: draw_image(show rndr=%p)\n",rndr); |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
416 // the surface have passed vf system without been skiped, it will be displayed |
33197 | 417 add_state(rndr, STATE_DISPLAY_PENDING); |
28642 | 418 p_render_surface_to_show = rndr; |
419 top_field_first = mpi->fields & MP_IMGFIELD_TOP_FIRST; | |
420 return VO_TRUE; | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
421 } |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
422 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15866
diff
changeset
|
423 static int preinit(const char *arg){ |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
424 int xv_version,xv_release,xv_request_base,xv_event_base,xv_error_base; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
425 int mc_eventBase,mc_errorBase; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
426 int mc_ver,mc_rev; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
427 strarg_t ck_src_arg = { 0, NULL }; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
428 strarg_t ck_method_arg = { 0, NULL }; |
28828
56eee6ffba9b
Make data related to suboption parsing const in libvo
reimar
parents:
28645
diff
changeset
|
429 const opt_t subopts [] = |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
430 { |
28642 | 431 /* name arg type arg var test */ |
30122
1772a5171ac7
Fix function declarations to avoid casting function pointers.
reimar
parents:
28930
diff
changeset
|
432 { "port", OPT_ARG_INT, &xv_port_request, int_pos }, |
1772a5171ac7
Fix function declarations to avoid casting function pointers.
reimar
parents:
28930
diff
changeset
|
433 { "adaptor", OPT_ARG_INT, &xv_adaptor, int_non_neg }, |
28642 | 434 { "ck", OPT_ARG_STR, &ck_src_arg, xv_test_ck }, |
435 { "ck-method", OPT_ARG_STR, &ck_method_arg, xv_test_ckm }, | |
436 { "benchmark", OPT_ARG_BOOL, &benchmark, NULL }, | |
437 { "sleep", OPT_ARG_BOOL, &use_sleep, NULL }, | |
438 { "queue", OPT_ARG_BOOL, &use_queue, NULL }, | |
439 { "bobdeint", OPT_ARG_BOOL, &bob_deinterlace, NULL }, | |
440 { NULL } | |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
441 }; |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
442 |
28642 | 443 //Obtain display handler |
444 if (!vo_init()) return -1;//vo_xv | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
445 |
28642 | 446 //XvMC is subdivision of XVideo |
447 if (Success != XvQueryExtension(mDisplay,&xv_version,&xv_release,&xv_request_base, | |
448 &xv_event_base,&xv_error_base) ){ | |
449 mp_msg(MSGT_VO,MSGL_ERR,"Sorry, Xv(MC) not supported by this X11 version/driver\n"); | |
450 mp_msg(MSGT_VO,MSGL_ERR,"********** Try with -vo x11 or -vo sdl ***********\n"); | |
451 return -1; | |
452 } | |
28645 | 453 mp_msg(MSGT_VO,MSGL_INFO,"vo_xvmc: X-Video extension %d.%d\n",xv_version,xv_release); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
454 |
28642 | 455 if( True != XvMCQueryExtension(mDisplay,&mc_eventBase,&mc_errorBase) ){ |
28645 | 456 mp_msg(MSGT_VO,MSGL_ERR,"vo_xvmc: No X-Video MotionCompensation Extension on %s\n", |
28642 | 457 XDisplayName(NULL)); |
458 return -1; | |
459 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
460 |
28642 | 461 if(Success == XvMCQueryVersion(mDisplay, &mc_ver, &mc_rev) ){ |
28645 | 462 mp_msg(MSGT_VO,MSGL_INFO,"vo_xvmc: X-Video MotionCompensation Extension version %i.%i\n", |
28569
fb881ea1a985
whitespace cosmetics: Remove all tabs and trailing whitespace.
diego
parents:
28568
diff
changeset
|
463 mc_ver,mc_rev); |
28642 | 464 } |
465 else{ | |
28645 | 466 mp_msg(MSGT_VO,MSGL_ERR,"vo_xvmc: Error querying version info!\n"); |
28642 | 467 return -1; |
468 } | |
469 surface_render = NULL; | |
470 xv_port = 0; | |
471 number_of_surfaces = 0; | |
472 subpicture_alloc = 0; | |
28569
fb881ea1a985
whitespace cosmetics: Remove all tabs and trailing whitespace.
diego
parents:
28568
diff
changeset
|
473 |
28642 | 474 benchmark = 0; //disable PutImageto allow faster display than screen refresh |
475 use_sleep = 0; | |
476 use_queue = 0; | |
477 bob_deinterlace = 0; | |
14742 | 478 |
28642 | 479 /* parse suboptions */ |
480 if ( subopt_parse( arg, subopts ) != 0 ) | |
481 { | |
482 return -1; | |
483 } | |
14742 | 484 |
28642 | 485 xv_setup_colorkeyhandling( ck_method_arg.str, ck_src_arg.str ); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
486 |
28642 | 487 return 0; |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
488 } |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
489 |
22246 | 490 static int config(uint32_t width, uint32_t height, |
28569
fb881ea1a985
whitespace cosmetics: Remove all tabs and trailing whitespace.
diego
parents:
28568
diff
changeset
|
491 uint32_t d_width, uint32_t d_height, |
fb881ea1a985
whitespace cosmetics: Remove all tabs and trailing whitespace.
diego
parents:
28568
diff
changeset
|
492 uint32_t flags, char *title, uint32_t format){ |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
493 int i,mode_id,rez; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
494 int numblocks,blocks_per_macroblock;//bpmb we have 6,8,12 |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
495 |
22246 | 496 //from vo_xv |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
497 XVisualInfo vinfo; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
498 XSetWindowAttributes xswa; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
499 XWindowAttributes attribs; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
500 unsigned long xswamask; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
501 int depth; |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
502 #ifdef CONFIG_XF86VM |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
503 int vm = flags & VOFLAG_MODESWITCHING; |
22246 | 504 #endif |
505 //end of vo_xv | |
506 | |
28642 | 507 if( !IMGFMT_IS_XVMC(format) ) |
508 { | |
509 assert(0);//should never happen, abort on debug or | |
510 return 1;//return error on relese | |
511 } | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
512 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
513 // Find free port that supports MC, by querying adaptors |
28642 | 514 if( xv_port != 0 || number_of_surfaces != 0 ){ |
515 if( height==image_height && width==image_width && image_format==format){ | |
516 xvmc_clean_surfaces(); | |
517 goto skip_surface_allocation; | |
518 } | |
519 xvmc_free(); | |
520 }; | |
521 numblocks=((width+15)/16)*((height+15)/16); | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
522 // Find Supported Surface Type |
28642 | 523 mode_id = xvmc_find_surface_by_format(format,width,height,&surface_info,0);//false=1 to grab port, not query |
524 if ( mode_id == 0 ) | |
525 { | |
526 return -1; | |
527 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
528 |
28642 | 529 rez = XvMCCreateContext(mDisplay, xv_port,mode_id,width,height,XVMC_DIRECT,&ctx); |
530 if( rez != Success ){ | |
28645 | 531 mp_msg(MSGT_VO,MSGL_ERR,"vo_xvmc: XvMCCreateContext failed with error %d\n",rez); |
28642 | 532 return -1; |
533 } | |
534 if( ctx.flags & XVMC_DIRECT ){ | |
28645 | 535 mp_msg(MSGT_VO,MSGL_INFO,"vo_xvmc: Allocated Direct Context\n"); |
28642 | 536 }else{ |
28645 | 537 mp_msg(MSGT_VO,MSGL_INFO,"vo_xvmc: Allocated Indirect Context!\n"); |
28642 | 538 } |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
539 |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
540 |
28642 | 541 blocks_per_macroblock = 6; |
542 if(surface_info.chroma_format == XVMC_CHROMA_FORMAT_422) | |
543 blocks_per_macroblock = 8; | |
544 if(surface_info.chroma_format == XVMC_CHROMA_FORMAT_444) | |
545 blocks_per_macroblock = 12; | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
546 |
28642 | 547 rez = XvMCCreateBlocks(mDisplay,&ctx,numblocks*blocks_per_macroblock,&data_blocks); |
548 if( rez != Success ){ | |
549 XvMCDestroyContext(mDisplay,&ctx); | |
550 return -1; | |
551 } | |
28645 | 552 mp_msg(MSGT_VO,MSGL_INFO,"vo_xvmc: data_blocks allocated\n"); |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
553 |
28642 | 554 rez = XvMCCreateMacroBlocks(mDisplay,&ctx,numblocks,&mv_blocks); |
555 if( rez != Success ){ | |
556 XvMCDestroyBlocks(mDisplay,&data_blocks); | |
557 XvMCDestroyContext(mDisplay,&ctx); | |
558 return -1; | |
559 } | |
28645 | 560 mp_msg(MSGT_VO,MSGL_INFO,"vo_xvmc: mv_blocks allocated\n"); |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
561 |
28642 | 562 if(surface_render==NULL) |
563 surface_render = malloc(MAX_SURFACES * sizeof(struct xvmc_pix_fmt)); //easy mem debug | |
564 memset(surface_render, 0, MAX_SURFACES * sizeof(struct xvmc_pix_fmt)); | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
565 |
28642 | 566 for(i=0; i<MAX_SURFACES; i++){ |
567 rez=XvMCCreateSurface(mDisplay,&ctx,&surface_array[i]); | |
568 if( rez != Success ) | |
569 break; | |
570 surface_render[i].xvmc_id = AV_XVMC_ID; | |
571 surface_render[i].data_blocks = data_blocks.blocks; | |
572 surface_render[i].mv_blocks = mv_blocks.macro_blocks; | |
573 surface_render[i].allocated_mv_blocks = numblocks; | |
574 surface_render[i].allocated_data_blocks = numblocks*blocks_per_macroblock; | |
575 surface_render[i].idct = (surface_info.mc_type & XVMC_IDCT) == XVMC_IDCT; | |
576 surface_render[i].unsigned_intra = (surface_info.flags & XVMC_INTRA_UNSIGNED) == XVMC_INTRA_UNSIGNED; | |
577 surface_render[i].p_surface = &surface_array[i]; | |
28644 | 578 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: surface[%d] = %p .rndr=%p\n", |
579 i,&surface_array[i], &surface_render[i]); | |
28642 | 580 } |
581 number_of_surfaces = i; | |
582 if( number_of_surfaces < 4 ){// +2 I or P and +2 for B (to avoid visible motion drawing) | |
28645 | 583 mp_msg(MSGT_VO,MSGL_ERR,"vo_xvmc: Unable to allocate at least 4 Surfaces\n"); |
28642 | 584 uninit(); |
585 return -1; | |
586 } | |
28645 | 587 mp_msg(MSGT_VO,MSGL_INFO,"vo_xvmc: Motion Compensation context allocated - %d surfaces\n", |
28642 | 588 number_of_surfaces); |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
589 |
28642 | 590 //debug |
28645 | 591 mp_msg(MSGT_VO,MSGL_INFO,"vo_xvmc: idct=%d unsigned_intra=%d\n", |
28642 | 592 (surface_info.mc_type & XVMC_IDCT) == XVMC_IDCT, |
593 (surface_info.flags & XVMC_INTRA_UNSIGNED) == XVMC_INTRA_UNSIGNED); | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
594 |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
595 // Find way to display OSD & subtitle |
28645 | 596 mp_msg(MSGT_VO,MSGL_INFO,"vo_xvmc: looking for OSD support\n"); |
28642 | 597 subpicture_mode = NO_SUBPICTURE; |
598 if(surface_info.flags & XVMC_OVERLAID_SURFACE) | |
599 subpicture_mode = OVERLAY_SUBPICTURE; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
600 |
28642 | 601 if(surface_info.subpicture_max_width != 0 && |
602 surface_info.subpicture_max_height != 0 ){ | |
603 int s,k,num_subpic; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
604 |
28642 | 605 XvImageFormatValues * xvfmv; |
606 xvfmv = XvMCListSubpictureTypes(mDisplay, xv_port, | |
607 surface_info.surface_type_id, &num_subpic); | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
608 |
28642 | 609 if(num_subpic != 0 && xvfmv != NULL){ |
610 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ){//Print all subpicture types for debug | |
611 for(s=0;s<num_subpic;s++) | |
612 print_xvimage_format_values(&xvfmv[s]); | |
613 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
614 |
28642 | 615 for(s=0;s<num_subpic;s++){ |
616 for(k=0;osd_render[k].draw_func_ptr!=NULL;k++){ | |
617 if(xvfmv[s].id == osd_render[k].id) | |
618 { | |
619 init_osd_fnc = osd_render[k].init_func_ptr; | |
620 draw_osd_fnc = osd_render[k].draw_func_ptr; | |
621 clear_osd_fnc = osd_render[k].clear_func_ptr; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
622 |
28642 | 623 subpicture_mode = BLEND_SUBPICTURE; |
624 subpicture_info = xvfmv[s]; | |
28645 | 625 mp_msg(MSGT_VO,MSGL_INFO," Subpicture id 0x%08X\n",subpicture_info.id); |
28642 | 626 goto found_subpic; |
627 } | |
628 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
629 } |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
630 found_subpic: |
28642 | 631 XFree(xvfmv); |
632 } | |
633 //Blend2 supicture is always possible, blend1 only at backend | |
634 if( (subpicture_mode == BLEND_SUBPICTURE) && | |
635 (surface_info.flags & XVMC_BACKEND_SUBPICTURE) ) | |
636 { | |
637 subpicture_mode = BACKEND_SUBPICTURE; | |
638 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
639 |
28642 | 640 } |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
641 |
28642 | 642 switch(subpicture_mode){ |
643 case NO_SUBPICTURE: | |
28645 | 644 mp_msg(MSGT_VO,MSGL_WARN,"vo_xvmc: No OSD support for this mode\n"); |
28642 | 645 break; |
646 case OVERLAY_SUBPICTURE: | |
28645 | 647 mp_msg(MSGT_VO,MSGL_WARN,"vo_xvmc: OSD support via color key tricks\n"); |
648 mp_msg(MSGT_VO,MSGL_WARN,"vo_xvmc: not yet implemented:(\n"); | |
28642 | 649 break; |
650 case BLEND_SUBPICTURE: | |
28645 | 651 mp_msg(MSGT_VO,MSGL_INFO,"vo_xvmc: OSD support by additional frontend rendering\n"); |
28642 | 652 break; |
653 case BACKEND_SUBPICTURE: | |
28645 | 654 mp_msg(MSGT_VO,MSGL_INFO,"vo_xvmc: OSD support by backend rendering (fast)\n"); |
655 mp_msg(MSGT_VO,MSGL_INFO,"vo_xvmc: Please send feedback to confirm that it works,otherwise send bugreport!\n"); | |
28642 | 656 break; |
657 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
658 |
14742 | 659 //take keycolor value and choose method for handling it |
28642 | 660 if ( !vo_xv_init_colorkey() ) |
661 { | |
662 return -1; // bail out, colorkey setup failed | |
663 } | |
14742 | 664 |
28642 | 665 vo_xv_enable_vsync();//it won't break anything |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
666 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
667 //taken from vo_xv |
28642 | 668 image_height = height; |
669 image_width = width; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
670 |
22257
f979aa12d8cc
Don't free and then allocate surfaces when config() is called again with same resolution and format.
iive
parents:
22246
diff
changeset
|
671 skip_surface_allocation: |
f979aa12d8cc
Don't free and then allocate surfaces when config() is called again with same resolution and format.
iive
parents:
22246
diff
changeset
|
672 |
28642 | 673 { |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
674 #ifdef CONFIG_XF86VM |
28642 | 675 if ( vm ) |
676 { | |
677 vo_vm_switch(); | |
678 } | |
679 // else | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
680 #endif |
28642 | 681 XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), &attribs); |
682 depth=attribs.depth; | |
683 if (depth != 15 && depth != 16 && depth != 24 && depth != 32) depth = 24; | |
684 XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &vinfo); | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
685 |
28642 | 686 xswa.background_pixel = 0; |
687 if (xv_ck_info.method == CK_METHOD_BACKGROUND) | |
688 xswa.background_pixel = xv_colorkey; | |
689 xswa.border_pixel = 0; | |
690 xswamask = CWBackPixel | CWBorderPixel; | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
691 |
28642 | 692 vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, d_width, d_height, flags, |
693 CopyFromParent, "xvmc", title); | |
694 XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa); | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
695 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
696 #ifdef CONFIG_XF86VM |
28642 | 697 if ( vm ) |
698 { | |
699 /* Grab the mouse pointer in our window */ | |
700 if(vo_grabpointer) | |
701 XGrabPointer(mDisplay, vo_window, True, 0, | |
702 GrabModeAsync, GrabModeAsync, | |
703 vo_window, None, CurrentTime ); | |
704 XSetInputFocus(mDisplay, vo_window, RevertToNone, CurrentTime); | |
705 } | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
706 #endif |
28642 | 707 } |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
708 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
709 //end vo_xv |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
710 |
28642 | 711 /* store image dimesions for displaying */ |
712 p_render_surface_visible = NULL; | |
713 p_render_surface_to_show = NULL; | |
22246 | 714 |
28642 | 715 free_element = 0; |
716 first_frame = 1; | |
22246 | 717 |
28642 | 718 image_format=format; |
719 return 0; | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
720 } |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
721 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15866
diff
changeset
|
722 static int draw_frame(uint8_t *srcp[]){ |
28642 | 723 assert(0); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
724 } |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
725 |
28232
8df85ad26746
Add missing 'void' keyword to parameterless function declarations.
diego
parents:
28202
diff
changeset
|
726 static void init_osd_yuv_pal(void) { |
28642 | 727 char * palette; |
728 int rez; | |
729 int i,j; | |
730 int snum,seb; | |
731 int Y,U,V; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
732 |
28642 | 733 subpicture_clear_color = 0; |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
734 |
28642 | 735 if(subpicture.num_palette_entries > 0){ |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
736 |
28642 | 737 snum = subpicture.num_palette_entries; |
738 seb = subpicture.entry_bytes; | |
739 palette = malloc(snum*seb);//check fail | |
740 if(palette == NULL) return; | |
741 for(i=0; i<snum; i++){ | |
742 // 0-black max-white the other are gradients | |
743 Y = i*(1 << subpicture_info.y_sample_bits)/snum;//snum=2;->(0),(1*(1<<1)/2) | |
744 U = 1 << (subpicture_info.u_sample_bits - 1); | |
745 V = 1 << (subpicture_info.v_sample_bits - 1); | |
746 for(j=0; j<seb; j++) | |
747 switch(subpicture.component_order[j]){ | |
748 case 'U': palette[i*seb+j] = U; break; | |
749 case 'V': palette[i*seb+j] = V; break; | |
750 case 'Y': | |
751 default: | |
752 palette[i*seb+j] = Y; break; | |
753 } | |
754 } | |
755 rez = XvMCSetSubpicturePalette(mDisplay, &subpicture, palette); | |
756 if(rez!=Success){ | |
28645 | 757 mp_msg(MSGT_VO,MSGL_ERR,"vo_xvmc: Setting palette failed.\n"); |
28642 | 758 } |
759 free(palette); | |
760 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
761 } |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
762 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
763 static void clear_osd_subpic(int x0, int y0, int w, int h){ |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
764 int rez; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
765 |
28642 | 766 rez=XvMCClearSubpicture(mDisplay, &subpicture, |
767 x0, y0, w,h, | |
768 subpicture_clear_color); | |
769 if(rez != Success) | |
28645 | 770 mp_msg(MSGT_VO,MSGL_ERR,"vo_xvmc: XvMCClearSubpicture failed!\n"); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
771 } |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
772 |
28232
8df85ad26746
Add missing 'void' keyword to parameterless function declarations.
diego
parents:
28202
diff
changeset
|
773 static void OSD_init(void) { |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
774 unsigned short osd_height, osd_width; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
775 int rez; |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
776 |
28642 | 777 if(subpicture_alloc){ |
28644 | 778 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: destroying subpicture\n"); |
28642 | 779 XvMCDestroySubpicture(mDisplay,&subpicture); |
780 deallocate_xvimage(); | |
781 subpicture_alloc = 0; | |
782 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
783 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
784 /* if(surface_info.flags & XVMC_SUBPICTURE_INDEPENDENT_SCALING){ |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
785 osd_width = vo_dwidth; |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
786 osd_height = vo_dheight; |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
787 }else*/ |
28642 | 788 { |
789 osd_width = image_width; | |
790 osd_height = image_height; | |
791 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
792 |
28642 | 793 if(osd_width > surface_info.subpicture_max_width) |
794 osd_width = surface_info.subpicture_max_width; | |
795 if(osd_height > surface_info.subpicture_max_height) | |
796 osd_height = surface_info.subpicture_max_height; | |
797 if(osd_width == 0 || osd_height == 0) | |
798 return;//if called before window size is known | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
799 |
28644 | 800 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: creating subpicture (%d,%d) format %X\n", |
28642 | 801 osd_width,osd_height,subpicture_info.id); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
802 |
28642 | 803 rez = XvMCCreateSubpicture(mDisplay,&ctx,&subpicture, |
804 osd_width,osd_height,subpicture_info.id); | |
805 if(rez != Success){ | |
806 subpicture_mode = NO_SUBPICTURE; | |
28645 | 807 mp_msg(MSGT_VO,MSGL_WARN,"vo_xvmc: Create Subpicture failed, OSD disabled\n"); |
28642 | 808 return; |
809 } | |
810 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ){ | |
811 int i; | |
28645 | 812 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: Created Subpicture:\n"); |
813 mp_msg(MSGT_VO,MSGL_DBG4," xvimage_id=0x%X\n",subpicture.xvimage_id); | |
814 mp_msg(MSGT_VO,MSGL_DBG4," width=%d\n",subpicture.width); | |
815 mp_msg(MSGT_VO,MSGL_DBG4," height=%d\n",subpicture.height); | |
816 mp_msg(MSGT_VO,MSGL_DBG4," num_palette_entries=0x%X\n",subpicture.num_palette_entries); | |
817 mp_msg(MSGT_VO,MSGL_DBG4," entry_bytes=0x%X\n",subpicture.entry_bytes); | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
818 |
28645 | 819 mp_msg(MSGT_VO,MSGL_DBG4," component_order=\""); |
28642 | 820 for(i=0; i<4; i++) |
821 if(subpicture.component_order[i] >= 32) | |
28645 | 822 mp_msg(MSGT_VO,MSGL_DBG4,"%c", subpicture.component_order[i]); |
823 mp_msg(MSGT_VO,MSGL_DBG4,"\"\n"); | |
28642 | 824 } |
28569
fb881ea1a985
whitespace cosmetics: Remove all tabs and trailing whitespace.
diego
parents:
28568
diff
changeset
|
825 |
28642 | 826 //call init for the surface type |
827 init_osd_fnc();//init palete,clear color etc ... | |
28644 | 828 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: clearing subpicture\n"); |
28642 | 829 clear_osd_fnc(0, 0, subpicture.width, subpicture.height); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
830 |
28642 | 831 allocate_xvimage(subpicture.width, subpicture.height, subpicture_info.id); |
832 subpicture_alloc = 1; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
833 } |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
834 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
835 static void draw_osd_IA44(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
836 int ox,oy; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
837 int rez; |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
838 |
28644 | 839 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc:composite AI44 subpicture (%d,%d - %d,%d)\n",x0,y0,w,h); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
840 |
28642 | 841 for(ox=0; ox<w; ox++){ |
842 for(oy=0; oy<h; oy++){ | |
843 xvimage->data[oy*xvimage->width+ox] = (src[oy*stride+ox]>>4) | ((0-srca[oy*stride+ox])&0xf0); | |
844 } | |
845 } | |
846 rez = XvMCCompositeSubpicture(mDisplay, &subpicture, xvimage, 0, 0, | |
847 w,h,x0,y0); | |
848 if(rez != Success){ | |
28645 | 849 mp_msg(MSGT_VO,MSGL_WARN,"vo_xvmc: composite subpicture failed\n"); |
28642 | 850 assert(0); |
851 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
852 } |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
853 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
854 static void draw_osd_AI44(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
855 int ox,oy; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
856 int rez; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
857 |
28644 | 858 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc:composite AI44 subpicture (%d,%d - %d,%d)\n",x0,y0,w,h); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
859 |
28642 | 860 for(ox=0; ox<w; ox++){ |
861 for(oy=0; oy<h; oy++){ | |
862 xvimage->data[oy*xvimage->width+ox] = (src[oy*stride+ox]&0xf0) | (((0-srca[oy*stride+ox])>>4)&0xf); | |
863 } | |
864 } | |
865 rez = XvMCCompositeSubpicture(mDisplay, &subpicture, xvimage, 0, 0, | |
866 w,h,x0,y0); | |
867 if(rez != Success){ | |
28645 | 868 mp_msg(MSGT_VO,MSGL_WARN,"vo_xvmc: composite subpicture failed\n"); |
28642 | 869 assert(0); |
870 } | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
871 } |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
872 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
873 static void draw_osd(void){ |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
874 struct xvmc_pix_fmt *osd_rndr; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
875 int osd_has_changed; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
876 int have_osd_to_draw; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
877 int rez; |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
878 |
28644 | 879 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: draw_osd ,OSD_mode=%d, surface_to_show=%p\n", |
28642 | 880 subpicture_mode,p_render_surface_to_show); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
881 |
28642 | 882 if(subpicture_mode == BLEND_SUBPICTURE || |
883 subpicture_mode == BACKEND_SUBPICTURE ){ | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
884 |
28642 | 885 if(!subpicture_alloc) //allocate subpicture when dimensions are known |
886 OSD_init(); | |
887 if(!subpicture_alloc) | |
888 return;//dimensions still unknown. | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
889 |
28642 | 890 osd_has_changed = vo_update_osd(subpicture.width, subpicture.height); |
891 have_osd_to_draw = vo_osd_check_range_update(0, 0, subpicture.width, | |
28569
fb881ea1a985
whitespace cosmetics: Remove all tabs and trailing whitespace.
diego
parents:
28568
diff
changeset
|
892 subpicture.height); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
893 |
28642 | 894 if(!have_osd_to_draw) |
895 return;//nothing to draw,no subpic, no blend | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
896 |
28642 | 897 if(osd_has_changed){ |
898 //vo_remove_text(subpicture.width, subpicture.height,clear_osd_fnc) | |
899 clear_osd_fnc(0,0,subpicture.width,subpicture.height); | |
900 vo_draw_text(subpicture.width, subpicture.height, draw_osd_fnc); | |
901 } | |
902 XvMCSyncSubpicture(mDisplay,&subpicture);//todo usleeep wait! | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
903 |
28642 | 904 if(subpicture_mode == BLEND_SUBPICTURE){ |
33195
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
905 struct render_info *info; |
28642 | 906 osd_rndr = find_free_surface(); |
907 if(osd_rndr == NULL) | |
908 return;// no free surface to draw OSD in | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
909 |
28642 | 910 rez = XvMCBlendSubpicture2(mDisplay, |
911 p_render_surface_to_show->p_surface, osd_rndr->p_surface, | |
912 &subpicture, | |
913 0, 0, subpicture.width, subpicture.height, | |
914 0, 0, image_width, image_height); | |
915 if(rez!=Success){ | |
28645 | 916 mp_msg(MSGT_VO,MSGL_WARN,"vo_xvmc: BlendSubpicture failed rez=%d\n",rez); |
28642 | 917 assert(0); |
918 return; | |
919 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
920 // XvMCFlushSurface(mDisplay,osd_rndr->p_surface);//fixme- should I? |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
921 |
28642 | 922 //When replaceing the surface with osd one, save the flags too! |
923 osd_rndr->picture_structure = p_render_surface_to_show->picture_structure; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
924 //add more if needed osd_rndr-> = p_render_surface_to_show->; |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
925 |
33197 | 926 add_state(p_render_surface_to_show, STATE_OSD_SOURCE); |
927 remove_state(p_render_surface_to_show, STATE_DISPLAY_PENDING); | |
33195
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
928 info = get_render_info(p_render_surface_to_show); |
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
929 info->p_osd_target_surface_render = osd_rndr; |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
930 |
28642 | 931 p_render_surface_to_show = osd_rndr; |
33197 | 932 add_state(p_render_surface_to_show, STATE_DISPLAY_PENDING); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
933 |
28644 | 934 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc:draw_osd: surface_to_show changed to %p\n",osd_rndr); |
28642 | 935 }//endof if(BLEND) |
936 if(subpicture_mode == BACKEND_SUBPICTURE){ | |
937 rez = XvMCBlendSubpicture(mDisplay, | |
938 p_render_surface_to_show->p_surface, | |
939 &subpicture, | |
940 0, 0, subpicture.width, subpicture.height, | |
941 0, 0, image_width, image_height); | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
942 |
28642 | 943 } |
28569
fb881ea1a985
whitespace cosmetics: Remove all tabs and trailing whitespace.
diego
parents:
28568
diff
changeset
|
944 |
28642 | 945 }//if(BLEND||BACKEND) |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
946 } |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
947 |
10452 | 948 static void xvmc_sync_surface(XvMCSurface * srf){ |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
949 int status,rez; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
950 |
28642 | 951 rez = XvMCGetSurfaceStatus(mDisplay,srf,&status); |
952 assert(rez==Success); | |
953 if((status & XVMC_RENDERING) == 0) | |
954 return;//surface is already complete | |
955 if(use_sleep){ | |
956 rez = XvMCFlushSurface(mDisplay, srf); | |
957 assert(rez==Success); | |
10452 | 958 |
28642 | 959 do{ |
960 usec_sleep(1000);//1ms (may be 20ms on linux) | |
961 XvMCGetSurfaceStatus(mDisplay,srf,&status); | |
962 } while (status & XVMC_RENDERING); | |
963 return;//done | |
964 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
965 |
28642 | 966 XvMCSyncSurface(mDisplay, srf); |
10452 | 967 } |
968 | |
28568
1a90167d9f0e
The xvmc_pixfmt_render structure was renamed to xvmc_pix_fmt in FFmpeg.
diego
parents:
28567
diff
changeset
|
969 static void put_xvmc_image(struct xvmc_pix_fmt *p_render_surface, |
28569
fb881ea1a985
whitespace cosmetics: Remove all tabs and trailing whitespace.
diego
parents:
28568
diff
changeset
|
970 int draw_ck){ |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
971 int rez; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
972 struct vo_rect src_rect, dst_rect; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
973 int i; |
15060 | 974 |
28642 | 975 if(p_render_surface == NULL) |
976 return; | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
977 |
28642 | 978 calc_src_dst_rects(image_width, image_height, &src_rect, &dst_rect, NULL, NULL); |
28569
fb881ea1a985
whitespace cosmetics: Remove all tabs and trailing whitespace.
diego
parents:
28568
diff
changeset
|
979 |
28642 | 980 if(draw_ck) |
981 vo_xv_draw_colorkey(dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height); | |
15102
1d3ba9fb75cd
incorporate all image drawing in single function and use fixed vo_xv_draw_colorkey() for proper key drawing.
iive
parents:
15060
diff
changeset
|
982 |
28642 | 983 if(benchmark) |
984 return; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
985 |
28642 | 986 for (i = 1; i <= bob_deinterlace + 1; i++) { |
987 int field = top_field_first ? i : i ^ 3; | |
988 rez = XvMCPutSurface(mDisplay, p_render_surface->p_surface, | |
989 vo_window, | |
990 src_rect.left, src_rect.top, src_rect.width, src_rect.height, | |
991 dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height, | |
992 bob_deinterlace ? field : 3); | |
993 if(rez != Success){ | |
28645 | 994 mp_msg(MSGT_VO,MSGL_ERR,"vo_xvmc: PutSurface failer, critical error %d!\n",rez); |
28642 | 995 assert(0); |
996 } | |
997 } | |
998 XFlush(mDisplay); | |
15060 | 999 } |
1000 | |
1001 static void flip_page(void){ | |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1002 int i,cfs; |
15060 | 1003 |
28644 | 1004 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: flip_page show(rndr=%p)\n\n",p_render_surface_to_show); |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1005 |
28642 | 1006 if(p_render_surface_to_show == NULL) return; |
1007 assert( p_render_surface_to_show->xvmc_id == AV_XVMC_ID ); | |
10452 | 1008 //fixme assert( p_render_surface_to_show != p_render_surface_visible); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1009 |
28642 | 1010 if(use_queue){ |
1011 // fill the queue until only n free surfaces remain | |
1012 // after that start displaying | |
1013 cfs = count_free_surfaces(); | |
1014 show_queue[free_element++] = p_render_surface_to_show; | |
1015 if(cfs > 3){//well have 3 free surfaces after add queue | |
1016 if(free_element > 1)//a little voodoo magic | |
1017 xvmc_sync_surface(show_queue[0]->p_surface); | |
1018 return; | |
1019 } | |
1020 p_render_surface_to_show=show_queue[0]; | |
28644 | 1021 mp_msg(MSGT_VO,MSGL_DBG5,"vo_xvmc: flip_queue free_element=%d\n",free_element); |
28642 | 1022 free_element--; |
1023 for(i=0; i<free_element; i++){ | |
1024 show_queue[i] = show_queue[i+1]; | |
1025 } | |
1026 show_queue[free_element] = NULL; | |
1027 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1028 |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1029 // make sure the rendering is done |
28642 | 1030 xvmc_sync_surface(p_render_surface_to_show->p_surface); |
10452 | 1031 |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1032 //the visible surface won't be displayed anymore, mark it as free |
28642 | 1033 if(p_render_surface_visible != NULL) |
33197 | 1034 remove_state(p_render_surface_visible, STATE_DISPLAY_PENDING); |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1035 |
33195
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
1036 //!!fixme assert(p_render_surface_to_show->state & STATE_DISPLAY_PENDING); |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1037 |
28642 | 1038 //show it, displaying is always vsynced, so skip it for benchmark |
1039 put_xvmc_image(p_render_surface_to_show,first_frame); | |
1040 first_frame=0;//make sure we won't draw it anymore | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1041 |
28642 | 1042 p_render_surface_visible = p_render_surface_to_show; |
1043 p_render_surface_to_show = NULL; | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1044 } |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1045 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1046 static void check_events(void){ |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1047 int e=vo_x11_check_events(mDisplay); |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1048 |
28642 | 1049 if(e&VO_EVENT_RESIZE) |
1050 { | |
1051 e |= VO_EVENT_EXPOSE; | |
1052 } | |
1053 if ( e & VO_EVENT_EXPOSE ) | |
1054 { | |
1055 put_xvmc_image(p_render_surface_visible,1); | |
1056 } | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1057 } |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1058 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1059 static void xvmc_free(void){ |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1060 int i; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1061 |
28642 | 1062 if( subpicture_alloc ){ |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1063 |
28642 | 1064 XvMCDestroySubpicture(mDisplay,&subpicture); |
1065 deallocate_xvimage(); | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1066 |
28642 | 1067 subpicture_alloc = 0; |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1068 |
28644 | 1069 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: subpicture destroyed\n"); |
28642 | 1070 } |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1071 |
28642 | 1072 if( number_of_surfaces ){ |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1073 |
28642 | 1074 XvMCDestroyMacroBlocks(mDisplay,&mv_blocks); |
1075 XvMCDestroyBlocks(mDisplay,&data_blocks); | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1076 |
28642 | 1077 for(i=0; i<number_of_surfaces; i++) |
1078 { | |
1079 XvMCHideSurface(mDisplay,&surface_array[i]);//it doesn't hurt, I hope | |
1080 XvMCDestroySurface(mDisplay,&surface_array[i]); | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1081 |
33195
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
1082 if( (surface_render_info[i].state != 0) && |
28642 | 1083 (p_render_surface_visible != &surface_render[i]) ) |
28645 | 1084 mp_msg(MSGT_VO,MSGL_INFO,"vo_xvmc::uninit surface_render[%d].status=%d\n",i, |
33195
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
1085 surface_render_info[i].state); |
28642 | 1086 } |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1087 |
28642 | 1088 memset(surface_render, 0, MAX_SURFACES * sizeof(struct xvmc_pix_fmt)); //for debugging |
1089 free(surface_render);surface_render=NULL; | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1090 |
28642 | 1091 XvMCDestroyContext(mDisplay,&ctx); |
1092 number_of_surfaces = 0; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1093 |
28644 | 1094 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: Context sucessfuly freed\n"); |
28642 | 1095 } |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1096 |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1097 |
28642 | 1098 if( xv_port !=0 ){ |
1099 XvUngrabPort(mDisplay,xv_port,CurrentTime); | |
1100 xv_port = 0; | |
28644 | 1101 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: xv_port sucessfuly ungrabed\n"); |
28642 | 1102 } |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1103 } |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1104 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1105 static void uninit(void){ |
28644 | 1106 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: uninit called\n"); |
28642 | 1107 xvmc_free(); |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1108 //from vo_xv |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
1109 #ifdef CONFIG_XF86VM |
28642 | 1110 vo_vm_close(); |
15211 | 1111 #endif |
28642 | 1112 vo_x11_uninit(); |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1113 } |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1114 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15866
diff
changeset
|
1115 static int query_format(uint32_t format){ |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1116 uint32_t flags; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1117 XvMCSurfaceInfo qsurface_info; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1118 int mode_id; |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1119 |
28644 | 1120 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: query_format=%X\n",format); |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1121 |
28642 | 1122 if(!IMGFMT_IS_XVMC(format)) return 0;// no caps supported |
31834
64ba1daa147a
various spelling fixes, found by the Debian QA tool 'lintian'
siretart
parents:
31316
diff
changeset
|
1123 mode_id = xvmc_find_surface_by_format(format, 16, 16, &qsurface_info, 1);//true=1 - querying |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1124 |
28642 | 1125 if( mode_id == 0 ) return 0; |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1126 |
28642 | 1127 flags = VFCAP_CSP_SUPPORTED | |
1128 VFCAP_CSP_SUPPORTED_BY_HW | | |
1129 VFCAP_ACCEPT_STRIDE; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1130 |
28642 | 1131 if( (qsurface_info.subpicture_max_width != 0) && |
1132 (qsurface_info.subpicture_max_height != 0) ) | |
1133 flags|=VFCAP_OSD; | |
1134 return flags; | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1135 } |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1136 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1137 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15866
diff
changeset
|
1138 static int draw_slice(uint8_t *image[], int stride[], |
28569
fb881ea1a985
whitespace cosmetics: Remove all tabs and trailing whitespace.
diego
parents:
28568
diff
changeset
|
1139 int w, int h, int x, int y){ |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1140 struct xvmc_pix_fmt *rndr; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1141 int rez; |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1142 |
28644 | 1143 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: draw_slice y=%d\n",y); |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1144 |
28642 | 1145 rndr = (struct xvmc_pix_fmt*)image[2]; //this is copy of priv-ate |
1146 assert( rndr != NULL ); | |
1147 assert( rndr->xvmc_id == AV_XVMC_ID ); | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1148 |
28642 | 1149 rez = XvMCRenderSurface(mDisplay,&ctx,rndr->picture_structure, |
1150 rndr->p_surface, | |
1151 rndr->p_past_surface, | |
1152 rndr->p_future_surface, | |
1153 rndr->flags, | |
1154 rndr->filled_mv_blocks_num,rndr->start_mv_blocks_num, | |
1155 &mv_blocks,&data_blocks); | |
1156 if(rez != Success) | |
1157 { | |
1158 int i; | |
28645 | 1159 mp_msg(MSGT_VO,MSGL_ERR,"vo_xvmc::slice: RenderSirface returned %d\n",rez); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1160 |
28645 | 1161 mp_msg(MSGT_VO,MSGL_ERR,"vo_xvmc::slice: pict=%d,flags=%x,start_blocks=%d,num_blocks=%d\n", |
28642 | 1162 rndr->picture_structure,rndr->flags,rndr->start_mv_blocks_num, |
1163 rndr->filled_mv_blocks_num); | |
28645 | 1164 mp_msg(MSGT_VO,MSGL_ERR,"vo_xvmc::slice: this_surf=%p, past_surf=%p, future_surf=%p\n", |
28642 | 1165 rndr->p_surface,rndr->p_past_surface,rndr->p_future_surface); |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1166 |
28642 | 1167 for(i=0; i<rndr->filled_mv_blocks_num; i++){ |
1168 XvMCMacroBlock* testblock; | |
1169 testblock = &mv_blocks.macro_blocks[i]; | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1170 |
28645 | 1171 mp_msg(MSGT_VO,MSGL_ERR,"vo_xvmc::slice: mv_block - x=%d,y=%d,mb_type=0x%x,mv_type=0x%x,mv_field_select=%d\n", |
28642 | 1172 testblock->x,testblock->y,testblock->macroblock_type, |
1173 testblock->motion_type,testblock->motion_vertical_field_select); | |
28645 | 1174 mp_msg(MSGT_VO,MSGL_ERR,"vo_xvmc::slice: dct_type=%d,data_index=0x%x,cbp=%d,pad0=%d\n", |
28642 | 1175 testblock->dct_type,testblock->index,testblock->coded_block_pattern, |
1176 testblock->pad0); | |
28645 | 1177 mp_msg(MSGT_VO,MSGL_ERR,"vo_xvmc::slice: PMV[0][0][0/1]=(%d,%d)\n", |
28642 | 1178 testblock->PMV[0][0][0],testblock->PMV[0][0][1]); |
1179 } | |
1180 } | |
1181 assert(rez==Success); | |
28644 | 1182 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: flush surface\n"); |
28642 | 1183 rez = XvMCFlushSurface(mDisplay, rndr->p_surface); |
1184 assert(rez==Success); | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1185 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1186 // rndr->start_mv_blocks_num += rndr->filled_mv_blocks_num; |
28642 | 1187 rndr->start_mv_blocks_num = 0; |
1188 rndr->filled_mv_blocks_num = 0; | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1189 |
28642 | 1190 rndr->next_free_data_block_num = 0; |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1191 |
28642 | 1192 return VO_TRUE; |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1193 } |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1194 |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1195 //XvMCHide hides the surface on next retrace, so |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1196 //check if the surface is not still displaying |
28568
1a90167d9f0e
The xvmc_pixfmt_render structure was renamed to xvmc_pix_fmt in FFmpeg.
diego
parents:
28567
diff
changeset
|
1197 static void check_osd_source(struct xvmc_pix_fmt *src_rndr) { |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1198 struct xvmc_pix_fmt *osd_rndr; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1199 int stat; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1200 |
28642 | 1201 //If this is source surface, check does the OSD rendering is compleate |
33195
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
1202 if(get_render_info(src_rndr)->state & STATE_OSD_SOURCE){ |
31834
64ba1daa147a
various spelling fixes, found by the Debian QA tool 'lintian'
siretart
parents:
31316
diff
changeset
|
1203 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: OSD surface=%p querying\n",src_rndr); |
33195
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
1204 osd_rndr = get_render_info(src_rndr)->p_osd_target_surface_render; |
28642 | 1205 XvMCGetSurfaceStatus(mDisplay, osd_rndr->p_surface, &stat); |
1206 if(!(stat & XVMC_RENDERING)) | |
33197 | 1207 remove_state(src_rndr, STATE_OSD_SOURCE); |
28642 | 1208 } |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1209 } |
28232
8df85ad26746
Add missing 'void' keyword to parameterless function declarations.
diego
parents:
28202
diff
changeset
|
1210 static int count_free_surfaces(void) { |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1211 int i,num; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1212 |
28642 | 1213 num=0; |
1214 for(i=0; i<number_of_surfaces; i++){ | |
1215 check_osd_source(&surface_render[i]); | |
33197 | 1216 if(!in_use(surface_render + i)) |
28642 | 1217 num++; |
1218 } | |
1219 return num; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1220 } |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1221 |
28568
1a90167d9f0e
The xvmc_pixfmt_render structure was renamed to xvmc_pix_fmt in FFmpeg.
diego
parents:
28567
diff
changeset
|
1222 static struct xvmc_pix_fmt *find_free_surface(void) { |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1223 int i,t; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1224 int stat; |
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1225 struct xvmc_pix_fmt *visible_rndr; |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1226 |
28642 | 1227 visible_rndr = NULL; |
1228 for(i=0; i<number_of_surfaces; i++){ | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1229 |
28642 | 1230 check_osd_source(&surface_render[i]); |
33197 | 1231 if( !in_use(surface_render + i)){ |
28642 | 1232 XvMCGetSurfaceStatus(mDisplay, surface_render[i].p_surface,&stat); |
1233 if( (stat & XVMC_DISPLAYING) == 0 ) | |
1234 return &surface_render[i]; | |
1235 visible_rndr = &surface_render[i];// remember it, use as last resort | |
1236 } | |
1237 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1238 |
28642 | 1239 //all surfaces are busy, but there is one that will be free |
1240 //on next monitor retrace, we just have to wait | |
1241 if(visible_rndr != NULL){ | |
28645 | 1242 mp_msg(MSGT_VO,MSGL_INFO,"vo_xvmc: waiting retrace\n"); |
28642 | 1243 for(t=0;t<1000;t++){ |
1244 usec_sleep(1000);//1ms | |
1245 XvMCGetSurfaceStatus(mDisplay, visible_rndr->p_surface,&stat); | |
1246 if( (stat & XVMC_DISPLAYING) == 0 ) | |
1247 return visible_rndr; | |
1248 } | |
1249 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1250 //todo remove when stable |
28645 | 1251 mp_msg(MSGT_VO,MSGL_WARN,"vo_xvmc: no free surfaces, this should not happen in g1\n"); |
28642 | 1252 for(i=0;i<number_of_surfaces;i++) |
33195
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
1253 mp_msg(MSGT_VO,MSGL_WARN,"vo_xvmc: surface[%d].state=%d\n",i,surface_render_info[i].state); |
28642 | 1254 return NULL; |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1255 } |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1256 |
22257
f979aa12d8cc
Don't free and then allocate surfaces when config() is called again with same resolution and format.
iive
parents:
22246
diff
changeset
|
1257 static void xvmc_clean_surfaces(void){ |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1258 int i; |
22257
f979aa12d8cc
Don't free and then allocate surfaces when config() is called again with same resolution and format.
iive
parents:
22246
diff
changeset
|
1259 |
28642 | 1260 for(i=0; i<number_of_surfaces; i++){ |
22257
f979aa12d8cc
Don't free and then allocate surfaces when config() is called again with same resolution and format.
iive
parents:
22246
diff
changeset
|
1261 |
33197 | 1262 remove_state(surface_render + i, STATE_DISPLAY_PENDING | STATE_OSD_SOURCE); |
33195
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
1263 surface_render_info[i].p_osd_target_surface_render=NULL; |
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
1264 if(surface_render_info[i].state != 0){ |
28642 | 1265 mp_msg(MSGT_VO,MSGL_WARN,"vo_xvmc: surface[%d].state=%d\n", |
33195
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
1266 i,surface_render_info[i].state); |
28642 | 1267 } |
1268 } | |
1269 free_element=0;//clean up the queue | |
22257
f979aa12d8cc
Don't free and then allocate surfaces when config() is called again with same resolution and format.
iive
parents:
22246
diff
changeset
|
1270 } |
f979aa12d8cc
Don't free and then allocate surfaces when config() is called again with same resolution and format.
iive
parents:
22246
diff
changeset
|
1271 |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1272 static uint32_t get_image(mp_image_t *mpi){ |
28642 | 1273 struct xvmc_pix_fmt *rndr; |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1274 |
28642 | 1275 rndr = find_free_surface(); |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1276 |
28642 | 1277 if(rndr == NULL){ |
28645 | 1278 mp_msg(MSGT_VO,MSGL_ERR,"vo_xvmc: get_image failed\n"); |
28642 | 1279 return VO_FALSE; |
1280 } | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1281 |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1282 assert(rndr->start_mv_blocks_num == 0); |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1283 assert(rndr->filled_mv_blocks_num == 0); |
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1284 assert(rndr->next_free_data_block_num == 0); |
10452 | 1285 |
28642 | 1286 mpi->flags |= MP_IMGFLAG_DIRECT; |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1287 //keep strides 0 to avoid field manipulations |
28642 | 1288 mpi->stride[0] = 0; |
1289 mpi->stride[1] = 0; | |
1290 mpi->stride[2] = 0; | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1291 |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1292 // these are shared!! so watch out |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1293 // do call RenderSurface before overwriting |
28642 | 1294 mpi->planes[0] = (char*)data_blocks.blocks; |
1295 mpi->planes[1] = (char*)mv_blocks.macro_blocks; | |
1296 mpi->priv = | |
1297 mpi->planes[2] = (char*)rndr; | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1298 |
28642 | 1299 rndr->picture_structure = 0; |
1300 rndr->flags = 0; | |
33195
2f560e361175
Quick hack to fix compilation. Testing and improvements welcome.
reimar
parents:
32467
diff
changeset
|
1301 get_render_info(rndr)->state = 0; |
33197 | 1302 get_render_info(rndr)->mpi = mpi; |
28642 | 1303 rndr->start_mv_blocks_num = 0; |
1304 rndr->filled_mv_blocks_num = 0; | |
1305 rndr->next_free_data_block_num = 0; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1306 |
28644 | 1307 mp_msg(MSGT_VO,MSGL_DBG4,"vo_xvmc: get_image: rndr=%p (surface=%p) \n", |
28642 | 1308 rndr,rndr->p_surface); |
28569
fb881ea1a985
whitespace cosmetics: Remove all tabs and trailing whitespace.
diego
parents:
28568
diff
changeset
|
1309 return VO_TRUE; |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1310 } |
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1311 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15866
diff
changeset
|
1312 static int control(uint32_t request, void *data, ... ) |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1313 { |
28642 | 1314 switch (request){ |
1315 case VOCTRL_GET_DEINTERLACE: | |
1316 *(int*)data = bob_deinterlace; | |
1317 return VO_TRUE; | |
1318 case VOCTRL_SET_DEINTERLACE: | |
1319 bob_deinterlace = *(int*)data; | |
1320 return VO_TRUE; | |
1321 case VOCTRL_QUERY_FORMAT: | |
1322 return query_format(*((uint32_t*)data)); | |
1323 case VOCTRL_DRAW_IMAGE: | |
1324 return xvmc_draw_image((mp_image_t *)data); | |
1325 case VOCTRL_GET_IMAGE: | |
1326 return get_image((mp_image_t *)data); | |
1327 //vo_xv | |
1328 case VOCTRL_GUISUPPORT: | |
1329 return VO_TRUE; | |
1330 case VOCTRL_ONTOP: | |
1331 vo_x11_ontop(); | |
1332 return VO_TRUE; | |
1333 case VOCTRL_FULLSCREEN: | |
1334 vo_x11_fullscreen(); | |
1335 // indended, fallthrough to update panscan on fullscreen/windowed switch | |
1336 case VOCTRL_SET_PANSCAN: | |
1337 if ( ( vo_fs && ( vo_panscan != vo_panscan_amount ) ) || ( !vo_fs && vo_panscan_amount ) ) | |
1338 { | |
1339 int old_y = vo_panscan_y; | |
1340 panscan_calc(); | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1341 |
28642 | 1342 if(old_y != vo_panscan_y) |
1343 { | |
1344 //this also draws the colorkey | |
1345 put_xvmc_image(p_render_surface_visible,1); | |
1346 } | |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1347 } |
28642 | 1348 return VO_TRUE; |
1349 case VOCTRL_GET_PANSCAN: | |
1350 if ( !vo_config_count || !vo_fs ) return VO_FALSE; | |
1351 return VO_TRUE; | |
1352 case VOCTRL_SET_EQUALIZER: | |
1353 { | |
1354 va_list ap; | |
1355 int value; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1356 |
28642 | 1357 va_start(ap, data); |
1358 value = va_arg(ap, int); | |
1359 va_end(ap); | |
1360 | |
1361 return vo_xv_set_eq(xv_port, data, value); | |
1362 } | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1363 |
28642 | 1364 case VOCTRL_GET_EQUALIZER: |
1365 { | |
1366 va_list ap; | |
1367 int *value; | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1368 |
28642 | 1369 va_start(ap, data); |
1370 value = va_arg(ap, int*); | |
1371 va_end(ap); | |
10698
7ab88b24cb81
OSD support, optinal queue, optional use of sleep(), and benchmark mode
iive
parents:
10608
diff
changeset
|
1372 |
28642 | 1373 return vo_xv_get_eq(xv_port, data, value); |
1374 } | |
1375 case VOCTRL_UPDATE_SCREENINFO: | |
1376 update_xinerama_info(); | |
1377 return VO_TRUE; | |
1378 } | |
28643
fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
iive
parents:
28642
diff
changeset
|
1379 return VO_NOTIMPL; |
10360
b79a4c15d081
Initial version of XVideo Motion Compensation video driver/render
iive
parents:
diff
changeset
|
1380 } |