annotate libvo/vo_dxr2.c @ 7981:3fac0256a842

Some little bugfixs New options to control the colorkey stuff Fix the osd to be less time consuming
author albeu
date Wed, 30 Oct 2002 17:54:07 +0000
parents f3a33e92e1c1
children 4c7ef4aeb88b
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"
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
19 #include "cfgparser.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 LIBVO_EXTERN (dxr2)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
29
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
30 extern char *get_path(char *filename);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
31
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
32 extern float monitor_aspect;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
33 extern float movie_aspect;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
34
6074
10a30eebafaf Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents: 6070
diff changeset
35 int dxr2_fd = -1;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
36
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
37 static int movie_w,movie_h;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
38 static int playing = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
39 static int last_freq_id = -1;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
40
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
41 // 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
42 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
43
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
44 static uint8_t* sub_img = NULL;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
45 static int sub_x,sub_y,sub_w,sub_h;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
46 static int sub_x_off,sub_y_off;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
47 static int sub_config_count;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
48 static int aspect;
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
49 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
50
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
51 static int use_ol = 1;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
52 static int ol_ratio = 1000;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
53 static char *norm = NULL;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
54 static char *ucode = NULL;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62 static int mute_mode = DXR2_AUDIO_MUTE_OFF;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
63 static int ignore_cache = 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
64 static int update_cache = 0;
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
65 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
66 static int ol_osd = 0;
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
67 static int ck_rmin = 0x40;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
68 static int ck_rmax = 0xFF;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
69 static int ck_r = 0xFF;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
70 static int ck_gmin = 0x00;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
71 static int ck_gmax = 0x20;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
72 static int ck_g = 0;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
73 static int ck_bmin = 0x40;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
74 static int ck_bmax = 0xFF;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
75 static int ck_b = 0xFF;
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
76
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
77
7867
3dc0b71630ff cleanup config option handling in libmpdemux.
arpi
parents: 7253
diff changeset
78 config_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},
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
128
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
129 { 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
130 };
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
131
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
132 static vo_info_t vo_info = {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
133 "DXR2 video out",
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
134 "dxr2",
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
135 "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
136 ""
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
137 };
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
138
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
139 static char *ucodesearchpath[] = {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
140 "/usr/local/lib/dxr2/dvd12.ux",
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
141 "/usr/lib/dxr2/dvd12.ux",
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
142 "/usr/src/dvd12.ux",
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
143 NULL,
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
144 };
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
145
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
146 #define BUF_SIZE 2048
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
147
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
148 static unsigned char dxr2buf[BUF_SIZE];
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
149 static unsigned int dxr2bufpos = 0;
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 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
152 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
153 int w = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
154 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
155 memcpy(dxr2buf+dxr2bufpos, data, len);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
156 dxr2bufpos+=len;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
157 len=0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
158 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
159 int copylen=BUF_SIZE-dxr2bufpos;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
160 if(copylen > 0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
161 memcpy(dxr2buf+dxr2bufpos, data, copylen);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
162 dxr2bufpos += copylen;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
163 data+=copylen;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
164 len-=copylen;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
165 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
166 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
167 if(w < 0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
168 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
169 dxr2bufpos = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
170 break;
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 dxr2bufpos -= w;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
173 if(dxr2bufpos)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
174 memmove(dxr2buf,dxr2buf + w,dxr2bufpos);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
175 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
176 }
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 static void flush_dxr2()
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
179 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
180 int w;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
181 while (dxr2bufpos) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
182 w = write(dxr2_fd, dxr2buf, dxr2bufpos);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
183 if(w < 0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
184 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
185 dxr2bufpos = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
186 break;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
187 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
188 dxr2bufpos -= w;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
189 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
190 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
191
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
192 #define PACK_MAX_SIZE 2048
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 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
195
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
196 static unsigned char mpg_header[]={
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
197 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
198 0x04, 0x01, 0x01, 0x86, 0xa3, 0xf8
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
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
201 static unsigned char mpg_eof[]={
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
202 0x00, 0x00, 0x01, 0xb9
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
203 };
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
204
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
205 static void dxr2_send_header(void)
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 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
208 }
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 static void dxr2_send_eof(void)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
211 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
212 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
213 }
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 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
216 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
217 int ptslen=5;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
218
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
219 if(dxr2_fd < 0) {
6074
10a30eebafaf Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents: 6070
diff changeset
220 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
221 return;
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
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
224 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
225 dxr2_send_header();
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
226
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
227 // startcode:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
228 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
229 // stream id
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
230 pack[3]=id;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
231
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
232 while(len>0){
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
233 int payload_size=len; // data + PTS
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
234 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
235
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
236 // 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
237 // packetsize:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
238 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
239 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
240
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
241 pack[6]=0x81;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
242 if(ptslen){
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
243 int x;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
244 pack[7]=0x80;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
245 pack[8]=ptslen;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
246 // presentation time stamp:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
247 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
248 pack[9]=x;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
249 x=((((timestamp >> 15) & 0x7fff) << 1) | 1);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
250 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
251 x=((((timestamp) & 0x7fff) << 1) | 1);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
252 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
253 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
254 pack[7]=0x00;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
255 pack[8]=0x00;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
256 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
257
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
258 write_dxr2(pack, 9+ptslen);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
259 write_dxr2(data, payload_size);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
260
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
261 len-=payload_size; data+=payload_size;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
262 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
263 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
264 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
265
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
266 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
267 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
268 int arg;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
269 int ptslen=5;
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 if(dxr2_fd < 0) {
6074
10a30eebafaf Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents: 6070
diff changeset
272 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
273 return;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
274 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
275
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
276 if(last_freq_id != freq_id) {
6074
10a30eebafaf Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents: 6070
diff changeset
277 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
278 last_freq_id = freq_id;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
279 }
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 if (((int) timestamp)<0)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
282 timestamp=0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
283
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
284 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
285 // startcode:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
286 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
287
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
288 // stream id
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
289 pack[3]=0xBD;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
290
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
291 while(len>=4){
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
292 int payload_size;
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 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
295 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
296 payload_size&=(~3); // align!
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
297
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
298 // packetsize:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
299 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
300 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
301
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
302 // stuffing:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
303 pack[6]=0x81;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
304 // pack[7]=0x00; //0x80
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
305
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
306 // hdrlen:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
307 pack[8]=ptslen;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
308
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
309 if(ptslen){
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
310 int x;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
311 pack[7]=0x80;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
312 // presentation time stamp:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
313 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
314 pack[9]=x;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
315 x=((((timestamp >> 15) & 0x7fff) << 1) | 1);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
316 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
317 x=((((timestamp) & 0x7fff) << 1) | 1);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
318 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
319 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
320 pack[7]=0x00;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
321 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
322
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
323 // ============ LPCM header: (7 bytes) =================
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
324 // Info by mocm@convergence.de
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
325
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
326 // ID:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
327 pack[ptslen+9]=id;
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 // number of frames:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
330 pack[ptslen+10]=0x07;
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 // 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
333 pack[ptslen+11]=0x00;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
334 pack[ptslen+12]=0x04;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
335
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
336 // audio emphasis on-off 1 bit
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
337 // audio mute on-off 1 bit
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
338 // reserved 1 bit
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
339 // audio frame number 5 bit
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
340 pack[ptslen+13]=0x0C;
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 // quantization word length 2 bit
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
343 // 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
344 // reserved 1 bit
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
345 // 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
346 pack[ptslen+14]=1;
6069
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 // dynamic range control (0x80 if off)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
349 pack[ptslen+15]=0x80;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
350
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
351 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
352 write_dxr2(data, payload_size);
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 len-=payload_size; data+=payload_size;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
355 timestamp+=90000/4*payload_size/48000;
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 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
358
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
359 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
360 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
361
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
362 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
363 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
364 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
365 }
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
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 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
368 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
369
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 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
371 // 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
372 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
373
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 // 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
375 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
376
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 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
378 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
379 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
380
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[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
382 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
383
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 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
385 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
386 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
387 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
388 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
389 // 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
390 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
391 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
392 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
393 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
394 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
395 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
396 } 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
397 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
398 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
399 }
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 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
401
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 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
403 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
404 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
405 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
406 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
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 }
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
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
410 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
411 // Init the overlay, don't ask me how it work ;-)
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
412 dxr2_sixArg_t oc;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
413 dxr2_oneArg_t om;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
414 dxr2_twoArg_t win;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
415 dxr2_fourArg_t crop;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
416
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
417 crop.arg1=0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
418 crop.arg2=0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
419 crop.arg3=55;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
420 crop.arg4=300;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
421 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_CROPPING, &crop);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
422
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
423 oc.arg1 = 0x40;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
424 oc.arg2 = 0xff;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
425 oc.arg3 = 0x40;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
426 oc.arg4 = 0xff;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
427 oc.arg5 = 0x40;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
428 oc.arg6 = 0xff;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
429 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_COLOUR, &oc);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
430
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
431 om.arg = ol_ratio;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
432 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_RATIO,&om);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
433
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
434 win.arg1 = 100;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
435 win.arg2 = 3;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
436 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_POSITION,&win);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
437
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
438 win.arg1 = vo_screenwidth;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
439 win.arg2 = vo_screenheight;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
440 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_DIMENSION,&win);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
441
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
442 om.arg = 0;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
443 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_IN_DELAY,&om);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
444
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
445 if(detect) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
446 // First we need a white screen
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
447 uint8_t* img = malloc(vo_screenwidth*vo_screenheight*3);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
448 uint8_t* src[] = { img, NULL, NULL };
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
449 int stride[] = { vo_screenwidth * 3 , 0, 0 };
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
450 int cc = vo_config_count;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
451
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
452 memset(img,255,vo_screenwidth*vo_screenheight*3);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
453 vo_config_count = sub_config_count;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
454 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
455 VOFLAG_FULLSCREEN ,"DXR2 sub vo",IMGFMT_BGR24) != 0) {
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
456 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
457 sub_vo->uninit();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
458 sub_vo = NULL;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
459 use_ol = 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
460 vo_config_count = cc;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
461 return 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
462 }
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
463 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
464 sub_vo->flip_page();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
465 free(img);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
466 sub_config_count++;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
467 vo_config_count = cc;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
468
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
469 om.arg = DXR2_OVERLAY_WINDOW_COLOUR_KEY;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
470 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_MODE,&om);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
471
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
472 vga->xScreen = vo_screenwidth;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
473 vga->yScreen = vo_screenheight;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
474 vga->hOffWinKey = 100;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
475 vga->vOffWinKey = 3;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
476 ioctl(dxr2_fd, DXR2_IOC_CALCULATE_VGA_PARAMETERS, vga);
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 ioctl(dxr2_fd, DXR2_IOC_SET_VGA_PARAMETERS,vga);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
479
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
480 return 1;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
481 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
482
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
483 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
484 struct stat s;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
485 char* p = get_path("dxr2_cache");
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
486 int p_len = strlen(p), name_len = strlen(name);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
487 char cache_path[p_len + name_len + 2];
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
488 int ret;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
489 FILE* fd;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
490
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
491 if(stat(p,&s) !=0) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
492 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
493 if(errno == EACCES) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
494 free(p);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
495 return 0;
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 // Try to create the dir
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
498 if(mkdir(p,S_IRWXU) != 0) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
499 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
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 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
504 sprintf(cache_path,"%s/%s",p,name);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
505 free(p);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
506 fd = fopen(cache_path,"w");
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
507 if(fd == NULL) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
508 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
509 return 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
510 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
511
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
512 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
513 vga->hOffWinKey,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
514 vga->vOffWinKey,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
515 vga->xScreen,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
516 vga->yScreen,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
517 vga->hsyncPol,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
518 vga->vsyncPol,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
519 vga->blankStart,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
520 vga->blankWidth,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
521 vga->hOffset,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
522 vga->vOffset,
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
523 vga->ratio,
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
524 olx_cor,
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
525 oly_cor,
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
526 olw_cor,
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
527 olh_cor);
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
528
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
529 fclose(fd);
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
530 return ret >= 11 ? 1 : 0;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
531 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
532
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
533 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
534 char* p = get_path("dxr2_cache");
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
535 int p_len = strlen(p), name_len = strlen(name);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
536 char cache_path[p_len + name_len + 2];
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
537 int ret;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
538 FILE* fd;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
539
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
540 sprintf(cache_path,"%s/%s",p,name);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
541 free(p);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
542
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
543 fd = fopen(cache_path,"r");
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
544 if(fd == NULL) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
545 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
546 return 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
547 }
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
548 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
549 &vga->hOffWinKey,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
550 &vga->vOffWinKey,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
551 &vga->xScreen,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
552 &vga->yScreen,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
553 &vga->hsyncPol,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
554 &vga->vsyncPol,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
555 &vga->blankStart,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
556 &vga->blankWidth,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
557 &vga->hOffset,
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
558 &vga->vOffset,
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
559 &vga->ratio,
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
560 &olx_cor,
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
561 &oly_cor,
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
562 &olw_cor,
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
563 &olh_cor);
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
564
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
565 fclose(fd);
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
566 return ret >= 11 ? 1 : 0;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
567 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
568
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
569 static int dxr2_setup_vga_params(void) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
570 const vo_info_t* vi = sub_vo->get_info();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
571 dxr2_vgaParams_t vga;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
572
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
573 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
574 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
575 return 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
576 if(!loaded || update_cache)
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
577 dxr2_save_vga_params(&vga,(char*)vi->short_name);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
578 return 1;
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
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
581 static void dxr2_set_overlay_window(void) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
582 uint8_t* src[] = { sub_img, NULL, NULL };
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
583 int stride[] = { movie_w * 3 , 0, 0 };
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
584 dxr2_twoArg_t win;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
585 int redisp = 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
586 int cc = vo_config_count;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
587 vo_config_count = sub_config_count;
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
588 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
589 sub_vo->flip_page();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
590 vo_config_count = cc;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
591
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
592
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
593 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
594
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
595 // 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
596 if(!sub_vo_win) {
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
597 if(vo_fs) {
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
598 vo_dwidth = vo_screenwidth;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
599 vo_dheight = vo_screenheight;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
600 vo_dx = vo_dy = 0;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
601 } else {
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
602 vo_dwidth = movie_w;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
603 vo_dheight = movie_h;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
604 vo_dx = (vo_screenwidth - vo_dwidth) / 2;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
605 vo_dy = (vo_screenheight - vo_dheight) / 2;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
606 }
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
607 }
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
608
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
609 if(sub_w != vo_dwidth || sub_h != vo_dheight) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
610 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
611 sub_w = vo_dwidth;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
612 sub_h = vo_dheight;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
613 if(new_aspect > aspect)
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
614 sub_w = (sub_h*aspect + (1<<15))>>16;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
615 else
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
616 sub_h = ((sub_w<<16) + (aspect>>1)) /aspect;
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
617 sub_w += olw_cor;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
618 sub_h += olh_cor;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
619 sub_x_off = (vo_dwidth-sub_w) / 2;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
620 sub_y_off = (vo_dheight-sub_h) / 2;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
621 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
622 win.arg1 = sub_w;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
623 win.arg2 = sub_h;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
624 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
625 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_DIMENSION, &win);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
626 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
627
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
628 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
629 sub_x = vo_dx + olx_cor + sub_x_off;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
630 sub_y = vo_dy + oly_cor + sub_y_off;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
631 win.arg1 = (sub_x > 0 ? sub_x : 0);
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
632 win.arg2 = (sub_y > 0 ? sub_y : 0);
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
633 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
634 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_POSITION,&win);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
635 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
636
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
7124
eca7dbad0166 finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents: 6817
diff changeset
639 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
640 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
641 int arg;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
642 dxr2_threeArg_t arg3;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
643
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
644 if(dxr2_fd < 0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
645 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
646 return VO_ERROR;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
647 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
648
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
649 if(playing) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
650 dxr2_send_eof();
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
651 flush_dxr2();
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
652 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
653 playing = 0;
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
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
656 last_freq_id = -1;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
657
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
658 // Video stream setup
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
659 arg3.arg1 = DXR2_STREAM_VIDEO;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
660 arg3.arg2 = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
661 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
662 if (vo_fps > 28)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
663 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
664 else arg3.arg1 = DXR2_SRC_VIDEO_FREQ_25;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
665 arg3.arg2 = s_width;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
666 arg3.arg3 = s_height;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
667 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
668 arg = DXR2_BITSTREAM_TYPE_MPEG_VOB;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
669 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
670
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
671 // Aspect ratio
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
672 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
673 arg = DXR2_ASPECTRATIO_16_9;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
674 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
675 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
676 arg = DXR2_ASPECTRATIO_4_3;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
677 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
678 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
679 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
680 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
681 arg = DXR2_ASPECTRATIO_16_9;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
682 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
683 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
684 arg = DXR2_ASPECTRATIO_4_3;
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] monitor aspect ratio 4:3\n");
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
686 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
687 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
688
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
689 arg = ar_mode;
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_ASPECT_RATIO_MODE, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
691
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
692 // TV setup
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
693 arg = mv_mode;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
694 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
695 arg = _75ire_mode;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
696 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
697 arg = bw_mode;
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_TV_BLACKWHITE_MODE, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
699 arg = interlaced_mode;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
700 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
701 arg = pixel_mode;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
702 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
703
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
704 if (norm) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
705 if (strcmp(norm, "ntsc")==0)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
706 arg = DXR2_OUTPUTFORMAT_NTSC;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
707 else if (strcmp(norm, "pal")==0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
708 if (vo_fps > 28) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
709 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
710 arg = DXR2_OUTPUTFORMAT_PAL_60;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
711 norm="pal60";
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
712 } else arg = DXR2_OUTPUTFORMAT_PAL_BDGHI;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
713 } else if (strcmp(norm, "pal60")==0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
714 if (vo_fps > 28)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
715 arg = DXR2_OUTPUTFORMAT_PAL_60;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
716 else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
717 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
718 arg = DXR2_OUTPUTFORMAT_PAL_BDGHI;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
719 norm="pal";
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
720 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
721 } else if (strcmp(norm, "palm")==0)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
722 arg = DXR2_OUTPUTFORMAT_PAL_M;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
723 else if (strcmp(norm, "paln")==0)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
724 arg = DXR2_OUTPUTFORMAT_PAL_N;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
725 else if (strcmp(norm, "palnc")==0)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
726 arg = DXR2_OUTPUTFORMAT_PAL_Nc;
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,"[dxr2] invalid norm %s\n", norm);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
729 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
730 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
731 norm="ntsc";
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
732 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
733 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
734 if (vo_fps > 28) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
735 arg = DXR2_OUTPUTFORMAT_NTSC;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
736 norm="ntsc";
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
737 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
738 arg = DXR2_OUTPUTFORMAT_PAL_BDGHI;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
739 norm="pal";
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
740 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
741 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
742 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
743 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
744
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
745 // 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
746
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
747 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
748 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
749 arg3.arg1 = DXR2_STREAM_SUBPICTURE;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
750 arg3.arg2 = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
751 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
752
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
753 // Audio
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
754 arg = iec958_mode;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
755 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
756 arg = DXR2_AUDIO_WIDTH_16;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
757 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
758 arg = DXR2_AUDIO_FREQ_48;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
759 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
760 arg3.arg1 = DXR2_STREAM_AUDIO_LPCM;
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 arg = 19;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
764 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
765 arg = mute_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_AUDIO_MUTE, &arg);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
767
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
768 movie_w = width;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
769 movie_h = height;
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
770 //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
771 // Overlay
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
772 while(use_ol) {
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
773 dxr2_twoArg_t win;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
774 dxr2_oneArg_t om;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
775 int cc = vo_config_count;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
776 vo_config_count = sub_config_count;
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
777 // Load or detect the overlay stuff
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
778 if(!dxr2_setup_vga_params()) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
779 sub_vo->uninit();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
780 sub_vo = NULL;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
781 vo_config_count = cc;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
782 break;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
783 }
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
784 // Does the sub vo support the x11 stuff
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
785 // Fix me : test the other x11 vo's and enable them
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
786 if(strcmp(sub_vo->get_info()->short_name,"x11") == 0)
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
787 sub_vo_win = 1;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
788 else
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
789 sub_vo_win = 0;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
790
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
791 // 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
792 if(!sub_vo_win && !ol_osd) {
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
793 sub_vo->uninit();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
794 sub_vo = NULL;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
795 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
796
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
797 while(sub_vo) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
798 dxr2_sixArg_t oc;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
799 int i,sub_flags = VOFLAG_SWSCALE | (flags & VOFLAG_FULLSCREEN);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
800 if(sub_vo->config(width,height,width,height,sub_flags,
7253
cb1ed89029e7 10l fix by Mark <CompGuy284@attbi.com>
alex
parents: 7124
diff changeset
801 "MPlayer DXR2 render",IMGFMT_BGR24) != 0) {
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
802 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
803 sub_vo->uninit();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
804 sub_vo = NULL;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
805 break;
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 sub_config_count++;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
808
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
809 // Feel free to try some other other color and report your results
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
810 oc.arg1 = ck_rmin;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
811 oc.arg2 = ck_rmax;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
812 oc.arg3 = ck_gmin;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
813 oc.arg4 = ck_gmax;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
814 oc.arg5 = ck_bmin;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
815 oc.arg6 = ck_bmax;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
816 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_COLOUR, &oc);
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 om.arg = DXR2_OVERLAY_WINDOW_COLOUR_KEY;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
819 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_MODE,&om);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
820 sub_img = malloc(width*height*3);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
821 for(i = 0 ; i < width*height*3 ; i += 3) {
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
822 sub_img[i] = ck_b;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
823 sub_img[i+1] = ck_g;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
824 sub_img[i+2] = ck_r;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
825 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
826 aspect = ((1<<16)*width + height/2)/height;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
827 sub_w = sub_h = 0;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
828 dxr2_set_overlay_window();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
829 break;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
830 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
831 vo_config_count = cc;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
832 if(!sub_vo) { // Fallback on non windowed overlay
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
833 vo_fs = flags & VOFLAG_FULLSCREEN ? 1 : 0;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
834 om.arg = DXR2_OVERLAY_WINDOW_KEY;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
835 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_MODE,&om);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
836 win.arg1 = flags & VOFLAG_FULLSCREEN ? vo_screenwidth : width;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
837 win.arg2 = flags & VOFLAG_FULLSCREEN ? vo_screenheight : height;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
838 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_DIMENSION, &win);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
839 win.arg1 = (vo_screenwidth - win.arg1) / 2;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
840 win.arg2 = (vo_screenheight - win.arg2) / 2;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
841 ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_POSITION,&win);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
842 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
843 break;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
844 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
845
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
846 // start playing
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
847 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
848 playing = 1;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
849 return 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
850 } else
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
851 return VO_ERROR;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
852 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
853
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
854 static const vo_info_t* get_info(void)
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 return &vo_info;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
857 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
858
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
859 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
860 uint8_t* src[] = { sub_img , NULL, NULL };
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
861 int stride[] = { movie_w * 3, 0, 0 };
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
862
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
863 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
864 }
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
865
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
866 static void draw_osd(void)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
867 {
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
868 if(sub_vo && ol_osd) {
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
869 vo_remove_text(movie_w,movie_h,clear_alpha);
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
870 sub_vo->draw_osd();
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 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
873
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
874 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
875 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
876 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
877 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
878 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
879 } 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
880 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
881 return 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
882 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
883
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
884 static void flip_page (void)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
885 {
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
886 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
887 sub_vo->flip_page();
6069
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 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
891 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
892 return 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
893 }
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 query_format(uint32_t format)
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 if (format==IMGFMT_MPEGPES)
6074
10a30eebafaf Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents: 6070
diff changeset
899 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
900 return 0;
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
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 static void uninit(void)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
905 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
906 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
907
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
908 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
909 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
910 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
911 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
912 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
913 }
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
914 close(dxr2_fd);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
915 dxr2_fd = -1;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
916 }
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
917 if(sub_img) {
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
918 free(sub_img);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
919 sub_img = NULL;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
920 }
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
921 if(sub_vo) {
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
922 int cc = vo_config_count;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
923 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
924 sub_vo->uninit();
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
925 sub_vo = NULL;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
926 vo_config_count = cc;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
927 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
928 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
929
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
930
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
931 static void check_events(void)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
932 {
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
933 // 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
934 // 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
935 #ifdef X11_FULLSCREEN
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
936 if(sub_vo && sub_vo_win) {
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
937 int e=vo_x11_check_events(mDisplay);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
938 if ( !(e&VO_EVENT_RESIZE) && !(e&VO_EVENT_EXPOSE) ) return;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
939 XSetBackground(mDisplay, vo_gc, 0);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
940 XClearWindow(mDisplay, vo_window);
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
941 dxr2_set_overlay_window();
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
942 }
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
943 #endif
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
944 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
945
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
946 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
947 int uCodeFD = -1;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
948 int uCodeSize;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
949 dxr2_uCode_t* uCode;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
950 dxr2_fourArg_t crop;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
951 int n=0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
952
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
953 sub_vo = NULL;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
954 sub_config_count = 0;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
955 if(use_ol) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
956 if (arg) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
957 for(n = 0 ; video_out_drivers[n] != NULL ; n++) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
958 const vo_info_t* vi = video_out_drivers[n]->get_info();
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
959 if(!vi)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
960 continue;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
961 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
962 break;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
963 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
964 sub_vo = video_out_drivers[n];
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
965 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
966 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
967 use_ol = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
968 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
969 }
6070
bad23f7960f1 10L Crash if no subdriver given and overlay enabled
albeu
parents: 6069
diff changeset
970
bad23f7960f1 10L Crash if no subdriver given and overlay enabled
albeu
parents: 6069
diff changeset
971 if(!sub_vo) {
bad23f7960f1 10L Crash if no subdriver given and overlay enabled
albeu
parents: 6069
diff changeset
972 if(use_ol)
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
973 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
974 use_ol = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
975 } else {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
976 if(sub_vo->preinit(NULL) != 0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
977 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
978 sub_vo = NULL;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
979 use_ol = 0;
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
980 } else {
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
981 uint32_t fmt = IMGFMT_BGR24;
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
982 mp_msg(MSGT_VO,MSGL_V,"VO: [dxr2] Sub vo %s inited\n",arg);
7981
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
983 if(sub_vo->control(VOCTRL_QUERY_FORMAT,&fmt) <= 0) {
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
984 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
985 sub_vo->uninit();
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
986 sub_vo = NULL;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
987 use_ol = 0;
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
988 }
3fac0256a842 Some little bugfixs
albeu
parents: 7970
diff changeset
989 }
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
990 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
991
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
992 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
993 if( dxr2_fd < 0 ) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
994 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
995 return VO_ERROR;
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 if(ucode)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
999 uCodeFD = open(ucode, O_RDONLY);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1000 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
1001 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
1002 ucodesearchpath[n]);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1003 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
1004 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
1005 break;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1006 } else {
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,"failed (%s)\n", strerror(errno));
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1008 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1009 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1010 if (uCodeFD < 0) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1011 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
1012 return VO_ERROR;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1013 }
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 uCodeSize = lseek(uCodeFD, 0, SEEK_END);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1016 if ((uCode = malloc(uCodeSize + 4)) == NULL) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1017
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1018 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
1019 return VO_ERROR;
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 lseek(uCodeFD, 0, SEEK_SET);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1022 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
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_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
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 close(uCodeFD);
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1028 uCode->uCodeLength = 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 // upload ucode
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1031 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
1032
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1033 // reset card
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1034 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
1035 playing = 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1036
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1037 if(!use_ol) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1038 crop.arg1=0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1039 crop.arg2=0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1040 crop.arg3=0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1041 crop.arg4=0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1042 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
1043 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1044 return 0;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1045 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1046
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1047 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
1048 {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1049 switch (request) {
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1050 case VOCTRL_QUERY_FORMAT:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1051 return query_format(*((uint32_t*)data));
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1052 case VOCTRL_PAUSE:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1053 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
1054 return VO_TRUE;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1055 case VOCTRL_RESUME:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1056 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
1057 return VO_TRUE;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1058 case VOCTRL_RESET:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1059 flush_dxr2();
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1060 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
1061 return VO_TRUE;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1062 case VOCTRL_FULLSCREEN:
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1063 if(!use_ol)
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1064 return VO_NOTIMPL;
7970
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
1065 else if(sub_vo) {
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
1066 int r = sub_vo->control(VOCTRL_FULLSCREEN,0);
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
1067 if(r == VO_TRUE && !sub_vo_win)
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
1068 dxr2_set_overlay_window();
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
1069 return r;
f3a33e92e1c1 Fixed the overlay, some opts to adjust the overlay
albeu
parents: 7867
diff changeset
1070 } else {
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1071 dxr2_twoArg_t win;
6181
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
1072 vo_fs = !vo_fs;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
1073 win.arg1 = vo_fs ? vo_screenwidth : movie_w;
b2938a374993 Overlay in a window (only with x11 subdriver)
albeu
parents: 6111
diff changeset
1074 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
1075 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
1076 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
1077 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
1078 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
1079 return VO_TRUE;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1080 }
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
1081 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
1082 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
1083 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
1084 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
1085 }
582960ab7cc7 Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents: 6074
diff changeset
1086 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
1087 }
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1088 }
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1089 return VO_NOTIMPL;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff changeset
1090 }