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