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