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