annotate libvo/vo_dxr2.c @ 11296:86916e46d445

different / faster / simpler "quantization" filtered images look like with the old quantization (to me at least) if anyone notices a difference then tell me ASAP
author michael
date Mon, 27 Oct 2003 21:12:29 +0000
parents 57bdcdb061d7
children 85e503ddf65f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
2 #include "fastmemcpy.h"
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
3 #include <stdio.h>
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
4 #include <stdlib.h>
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
5 #include <string.h>
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
6 #include <unistd.h>
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
7 #include <sys/ioctl.h>
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
8 #include <sys/stat.h>
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
9 #include <sys/types.h>
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
10 #include <fcntl.h>
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
11 #include <stdio.h>
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
12 #include <time.h>
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
13 #include <errno.h>
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
14
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
15 #include "config.h"
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
16 #include "video_out.h"
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
17 #include "video_out_internal.h"
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
18 #include "mp_msg.h"
10594
57bdcdb061d7 Removed the historic cfgparser and switched full to the new config parser (altought some macros still remain for compatibility). As a side effect 90% of the warning messages are gone from the core. Things should be cleaner now and less confusing for newbies.
alex
parents: 8148
diff changeset
19 #include "m_option.h"
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
20 #include "sub.h"
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
21
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
22 #ifdef X11_FULLSCREEN
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
23 #include "x11_common.h"
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
24 #endif
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
25
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
26 #include <dxr2ioctl.h>
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
27
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
28
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
29 extern char *get_path(char *filename);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
30
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
31 extern float monitor_aspect;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
32 extern float movie_aspect;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
33
6074
10a30eebafaf Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents: 6070
diff changeset
34 int dxr2_fd = -1;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
35
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
36 static int movie_w,movie_h;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
37 static int playing = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
38 static int last_freq_id = -1;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
39
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
40 // vo device used to blank the screen for the overlay init
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
41 static vo_functions_t* sub_vo = NULL;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
42
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
43 static uint8_t* sub_img = NULL;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
44 static int sub_x,sub_y,sub_w,sub_h;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
45 static int sub_x_off,sub_y_off;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
46 static int sub_config_count;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
47 static int aspect;
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
48 static int sub_vo_win = 0;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
49
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
50 static int use_ol = 1;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
51 static int ol_ratio = 1000;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
52 static char *norm = NULL;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
53 static char *ucode = NULL;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
54 static int ar_mode = DXR2_ASPECTRATIOMODE_LETTERBOX;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
55 static int mv_mode = DXR2_MACROVISION_OFF;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
56 static int _75ire_mode = DXR2_75IRE_OFF;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
57 static int bw_mode = DXR2_BLACKWHITE_OFF;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
58 static int interlaced_mode = DXR2_INTERLACED_ON;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
59 static int pixel_mode = DXR2_PIXEL_CCIR601;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
60 static int iec958_mode = DXR2_IEC958_DECODED;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
61 static int mute_mode = DXR2_AUDIO_MUTE_OFF;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
62 static int ignore_cache = 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
63 static int update_cache = 0;
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
64 static int olw_cor = 0, olh_cor = 0,olx_cor = 0, oly_cor = 0;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
65 static int ol_osd = 0;
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
66 static int ck_rmin = 0x40;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
67 static int ck_rmax = 0xFF;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
68 static int ck_r = 0xFF;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
69 static int ck_gmin = 0x00;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
70 static int ck_gmax = 0x20;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
71 static int ck_g = 0;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
72 static int ck_bmin = 0x40;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
73 static int ck_bmax = 0xFF;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
74 static int ck_b = 0xFF;
8063
4c7ef4aeb88b Overlay cropping options. Patch by Mark <CompGuy284 at attbi dot com> extanded
albeu
parents: 7981
diff changeset
75 static int cr_left = 0, cr_right = 0;
4c7ef4aeb88b Overlay cropping options. Patch by Mark <CompGuy284 at attbi dot com> extanded
albeu
parents: 7981
diff changeset
76 static int cr_top = 55, cr_bot = 300;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
77
10594
57bdcdb061d7 Removed the historic cfgparser and switched full to the new config parser (altought some macros still remain for compatibility). As a side effect 90% of the warning messages are gone from the core. Things should be cleaner now and less confusing for newbies.
alex
parents: 8148
diff changeset
78 m_option_t dxr2_opts[] = {
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
79 { "overlay", &use_ol, CONF_TYPE_FLAG, 0, 0, 1, NULL},
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
80 { "nooverlay", &use_ol, CONF_TYPE_FLAG, 0, 1, 0, NULL},
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
81 { "overlay-ratio", &ol_ratio, CONF_TYPE_INT, CONF_RANGE, 1, 2500, NULL },
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
82 { "ucode", &ucode, CONF_TYPE_STRING,0, 0, 0, NULL},
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
83
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
84 { "norm", &norm, CONF_TYPE_STRING,0, 0, 0, NULL},
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
85
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
86 { "ar-mode",&ar_mode, CONF_TYPE_INT, CONF_RANGE,0,2,NULL },
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
87
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
88 { "macrovision",&mv_mode,CONF_TYPE_INT,CONF_RANGE,0,3, NULL },
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
89
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
90 { "75ire",&_75ire_mode,CONF_TYPE_FLAG, 0, 0, 1, NULL},
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
91 { "no75ire",&_75ire_mode,CONF_TYPE_FLAG, 0, 1, 0, NULL},
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
92
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
93 { "bw",&bw_mode,CONF_TYPE_FLAG, 0, 0, 1, NULL},
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
94 { "color",&bw_mode,CONF_TYPE_FLAG, 0, 1, 0, NULL},
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
95
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
96 { "interlaced",&interlaced_mode,CONF_TYPE_FLAG, 0, 0, 1, NULL},
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
97 { "nointerlaced",&interlaced_mode,CONF_TYPE_FLAG, 0, 1, 0, NULL},
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
98
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
99 { "square-pixel",&pixel_mode,CONF_TYPE_FLAG, 0, 0, 1, NULL},
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
100 { "ccir601-pixel",&pixel_mode,CONF_TYPE_FLAG, 0, 1, 0, NULL},
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
101
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
102 { "iec958-encoded",&iec958_mode,CONF_TYPE_FLAG, 0, 0, 1, NULL},
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
103 { "iec958-decoded",&iec958_mode,CONF_TYPE_FLAG, 0, 1, 0, NULL},
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
104
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
105 { "mute", &mute_mode,CONF_TYPE_FLAG, 0, 1, 0, NULL},
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
106 { "nomute",&mute_mode,CONF_TYPE_FLAG, 0, 0, 1, NULL},
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
107
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
108 { "ignore-cache",&ignore_cache,CONF_TYPE_FLAG, 0, 0, 1, NULL},
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
109 { "update-cache",&update_cache,CONF_TYPE_FLAG, 0, 0, 1, NULL},
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
110
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
111 { "olh-cor", &olh_cor, CONF_TYPE_INT, CONF_RANGE, -20, 20, NULL},
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
112 { "olw-cor", &olw_cor, CONF_TYPE_INT, CONF_RANGE, -20, 20, NULL},
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
113 { "olx-cor", &olx_cor, CONF_TYPE_INT, CONF_RANGE, -20, 20, NULL},
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
114 { "oly-cor", &oly_cor, CONF_TYPE_INT, CONF_RANGE, -20, 20, NULL},
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
115
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
116 { "ol-osd", &ol_osd, CONF_TYPE_FLAG, 0, 0, 1, NULL},
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
117 { "nool-osd", &ol_osd, CONF_TYPE_FLAG, 0, 1, 0, NULL},
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
118
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
119 { "ck-rmin", &ck_rmin, CONF_TYPE_INT, CONF_RANGE, 0, 0xFF, NULL},
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
120 { "ck-rmax", &ck_rmax, CONF_TYPE_INT, CONF_RANGE, 0, 0xFF, NULL},
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
121 { "ck-r", &ck_r, CONF_TYPE_INT, CONF_RANGE, 0, 0xFF, NULL},
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
122 { "ck-gmin", &ck_gmin, CONF_TYPE_INT, CONF_RANGE, 0, 0xFF, NULL},
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
123 { "ck-gmax", &ck_gmax, CONF_TYPE_INT, CONF_RANGE, 0, 0xFF, NULL},
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
124 { "ck-g", &ck_g, CONF_TYPE_INT, CONF_RANGE, 0, 0xFF, NULL},
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
125 { "ck-bmin", &ck_bmin, CONF_TYPE_INT, CONF_RANGE, 0, 0xFF, NULL},
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
126 { "ck-bmax", &ck_bmax, CONF_TYPE_INT, CONF_RANGE, 0, 0xFF, NULL},
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
127 { "ck-b", &ck_b, CONF_TYPE_INT, CONF_RANGE, 0, 0xFF, NULL},
8063
4c7ef4aeb88b Overlay cropping options. Patch by Mark <CompGuy284 at attbi dot com> extanded
albeu
parents: 7981
diff changeset
128 { "cr-left", &cr_left, CONF_TYPE_INT, CONF_RANGE, 0, 500, NULL},
4c7ef4aeb88b Overlay cropping options. Patch by Mark <CompGuy284 at attbi dot com> extanded
albeu
parents: 7981
diff changeset
129 { "cr-right", &cr_right, CONF_TYPE_INT, CONF_RANGE, 0, 500, NULL},
4c7ef4aeb88b Overlay cropping options. Patch by Mark <CompGuy284 at attbi dot com> extanded
albeu
parents: 7981
diff changeset
130 { "cr-top", &cr_top, CONF_TYPE_INT, CONF_RANGE, 0, 500, NULL},
4c7ef4aeb88b Overlay cropping options. Patch by Mark <CompGuy284 at attbi dot com> extanded
albeu
parents: 7981
diff changeset
131 { "cr-bot", &cr_bot, CONF_TYPE_INT, CONF_RANGE, 0, 500, NULL},
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
132
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
133 { NULL,NULL, 0, 0, 0, 0, NULL}
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
134 };
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
135
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 8115
diff changeset
136 static vo_info_t info = {
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
137 "DXR2 video out",
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
138 "dxr2",
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
139 "Alban Bedel <albeu@free.fr> and Tobias Diedrich <ranma@gmx.at>",
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
140 ""
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
141 };
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
142
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 8115
diff changeset
143 LIBVO_EXTERN (dxr2)
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 8115
diff changeset
144
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
145 static char *ucodesearchpath[] = {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
146 "/usr/local/lib/dxr2/dvd12.ux",
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
147 "/usr/lib/dxr2/dvd12.ux",
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
148 "/usr/src/dvd12.ux",
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
149 NULL,
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
150 };
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
151
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
152 #define BUF_SIZE 2048
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
153
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
154 static unsigned char dxr2buf[BUF_SIZE];
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
155 static unsigned int dxr2bufpos = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
156
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
157 static void write_dxr2(void *data, int len)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
158 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
159 int w = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
160 while (len>0) if ((dxr2bufpos+len) <= BUF_SIZE) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
161 memcpy(dxr2buf+dxr2bufpos, data, len);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
162 dxr2bufpos+=len;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
163 len=0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
164 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
165 int copylen=BUF_SIZE-dxr2bufpos;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
166 if(copylen > 0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
167 memcpy(dxr2buf+dxr2bufpos, data, copylen);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
168 dxr2bufpos += copylen;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
169 data+=copylen;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
170 len-=copylen;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
171 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
172 w = write(dxr2_fd, dxr2buf, BUF_SIZE);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
173 if(w < 0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
174 mp_msg(MSGT_VO,MSGL_WARN,"DXR2 : write failed : %s \n",strerror(errno));
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
175 dxr2bufpos = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
176 break;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
177 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
178 dxr2bufpos -= w;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
179 if(dxr2bufpos)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
180 memmove(dxr2buf,dxr2buf + w,dxr2bufpos);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
181 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
182 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
183
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
184 static void flush_dxr2()
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
185 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
186 int w;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
187 while (dxr2bufpos) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
188 w = write(dxr2_fd, dxr2buf, dxr2bufpos);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
189 if(w < 0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
190 mp_msg(MSGT_VO,MSGL_WARN,"DXR2 : write failed %s \n",strerror(errno));
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
191 dxr2bufpos = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
192 break;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
193 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
194 dxr2bufpos -= w;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
195 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
196 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
197
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
198 #define PACK_MAX_SIZE 2048
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
199
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
200 static unsigned char pack[PACK_MAX_SIZE];
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
201
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
202 static unsigned char mpg_header[]={
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
203 0x00, 0x00, 0x01, 0xba, 0x44, 0x00, 0x04, 0x00,
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
204 0x04, 0x01, 0x01, 0x86, 0xa3, 0xf8
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
205 };
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
206
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
207 static unsigned char mpg_eof[]={
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
208 0x00, 0x00, 0x01, 0xb9
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
209 };
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
210
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
211 static void dxr2_send_header(void)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
212 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
213 write_dxr2(&mpg_header, sizeof(mpg_header));
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
214 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
215
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
216 static void dxr2_send_eof(void)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
217 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
218 write_dxr2(&mpg_eof, sizeof(mpg_eof));
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
219 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
220
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
221 void dxr2_send_packet(unsigned char* data,int len,int id,int timestamp)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
222 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
223 int ptslen=5;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
224
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
225 if(dxr2_fd < 0) {
6074
10a30eebafaf Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents: 6070
diff changeset
226 mp_msg(MSGT_VO,MSGL_ERR,"DXR2 fd is not valid\n");
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
227 return;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
228 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
229
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
230 mp_msg(MSGT_VO,MSGL_DBG2,"DXR2 packet : 0x%x => %d \n",id,timestamp);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
231 dxr2_send_header();
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
232
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
233 // startcode:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
234 pack[0]=pack[1]=0;pack[2]=0x01;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
235 // stream id
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
236 pack[3]=id;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
237
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
238 while(len>0){
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
239 int payload_size=len; // data + PTS
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
240 if(9+ptslen+payload_size>PACK_MAX_SIZE) payload_size=PACK_MAX_SIZE-(6+ptslen);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
241
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
242 // construct PES header: (code from ffmpeg's libav)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
243 // packetsize:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
244 pack[4]=(3+ptslen+payload_size)>>8;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
245 pack[5]=(3+ptslen+payload_size)&255;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
246
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
247 pack[6]=0x81;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
248 if(ptslen){
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
249 int x;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
250 pack[7]=0x80;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
251 pack[8]=ptslen;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
252 // presentation time stamp:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
253 x=(0x02 << 4) | (((timestamp >> 30) & 0x07) << 1) | 1;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
254 pack[9]=x;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
255 x=((((timestamp >> 15) & 0x7fff) << 1) | 1);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
256 pack[10]=x>>8; pack[11]=x&255;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
257 x=((((timestamp) & 0x7fff) << 1) | 1);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
258 pack[12]=x>>8; pack[13]=x&255;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
259 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
260 pack[7]=0x00;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
261 pack[8]=0x00;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
262 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
263
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
264 write_dxr2(pack, 9+ptslen);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
265 write_dxr2(data, payload_size);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
266
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
267 len-=payload_size; data+=payload_size;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
268 ptslen=0; // store PTS only once, at first packet!
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
269 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
270 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
271
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
272 void dxr2_send_lpcm_packet(unsigned char* data,int len,int id,unsigned int timestamp,int freq_id)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
273 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
274 int arg;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
275 int ptslen=5;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
276
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
277 if(dxr2_fd < 0) {
6074
10a30eebafaf Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents: 6070
diff changeset
278 mp_msg(MSGT_VO,MSGL_ERR,"DXR2 fd is not valid\n");
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
279 return;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
280 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
281
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
282 if(last_freq_id != freq_id) {
6074
10a30eebafaf Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents: 6070
diff changeset
283 ioctl(dxr2_fd, DXR2_IOC_SET_AUDIO_SAMPLE_FREQUENCY, &freq_id);
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
284 last_freq_id = freq_id;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
285 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
286
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
287 if (((int) timestamp)<0)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
288 timestamp=0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
289
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
290 mp_msg(MSGT_VO,MSGL_DBG2,"dxr2_send_lpcm_packet(timestamp=%d)\n", timestamp);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
291 // startcode:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
292 pack[0]=pack[1]=0;pack[2]=0x01;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
293
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
294 // stream id
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
295 pack[3]=0xBD;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
296
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
297 while(len>=4){
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
298 int payload_size;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
299
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
300 payload_size=PACK_MAX_SIZE-6-3-ptslen-7; // max possible data len
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
301 if(payload_size>len) payload_size=len;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
302 payload_size&=(~3); // align!
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
303
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
304 // packetsize:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
305 pack[4]=(payload_size+3+ptslen+7)>>8;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
306 pack[5]=(payload_size+3+ptslen+7)&255;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
307
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
308 // stuffing:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
309 pack[6]=0x81;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
310 // pack[7]=0x00; //0x80
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
311
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
312 // hdrlen:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
313 pack[8]=ptslen;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
314
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
315 if(ptslen){
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
316 int x;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
317 pack[7]=0x80;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
318 // presentation time stamp:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
319 x=(0x02 << 4) | (((timestamp >> 30) & 0x07) << 1) | 1;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
320 pack[9]=x;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
321 x=((((timestamp >> 15) & 0x7fff) << 1) | 1);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
322 pack[10]=x>>8; pack[11]=x&255;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
323 x=((((timestamp) & 0x7fff) << 1) | 1);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
324 pack[12]=x>>8; pack[13]=x&255;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
325 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
326 pack[7]=0x00;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
327 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
328
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
329 // ============ LPCM header: (7 bytes) =================
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
330 // Info by mocm@convergence.de
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
331
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
332 // ID:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
333 pack[ptslen+9]=id;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
334
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
335 // number of frames:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
336 pack[ptslen+10]=0x07;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
337
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
338 // first acces unit pointer, i.e. start of audio frame:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
339 pack[ptslen+11]=0x00;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
340 pack[ptslen+12]=0x04;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
341
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
342 // audio emphasis on-off 1 bit
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
343 // audio mute on-off 1 bit
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
344 // reserved 1 bit
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
345 // audio frame number 5 bit
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
346 pack[ptslen+13]=0x0C;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
347
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
348 // quantization word length 2 bit
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
349 // audio sampling frequency (48khz = 0, 96khz = 1) 2 bit
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
350 // reserved 1 bit
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
351 // number of audio channels - 1 (e.g. stereo = 1) 3 bit
6074
10a30eebafaf Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents: 6070
diff changeset
352 pack[ptslen+14]=1;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
353
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
354 // dynamic range control (0x80 if off)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
355 pack[ptslen+15]=0x80;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
356
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
357 write_dxr2(pack, 6+3+ptslen+7);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
358 write_dxr2(data, payload_size);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
359
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
360 len-=payload_size; data+=payload_size;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
361 timestamp+=90000/4*payload_size/48000;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
362 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
363 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
364
6111
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
365 void dxr2_send_sub_packet(unsigned char* data,int len,int id,unsigned int timestamp) {
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
366 int ptslen=5;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
367
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
368 if(dxr2_fd < 0) {
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
369 mp_msg(MSGT_VO,MSGL_ERR,"DXR2 fd is not valid\n");
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
370 return;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
371 }
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
372
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
373 if (((int) timestamp)<0)
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
374 timestamp=0;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
375
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
376 mp_msg(MSGT_VO,MSGL_DBG2,"dxr2_send_sub_packet(timestamp=%d)\n", timestamp);
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
377 // startcode:
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
378 pack[0]=pack[1]=0;pack[2]=0x01;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
379
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
380 // stream id
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
381 pack[3]=0xBD;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
382
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
383 while(len>=4){
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
384 int payload_size= PACK_MAX_SIZE-(7+ptslen+3);
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
385 if(payload_size>len) payload_size= len;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
386
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
387 pack[4]=(3+ptslen+1+payload_size)>>8;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
388 pack[5]=(3+ptslen+1+payload_size)&255;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
389
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
390 pack[6]=0x81;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
391 if(ptslen){
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
392 int x;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
393 pack[7]=0x80;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
394 pack[8]=ptslen;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
395 // presentation time stamp:
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
396 x=(0x02 << 4) | (((timestamp >> 30) & 0x07) << 1) | 1;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
397 pack[9]=x;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
398 x=((((timestamp >> 15) & 0x7fff) << 1) | 1);
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
399 pack[10]=x>>8; pack[11]=x&255;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
400 x=((((timestamp) & 0x7fff) << 1) | 1);
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
401 pack[12]=x>>8; pack[13]=x&255;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
402 } else {
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
403 pack[7]=0x00;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
404 pack[8]=0x00;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
405 }
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
406 pack[ptslen+9] = id;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
407
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
408 write_dxr2(pack,7+ptslen+3);
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
409 write_dxr2(data,payload_size);
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
410 len -= payload_size;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
411 data += payload_size;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
412 ptslen = 0;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
413 }
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
414 }
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
415
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
416 static int dxr2_set_vga_params(dxr2_vgaParams_t* vga,int detect) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
417 // Init the overlay, don't ask me how it work ;-)
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
418 dxr2_sixArg_t oc;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
419 dxr2_oneArg_t om;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
420 dxr2_twoArg_t win;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
421 dxr2_fourArg_t crop;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
422
8063
4c7ef4aeb88b Overlay cropping options. Patch by Mark <CompGuy284 at attbi dot com> extanded
albeu
parents: 7981
diff changeset
423 crop.arg1= cr_left;
4c7ef4aeb88b Overlay cropping options. Patch by Mark <CompGuy284 at attbi dot com> extanded
albeu
parents: 7981
diff changeset
424 crop.arg2= cr_right;
4c7ef4aeb88b Overlay cropping options. Patch by Mark <CompGuy284 at attbi dot com> extanded
albeu
parents: 7981
diff changeset
425 crop.arg3 = cr_top;
4c7ef4aeb88b Overlay cropping options. Patch by Mark <CompGuy284 at attbi dot com> extanded
albeu
parents: 7981
diff changeset
426 crop.arg4 = cr_bot;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
427 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_CROPPING, &crop);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
428
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
429 oc.arg1 = 0x40;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
430 oc.arg2 = 0xff;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
431 oc.arg3 = 0x40;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
432 oc.arg4 = 0xff;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
433 oc.arg5 = 0x40;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
434 oc.arg6 = 0xff;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
435 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_COLOUR, &oc);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
436
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
437 om.arg = ol_ratio;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
438 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_RATIO,&om);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
439
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
440 win.arg1 = 100;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
441 win.arg2 = 3;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
442 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_POSITION,&win);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
443
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
444 win.arg1 = vo_screenwidth;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
445 win.arg2 = vo_screenheight;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
446 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_DIMENSION,&win);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
447
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
448 om.arg = 0;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
449 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_IN_DELAY,&om);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
450
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
451 if(detect) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
452 // First we need a white screen
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
453 uint8_t* img = malloc(vo_screenwidth*vo_screenheight*3);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
454 uint8_t* src[] = { img, NULL, NULL };
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
455 int stride[] = { vo_screenwidth * 3 , 0, 0 };
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
456 int cc = vo_config_count;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
457
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
458 memset(img,255,vo_screenwidth*vo_screenheight*3);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
459 vo_config_count = sub_config_count;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
460 if(sub_vo->config(vo_screenwidth,vo_screenheight,vo_screenwidth,vo_screenheight,
7253
cb1ed89029e7 10l fix by Mark <CompGuy284@attbi.com>
alex
parents: 7124
diff changeset
461 VOFLAG_FULLSCREEN ,"DXR2 sub vo",IMGFMT_BGR24) != 0) {
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
462 mp_msg(MSGT_VO,MSGL_WARN,"VO: [dxr2] sub vo config failed => No overlay\n");
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
463 sub_vo->uninit();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
464 sub_vo = NULL;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
465 use_ol = 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
466 vo_config_count = cc;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
467 return 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
468 }
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
469 sub_vo->draw_slice(src,stride,vo_screenwidth,vo_screenheight,0,0);
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
470 sub_vo->flip_page();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
471 free(img);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
472 sub_config_count++;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
473 vo_config_count = cc;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
474
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
475 om.arg = DXR2_OVERLAY_WINDOW_COLOUR_KEY;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
476 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_MODE,&om);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
477
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
478 vga->xScreen = vo_screenwidth;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
479 vga->yScreen = vo_screenheight;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
480 vga->hOffWinKey = 100;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
481 vga->vOffWinKey = 3;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
482 ioctl(dxr2_fd, DXR2_IOC_CALCULATE_VGA_PARAMETERS, vga);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
483 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
484 ioctl(dxr2_fd, DXR2_IOC_SET_VGA_PARAMETERS,vga);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
485
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
486 return 1;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
487 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
488
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
489 static int dxr2_save_vga_params(dxr2_vgaParams_t* vga,char* name) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
490 struct stat s;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
491 char* p = get_path("dxr2_cache");
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
492 int p_len = strlen(p), name_len = strlen(name);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
493 char cache_path[p_len + name_len + 2];
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
494 int ret;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
495 FILE* fd;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
496
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
497 if(stat(p,&s) !=0) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
498 mp_msg(MSGT_VO,MSGL_WARN,"VO: [dxr2] No vga cache dir found (%s)\n",strerror(errno));
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
499 if(errno == EACCES) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
500 free(p);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
501 return 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
502 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
503 // Try to create the dir
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
504 if(mkdir(p,S_IRWXU) != 0) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
505 mp_msg(MSGT_VO,MSGL_ERR,"VO: [dxr2] Unable to create vga cache dir %s (%s)\n",p,strerror(errno));
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
506 free(p);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
507 return 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
508 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
509 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
510 sprintf(cache_path,"%s/%s",p,name);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
511 free(p);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
512 fd = fopen(cache_path,"w");
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
513 if(fd == NULL) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
514 mp_msg(MSGT_VO,MSGL_ERR,"VO: [dxr2] Unable to open cache file %s for writing (%s)\n",cache_path,strerror(errno));
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
515 return 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
516 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
517
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
518 ret = fprintf(fd,"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
519 vga->hOffWinKey,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
520 vga->vOffWinKey,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
521 vga->xScreen,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
522 vga->yScreen,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
523 vga->hsyncPol,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
524 vga->vsyncPol,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
525 vga->blankStart,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
526 vga->blankWidth,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
527 vga->hOffset,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
528 vga->vOffset,
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
529 vga->ratio,
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
530 olx_cor,
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
531 oly_cor,
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
532 olw_cor,
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
533 olh_cor);
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
534
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
535 fclose(fd);
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
536 return ret >= 11 ? 1 : 0;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
537 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
538
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
539 static int dxr2_load_vga_params(dxr2_vgaParams_t* vga,char* name) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
540 char* p = get_path("dxr2_cache");
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
541 int p_len = strlen(p), name_len = strlen(name);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
542 char cache_path[p_len + name_len + 2];
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
543 int ret;
8115
2406eb28a601 10L found by Mark <CompGuy284 at attbi dot com>
albeu
parents: 8063
diff changeset
544 int xc,yc,wc,hc;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
545 FILE* fd;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
546
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
547 sprintf(cache_path,"%s/%s",p,name);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
548 free(p);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
549
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
550 fd = fopen(cache_path,"r");
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
551 if(fd == NULL) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
552 mp_msg(MSGT_VO,MSGL_ERR,"VO: [dxr2] Unable to open cache file %s for reading (%s)\n",cache_path,strerror(errno));
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
553 return 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
554 }
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
555 ret = fscanf(fd, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
556 &vga->hOffWinKey,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
557 &vga->vOffWinKey,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
558 &vga->xScreen,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
559 &vga->yScreen,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
560 &vga->hsyncPol,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
561 &vga->vsyncPol,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
562 &vga->blankStart,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
563 &vga->blankWidth,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
564 &vga->hOffset,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
565 &vga->vOffset,
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
566 &vga->ratio,
8115
2406eb28a601 10L found by Mark <CompGuy284 at attbi dot com>
albeu
parents: 8063
diff changeset
567 &xc,
2406eb28a601 10L found by Mark <CompGuy284 at attbi dot com>
albeu
parents: 8063
diff changeset
568 &yc,
2406eb28a601 10L found by Mark <CompGuy284 at attbi dot com>
albeu
parents: 8063
diff changeset
569 &wc,
2406eb28a601 10L found by Mark <CompGuy284 at attbi dot com>
albeu
parents: 8063
diff changeset
570 &hc);
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
571
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
572 fclose(fd);
8115
2406eb28a601 10L found by Mark <CompGuy284 at attbi dot com>
albeu
parents: 8063
diff changeset
573 if(ret > 11 && !olx_cor) olx_cor = xc;
2406eb28a601 10L found by Mark <CompGuy284 at attbi dot com>
albeu
parents: 8063
diff changeset
574 if(ret > 12 && !oly_cor) oly_cor = yc;
2406eb28a601 10L found by Mark <CompGuy284 at attbi dot com>
albeu
parents: 8063
diff changeset
575 if(ret > 13 && !olw_cor) olw_cor = wc;
2406eb28a601 10L found by Mark <CompGuy284 at attbi dot com>
albeu
parents: 8063
diff changeset
576 if(ret > 14 && !olh_cor) olh_cor = hc;
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
577 return ret >= 11 ? 1 : 0;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
578 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
579
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
580 static int dxr2_setup_vga_params(void) {
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 8115
diff changeset
581 const vo_info_t* vi = sub_vo->info;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
582 dxr2_vgaParams_t vga;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
583
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
584 int loaded = dxr2_load_vga_params(&vga,(char*)vi->short_name);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
585 if(!dxr2_set_vga_params(&vga,(update_cache || ignore_cache) ? 1 : !loaded ))
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
586 return 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
587 if(!loaded || update_cache)
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
588 dxr2_save_vga_params(&vga,(char*)vi->short_name);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
589 return 1;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
590 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
591
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
592 static void dxr2_set_overlay_window(void) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
593 uint8_t* src[] = { sub_img, NULL, NULL };
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
594 int stride[] = { movie_w * 3 , 0, 0 };
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
595 dxr2_twoArg_t win;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
596 int redisp = 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
597 int cc = vo_config_count;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
598 vo_config_count = sub_config_count;
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
599 sub_vo->draw_slice(src,stride,movie_w,movie_h,0,0);
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
600 sub_vo->flip_page();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
601 vo_config_count = cc;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
602
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
603
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
604 mp_msg(MSGT_VO,MSGL_V,"VO: [dxr2] setting overlay with correction x=%d y=%d w=%d h=%d\n",olx_cor,oly_cor, olw_cor,olh_cor);
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
605
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
606 // Sub vo isn't a windowed one, fill in the needed stuff
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
607 if(!sub_vo_win) {
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
608 if(vo_fs) {
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
609 vo_dwidth = vo_screenwidth;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
610 vo_dheight = vo_screenheight;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
611 vo_dx = vo_dy = 0;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
612 } else {
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
613 vo_dwidth = movie_w;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
614 vo_dheight = movie_h;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
615 vo_dx = (vo_screenwidth - vo_dwidth) / 2;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
616 vo_dy = (vo_screenheight - vo_dheight) / 2;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
617 }
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
618 }
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
619
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
620 if(sub_w != vo_dwidth || sub_h != vo_dheight) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
621 int new_aspect = ((1<<16)*vo_dwidth + vo_dheight/2)/vo_dheight;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
622 sub_w = vo_dwidth;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
623 sub_h = vo_dheight;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
624 if(new_aspect > aspect)
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
625 sub_w = (sub_h*aspect + (1<<15))>>16;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
626 else
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
627 sub_h = ((sub_w<<16) + (aspect>>1)) /aspect;
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
628 sub_w += olw_cor;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
629 sub_h += olh_cor;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
630 sub_x_off = (vo_dwidth-sub_w) / 2;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
631 sub_y_off = (vo_dheight-sub_h) / 2;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
632 sub_x = -vo_dx; // Be sure to also replace the overlay
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
633 win.arg1 = sub_w;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
634 win.arg2 = sub_h;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
635 mp_msg(MSGT_VO,MSGL_V,"VO: [dxr2] set win size w=%d h=%d and offset x=%d y=%d \n",win.arg1,win.arg2,sub_x_off,sub_y_off);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
636 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_DIMENSION, &win);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
637 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
638
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
639 if(vo_dx != sub_x || vo_dy != sub_y) {
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
640 sub_x = vo_dx + olx_cor + sub_x_off;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
641 sub_y = vo_dy + oly_cor + sub_y_off;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
642 win.arg1 = (sub_x > 0 ? sub_x : 0);
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
643 win.arg2 = (sub_y > 0 ? sub_y : 0);
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
644 mp_msg(MSGT_VO,MSGL_V,"VO: [dxr2] set pos x=%d y=%d \n",win.arg1,win.arg2);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
645 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_POSITION,&win);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
646 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
647
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
648 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
649
7124
eca7dbad0166 finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents: 6817
diff changeset
650 static uint32_t config(uint32_t s_width, uint32_t s_height, uint32_t width, uint32_t height, uint32_t flags, char *title, uint32_t format)
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
651 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
652 int arg;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
653 dxr2_threeArg_t arg3;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
654
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
655 if(dxr2_fd < 0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
656 mp_msg(MSGT_VO,MSGL_ERR,"DXR2 fd is not valid\n");
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
657 return VO_ERROR;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
658 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
659
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
660 if(playing) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
661 dxr2_send_eof();
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
662 flush_dxr2();
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
663 ioctl(dxr2_fd, DXR2_IOC_STOP, NULL);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
664 playing = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
665 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
666
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
667 last_freq_id = -1;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
668
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
669 // Video stream setup
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
670 arg3.arg1 = DXR2_STREAM_VIDEO;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
671 arg3.arg2 = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
672 ioctl(dxr2_fd, DXR2_IOC_SELECT_STREAM, &arg3);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
673 if (vo_fps > 28)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
674 arg3.arg1 = DXR2_SRC_VIDEO_FREQ_30;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
675 else arg3.arg1 = DXR2_SRC_VIDEO_FREQ_25;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
676 arg3.arg2 = s_width;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
677 arg3.arg3 = s_height;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
678 ioctl(dxr2_fd, DXR2_IOC_SET_SOURCE_VIDEO_FORMAT, &arg3);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
679 arg = DXR2_BITSTREAM_TYPE_MPEG_VOB;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
680 ioctl(dxr2_fd, DXR2_IOC_SET_BITSTREAM_TYPE, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
681
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
682 // Aspect ratio
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
683 if (1.76 <= movie_aspect && movie_aspect <= 1.80) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
684 arg = DXR2_ASPECTRATIO_16_9;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
685 mp_msg(MSGT_VO,MSGL_V,"VO: [dxr2] source aspect ratio 16:9\n");
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
686 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
687 arg = DXR2_ASPECTRATIO_4_3;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
688 mp_msg(MSGT_VO,MSGL_V,"VO: [dxr2] source aspect ratio 4:3\n");
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
689 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
690 ioctl(dxr2_fd, DXR2_IOC_SET_SOURCE_ASPECT_RATIO, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
691 if (1.76 <= monitor_aspect && monitor_aspect <=1.80) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
692 arg = DXR2_ASPECTRATIO_16_9;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
693 mp_msg(MSGT_VO,MSGL_V,"VO: [dxr2] monitor aspect ratio 16:9\n");
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
694 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
695 arg = DXR2_ASPECTRATIO_4_3;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
696 mp_msg(MSGT_VO,MSGL_V,"VO: [dxr2] monitor aspect ratio 4:3\n");
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
697 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
698 ioctl(dxr2_fd, DXR2_IOC_SET_OUTPUT_ASPECT_RATIO, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
699
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
700 arg = ar_mode;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
701 ioctl(dxr2_fd, DXR2_IOC_SET_ASPECT_RATIO_MODE, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
702
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
703 // TV setup
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
704 arg = mv_mode;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
705 ioctl(dxr2_fd, DXR2_IOC_SET_TV_MACROVISION_MODE, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
706 arg = _75ire_mode;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
707 ioctl(dxr2_fd, DXR2_IOC_SET_TV_75IRE_MODE, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
708 arg = bw_mode;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
709 ioctl(dxr2_fd, DXR2_IOC_SET_TV_BLACKWHITE_MODE, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
710 arg = interlaced_mode;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
711 ioctl(dxr2_fd, DXR2_IOC_SET_TV_INTERLACED_MODE, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
712 arg = pixel_mode;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
713 ioctl(dxr2_fd, DXR2_IOC_SET_TV_PIXEL_MODE, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
714
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
715 if (norm) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
716 if (strcmp(norm, "ntsc")==0)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
717 arg = DXR2_OUTPUTFORMAT_NTSC;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
718 else if (strcmp(norm, "pal")==0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
719 if (vo_fps > 28) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
720 mp_msg(MSGT_VO,MSGL_WARN,"VO: [dxr2] you want pal, but we play at 30 fps, selecting pal60 instead\n");
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
721 arg = DXR2_OUTPUTFORMAT_PAL_60;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
722 norm="pal60";
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
723 } else arg = DXR2_OUTPUTFORMAT_PAL_BDGHI;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
724 } else if (strcmp(norm, "pal60")==0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
725 if (vo_fps > 28)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
726 arg = DXR2_OUTPUTFORMAT_PAL_60;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
727 else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
728 mp_msg(MSGT_VO,MSGL_WARN,"VO: [dxr2] you want pal60, but we play at 25 fps, selecting pal instead\n");
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
729 arg = DXR2_OUTPUTFORMAT_PAL_BDGHI;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
730 norm="pal";
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
731 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
732 } else if (strcmp(norm, "palm")==0)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
733 arg = DXR2_OUTPUTFORMAT_PAL_M;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
734 else if (strcmp(norm, "paln")==0)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
735 arg = DXR2_OUTPUTFORMAT_PAL_N;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
736 else if (strcmp(norm, "palnc")==0)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
737 arg = DXR2_OUTPUTFORMAT_PAL_Nc;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
738 else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
739 mp_msg(MSGT_VO,MSGL_WARN,"[dxr2] invalid norm %s\n", norm);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
740 mp_msg(MSGT_VO,MSGL_WARN,"Valid values are ntsc,pal,pal60,palm,paln,palnc\n");
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
741 mp_msg(MSGT_VO,MSGL_WARN,"Using ntsc\n");
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
742 norm="ntsc";
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
743 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
744 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
745 if (vo_fps > 28) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
746 arg = DXR2_OUTPUTFORMAT_NTSC;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
747 norm="ntsc";
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
748 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
749 arg = DXR2_OUTPUTFORMAT_PAL_BDGHI;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
750 norm="pal";
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
751 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
752 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
753 mp_msg(MSGT_VO,MSGL_V,"VO: [dxr2] output norm set to %s\n", norm);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
754 ioctl(dxr2_fd, DXR2_IOC_SET_TV_OUTPUT_FORMAT, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
755
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
756 // Subtitles
6111
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
757
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
758 arg = DXR2_SUBPICTURE_ON;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
759 ioctl(dxr2_fd,DXR2_IOC_ENABLE_SUBPICTURE,&arg);
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
760 arg3.arg1 = DXR2_STREAM_SUBPICTURE;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
761 arg3.arg2 = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
762 ioctl(dxr2_fd, DXR2_IOC_SELECT_STREAM, &arg3);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
763
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
764 // Audio
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
765 arg = iec958_mode;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
766 ioctl(dxr2_fd, DXR2_IOC_IEC958_OUTPUT_MODE, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
767 arg = DXR2_AUDIO_WIDTH_16;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
768 ioctl(dxr2_fd, DXR2_IOC_SET_AUDIO_DATA_WIDTH, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
769 arg = DXR2_AUDIO_FREQ_48;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
770 ioctl(dxr2_fd, DXR2_IOC_SET_AUDIO_SAMPLE_FREQUENCY, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
771 arg3.arg1 = DXR2_STREAM_AUDIO_LPCM;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
772 arg3.arg2 = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
773 ioctl(dxr2_fd, DXR2_IOC_SELECT_STREAM, &arg3);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
774 arg = 19;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
775 ioctl(dxr2_fd, DXR2_IOC_SET_AUDIO_VOLUME, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
776 arg = mute_mode;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
777 ioctl(dxr2_fd, DXR2_IOC_AUDIO_MUTE, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
778
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
779 movie_w = width;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
780 movie_h = height;
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
781 //vo_fs = flags & VOFLAG_FULLSCREEN ? 1 : 0;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
782 // Overlay
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
783 while(use_ol) {
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
784 dxr2_twoArg_t win;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
785 dxr2_oneArg_t om;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
786 int cc = vo_config_count;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
787 vo_config_count = sub_config_count;
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
788 // Load or detect the overlay stuff
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
789 if(!dxr2_setup_vga_params()) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
790 sub_vo->uninit();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
791 sub_vo = NULL;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
792 vo_config_count = cc;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
793 break;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
794 }
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
795 // Does the sub vo support the x11 stuff
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
796 // Fix me : test the other x11 vo's and enable them
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 8115
diff changeset
797 if(strcmp(sub_vo->info->short_name,"x11") == 0)
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
798 sub_vo_win = 1;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
799 else
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
800 sub_vo_win = 0;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
801
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
802 // No window and no osd => we don't need any subdriver
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
803 if(!sub_vo_win && !ol_osd) {
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
804 sub_vo->uninit();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
805 sub_vo = NULL;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
806 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
807
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
808 while(sub_vo) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
809 dxr2_sixArg_t oc;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
810 int i,sub_flags = VOFLAG_SWSCALE | (flags & VOFLAG_FULLSCREEN);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
811 if(sub_vo->config(width,height,width,height,sub_flags,
7253
cb1ed89029e7 10l fix by Mark <CompGuy284@attbi.com>
alex
parents: 7124
diff changeset
812 "MPlayer DXR2 render",IMGFMT_BGR24) != 0) {
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
813 mp_msg(MSGT_VO,MSGL_WARN,"VO: [dxr2] sub vo config failed => No X11 window\n");
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
814 sub_vo->uninit();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
815 sub_vo = NULL;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
816 break;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
817 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
818 sub_config_count++;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
819
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
820 // Feel free to try some other other color and report your results
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
821 oc.arg1 = ck_rmin;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
822 oc.arg2 = ck_rmax;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
823 oc.arg3 = ck_gmin;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
824 oc.arg4 = ck_gmax;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
825 oc.arg5 = ck_bmin;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
826 oc.arg6 = ck_bmax;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
827 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_COLOUR, &oc);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
828
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
829 om.arg = DXR2_OVERLAY_WINDOW_COLOUR_KEY;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
830 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_MODE,&om);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
831 sub_img = malloc(width*height*3);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
832 for(i = 0 ; i < width*height*3 ; i += 3) {
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
833 sub_img[i] = ck_b;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
834 sub_img[i+1] = ck_g;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
835 sub_img[i+2] = ck_r;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
836 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
837 aspect = ((1<<16)*width + height/2)/height;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
838 sub_w = sub_h = 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
839 dxr2_set_overlay_window();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
840 break;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
841 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
842 vo_config_count = cc;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
843 if(!sub_vo) { // Fallback on non windowed overlay
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
844 vo_fs = flags & VOFLAG_FULLSCREEN ? 1 : 0;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
845 om.arg = DXR2_OVERLAY_WINDOW_KEY;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
846 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_MODE,&om);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
847 win.arg1 = flags & VOFLAG_FULLSCREEN ? vo_screenwidth : width;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
848 win.arg2 = flags & VOFLAG_FULLSCREEN ? vo_screenheight : height;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
849 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_DIMENSION, &win);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
850 win.arg1 = (vo_screenwidth - win.arg1) / 2;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
851 win.arg2 = (vo_screenheight - win.arg2) / 2;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
852 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_POSITION,&win);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
853 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
854 break;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
855 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
856
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
857 // start playing
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
858 if(ioctl(dxr2_fd, DXR2_IOC_PLAY, NULL) == 0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
859 playing = 1;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
860 return 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
861 } else
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
862 return VO_ERROR;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
863 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
864
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
865 static void clear_alpha(int x0,int y0, int w,int h) {
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
866 uint8_t* src[] = { sub_img , NULL, NULL };
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
867 int stride[] = { movie_w * 3, 0, 0 };
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
868
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
869 sub_vo->draw_slice(src,stride,w,h,x0,y0);
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
870 }
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
871
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
872 static void draw_osd(void)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
873 {
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
874 if(sub_vo && ol_osd) {
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
875 vo_remove_text(movie_w,movie_h,clear_alpha);
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
876 sub_vo->draw_osd();
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
877 }
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
878 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
879
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
880 static uint32_t draw_frame(uint8_t * src[])
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
881 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
882 vo_mpegpes_t *p=(vo_mpegpes_t *)src[0];
6111
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
883 if(p->id == 0x1E0) {// Video
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
884 dxr2_send_packet(p->data, p->size, p->id, p->timestamp);
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
885 } else if(p->id == 0x20) // Subtitles
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
886 dxr2_send_sub_packet(p->data, p->size, p->id, p->timestamp);
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
887 return 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
888 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
889
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
890 static void flip_page (void)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
891 {
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
892 if(sub_vo && ol_osd && vo_osd_changed_flag)
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
893 sub_vo->flip_page();
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
894 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
895
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
896 static uint32_t draw_slice( uint8_t *srcimg[], int stride[], int w, int h, int x0, int y0 )
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
897 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
898 return 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
899 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
900
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
901
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
902 static uint32_t query_format(uint32_t format)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
903 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
904 if (format==IMGFMT_MPEGPES)
6074
10a30eebafaf Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents: 6070
diff changeset
905 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_TIMER|VFCAP_SPU;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
906 return 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
907 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
908
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
909
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
910 static void uninit(void)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
911 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
912 mp_msg(MSGT_VO,MSGL_DBG2, "VO: [dxr2] Uninitializing\n" );
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
913
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
914 if (dxr2_fd > 0) {
6111
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
915 if(playing) {
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
916 dxr2_send_eof();
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
917 flush_dxr2();
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
918 playing = 0;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
919 }
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
920 close(dxr2_fd);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
921 dxr2_fd = -1;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
922 }
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
923 if(sub_img) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
924 free(sub_img);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
925 sub_img = NULL;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
926 }
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
927 if(sub_vo) {
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
928 int cc = vo_config_count;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
929 vo_config_count = sub_config_count;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
930 sub_vo->uninit();
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
931 sub_vo = NULL;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
932 vo_config_count = cc;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
933 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
934 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
935
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
936
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
937 static void check_events(void)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
938 {
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
939 // I'd like to have this done in an x11 independent way
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
940 // It's because of this that we are limited to vo_x11 for windowed overlay :-(
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
941 #ifdef X11_FULLSCREEN
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
942 if(sub_vo && sub_vo_win) {
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
943 int e=vo_x11_check_events(mDisplay);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
944 if ( !(e&VO_EVENT_RESIZE) && !(e&VO_EVENT_EXPOSE) ) return;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
945 XSetBackground(mDisplay, vo_gc, 0);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
946 XClearWindow(mDisplay, vo_window);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
947 dxr2_set_overlay_window();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
948 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
949 #endif
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
950 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
951
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
952 static uint32_t preinit(const char *arg) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
953 int uCodeFD = -1;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
954 int uCodeSize;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
955 dxr2_uCode_t* uCode;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
956 dxr2_fourArg_t crop;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
957 int n=0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
958
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
959 sub_vo = NULL;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
960 sub_config_count = 0;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
961 if(use_ol) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
962 if (arg) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
963 for(n = 0 ; video_out_drivers[n] != NULL ; n++) {
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 8115
diff changeset
964 const vo_info_t* vi = video_out_drivers[n]->info;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
965 if(!vi)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
966 continue;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
967 if(strcasecmp(arg,vi->short_name) == 0)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
968 break;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
969 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
970 sub_vo = video_out_drivers[n];
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
971 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
972 mp_msg(MSGT_VO,MSGL_WARN,"VO: [dxr2] We need a sub driver to initialize the overlay\n");
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
973 use_ol = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
974 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
975 }
6070
bad23f7960f1 10L Crash if no subdriver given and overlay enabled
albeu
parents: 6069
diff changeset
976
bad23f7960f1 10L Crash if no subdriver given and overlay enabled
albeu
parents: 6069
diff changeset
977 if(!sub_vo) {
bad23f7960f1 10L Crash if no subdriver given and overlay enabled
albeu
parents: 6069
diff changeset
978 if(use_ol)
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
979 mp_msg(MSGT_VO,MSGL_WARN,"VO: [dxr2] Sub driver '%s' not found => no overlay\n",arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
980 use_ol = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
981 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
982 if(sub_vo->preinit(NULL) != 0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
983 mp_msg(MSGT_VO,MSGL_WARN,"VO: [dxr2] Sub vo %s preinit failed => no overlay\n",arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
984 sub_vo = NULL;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
985 use_ol = 0;
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
986 } else {
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
987 uint32_t fmt = IMGFMT_BGR24;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
988 mp_msg(MSGT_VO,MSGL_V,"VO: [dxr2] Sub vo %s inited\n",arg);
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
989 if(sub_vo->control(VOCTRL_QUERY_FORMAT,&fmt) <= 0) {
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
990 mp_msg(MSGT_VO,MSGL_WARN,"VO: [dxr2] Sub vo %s doesn't support BGR24 => no overlay\n",arg);
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
991 sub_vo->uninit();
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
992 sub_vo = NULL;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
993 use_ol = 0;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
994 }
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
995 }
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
996 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
997
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
998 dxr2_fd = open( "/dev/dxr2", O_WRONLY);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
999 if( dxr2_fd < 0 ) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1000 mp_msg(MSGT_VO,MSGL_V, "VO: [dxr2] Error opening /dev/dxr2 for writing!\n" );
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1001 return VO_ERROR;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1002 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1003
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1004 if(ucode)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1005 uCodeFD = open(ucode, O_RDONLY);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1006 else for (n=0; ucodesearchpath[n] != NULL; n++) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1007 mp_msg(MSGT_VO,MSGL_V,"VO: [dxr2] Looking for microcode in %s... ",
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1008 ucodesearchpath[n]);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1009 if ((uCodeFD = open(ucodesearchpath[n], O_RDONLY))>0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1010 mp_msg(MSGT_VO,MSGL_V,"ok\n");
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1011 break;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1012 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1013 mp_msg(MSGT_VO,MSGL_V,"failed (%s)\n", strerror(errno));
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1014 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1015 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1016 if (uCodeFD < 0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1017 mp_msg(MSGT_VO,MSGL_ERR,"VO: [dxr2] Could not open microcode\n");
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1018 return VO_ERROR;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1019 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1020
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1021 uCodeSize = lseek(uCodeFD, 0, SEEK_END);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1022 if ((uCode = malloc(uCodeSize + 4)) == NULL) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1023
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1024 mp_msg(MSGT_VO,MSGL_FATAL,"VO: [dxr2] Could not allocate memory for uCode: %s\n", strerror(errno));
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1025 return VO_ERROR;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1026 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1027 lseek(uCodeFD, 0, SEEK_SET);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1028 if (read(uCodeFD, uCode+4, uCodeSize) != uCodeSize) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1029
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1030 mp_msg(MSGT_VO,MSGL_ERR,"VO: [dxr2] Could not read uCode uCode: %s\n", strerror(errno));
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1031 return VO_ERROR;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1032 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1033 close(uCodeFD);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1034 uCode->uCodeLength = uCodeSize;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1035
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1036 // upload ucode
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1037 ioctl(dxr2_fd, DXR2_IOC_INIT_ZIVADS, uCode);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1038
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1039 // reset card
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1040 ioctl(dxr2_fd, DXR2_IOC_RESET, NULL);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1041 playing = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1042
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1043 if(!use_ol) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1044 crop.arg1=0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1045 crop.arg2=0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1046 crop.arg3=0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1047 crop.arg4=0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1048 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_CROPPING, &crop);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1049 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1050 return 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1051 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1052
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1053 static uint32_t control(uint32_t request, void *data, ...)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1054 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1055 switch (request) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1056 case VOCTRL_QUERY_FORMAT:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1057 return query_format(*((uint32_t*)data));
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1058 case VOCTRL_PAUSE:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1059 ioctl(dxr2_fd,DXR2_IOC_PAUSE, NULL);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1060 return VO_TRUE;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1061 case VOCTRL_RESUME:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1062 ioctl(dxr2_fd, DXR2_IOC_PLAY, NULL);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1063 return VO_TRUE;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1064 case VOCTRL_RESET:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1065 flush_dxr2();
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1066 ioctl(dxr2_fd, DXR2_IOC_PLAY, NULL);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1067 return VO_TRUE;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1068 case VOCTRL_FULLSCREEN:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1069 if(!use_ol)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1070 return VO_NOTIMPL;
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
1071 else if(sub_vo) {
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
1072 int r = sub_vo->control(VOCTRL_FULLSCREEN,0);
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
1073 if(r == VO_TRUE && !sub_vo_win)
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
1074 dxr2_set_overlay_window();
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
1075 return r;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
1076 } else {
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1077 dxr2_twoArg_t win;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
1078 vo_fs = !vo_fs;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
1079 win.arg1 = vo_fs ? vo_screenwidth : movie_w;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
1080 win.arg2 = vo_fs ? vo_screenheight : movie_h;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1081 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_DIMENSION, &win);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1082 win.arg1 = (vo_screenwidth - win.arg1) / 2;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1083 win.arg2 = (vo_screenheight - win.arg2) / 2;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1084 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_POSITION,&win);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1085 return VO_TRUE;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1086 }
6111
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
1087 case VOCTRL_SET_SPU_PALETTE: {
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
1088 if(ioctl(dxr2_fd,DXR2_IOC_SET_SUBPICTURE_PALETTE,data) < 0) {
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
1089 mp_msg(MSGT_VO,MSGL_WARN,"VO: [dxr2] SPU palette loading failed\n");
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
1090 return VO_ERROR;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
1091 }
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
1092 return VO_TRUE;
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
1093 }
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1094 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1095 return VO_NOTIMPL;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1096 }