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