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