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