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