Codebase list xrdp / 8457b7d
Imported Upstream version 0.9.0~20160601+git703fedd Dominik George 7 years ago
337 changed file(s) with 12973 addition(s) and 3200 deletion(s). Raw diff Collapse all Expand all
Coding_Style.odt less more
Binary diff not shown
0 EXTRA_DIST = bootstrap COPYING design.txt faq-compile.txt faq-general.txt file-loc.txt install.txt prog_std.txt readme.txt
0 ACLOCAL_AMFLAGS = -I m4
1 AM_DISTCHECK_CONFIGURE_FLAGS = --without-systemdsystemunitdir
2
3 EXTRA_DIST = bootstrap COPYING coding_style.md design.txt faq-compile.txt \
4 faq-general.txt file-loc.txt install.txt m4 prog_std.txt readme.txt
15
26 if XRDP_NEUTRINORDP
37 NEUTRINORDPDIR = neutrinordp
2727 exit 1
2828 fi
2929
30 touch configure.ac
31 touch NEWS
32 touch AUTHORS
33 touch README
34 touch ChangeLog
35 ln -s ../config.c $PWD/sesman/tools/config.c
3630 autoreconf -fvi
0 XRdp Coding Style
1 =================
2
3 The coding style used by XRdp is described below.
4
5 The XRdp project uses astyle (artistic style) to format the code. Astyle
6 requires a configuration file that describes how you want your code
7 formatted. This file is present in the XRdp root directory and is named
8 `astyle_config.as`.
9
10 Here is how we run the astyle command:
11
12 astyle --options=/path/to/file/astyle_config.as "*.c"
13
14 This coding style is a work in progress and is still evolving.
15
16
17 Indentation
18 -----------
19
20 * 4 spaces per indent
21 * No tabs for any indents
22
23
24
25 if (fd < 0)
26 {
27 return -1;
28 }
29
30
31 Line wrapping
32 -------------
33
34 * Keep lines shorter than 80 chars
35 * Align wrapped argument to the first argument
36
37
38
39 log_message("connection aborted: error %d",
40 ret);
41
42
43 Variable names
44 --------------
45
46 * Use lowercase with underscores as needed
47 * Don't use camelCase
48
49
50
51 int fd;
52 int bytes_in_stream;
53
54
55 Variable declaration
56 --------------------
57
58 * Each variable is declared on a separate line
59
60
61
62 int i;
63 int j;
64
65
66 Whitespace
67 ----------
68
69 * Use blank lines to group statements
70 * Use at most one empty line between statements
71 * For pointers and references, use a single space before * or & but not after
72 * Use one space after a cast
73 * No space before square brackets
74
75
76
77 char *cptr;
78 int *iptr;
79 cptr = (char *) malloc(1024);
80
81 write(fd, &buf[12], 16);
82
83
84 Function declarations
85 ---------------------
86
87 * Use newline before function name
88
89
90
91 static int
92 value_ok(int val)
93 {
94 return (val >= 0);
95 }
96
97
98 Braces
99 ------
100
101 * Opening brace is always on a separate line
102 * Align braces with the line preceding the opening brace
103
104
105
106 struct stream
107 {
108 int flags;
109 char *data;
110 };
111
112 void
113 process_data(struct stream *s)
114 {
115 if (stream == NULL)
116 {
117 return;
118 }
119 }
120
121
122 `if` statements
123 ---------------
124
125 * Always use braces
126 * Put both braces on separate lines
127
128
129
130 if (val <= 0xff)
131 {
132 out_uint8(s, val);
133 }
134 else if (val <= 0xffff)
135 {
136 out_uint16_le(s, val);
137 }
138 else
139 {
140 out_uint32_le(s, val);
141 }
142
143
144 `for` statements
145 ----------------
146
147 * Always use braces
148 * Put both braces on separate lines
149
150
151
152 for (i = 0; i < 10; i++)
153 {
154 printf("i = %d\n", i);
155 }
156
157
158 `while` and `do while` statements
159 ---------------------------------
160
161 * Always use braces
162 * `while` after the closing brace is on the same line
163
164
165
166 while (cptr)
167 {
168 cptr—;
169 }
170
171 do
172 {
173 cptr--;
174 } while (cptr);
175
176
177 `switch` statements
178 -------------------
179
180 * Indent `case` once
181 * Indent statements under `case` one more time
182 * Put both braces on separate lines
183
184
185
186 switch (cmd)
187 {
188 case READ:
189 read(fd, buf, 1024);
190 break;
191
192 default:
193 printf("bad cmd\n");
194 }
0 EXTRA_DIST = \
1 arch.h \
2 defines.h \
3 file.h \
4 file_loc.h \
5 list.h \
6 list16.h \
7 fifo.h \
8 log.h \
9 os_calls.h \
10 os_calls.h \
11 parse.h \
12 rail.h \
13 ssl_calls.h \
14 thread_calls.h \
15 trans.h \
16 xrdp_client_info.h \
17 xrdp_constants.h \
18 xrdp_rail.h \
19 crc16.h
20
21 AM_CFLAGS = \
0 AM_CPPFLAGS = \
221 -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
232 -DXRDP_SBIN_PATH=\"${sbindir}\" \
243 -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
254 -DXRDP_PID_PATH=\"${localstatedir}/run\" \
265 -DXRDP_LOG_PATH=\"${localstatedir}/log\"
276
28 lib_LTLIBRARIES = \
7 module_LTLIBRARIES = \
298 libcommon.la
309
3110 libcommon_la_SOURCES = \
11 arch.h \
12 crc16.h \
13 defines.h \
14 fifo.c \
15 fifo.h \
3216 file.c \
17 file.h \
18 file_loc.h \
3319 list.c \
20 list.h \
3421 list16.c \
35 fifo.c \
22 list16.h \
3623 log.c \
24 log.h \
3725 os_calls.c \
26 os_calls.h \
27 os_calls.h \
28 parse.h \
29 rail.h \
3830 ssl_calls.c \
31 ssl_calls.h \
3932 thread_calls.c \
40 trans.c
33 thread_calls.h \
34 trans.c \
35 trans.h \
36 xrdp_client_info.h \
37 xrdp_constants.h \
38 xrdp_rail.h
4139
4240 libcommon_la_LIBADD = \
4341 -lcrypto \
2121 /* you can define L_ENDIAN or B_ENDIAN and NEED_ALIGN or NO_NEED_ALIGN
2222 in the makefile to override */
2323
24 /* check endianess */
24 /* check endianness */
2525 #if !(defined(L_ENDIAN) || defined(B_ENDIAN))
2626 #if !defined(__BYTE_ORDER) && defined(__linux__)
2727 #include <endian.h>
2525
2626 #define FILE_MAX_LINE_BYTES 2048
2727
28 static int APP_CC
29 file_read_ini_line(struct stream *s, char *text, int text_bytes);
30
31 /*****************************************************************************/
32 /* look up for a section name within str (i.e. pattern [section_name])
33 * if a section name is found, this function return 1 and copy the section
34 * inplace of str. */
35 static int APP_CC
36 line_lookup_for_section_name(char *str, int str_bytes)
37 {
38 int name_index_start;
39 int index;
40 char c;
41
42 name_index_start = -1;
43 index = 0;
44 while ((c = str[index]) != 0)
45 {
46 if (c == '[')
47 {
48 name_index_start = index + 1;
49 }
50 else if (c == ']' && name_index_start > 0)
51 {
52 if (name_index_start + index >= str_bytes)
53 {
54 return 0;
55 }
56 for (index = index - name_index_start; index > 0; index--)
57 {
58 str[0] = str[name_index_start];
59 str++;
60 }
61 str[0] = 0;
62 return 1;
63 }
64 ++index;
65 }
66 return 0;
67 }
68
69
2870 /*****************************************************************************/
2971 /* returns error
3072 returns 0 if everything is ok
3476 {
3577 struct stream *s;
3678 char text[FILE_MAX_LINE_BYTES];
37 char c;
38 int in_it;
39 int in_it_index;
4079 int len;
41 int index;
4280 int rv;
4381
4482 rv = 0;
4583 g_file_seek(fd, 0);
46 in_it_index = 0;
47 in_it = 0;
4884 g_memset(text, 0, FILE_MAX_LINE_BYTES);
4985 list_clear(names);
5086 make_stream(s);
5490 if (len > 0)
5591 {
5692 s->end = s->p + len;
57
58 for (index = 0; index < len; index++)
59 {
60 in_uint8(s, c);
61
62 if (c == '[')
63 {
64 in_it = 1;
65 }
66 else if (c == ']')
93 while (file_read_ini_line(s, text, FILE_MAX_LINE_BYTES) == 0)
94 {
95 if (line_lookup_for_section_name(text, FILE_MAX_LINE_BYTES) != 0)
6796 {
6897 list_add_item(names, (tbus)g_strdup(text));
69 in_it = 0;
70 in_it_index = 0;
71 g_memset(text, 0, FILE_MAX_LINE_BYTES);
72 }
73 else if (in_it)
74 {
75 text[in_it_index] = c;
76 in_it_index++;
7798 }
7899 }
79100 }
87108 }
88109
89110 /*****************************************************************************/
90 /* returns error */
91 static int APP_CC
92 file_read_line(struct stream *s, char *text, int text_bytes)
111 /* Read a line in the stream 's', removing comments.
112 * returns error
113 * returns 0 if everything is ok
114 * returns 1 if problem reading file */
115 static int APP_CC
116 file_read_ini_line(struct stream *s, char *text, int text_bytes)
93117 {
94118 int i;
95119 int skip_to_end;
96120 int at_end;
97121 char c;
98 char *hold;
99122
100123 skip_to_end = 0;
101124
104127 return 1;
105128 }
106129
107 hold = s->p;
108130 i = 0;
109131 in_uint8(s, c);
110132
162184
163185 text[i] = 0;
164186
165 if (text[0] == '[')
166 {
167 s->p = hold;
168 return 1;
169 }
170
171187 return 0;
172188 }
189
173190
174191 /*****************************************************************************/
175192 /* returns error */
226243 char *name;
227244 char *value;
228245 char *lvalue;
229 char c;
230 int in_it;
231 int in_it_index;
232246 int len;
233 int index;
234247 int file_size;
235248
236249 data = (char *) g_malloc(FILE_MAX_LINE_BYTES * 3, 0);
240253
241254 file_size = 32 * 1024; /* 32 K file size limit */
242255 g_file_seek(fd, 0);
243 in_it_index = 0;
244 in_it = 0;
245256 g_memset(text, 0, FILE_MAX_LINE_BYTES);
246257 list_clear(names);
247258 list_clear(values);
252263 if (len > 0)
253264 {
254265 s->end = s->p + len;
255
256 for (index = 0; index < len; index++)
257 {
258 if (!s_check_rem(s, 1))
259 {
260 break;
261 }
262 in_uint8(s, c);
263 if ((c == '#') || (c == ';'))
264 {
265 if (file_read_line(s, text, FILE_MAX_LINE_BYTES) != 0)
266 {
267 break;
268 }
269 in_it = 0;
270 in_it_index = 0;
271 g_memset(text, 0, FILE_MAX_LINE_BYTES);
272 continue;
273 }
274 if (c == '[')
275 {
276 in_it = 1;
277 }
278 else if (c == ']')
266 while (file_read_ini_line(s, text, FILE_MAX_LINE_BYTES) == 0)
267 {
268 if (line_lookup_for_section_name(text, FILE_MAX_LINE_BYTES) != 0)
279269 {
280270 if (g_strcasecmp(section, text) == 0)
281271 {
282 file_read_line(s, text, FILE_MAX_LINE_BYTES);
283 while (file_read_line(s, text, FILE_MAX_LINE_BYTES) == 0)
272 while (file_read_ini_line(s, text,
273 FILE_MAX_LINE_BYTES) == 0)
284274 {
275 if (line_lookup_for_section_name(text, FILE_MAX_LINE_BYTES) != 0)
276 {
277 break;
278 }
279
285280 if (g_strlen(text) > 0)
286281 {
287282 file_split_name_value(text, name, value);
306301 }
307302 }
308303 }
309
310304 free_stream(s);
311305 g_free(data);
312306 return 0;
313307 }
314
315 in_it = 0;
316 in_it_index = 0;
317 g_memset(text, 0, FILE_MAX_LINE_BYTES);
318 }
319 else if (in_it)
320 {
321 text[in_it_index] = c;
322 in_it_index++;
323 if (in_it_index >= FILE_MAX_LINE_BYTES)
324 {
325 break;
326 }
327 }
328 }
329 }
308 }
309 }
310 }
311
330312 free_stream(s);
331313 g_free(data);
332314 return 1;
345327
346328 /*****************************************************************************/
347329 /* return error */
348 /* this function should be prefered over file_read_sections because it can
330 /* this function should be preferred over file_read_sections because it can
349331 read any file size */
350332 int APP_CC
351333 file_by_name_read_sections(const char *file_name, struct list *names)
361343 return 1;
362344 }
363345
364 fd = g_file_open(file_name);
346 fd = g_file_open_ex(file_name, 1, 0, 0, 0);
365347
366348 if (fd < 0)
367349 {
385367
386368 /*****************************************************************************/
387369 /* return error */
388 /* this function should be prefered over file_read_section because it can
370 /* this function should be preferred over file_read_section because it can
389371 read any file size */
390372 int APP_CC
391373 file_by_name_read_section(const char *file_name, const char *section,
402384 return 1;
403385 }
404386
405 fd = g_file_open(file_name);
387 fd = g_file_open_ex(file_name, 1, 0, 0, 0);
406388
407389 if (fd < 0)
408390 {
3636 #define XRDP_SHARE_PATH "/usr/local/share/xrdp"
3737 #endif
3838
39 #if !defined(XRDP_LIB_PATH)
40 #define XRDP_LIB_PATH "/usr/local/lib/xrdp"
39 #if !defined(XRDP_MODULE_PATH)
40 #define XRDP_MODULE_PATH "/usr/local/lib/xrdp"
4141 #endif
4242
4343 #if !defined(XRDP_LOG_PATH)
191191
192192 /*****************************************************************************/
193193 /* append one list to another using strdup for each item in the list */
194 /* begins copy at start_index, a zero based index on the soure list */
194 /* begins copy at start_index, a zero based index on the source list */
195195 void APP_CC
196196 list_append_list_strdup(struct list *self, struct list *dest, int start_index)
197197 {
220220
221221 for (index = 0; index < self->count; index++)
222222 {
223 g_writeln("%d: %s", index, list_get_item(self, index));
224 }
225 }
223 g_writeln("%d: 0x%lx", index, list_get_item(self, index));
224 }
225 }
5757 ret = open(fname, O_WRONLY | O_CREAT | O_APPEND | O_SYNC,
5858 S_IRUSR | S_IWUSR);
5959 }
60
61 #ifdef FD_CLOEXEC
62 if (ret != -1)
63 {
64 fcntl(ret, F_SETFD, FD_CLOEXEC);
65 }
66 #endif
6067
6168 return ret;
6269 }
141148 return ret;
142149 }
143150
144 /* if progname is NULL, we ureturn error */
151 /* if progname is NULL, we return error */
145152 if (0 == l_cfg->program_name)
146153 {
147154 g_writeln("program_name not properly assigned");
185192 /* closing log file */
186193 log_message(LOG_LEVEL_ALWAYS, "shutting down log subsystem...");
187194
188 if (0 > l_cfg->fd)
195 if (-1 != l_cfg->fd)
189196 {
190197 /* closing logfile... */
191198 g_file_close(l_cfg->fd);
8080 /**
8181 *
8282 * @brief Starts the logging subsystem
83 * @param l_cfg loggging system configuration
83 * @param l_cfg logging system configuration
8484 * @return
8585 *
8686 */
9999 #define INADDR_NONE ((unsigned long)-1)
100100 #endif
101101
102 static char g_temp_base[128] = "";
103 static char g_temp_base_org[128] = "";
104
105102 /*****************************************************************************/
106103 int APP_CC
107104 g_rm_temp_dir(void)
108105 {
109 if (g_temp_base[0] != 0)
110 {
111 if (!g_remove_dir(g_temp_base))
112 {
113 printf("g_rm_temp_dir: removing temp directory [%s] failed\n", g_temp_base);
114 }
115
116 g_temp_base[0] = 0;
117 }
118
119106 return 0;
120107 }
121108
123110 int APP_CC
124111 g_mk_temp_dir(const char *app_name)
125112 {
126 if (app_name != 0)
127 {
128 if (app_name[0] != 0)
129 {
113 if (!g_directory_exist("/tmp/.xrdp"))
114 {
115 if (!g_create_dir("/tmp/.xrdp"))
116 {
117 /* if failed, still check if it got created by someone else */
130118 if (!g_directory_exist("/tmp/.xrdp"))
131119 {
132 if (!g_create_dir("/tmp/.xrdp"))
133 {
134 /* if failed, still check if it got created by someone else */
135 if (!g_directory_exist("/tmp/.xrdp"))
136 {
137 printf("g_mk_temp_dir: g_create_dir failed\n");
138 return 1;
139 }
140 }
141
142 g_chmod_hex("/tmp/.xrdp", 0x1777);
143 }
144
145 snprintf(g_temp_base, sizeof(g_temp_base),
146 "/tmp/.xrdp/%s-XXXXXX", app_name);
147 snprintf(g_temp_base_org, sizeof(g_temp_base_org),
148 "/tmp/.xrdp/%s-XXXXXX", app_name);
149
150 if (mkdtemp(g_temp_base) == 0)
151 {
152 printf("g_mk_temp_dir: mkdtemp failed [%s]\n", g_temp_base);
120 printf("g_mk_temp_dir: g_create_dir failed\n");
153121 return 1;
154122 }
155123 }
156 else
157 {
158 printf("g_mk_temp_dir: bad app name\n");
159 return 1;
160 }
161 }
162 else
163 {
164 if (g_temp_base_org[0] == 0)
165 {
166 printf("g_mk_temp_dir: g_temp_base_org not set\n");
167 return 1;
168 }
169
170 g_strncpy(g_temp_base, g_temp_base_org, 127);
171
172 if (mkdtemp(g_temp_base) == 0)
173 {
174 printf("g_mk_temp_dir: mkdtemp failed [%s]\n", g_temp_base);
175 }
176 }
177
124 g_chmod_hex("/tmp/.xrdp", 0x1777);
125 }
178126 return 0;
179127 }
180128
333281 g_printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.');
334282 }
335283
336 g_writeln("");
284 g_writeln("%s", "");
337285 offset += thisline;
338286 line += thisline;
339287 }
462410 unsigned int option_len;
463411 #endif
464412
465 #if defined(XRDP_ENABLE_IPV6) && !defined(NO_ARPA_INET_H_IP6)
413 #if defined(XRDP_ENABLE_IPV6)
466414 rv = (int)socket(AF_INET6, SOCK_STREAM, 0);
467415 #else
468416 rv = (int)socket(AF_INET, SOCK_STREAM, 0);
471419 {
472420 return -1;
473421 }
474 #if defined(XRDP_ENABLE_IPV6) && !defined(NO_ARPA_INET_H_IP6)
422 #if defined(XRDP_ENABLE_IPV6)
475423 option_len = sizeof(option_value);
476424 if (getsockopt(rv, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&option_value,
477425 &option_len) == 0)
478426 {
479427 if (option_value != 0)
480428 {
429 #if defined(XRDP_ENABLE_IPV6ONLY)
430 option_value = 1;
431 #else
481432 option_value = 0;
433 #endif
482434 option_len = sizeof(option_value);
483435 if (setsockopt(rv, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&option_value,
484436 option_len) < 0)
616568
617569 /*****************************************************************************/
618570 int APP_CC
619 g_tcp_local_socket(void)
571 g_sck_local_socket(void)
620572 {
621573 #if defined(_WIN32)
622574 return 0;
690642
691643 /*****************************************************************************/
692644 void APP_CC
693 g_tcp_close(int sck)
645 g_sck_close(int sck)
694646 {
695647 char ip[256];
696648
710662
711663 /*****************************************************************************/
712664 /* returns error, zero is good */
713 #if defined(XRDP_ENABLE_IPV6) && !defined(NO_ARPA_INET_H_IP6)
665 #if defined(XRDP_ENABLE_IPV6)
714666 int APP_CC
715667 g_tcp_connect(int sck, const char *address, const char *port)
716668 {
717669 int res = 0;
670 char errorMsg[256];
718671 struct addrinfo p;
719672 struct addrinfo *h = (struct addrinfo *)NULL;
720673 struct addrinfo *rp = (struct addrinfo *)NULL;
740693 {
741694 res = getaddrinfo(address, port, &p, &h);
742695 }
696 if (res != 0)
697 {
698 snprintf(errorMsg, 255, "g_tcp_connect: getaddrinfo() failed: %s",
699 gai_strerror(res));
700 log_message(LOG_LEVEL_ERROR, errorMsg);
701 }
743702 if (res > -1)
744703 {
745704 if (h != NULL)
762721 int APP_CC
763722 g_tcp_connect(int sck, const char* address, const char* port)
764723 {
765 struct sockaddr_in s;
766 struct hostent* h;
767
768 g_memset(&s, 0, sizeof(struct sockaddr_in));
769 s.sin_family = AF_INET;
770 s.sin_port = htons((tui16)atoi(port));
771 s.sin_addr.s_addr = inet_addr(address);
772 if (s.sin_addr.s_addr == INADDR_NONE)
773 {
774 h = gethostbyname(address);
775 if (h != 0)
776 {
777 if (h->h_name != 0)
778 {
779 if (h->h_addr_list != 0)
780 {
781 if ((*(h->h_addr_list)) != 0)
782 {
783 s.sin_addr.s_addr = *((int*)(*(h->h_addr_list)));
784 }
785 }
786 }
787 }
788 }
789 return connect(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in));
724 struct sockaddr_in s;
725 struct hostent* h;
726
727 g_memset(&s, 0, sizeof(struct sockaddr_in));
728 s.sin_family = AF_INET;
729 s.sin_port = htons((tui16)atoi(port));
730 s.sin_addr.s_addr = inet_addr(address);
731 if (s.sin_addr.s_addr == INADDR_NONE)
732 {
733 h = gethostbyname(address);
734 if (h != 0)
735 {
736 if (h->h_name != 0)
737 {
738 if (h->h_addr_list != 0)
739 {
740 if ((*(h->h_addr_list)) != 0)
741 {
742 s.sin_addr.s_addr = *((int*)(*(h->h_addr_list)));
743 }
744 }
745 }
746 }
747 }
748 return connect(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in));
790749 }
791750 #endif
792751
793752 /*****************************************************************************/
794753 /* returns error, zero is good */
795754 int APP_CC
796 g_tcp_local_connect(int sck, const char *port)
755 g_sck_local_connect(int sck, const char *port)
797756 {
798757 #if defined(_WIN32)
799758 return -1;
811770
812771 /*****************************************************************************/
813772 int APP_CC
814 g_tcp_set_non_blocking(int sck)
773 g_sck_set_non_blocking(int sck)
815774 {
816775 unsigned long i;
817776
823782 i = i | O_NONBLOCK;
824783 if (fcntl(sck, F_SETFL, i) < 0)
825784 {
826 log_message(LOG_LEVEL_ERROR, "g_tcp_set_non_blocking: fcntl() failed\n");
785 log_message(LOG_LEVEL_ERROR, "g_sck_set_non_blocking: fcntl() failed\n");
827786 }
828787 #endif
829788 return 0;
943902 int APP_CC
944903 g_tcp_bind(int sck, const char* port)
945904 {
946 struct sockaddr_in s;
947
948 memset(&s, 0, sizeof(struct sockaddr_in));
949 s.sin_family = AF_INET;
950 s.sin_port = htons((tui16)atoi(port));
951 s.sin_addr.s_addr = INADDR_ANY;
952 return bind(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in));
953 }
954 #endif
955
956 /*****************************************************************************/
957 int APP_CC
958 g_tcp_local_bind(int sck, const char *port)
905 struct sockaddr_in s;
906
907 memset(&s, 0, sizeof(struct sockaddr_in));
908 s.sin_family = AF_INET;
909 s.sin_port = htons((tui16)atoi(port));
910 s.sin_addr.s_addr = INADDR_ANY;
911 return bind(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in));
912 }
913 #endif
914
915 /*****************************************************************************/
916 int APP_CC
917 g_sck_local_bind(int sck, const char *port)
959918 {
960919 #if defined(_WIN32)
961920 return -1;
986945 int APP_CC
987946 g_tcp_bind_address(int sck, const char* port, const char* address)
988947 {
989 struct sockaddr_in s;
990
991 memset(&s, 0, sizeof(struct sockaddr_in));
992 s.sin_family = AF_INET;
993 s.sin_port = htons((tui16)atoi(port));
994 s.sin_addr.s_addr = INADDR_ANY;
995 if (inet_aton(address, &s.sin_addr) < 0)
996 {
997 return -1; /* bad address */
998 }
999 return bind(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in));
948 struct sockaddr_in s;
949
950 memset(&s, 0, sizeof(struct sockaddr_in));
951 s.sin_family = AF_INET;
952 s.sin_port = htons((tui16)atoi(port));
953 s.sin_addr.s_addr = INADDR_ANY;
954 if (inet_aton(address, &s.sin_addr) < 0)
955 {
956 return -1; /* bad address */
957 }
958 return bind(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in));
1000959 }
1001960 #endif
1002961
1003962 /*****************************************************************************/
1004963 /* returns error, zero is good */
1005964 int APP_CC
1006 g_tcp_listen(int sck)
965 g_sck_listen(int sck)
1007966 {
1008967 return listen(sck, 2);
1009968 }
1026985 ret = accept(sck, (struct sockaddr *)&s, &i);
1027986 if(ret>0)
1028987 {
1029 snprintf(ipAddr,255,"A connection received from: %s port %d"
1030 ,inet_ntoa(s.sin_addr),ntohs(s.sin_port));
988 snprintf(ipAddr, 255, "A connection received from: %s port %d",
989 inet_ntoa(s.sin_addr), ntohs(s.sin_port));
1031990 log_message(LOG_LEVEL_INFO,ipAddr);
1032991 }
1033992 return ret ;
11191078
11201079 /*****************************************************************************/
11211080 int APP_CC
1122 g_tcp_last_error_would_block(int sck)
1081 g_sck_last_error_would_block(int sck)
11231082 {
11241083 #if defined(_WIN32)
11251084 return WSAGetLastError() == WSAEWOULDBLOCK;
11301089
11311090 /*****************************************************************************/
11321091 int APP_CC
1133 g_tcp_recv(int sck, void *ptr, int len, int flags)
1092 g_sck_recv(int sck, void *ptr, int len, int flags)
11341093 {
11351094 #if defined(_WIN32)
11361095 return recv(sck, (char *)ptr, len, flags);
11411100
11421101 /*****************************************************************************/
11431102 int APP_CC
1144 g_tcp_send(int sck, const void *ptr, int len, int flags)
1103 g_sck_send(int sck, const void *ptr, int len, int flags)
11451104 {
11461105 #if defined(_WIN32)
11471106 return send(sck, (const char *)ptr, len, flags);
11531112 /*****************************************************************************/
11541113 /* returns boolean */
11551114 int APP_CC
1156 g_tcp_socket_ok(int sck)
1115 g_sck_socket_ok(int sck)
11571116 {
11581117 #if defined(_WIN32)
11591118 int opt;
11801139 /* wait 'millis' milliseconds for the socket to be able to write */
11811140 /* returns boolean */
11821141 int APP_CC
1183 g_tcp_can_send(int sck, int millis)
1142 g_sck_can_send(int sck, int millis)
11841143 {
11851144 fd_set wfds;
11861145 struct timeval time;
11971156
11981157 if (rv > 0)
11991158 {
1200 return g_tcp_socket_ok(sck);
1159 return 1;
12011160 }
12021161 }
12031162
12081167 /* wait 'millis' milliseconds for the socket to be able to receive */
12091168 /* returns boolean */
12101169 int APP_CC
1211 g_tcp_can_recv(int sck, int millis)
1170 g_sck_can_recv(int sck, int millis)
12121171 {
12131172 fd_set rfds;
12141173 struct timeval time;
12151174 int rv;
12161175
1176 g_memset(&time, 0, sizeof(time));
12171177 time.tv_sec = millis / 1000;
12181178 time.tv_usec = (millis * 1000) % 1000000;
12191179 FD_ZERO(&rfds);
12251185
12261186 if (rv > 0)
12271187 {
1228 return g_tcp_socket_ok(sck);
1229 }
1230 }
1231
1232 return 0;
1233 }
1234
1235 /*****************************************************************************/
1236 int APP_CC
1237 g_tcp_select(int sck1, int sck2)
1188 return 1;
1189 }
1190 }
1191
1192 return 0;
1193 }
1194
1195 /*****************************************************************************/
1196 int APP_CC
1197 g_sck_select(int sck1, int sck2)
12381198 {
12391199 fd_set rfds;
12401200 struct timeval time;
1241 int max = 0;
1242 int rv = 0;
1243
1244 g_memset(&rfds, 0, sizeof(fd_set));
1201 int max;
1202 int rv;
1203
12451204 g_memset(&time, 0, sizeof(struct timeval));
1246
1247 time.tv_sec = 0;
1248 time.tv_usec = 0;
12491205 FD_ZERO(&rfds);
12501206
12511207 if (sck1 > 0)
12901246 }
12911247
12921248 /*****************************************************************************/
1249 /* returns boolean */
1250 static int APP_CC
1251 g_fd_can_read(int fd)
1252 {
1253 fd_set rfds;
1254 struct timeval time;
1255 int rv;
1256
1257 g_memset(&time, 0, sizeof(time));
1258 FD_ZERO(&rfds);
1259 FD_SET(((unsigned int)fd), &rfds);
1260 rv = select(fd + 1, &rfds, 0, 0, &time);
1261 if (rv == 1)
1262 {
1263 return 1;
1264 }
1265 return 0;
1266 }
1267
1268 /*****************************************************************************/
1269 /* returns error */
1270 /* O_NONBLOCK = 0x00000800 */
1271 static int APP_CC
1272 g_set_nonblock(int fd)
1273 {
1274 int error;
1275 int flags;
1276
1277 error = fcntl(fd, F_GETFL);
1278 if (error < 0)
1279 {
1280 return 1;
1281 }
1282 flags = error;
1283 if ((flags & O_NONBLOCK) != O_NONBLOCK)
1284 {
1285 flags |= O_NONBLOCK;
1286 error = fcntl(fd, F_SETFL, flags);
1287 if (error < 0)
1288 {
1289 return 1;
1290 }
1291 }
1292 return 0;
1293 }
1294
1295 /*****************************************************************************/
12931296 /* returns 0 on error */
1294 tbus APP_CC
1297 tintptr APP_CC
12951298 g_create_wait_obj(char *name)
12961299 {
12971300 #ifdef _WIN32
1298 tbus obj;
1299
1300 obj = (tbus)CreateEvent(0, 1, 0, name);
1301 tintptr obj;
1302
1303 obj = (tintptr)CreateEvent(0, 1, 0, name);
13011304 return obj;
13021305 #else
1303 tbus obj;
1304 struct sockaddr_un sa;
1305 size_t len;
1306 tbus sck;
1307 int i;
1308 int safety;
1309 int unnamed;
1310
1311 if (g_temp_base[0] == 0)
1306 int fds[2];
1307 int error;
1308
1309 error = pipe(fds);
1310 if (error != 0)
13121311 {
13131312 return 0;
13141313 }
1315
1316 sck = socket(PF_UNIX, SOCK_DGRAM, 0);
1317
1318 if (sck < 0)
1319 {
1314 if (g_set_nonblock(fds[0]) != 0)
1315 {
1316 close(fds[0]);
1317 close(fds[1]);
13201318 return 0;
13211319 }
1322
1323 safety = 0;
1324 g_memset(&sa, 0, sizeof(sa));
1325 sa.sun_family = AF_UNIX;
1326 unnamed = 1;
1327
1328 if (name != 0)
1329 {
1330 if (name[0] != 0)
1331 {
1332 unnamed = 0;
1333 }
1334 }
1335
1336 if (unnamed)
1337 {
1338 do
1339 {
1340 if (safety > 100)
1341 {
1342 break;
1343 }
1344
1345 safety++;
1346 g_random((char *)&i, sizeof(i));
1347 len = sizeof(sa.sun_path);
1348 g_snprintf(sa.sun_path, len, "%s/auto_%8.8x", g_temp_base, i);
1349 len = sizeof(sa);
1350 }
1351 while (bind(sck, (struct sockaddr *)&sa, len) < 0);
1352 }
1353 else
1354 {
1355 do
1356 {
1357 if (safety > 100)
1358 {
1359 break;
1360 }
1361
1362 safety++;
1363 g_random((char *)&i, sizeof(i));
1364 len = sizeof(sa.sun_path);
1365 g_snprintf(sa.sun_path, len, "%s/%s_%8.8x", g_temp_base, name, i);
1366 len = sizeof(sa);
1367 }
1368 while (bind(sck, (struct sockaddr *)&sa, len) < 0);
1369 }
1370
1371 obj = (tbus)sck;
1372 return obj;
1320 if (g_set_nonblock(fds[1]) != 0)
1321 {
1322 close(fds[0]);
1323 close(fds[1]);
1324 return 0;
1325 }
1326 return (fds[1] << 16) | fds[0];
13731327 #endif
13741328 }
13751329
13761330 /*****************************************************************************/
13771331 /* returns 0 on error */
1378 tbus APP_CC
1379 g_create_wait_obj_from_socket(tbus socket, int write)
1332 tintptr APP_CC
1333 g_create_wait_obj_from_socket(tintptr socket, int write)
13801334 {
13811335 #ifdef _WIN32
1382 /* Create and return corresponding event handle for WaitForMultipleObjets */
1336 /* Create and return corresponding event handle for WaitForMultipleObjects */
13831337 WSAEVENT event;
13841338 long lnetevent = 0;
13851339
14041358
14051359 /*****************************************************************************/
14061360 void APP_CC
1407 g_delete_wait_obj_from_socket(tbus wait_obj)
1361 g_delete_wait_obj_from_socket(tintptr wait_obj)
14081362 {
14091363 #ifdef _WIN32
14101364
14211375 /*****************************************************************************/
14221376 /* returns error */
14231377 int APP_CC
1424 g_set_wait_obj(tbus obj)
1378 g_set_wait_obj(tintptr obj)
14251379 {
14261380 #ifdef _WIN32
1427
14281381 if (obj == 0)
14291382 {
14301383 return 0;
14311384 }
1432
14331385 SetEvent((HANDLE)obj);
14341386 return 0;
14351387 #else
1436 socklen_t sa_size;
1437 int s;
1438 struct sockaddr_un sa;
1388 int error;
1389 int fd;
1390 int written;
1391 int to_write;
1392 char buf[4] = "sig";
14391393
14401394 if (obj == 0)
14411395 {
14421396 return 0;
14431397 }
1444
1445 if (g_tcp_can_recv((int)obj, 0))
1398 fd = obj & 0xffff;
1399 if (g_fd_can_read(fd))
14461400 {
14471401 /* already signalled */
14481402 return 0;
14491403 }
1450
1451 sa_size = sizeof(sa);
1452
1453 if (getsockname((int)obj, (struct sockaddr *)&sa, &sa_size) < 0)
1404 fd = obj >> 16;
1405 to_write = 4;
1406 written = 0;
1407 while (written < to_write)
1408 {
1409 error = write(fd, buf + written, to_write - written);
1410 if (error == -1)
1411 {
1412 error = errno;
1413 if ((error == EAGAIN) || (error == EWOULDBLOCK) ||
1414 (error == EINPROGRESS) || (error == EINTR))
1415 {
1416 /* ok */
1417 }
1418 else
1419 {
1420 return 1;
1421 }
1422 }
1423 else if (error > 0)
1424 {
1425 written += error;
1426 }
1427 else
1428 {
1429 return 1;
1430 }
1431 }
1432 return 0;
1433 #endif
1434 }
1435
1436 /*****************************************************************************/
1437 /* returns error */
1438 int APP_CC
1439 g_reset_wait_obj(tintptr obj)
1440 {
1441 #ifdef _WIN32
1442 if (obj == 0)
1443 {
1444 return 0;
1445 }
1446 ResetEvent((HANDLE)obj);
1447 return 0;
1448 #else
1449 char buf[4];
1450 int error;
1451 int fd;
1452
1453 if (obj == 0)
1454 {
1455 return 0;
1456 }
1457 fd = obj & 0xffff;
1458 while (g_fd_can_read(fd))
1459 {
1460 error = read(fd, buf, 4);
1461 if (error == -1)
1462 {
1463 error = errno;
1464 if ((error == EAGAIN) || (error == EWOULDBLOCK) ||
1465 (error == EINPROGRESS) || (error == EINTR))
1466 {
1467 /* ok */
1468 }
1469 else
1470 {
1471 return 1;
1472 }
1473 }
1474 else if (error == 0)
1475 {
1476 return 1;
1477 }
1478 }
1479 return 0;
1480 #endif
1481 }
1482
1483 /*****************************************************************************/
1484 /* returns boolean */
1485 int APP_CC
1486 g_is_wait_obj_set(tintptr obj)
1487 {
1488 #ifdef _WIN32
1489 if (obj == 0)
1490 {
1491 return 0;
1492 }
1493 if (WaitForSingleObject((HANDLE)obj, 0) == WAIT_OBJECT_0)
14541494 {
14551495 return 1;
14561496 }
1457
1458 s = socket(PF_UNIX, SOCK_DGRAM, 0);
1459
1460 if (s < 0)
1461 {
1462 return 1;
1463 }
1464
1465 if (sendto(s, "sig", 4, 0, (struct sockaddr *)&sa, sa_size) < 0)
1466 {
1467 close(s);
1468 return 1;
1469 }
1470
1471 close(s);
1472 return 0;
1497 return 0;
1498 #else
1499 if (obj == 0)
1500 {
1501 return 0;
1502 }
1503 return g_fd_can_read(obj & 0xffff);
14731504 #endif
14741505 }
14751506
14761507 /*****************************************************************************/
14771508 /* returns error */
14781509 int APP_CC
1479 g_reset_wait_obj(tbus obj)
1510 g_delete_wait_obj(tintptr obj)
14801511 {
14811512 #ifdef _WIN32
1482
14831513 if (obj == 0)
14841514 {
14851515 return 0;
14861516 }
1487
1488 ResetEvent((HANDLE)obj);
1489 return 0;
1490 #else
1491 char buf[64];
1492
1493 if (obj == 0)
1494 {
1495 return 0;
1496 }
1497
1498 while (g_tcp_can_recv((int)obj, 0))
1499 {
1500 recvfrom((int)obj, &buf, 64, 0, 0, 0);
1501 }
1502
1503 return 0;
1504 #endif
1505 }
1506
1507 /*****************************************************************************/
1508 /* returns boolean */
1509 int APP_CC
1510 g_is_wait_obj_set(tbus obj)
1511 {
1512 #ifdef _WIN32
1513
1514 if (obj == 0)
1515 {
1516 return 0;
1517 }
1518
1519 if (WaitForSingleObject((HANDLE)obj, 0) == WAIT_OBJECT_0)
1520 {
1521 return 1;
1522 }
1523
1524 return 0;
1525 #else
1526
1527 if (obj == 0)
1528 {
1529 return 0;
1530 }
1531
1532 return g_tcp_can_recv((int)obj, 0);
1533 #endif
1534 }
1535
1536 /*****************************************************************************/
1537 /* returns error */
1538 int APP_CC
1539 g_delete_wait_obj(tbus obj)
1540 {
1541 #ifdef _WIN32
1542
1543 if (obj == 0)
1544 {
1545 return 0;
1546 }
1547
15481517 /* Close event handle */
15491518 CloseHandle((HANDLE)obj);
15501519 return 0;
15511520 #else
1552 socklen_t sa_size;
1553 struct sockaddr_un sa;
1554
15551521 if (obj == 0)
15561522 {
15571523 return 0;
15581524 }
1559
1560 sa_size = sizeof(sa);
1561
1562 if (getsockname((int)obj, (struct sockaddr *)&sa, &sa_size) < 0)
1563 {
1564 return 1;
1565 }
1566
1567 close((int)obj);
1568 unlink(sa.sun_path);
1525 close(obj & 0xffff);
1526 close(obj >> 16);
15691527 return 0;
15701528 #endif
15711529 }
15721530
15731531 /*****************************************************************************/
15741532 /* returns error */
1575 /* close but do not delete the wait obj, used after fork */
1576 int APP_CC
1577 g_close_wait_obj(tbus obj)
1578 {
1579 #ifdef _WIN32
1580 #else
1581 close((int)obj);
1582 #endif
1583 return 0;
1584 }
1585
1586 /*****************************************************************************/
1587 /* returns error */
1588 int APP_CC
1589 g_obj_wait(tbus *read_objs, int rcount, tbus *write_objs, int wcount,
1533 int APP_CC
1534 g_obj_wait(tintptr *read_objs, int rcount, tintptr *write_objs, int wcount,
15901535 int mstimeout)
15911536 {
15921537 #ifdef _WIN32
16261571 fd_set rfds;
16271572 fd_set wfds;
16281573 struct timeval time;
1629 struct timeval *ptime = (struct timeval *)NULL;
1574 struct timeval *ptime;
16301575 int i = 0;
16311576 int res = 0;
16321577 int max = 0;
16331578 int sck = 0;
16341579
1635 g_memset(&rfds, 0, sizeof(fd_set));
1636 g_memset(&wfds, 0, sizeof(fd_set));
1637 g_memset(&time, 0, sizeof(struct timeval));
1638
16391580 max = 0;
1640
16411581 if (mstimeout < 1)
16421582 {
1643 ptime = (struct timeval *)NULL;
1583 ptime = 0;
16441584 }
16451585 else
16461586 {
1587 g_memset(&time, 0, sizeof(struct timeval));
16471588 time.tv_sec = mstimeout / 1000;
16481589 time.tv_usec = (mstimeout % 1000) * 1000;
16491590 ptime = &time;
16571598 {
16581599 for (i = 0; i < rcount; i++)
16591600 {
1660 sck = (int)(read_objs[i]);
1601 sck = read_objs[i] & 0xffff;
16611602
16621603 if (sck > 0)
16631604 {
18681809 }
18691810
18701811 /*****************************************************************************/
1871 /* write to file, returns the number of bytes writen or -1 on error */
1812 /* write to file, returns the number of bytes written or -1 on error */
18721813 int APP_CC
18731814 g_file_write(int fd, char *ptr, int len)
18741815 {
20441985 {
20451986 #if defined(_WIN32)
20461987 return 0; // use GetFileAttributes and check return value
2047 // is not -1 and FILE_ATTRIBUT_DIRECTORY bit is set
1988 // is not -1 and FILE_ATTRIBUTE_DIRECTORY bit is set
20481989 #else
20491990 struct stat st;
20501991
22652206
22662207 return p;
22672208 }
2209
22682210 /*****************************************************************************/
22692211 /* if in = 0, return 0 else return newly alloced copy of input string
22702212 * if the input string is larger than maxlen the returned string will be
22962238
22972239 return p;
22982240 }
2241
22992242 /*****************************************************************************/
23002243 int APP_CC
23012244 g_strcmp(const char *c1, const char *c2)
23182261 char c1;
23192262 char c2;
23202263
2264 c1 = 0;
2265 c2 = 0;
23212266 while (n > 0)
23222267 {
2323 c1 = *s1++;
2324 c2 = *s2++;
2268 c1 = *(s1++);
2269 c2 = *(s2++);
23252270 if ((c1 == 0) || (c1 != c2) || (c1 == delim) || (c2 == delim))
23262271 {
23272272 return c1 - c2;
27822727 /*****************************************************************************/
27832728 /* does not work in win32 */
27842729 void APP_CC
2785 g_signal_kill(void (*func)(int))
2786 {
2787 #if defined(_WIN32)
2788 #else
2789 signal(SIGKILL, func);
2790 #endif
2791 }
2792
2793 /*****************************************************************************/
2794 /* does not work in win32 */
2795 void APP_CC
27962730 g_signal_terminate(void (*func)(int))
27972731 {
27982732 #if defined(_WIN32)
29052839 return 0;
29062840 #else
29072841 return setuid(pid);
2842 #endif
2843 }
2844
2845 /*****************************************************************************/
2846 int APP_CC
2847 g_setsid(void)
2848 {
2849 #if defined(_WIN32)
2850 return -1;
2851 #else
2852 return setsid();
2853 #endif
2854 }
2855
2856 /*****************************************************************************/
2857 int APP_CC
2858 g_setlogin(const char *name)
2859 {
2860 #ifdef BSD
2861 return setlogin(name);
2862 #else
2863 return -1;
29082864 #endif
29092865 }
29102866
2020 #if !defined(OS_CALLS_H)
2121 #define OS_CALLS_H
2222
23 #if defined(HAVE_CONFIG_H)
24 #include "config_ac.h"
25 #endif
26
2327 #ifndef NULL
2428 #define NULL 0
2529 #endif
2630
2731 #include "arch.h"
32
33 #define g_tcp_can_recv g_sck_can_recv
34 #define g_tcp_can_send g_sck_can_send
35 #define g_tcp_recv g_sck_recv
36 #define g_tcp_send g_sck_send
37 #define g_tcp_close g_sck_close
38 #define g_tcp_last_error_would_block g_sck_last_error_would_block
39 #define g_tcp_set_non_blocking g_sck_set_non_blocking
40 #define g_tcp_local_socket g_sck_local_socket
41 #define g_tcp_local_connect g_sck_local_connect
42 #define g_tcp_listen g_sck_listen
43 #define g_tcp_local_bind g_sck_local_bind
44 #define g_tcp_select g_sck_select
45 #define g_close_wait_obj g_delete_wait_obj
46
47 #if defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
48 #define printflike(arg_format, arg_first_check) \
49 __attribute__((__format__(__printf__, arg_format, arg_first_check)))
50 #else
51 #define printflike(arg_format, arg_first_check)
52 #endif
2853
2954 int APP_CC g_rm_temp_dir(void);
3055 int APP_CC g_mk_temp_dir(const char* app_name);
3257 void APP_CC g_deinit(void);
3358 void* APP_CC g_malloc(int size, int zero);
3459 void APP_CC g_free(void* ptr);
35 void DEFAULT_CC g_printf(const char *format, ...);
36 void DEFAULT_CC g_sprintf(char* dest, const char* format, ...);
37 void DEFAULT_CC g_snprintf(char* dest, int len, const char* format, ...);
38 void DEFAULT_CC g_writeln(const char* format, ...);
39 void DEFAULT_CC g_write(const char* format, ...);
60 void DEFAULT_CC g_printf(const char *format, ...) printflike(1, 2);
61 void DEFAULT_CC g_sprintf(char* dest, const char* format, ...) \
62 printflike(2, 3);
63 void DEFAULT_CC g_snprintf(char* dest, int len, const char* format, ...) \
64 printflike(3, 4);
65 void DEFAULT_CC g_writeln(const char* format, ...) printflike(1, 2);
66 void DEFAULT_CC g_write(const char* format, ...) printflike(1, 2);
4067 void APP_CC g_hexdump(char* p, int len);
4168 void APP_CC g_memset(void* ptr, int val, int size);
4269 void APP_CC g_memcpy(void* d_ptr, const void* s_ptr, int size);
4875 int APP_CC g_sck_get_send_buffer_bytes(int sck, int *bytes);
4976 int APP_CC g_sck_set_recv_buffer_bytes(int sck, int bytes);
5077 int APP_CC g_sck_get_recv_buffer_bytes(int sck, int *bytes);
51 int APP_CC g_tcp_local_socket(void);
78 int APP_CC g_sck_local_socket(void);
5279 int APP_CC g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid);
53 void APP_CC g_tcp_close(int sck);
80 void APP_CC g_sck_close(int sck);
5481 int APP_CC g_tcp_connect(int sck, const char* address, const char* port);
55 int APP_CC g_tcp_local_connect(int sck, const char* port);
56 int APP_CC g_tcp_force_send(int sck, char* data, int len);
57 int APP_CC g_tcp_force_recv(int sck, char* data, int len);
58 int APP_CC g_tcp_set_non_blocking(int sck);
82 int APP_CC g_sck_local_connect(int sck, const char* port);
83 int APP_CC g_sck_set_non_blocking(int sck);
5984 int APP_CC g_tcp_bind(int sck, const char *port);
60 int APP_CC g_tcp_local_bind(int sck, const char* port);
85 int APP_CC g_sck_local_bind(int sck, const char* port);
6186 int APP_CC g_tcp_bind_address(int sck, const char* port, const char* address);
62 int APP_CC g_tcp_listen(int sck);
87 int APP_CC g_sck_listen(int sck);
6388 int APP_CC g_tcp_accept(int sck);
6489 int APP_CC g_sck_accept(int sck, char *addr, int addr_bytes,
6590 char *port, int port_bytes);
66 int APP_CC g_tcp_recv(int sck, void* ptr, int len, int flags);
67 int APP_CC g_tcp_send(int sck, const void* ptr, int len, int flags);
68 int APP_CC g_tcp_last_error_would_block(int sck);
69 int APP_CC g_tcp_socket_ok(int sck);
70 int APP_CC g_tcp_can_send(int sck, int millis);
71 int APP_CC g_tcp_can_recv(int sck, int millis);
72 int APP_CC g_tcp_select(int sck1, int sck2);
91 int APP_CC g_sck_recv(int sck, void* ptr, int len, int flags);
92 int APP_CC g_sck_send(int sck, const void* ptr, int len, int flags);
93 int APP_CC g_sck_last_error_would_block(int sck);
94 int APP_CC g_sck_socket_ok(int sck);
95 int APP_CC g_sck_can_send(int sck, int millis);
96 int APP_CC g_sck_can_recv(int sck, int millis);
97 int APP_CC g_sck_select(int sck1, int sck2);
7398 void APP_CC g_write_ip_address(int rcv_sck, char* ip_address, int bytes);
7499 void APP_CC g_sleep(int msecs);
75 tbus APP_CC g_create_wait_obj(char* name);
76 tbus APP_CC g_create_wait_obj_from_socket(tbus socket, int write);
77 void APP_CC g_delete_wait_obj_from_socket(tbus wait_obj);
78 int APP_CC g_set_wait_obj(tbus obj);
79 int APP_CC g_reset_wait_obj(tbus obj);
80 int APP_CC g_is_wait_obj_set(tbus obj);
81 int APP_CC g_delete_wait_obj(tbus obj);
82 int APP_CC g_close_wait_obj(tbus obj);
83 int APP_CC g_obj_wait(tbus* read_objs, int rcount, tbus* write_objs,
100 tintptr APP_CC g_create_wait_obj(char* name);
101 tintptr APP_CC g_create_wait_obj_from_socket(tintptr socket, int write);
102 void APP_CC g_delete_wait_obj_from_socket(tintptr wait_obj);
103 int APP_CC g_set_wait_obj(tintptr obj);
104 int APP_CC g_reset_wait_obj(tintptr obj);
105 int APP_CC g_is_wait_obj_set(tintptr obj);
106 int APP_CC g_delete_wait_obj(tintptr obj);
107 int APP_CC g_obj_wait(tintptr* read_objs, int rcount, tintptr* write_objs,
84108 int wcount,int mstimeout);
85109 void APP_CC g_random(char* data, int len);
86110 int APP_CC g_abs(int i);
135159 void APP_CC g_signal_segfault(void (*func)(int));
136160 void APP_CC g_signal_hang_up(void (*func)(int));
137161 void APP_CC g_signal_user_interrupt(void (*func)(int));
138 void APP_CC g_signal_kill(void (*func)(int));
139162 void APP_CC g_signal_terminate(void (*func)(int));
140163 void APP_CC g_signal_pipe(void (*func)(int));
141164 void APP_CC g_signal_usr1(void (*func)(int));
145168 int APP_CC g_getuid(void);
146169 int APP_CC g_getgid(void);
147170 int APP_CC g_setuid(int pid);
171 int APP_CC g_setsid(void);
172 int APP_CC g_setlogin(const char *name);
148173 int APP_CC g_waitchild(void);
149174 int APP_CC g_waitpid(int pid);
150175 void APP_CC g_clearenv(void);
400400 tui8 *lexp;
401401 int error;
402402 int len;
403 int diff;
403404
404405 if ((exp_len != 4) || ((mod_len != 64) && (mod_len != 256)) ||
405406 ((pri_len != 64) && (pri_len != 256)))
407408 return 1;
408409 }
409410
410 lmod = (char *)g_malloc(mod_len, 0);
411 lpri = (char *)g_malloc(pri_len, 0);
411 diff = 0;
412 lmod = (char *)g_malloc(mod_len, 1);
413 lpri = (char *)g_malloc(pri_len, 1);
412414 lexp = (tui8 *)exp;
413415 my_e = lexp[0];
414416 my_e |= lexp[1] << 8;
422424 if (error == 0)
423425 {
424426 len = BN_num_bytes(my_key->n);
425 error = len != mod_len;
426 }
427
428 if (error == 0)
429 {
430 BN_bn2bin(my_key->n, (tui8 *)lmod);
427 error = (len < 1) || (len > mod_len);
428 diff = mod_len - len;
429 }
430
431 if (error == 0)
432 {
433 BN_bn2bin(my_key->n, (tui8 *)(lmod + diff));
431434 ssl_reverse_it(lmod, mod_len);
432435 }
433436
434437 if (error == 0)
435438 {
436439 len = BN_num_bytes(my_key->d);
437 error = len != pri_len;
438 }
439
440 if (error == 0)
441 {
442 BN_bn2bin(my_key->d, (tui8 *)lpri);
440 error = (len < 1) || (len > pri_len);
441 diff = pri_len - len;
442 }
443
444 if (error == 0)
445 {
446 BN_bn2bin(my_key->d, (tui8 *)(lpri + diff));
443447 ssl_reverse_it(lpri, pri_len);
444448 }
445449
470474 char *lpri;
471475 int error;
472476 int len;
477 int diff;
473478
474479 if ((exp_len != 4) || ((mod_len != 64) && (mod_len != 256)) ||
475480 ((pri_len != 64) && (pri_len != 256)))
477482 return 1;
478483 }
479484
480 lexp = (char *)g_malloc(exp_len, 0);
481 lmod = (char *)g_malloc(mod_len, 0);
482 lpri = (char *)g_malloc(pri_len, 0);
485 diff = 0;
486 lexp = (char *)g_malloc(exp_len, 1);
487 lmod = (char *)g_malloc(mod_len, 1);
488 lpri = (char *)g_malloc(pri_len, 1);
483489 g_memcpy(lexp, exp, exp_len);
484490 ssl_reverse_it(lexp, exp_len);
485491 my_e = BN_new();
490496 if (error == 0)
491497 {
492498 len = BN_num_bytes(my_key->n);
493 error = len != mod_len;
494 }
495
496 if (error == 0)
497 {
498 BN_bn2bin(my_key->n, (tui8 *)lmod);
499 error = (len < 1) || (len > mod_len);
500 diff = mod_len - len;
501 }
502
503 if (error == 0)
504 {
505 BN_bn2bin(my_key->n, (tui8 *)(lmod + diff));
499506 ssl_reverse_it(lmod, mod_len);
500507 }
501508
502509 if (error == 0)
503510 {
504511 len = BN_num_bytes(my_key->d);
505 error = len != pri_len;
506 }
507
508 if (error == 0)
509 {
510 BN_bn2bin(my_key->d, (tui8 *)lpri);
512 error = (len < 1) || (len > pri_len);
513 diff = pri_len - len;
514 }
515
516 if (error == 0)
517 {
518 BN_bn2bin(my_key->d, (tui8 *)(lpri + diff));
511519 ssl_reverse_it(lpri, pri_len);
512520 }
513521
840848 return 1;
841849 }
842850 g_reset_wait_obj(tls->rwo);
843 return g_tcp_can_recv(sck, millis);
844 }
845
851 return g_sck_can_recv(sck, millis);
852 }
853
1919
2020 #if defined(_WIN32)
2121 #include <windows.h>
22 #elif defined(__APPLE__)
23 #include <pthread.h>
24 #include <dispatch/dispatch.h>
25 #include <dispatch/time.h>
2226 #else
2327 #include <pthread.h>
2428 #include <semaphore.h>
158162
159163 sem = CreateSemaphore(0, init_count, init_count + 10, 0);
160164 return (tbus)sem;
165 #elif defined(__APPLE__)
166 dispatch_semaphore_t sem = dispatch_semaphore_create(init_count);
167 return (tbus)sem;
161168 #else
162169 sem_t *sem = (sem_t *)NULL;
163170
173180 {
174181 #if defined(_WIN32)
175182 CloseHandle((HANDLE)sem);
183 #elif defined(__APPLE__)
184 dispatch_release((dispatch_semaphore_t)sem);
176185 #else
177186 sem_t *lsem;
178187
189198 #if defined(_WIN32)
190199 WaitForSingleObject((HANDLE)sem, INFINITE);
191200 return 0;
201 #elif defined(__APPLE__)
202 dispatch_semaphore_wait((dispatch_semaphore_t)sem, DISPATCH_TIME_FOREVER);
203 return 0;
192204 #else
193205 sem_wait((sem_t *)sem);
194206 return 0;
202214 #if defined(_WIN32)
203215 ReleaseSemaphore((HANDLE)sem, 1, 0);
204216 return 0;
217 #elif defined(__APPLE__)
218 dispatch_semaphore_signal((dispatch_semaphore_t)sem);
219 return 0;
205220 #else
206221 sem_post((sem_t *)sem);
207222 return 0;
7676 int APP_CC
7777 trans_tcp_can_recv(struct trans *self, int sck, int millis)
7878 {
79 return g_tcp_can_recv(sck, millis);
79 return g_sck_can_recv(sck, millis);
8080 }
8181
8282 /*****************************************************************************/
248248 }
249249 }
250250 }
251 else if (block)
252 {
253 /* check for term here */
254 if (self->is_term != 0)
255 {
256 if (self->is_term())
257 {
258 /* term */
259 return 1;
260 }
261 }
262 }
251263 }
252264 else
253265 {
284296
285297 if (self->type1 == TRANS_TYPE_LISTENER) /* listening */
286298 {
287 if (g_tcp_can_recv(self->sck, 0))
299 if (g_sck_can_recv(self->sck, 0))
288300 {
289301 in_sck = g_sck_accept(self->sck, self->addr, sizeof(self->addr),
290302 self->port, sizeof(self->port));
317329 sizeof(self->addr) - 1);
318330 g_strncpy(in_trans->port, self->port,
319331 sizeof(self->port) - 1);
320
332 g_sck_set_non_blocking(in_sck);
321333 if (self->trans_conn_in(self, in_trans) != 0)
322334 {
323335 trans_delete(in_trans);
411423
412424 return rv;
413425 }
426
414427 /*****************************************************************************/
415428 int APP_CC
416429 trans_force_read_s(struct trans *self, struct stream *in_s, int size)
421434 {
422435 return 1;
423436 }
424
425437 while (size > 0)
426438 {
427439 /* make sure stream has room */
429441 {
430442 return 1;
431443 }
432
433444 rcvd = self->trans_recv(self, in_s->end, size);
434
435445 if (rcvd == -1)
436446 {
437447 if (g_tcp_last_error_would_block(self->sck))
438448 {
439 if (!g_tcp_can_recv(self->sck, 100))
449 if (!self->trans_can_recv(self, self->sck, 100))
440450 {
441451 /* check for term here */
442452 if (self->is_term != 0)
469479 size -= rcvd;
470480 }
471481 }
472
473482 return 0;
474483 }
475484
492501 {
493502 return 1;
494503 }
495
496504 size = (int) (out_s->end - out_s->data);
497505 total = 0;
498
499506 if (trans_send_waiting(self, 1) != 0)
500507 {
501508 self->status = TRANS_STATUS_DOWN;
502509 return 1;
503510 }
504
505511 while (total < size)
506512 {
507513 sent = self->trans_send(self, out_s->data + total, size - total);
508
509514 if (sent == -1)
510515 {
511516 if (g_tcp_last_error_would_block(self->sck))
542547 total = total + sent;
543548 }
544549 }
545
546550 return 0;
547551 }
548552
606610 return 0;
607611 }
608612 /* did not send right away, have to copy */
609 make_stream(wait_s);
613 make_stream(wait_s);
610614 init_stream(wait_s, size);
611615 if (self->si != 0)
612616 {
613 if (self->si->cur_source != 0)
617 if ((self->si->cur_source != 0) &&
618 (self->si->cur_source != self->my_source))
614619 {
615620 self->si->source[self->si->cur_source] += size;
616621 wait_s->source = self->si->source + self->si->cur_source;
871876
872877 return rv;
873878 }
879
874880 /*****************************************************************************/
875881 /* returns error */
876882 int APP_CC
896902
897903 return 0;
898904 }
905
899906 /*****************************************************************************/
900907 /* returns error */
901908 int APP_CC
109109 int multimon; /* 0 = deny , 1 = allow */
110110 int monitorCount; /* number of monitors detected (max = 16) */
111111 struct monitor_info minfo[16]; /* client monitor data */
112 struct monitor_info minfo_wm[16]; /* client monitor data, non-negative values */
112113
113114 int keyboard_type;
114115 int keyboard_subtype;
520520 #define NO_BITMAP_COMPRESSION_HDR 0x0400
521521 #define LONG_CREDENTIALS_SUPPORTED 0x0004
522522 #define AUTORECONNECT_SUPPORTED 0x0008
523 #define ENC_SALTED_CHEKSUM 0x0010
523 #define ENC_SALTED_CHECKSUM 0x0010
524524 #define NEGOTIATEORDERSUPPORT 0x0002
525525 #define ZEROBOUNDSDELTASUPPORT 0x0008
526526 #define COLORINDEXSUPPORT 0x0020
540540 #define SURCMDS_FRAMEMARKER 0x00000010
541541 #define SURCMDS_STREAMSUFRACEBITS 0x00000040
542542
543 /* CODEC_GUID_NSCODEC 0xCA8D1BB9000F154F589FAE2D1A87E2D6 */
543 /* CODEC_GUID_NSCODEC CA8D1BB9-000F-154F-589FAE2D1A87E2D6 */
544544 #define XR_CODEC_GUID_NSCODEC \
545545 "\xb9\x1b\x8d\xca\x0f\x00\x4f\x15\x58\x9f\xae\x2d\x1a\x87\xe2\xd6"
546546
547 /* CODEC_GUID_REMOTEFX 0x76772F12BD724463AFB3B73C9C6F7886 */
547 /* CODEC_GUID_REMOTEFX 76772F12-BD72-4463-AFB3B73C9C6F7886 */
548548 #define XR_CODEC_GUID_REMOTEFX \
549549 "\x12\x2F\x77\x76\x72\xBD\x63\x44\xAF\xB3\xB7\x3C\x9C\x6F\x78\x86"
550550
551 /* CODEC_GUID_JPEG 0x1BAF4CE6 9EED 430C 869ACB8B37B66237 */
551 /* CODEC_GUID_JPEG 1BAF4CE6-9EED-430C-869ACB8B37B66237 */
552552 #define XR_CODEC_GUID_JPEG \
553553 "\xE6\x4C\xAF\x1B\xED\x9E\x0C\x43\x86\x9A\xCB\x8B\x37\xB6\x62\x37"
554554
555 /* CODEC_GUID_PNG 0xOE0C858D 28E0 45DB ADAA0F83E57CC560 */
555 /* CODEC_GUID_PNG 0E0C858D-28E0-45DB-ADAA0F83E57CC560 */
556556 #define XR_CODEC_GUID_PNG \
557557 "\x8D\x85\x0C\x0E\xE0\x28\xDB\x45\xAD\xAA\x0F\x83\xE5\x7C\xC5\x60"
558558
559 /* MFVideoFormat_H264 ({34363248-0000-0010-8000-00AA00389B71}) */
559 /* MFVideoFormat_H264 0x34363248-0000-0010-800000AA00389B71 */
560560 #define XR_CODEC_GUID_H264 \
561561 "\x48\x32\x36\x34\x00\x00\x10\x00\x80\x00\x00\xAA\x00\x38\x9B\x71"
562562
00 # Process this file with autoconf to produce a configure script
11
2 AC_PREREQ(2.59)
3 AC_INIT([xrdp], [0.9.0], [xrdp-devel@lists.sourceforge.net])
2 AC_PREREQ(2.65)
3 AC_INIT([xrdp], [0.9.0], [xrdp-devel@googlegroups.com])
44 AC_CONFIG_HEADERS(config_ac.h:config_ac-h.in)
5 AM_INIT_AUTOMAKE([1.6 foreign])
5 AM_INIT_AUTOMAKE([1.7.2 foreign])
6 AC_CONFIG_MACRO_DIR([m4])
67 AC_PROG_CC
78 AC_C_CONST
89 AC_PROG_LIBTOOL
910 PKG_PROG_PKG_CONFIG
11
12 # Use silent rules by default if supported by Automake
13 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
14
15 AX_CFLAGS_WARN_ALL
16 AX_GCC_FUNC_ATTRIBUTE([format])
1017
1118 case $host_os in
1219 *linux*)
5259 AC_ARG_ENABLE(ipv6, AS_HELP_STRING([--enable-ipv6],
5360 [Build IPv6 support (default: no, experimental)]),
5461 [], [enable_ipv6=no])
62 AC_ARG_ENABLE(ipv6only, AS_HELP_STRING([--enable-ipv6only],
63 [Build IPv6-only (default: no)]),
64 [], [enable_ipv6only=no])
5565 AC_ARG_ENABLE(kerberos, AS_HELP_STRING([--enable-kerberos],
5666 [Build kerberos support (default: no)]),
5767 [], [enable_kerberos=no])
97107 [], [enable_opus=no])
98108 AM_CONDITIONAL(XRDP_OPUS, [test x$enable_opus = xyes])
99109
100 AM_CONDITIONAL(GOT_PREFIX, test "x${prefix}" != "xNONE"])
101
102110 # checking for openssl
103111 AC_CHECK_HEADER([openssl/rc4.h], [],
104112 [AC_MSG_ERROR([please install libssl-dev or openssl-devel])],
126134 fi
127135 fi
128136
137 if test "x$enable_ipv6only" = "xyes"
138 then
139 enable_ipv6=yes
140 AC_DEFINE([XRDP_ENABLE_IPV6ONLY],1,[Enable IPv6 only])
141 fi
142
129143 if test "x$enable_ipv6" = "xyes"
130144 then
131145 AC_DEFINE([XRDP_ENABLE_IPV6],1,[Enable IPv6])
132146 fi
133
134 AC_CHECK_MEMBER([struct in6_addr.s6_addr],
135 [],
136 [AC_DEFINE(NO_ARPA_INET_H_IP6, 1, [for IPv6])],
137 [#include <arpa/inet.h>])
138147
139148 if test "x$enable_pam" != "xyes" || test "x$bsd" = "xtrue"
140149 then
199208 fi
200209 fi
201210
202 # checking for Xlib, Xfixes
203 AC_CHECK_HEADER([X11/Xlib.h], [],
204 [AC_MSG_ERROR([please install libx11-dev or libX11-devel])])
211 AC_PATH_XTRA
212 if test "x$no_x" == "xyes"; then
213 AC_MSG_ERROR([please install libx11-dev or libX11-devel])
214 fi
215
216 save_CFLAGS="$CFLAGS"
217 CFLAGS="$CFLAGS $X_CFLAGS"
218
219 # checking for Xfixes
205220 AC_CHECK_HEADER([X11/extensions/Xfixes.h], [],
206221 [AC_MSG_ERROR([please install libx11-dev and libxfixes-dev or libXfixes-devel])],
207222 [#include <X11/Xlib.h>])
223
224 # checking for Xrandr
208225 AC_CHECK_HEADER([X11/extensions/Xrandr.h], [],
209226 [AC_MSG_ERROR([please install libxrandr-dev or libXrandr-devel])],
210227 [#include <X11/Xlib.h>])
211228
212 libdir="${libdir}/xrdp";
229 CFLAGS="$save_CFLAGS"
230
231 AC_SUBST([moduledir], '${libdir}/xrdp')
232
213233 if test "x${prefix}" = "xNONE" ; then
214234 sysconfdir="/etc";
215235 localstatedir="/var";
3030
3131 For X11, start the XServer after the user is
3232 authenticated. First check for the next available X11 display,
33 create a user session, start the XServer and set the DISPLAY enviromenet
33 create a user session, start the XServer and set the DISPLAY environment
3434 variable.
0 man_MANS = \
0 dist_man_MANS = \
11 xrdp-dis.1 \
22 sesman.ini.5 \
33 xrdp.ini.5 \
1313 noinst_man_MANS = \
1414 xrdp-xcon.8
1515
16 EXTRA_DIST = $(man_MANS) $(noinst_man_MANS)
16 EXTRA_DIST = $(noinst_man_MANS)
22 xrdp\-sessvc \- \fBxrdp\fR session supervisor
33
44 .SH "SYNTAX"
5 .B xrdp\-sessman
5 .B xrdp\-sessvc
66 .I x_pid wm_pid
77
88 .SH "DESCRIPTION"
213213 .TP
214214 \fBport\fR=\fI<number>\fR|\fI\-1\fR
215215 Specifies the port number to connect to. If set to \fI\-1\fR, the default port for the specified library is used.
216
217 .TP
218 \fBcode\fR=\fI<number>\fR|\fI\-1\fR
219 Specifies the session type, the default, \fI\0\fR, is Xvnc, \fI\10\fR, is X11rdp, and \fI\20\fR, uses Xorg driver mode.
216220
217221 .SH "EXAMPLES"
218222 This is an example \fBxrdp.ini\fR:
(No changes)
(No changes)
0 AM_CFLAGS = $(X_CFLAGS)
01
12 bin_PROGRAMS = \
23 xrdp-genkeymap
34
45 xrdp_genkeymap_SOURCES = genkeymap.c evdev-map.c
56
7 xrdp_genkeymap_LDFLAGS = \
8 $(X_LIBS)
9
610 xrdp_genkeymap_LDADD = \
7 -L/usr/X11R6/lib \
8 -lX11
11 $(X_PRE_LIBS) -lX11 $(X_EXTRA_LIBS)
2020
2121 Updated Jay Sorg 2009
2222
23 cs czech 0x405
24 de german 0x407
25 en-us us english 0x409
26 fr french 0x40c
27 it italy 0x410
23 cs Czech 0x405
24 de German 0x407
25 en-us US English 0x409
26 fr French 0x40c
27 it Italian 0x410
2828 br Portuguese (Brazil) 0x416
29 ru russian 0x419
30 se swedish 0x41d
31 en-uk uk english 0x809
29 ru Russian 0x419
30 se Swedish 0x41d
31 en-uk UK English 0x809
3232 */
3333
3434 #include <stdio.h>
1010 for that.
1111 I also have a replacement ssl_calls.c to avoid the openssl dependency
1212 email me(Jay) for it or see http://server1.xrdp.org/xrdp/openssl.
13 Due to the licence, I can't include it in this project.
13 Due to the license, I can't include it in this project.
1414
1515 http://server1.xrdp.org/xrdp/openssl/
1616
17 unpackage the tarball
17 unpack the tarball
1818
1919 tar -zxvf xrdp-0.1.tar.gz
2020
2727 as root, run make install
2828
2929 This will install most of the files in /usr/local/xrdp.
30 Some files install in /etc/xrdp. These are configuation
30 Some files install in /etc/xrdp. These are configuration
3131 files.
3232
3333 files and location
00 EXTRA_DIST = \
11 xrdp.sh \
22 xrdp-sesman.service \
3 xrdp.service \
4 $(startscript_DATA)
3 xrdp.service
54
65 #
76 # files for all platforms
87 #
98 startscriptdir=$(sysconfdir)/xrdp
109
11 startscript_DATA = \
10 dist_startscript_DATA = \
1211 km-0407.ini \
1312 km-0409.ini \
1413 km-040c.ini \
2322 km-080c.ini \
2423 km-0813.ini \
2524 km-0816.ini \
25 km-100c.ini \
2626 km-e0010411.ini \
2727 km-e0200411.ini \
2828 km-e0210411.ini
3030 #
3131 # platform specific files
3232 #
33 SUBDIRS=
33 SUBDIRS =
3434 if LINUX
35 SUBDIRS+= \
36 pam.d \
37 pulse
38 startscript_DATA+= xrdp.sh
35 SUBDIRS += \
36 pam.d \
37 pulse
38 dist_startscript_SCRIPTS = xrdp.sh
3939 if HAVE_SYSTEMD
40 systemdsystemunit_DATA = \
41 xrdp-sesman.service \
42 xrdp.service
40 dist_systemdsystemunit_DATA = \
41 xrdp-sesman.service \
42 xrdp.service
4343 else
44 SUBDIRS+= \
45 default \
46 init.d
44 SUBDIRS += \
45 default \
46 init.d
4747 endif # HAVE_SYSTEMD
4848 endif # LINUX
4949
5050 if FREEBSD
51 SUBDIRS+= \
52 pam.d \
53 rc.d \
54 pulse
51 SUBDIRS += \
52 pam.d \
53 rc.d \
54 pulse
5555 endif
5656
5757 #
6060 if LINUX
6161 # must be tab below
6262 install-data-hook:
63 chmod 755 $(DESTDIR)$(sysconfdir)/xrdp/xrdp.sh
6463 if [ -f $(DESTDIR)$(sysconfdir)/init.d/xrdp ]; then \
65 chmod 755 $(DESTDIR)$(sysconfdir)/init.d/xrdp; \
6664 sed -i 's|__BASE__|$(prefix)|' $(DESTDIR)$(sysconfdir)/init.d/xrdp; \
6765 fi
6866 endif
7068 if FREEBSD
7169 # must be tab below
7270 install-data-hook:
73 chmod 755 $(DESTDIR)$(sysconfdir)/rc.d/xrdp
7471 sed -i '' 's|%%PREFIX%%|$(prefix)|g' $(DESTDIR)$(sysconfdir)/rc.d/xrdp
7572 endif
0 EXTRA_DIST = xrdp
1 startscriptdir=$(sysconfdir)/default
2 startscript_DATA = xrdp
0 startscriptdir = $(sysconfdir)/default
1 dist_startscript_DATA = xrdp
0 EXTRA_DIST = xrdp
1 startscriptdir=$(sysconfdir)/init.d
2 startscript_DATA = xrdp
3
0 startscriptdir = $(sysconfdir)/init.d
1 dist_startscript_SCRIPTS = xrdp
1717 BASE=__BASE__
1818 DAEMON=${BASE}/sbin/xrdp
1919 SDAEMON=${BASE}/sbin/xrdp-sesman
20 PIDDIR=/var/run/xrdp/
20 PIDDIR=/var/run/
2121 SESMAN_START=yes
2222 #USERID=xrdp
2323 # the X11rdp backend only works as root at the moment - GH 20/03/2013
2424 USERID=root
25 RSAKEYS=/etc/xrdp/rsakeys.ini
2625 NAME=xrdp
2726 DESC="Remote Desktop Protocol server"
2827
6665 mkdir $PIDDIR
6766 fi
6867 chown $USERID:$USERID $PIDDIR
69
70 # Check for rsa key
71 if [ ! -f $RSAKEYS ] ; then
72 log_action_begin_msg "Generating xrdp RSA keys..."
73 (umask 077 ; xrdp-keygen xrdp $RSAKEYS)
74 chown $USERID:$USERID $RSAKEYS
75 if [ ! -f $RSAKEYS ] ; then
76 log_action_end_msg 1 "could not create $RSAKEYS"
77 exit 1
78 fi
79 log_action_end_msg 0 "done"
80 fi
8168 fi
8269
8370
138125 ;;
139126 force-stop)
140127 $0 stop
141 # because it doesn't allways die the right way
128 # because it doesn't always die the right way
142129 force_stop
143130 ;;
144131 restart|force-reload)
119119 Key126=65469:61
120120 Key127=0:0
121121 Key128=0:0
122 Key129=0:0
122 Key129=65315:0
123123 Key130=0:0
124 Key131=0:0
124 Key131=65314:0
125125 Key132=0:0
126126 Key133=165:165
127127 Key134=0:0
251251 Key126=65469:61
252252 Key127=65515:0
253253 Key128=65517:0
254 Key129=0:0
254 Key129=65315:0
255255 Key130=0:0
256 Key131=0:0
256 Key131=65314:0
257257 Key132=0:0
258258 Key133=124:124
259259 Key134=0:0
383383 Key126=65469:61
384384 Key127=0:0
385385 Key128=0:0
386 Key129=0:0
386 Key129=65315:0
387387 Key130=0:0
388 Key131=0:0
388 Key131=65314:0
389389 Key132=0:0
390390 Key133=165:165
391391 Key134=0:0
515515 Key126=65469:61
516516 Key127=65515:0
517517 Key128=65517:0
518 Key129=0:0
518 Key129=65315:0
519519 Key130=0:0
520 Key131=0:0
520 Key131=65314:0
521521 Key132=0:0
522522 Key133=124:124
523523 Key134=0:0
647647 Key126=65469:61
648648 Key127=0:0
649649 Key128=0:0
650 Key129=0:0
650 Key129=65315:0
651651 Key130=0:0
652 Key131=0:0
652 Key131=65314:0
653653 Key132=0:0
654654 Key133=165:165
655655 Key134=0:0
779779 Key126=65469:61
780780 Key127=0:0
781781 Key128=0:0
782 Key129=0:0
782 Key129=65315:0
783783 Key130=0:0
784 Key131=0:0
784 Key131=65314:0
785785 Key132=0:0
786786 Key133=165:165
787787 Key134=0:0
911911 Key126=65469:61
912912 Key127=65515:0
913913 Key128=65517:0
914 Key129=0:0
914 Key129=65315:0
915915 Key130=0:0
916 Key131=0:0
916 Key131=65314:0
917917 Key132=0:0
918918 Key133=124:124
919919 Key134=0:0
10431043 Key126=65469:61
10441044 Key127=65515:0
10451045 Key128=65517:0
1046 Key129=0:0
1046 Key129=65315:0
10471047 Key130=0:0
1048 Key131=0:0
1048 Key131=65314:0
10491049 Key132=0:0
10501050 Key133=124:124
10511051 Key134=0:0
0 [noshift]
1 Key8=0:0
2 Key9=65307:27
3 Key10=49:49
4 Key11=50:50
5 Key12=51:51
6 Key13=52:52
7 Key14=53:53
8 Key15=54:54
9 Key16=55:55
10 Key17=56:56
11 Key18=57:57
12 Key19=48:48
13 Key20=39:39
14 Key21=65106:94
15 Key22=65288:8
16 Key23=65289:9
17 Key24=113:113
18 Key25=119:119
19 Key26=101:101
20 Key27=114:114
21 Key28=116:116
22 Key29=122:122
23 Key30=117:117
24 Key31=105:105
25 Key32=111:111
26 Key33=112:112
27 Key34=232:232
28 Key35=65111:168
29 Key36=65293:13
30 Key37=65507:0
31 Key38=97:97
32 Key39=115:115
33 Key40=100:100
34 Key41=102:102
35 Key42=103:103
36 Key43=104:104
37 Key44=106:106
38 Key45=107:107
39 Key46=108:108
40 Key47=233:233
41 Key48=224:224
42 Key49=167:167
43 Key50=65505:0
44 Key51=36:36
45 Key52=121:121
46 Key53=120:120
47 Key54=99:99
48 Key55=118:118
49 Key56=98:98
50 Key57=110:110
51 Key58=109:109
52 Key59=44:44
53 Key60=46:46
54 Key61=45:45
55 Key62=65506:0
56 Key63=65450:42
57 Key64=65513:0
58 Key65=32:32
59 Key66=65509:0
60 Key67=65470:0
61 Key68=65471:0
62 Key69=65472:0
63 Key70=65473:0
64 Key71=65474:0
65 Key72=65475:0
66 Key73=65476:0
67 Key74=65477:0
68 Key75=65478:0
69 Key76=65479:0
70 Key77=65407:0
71 Key78=65300:0
72 Key79=65429:0
73 Key80=65431:0
74 Key81=65434:0
75 Key82=65453:45
76 Key83=65430:0
77 Key84=65437:0
78 Key85=65432:0
79 Key86=65451:43
80 Key87=65436:0
81 Key88=65433:0
82 Key89=65435:0
83 Key90=65438:0
84 Key91=65439:0
85 Key92=0:0
86 Key93=65406:0
87 Key94=60:60
88 Key95=65480:0
89 Key96=65481:0
90 Key97=65360:0
91 Key98=65362:0
92 Key99=65365:0
93 Key100=65361:0
94 Key101=0:0
95 Key102=65363:0
96 Key103=65367:0
97 Key104=65364:0
98 Key105=65366:0
99 Key106=65379:0
100 Key107=65535:127
101 Key108=65421:13
102 Key109=65508:0
103 Key110=65299:0
104 Key111=65377:0
105 Key112=65455:47
106 Key113=65027:0
107 Key114=0:0
108 Key115=0:0
109 Key116=0:0
110 Key117=0:0
111 Key118=0:0
112 Key119=0:0
113 Key120=0:0
114 Key121=0:0
115 Key122=0:0
116 Key123=0:0
117 Key124=65027:0
118 Key125=0:0
119 Key126=65469:61
120 Key127=0:0
121 Key128=0:0
122 Key129=0:0
123 Key130=0:0
124 Key131=0:0
125 Key132=0:0
126 Key133=0:0
127 Key134=0:0
128 Key135=0:0
129 Key136=0:0
130 Key137=0:0
131
132 [shift]
133 Key8=0:0
134 Key9=65307:27
135 Key10=43:43
136 Key11=34:34
137 Key12=42:42
138 Key13=231:231
139 Key14=37:37
140 Key15=38:38
141 Key16=47:47
142 Key17=40:40
143 Key18=41:41
144 Key19=61:61
145 Key20=63:63
146 Key21=65104:96
147 Key22=65288:8
148 Key23=65056:0
149 Key24=81:81
150 Key25=87:87
151 Key26=69:69
152 Key27=82:82
153 Key28=84:84
154 Key29=90:90
155 Key30=85:85
156 Key31=73:73
157 Key32=79:79
158 Key33=80:80
159 Key34=252:252
160 Key35=33:33
161 Key36=65293:13
162 Key37=65507:0
163 Key38=65:65
164 Key39=83:83
165 Key40=68:68
166 Key41=70:70
167 Key42=71:71
168 Key43=72:72
169 Key44=74:74
170 Key45=75:75
171 Key46=76:76
172 Key47=246:246
173 Key48=228:228
174 Key49=176:176
175 Key50=65505:0
176 Key51=163:163
177 Key52=89:89
178 Key53=88:88
179 Key54=67:67
180 Key55=86:86
181 Key56=66:66
182 Key57=78:78
183 Key58=77:77
184 Key59=59:59
185 Key60=58:58
186 Key61=95:95
187 Key62=65506:0
188 Key63=65450:42
189 Key64=65511:0
190 Key65=32:32
191 Key66=65509:0
192 Key67=65470:0
193 Key68=65471:0
194 Key69=65472:0
195 Key70=65473:0
196 Key71=65474:0
197 Key72=65475:0
198 Key73=65476:0
199 Key74=65477:0
200 Key75=65478:0
201 Key76=65479:0
202 Key77=65273:0
203 Key78=65300:0
204 Key79=65463:55
205 Key80=65464:56
206 Key81=65465:57
207 Key82=65453:45
208 Key83=65460:52
209 Key84=65461:53
210 Key85=65462:54
211 Key86=65451:43
212 Key87=65457:49
213 Key88=65458:50
214 Key89=65459:51
215 Key90=65456:48
216 Key91=65454:46
217 Key92=0:0
218 Key93=65406:0
219 Key94=62:62
220 Key95=65480:0
221 Key96=65481:0
222 Key97=65360:0
223 Key98=65362:0
224 Key99=65365:0
225 Key100=65361:0
226 Key101=0:0
227 Key102=65363:0
228 Key103=65367:0
229 Key104=65364:0
230 Key105=65366:0
231 Key106=65379:0
232 Key107=65535:127
233 Key108=65421:13
234 Key109=65508:0
235 Key110=65299:0
236 Key111=65377:0
237 Key112=65455:47
238 Key113=65312:0
239 Key114=0:0
240 Key115=0:0
241 Key116=0:0
242 Key117=0:0
243 Key118=0:0
244 Key119=0:0
245 Key120=0:0
246 Key121=0:0
247 Key122=0:0
248 Key123=0:0
249 Key124=65027:0
250 Key125=65513:0
251 Key126=65469:61
252 Key127=65515:0
253 Key128=65517:0
254 Key129=0:0
255 Key130=0:0
256 Key131=0:0
257 Key132=0:0
258 Key133=0:0
259 Key134=0:0
260 Key135=0:0
261 Key136=0:0
262 Key137=0:0
263
264 [altgr]
265 Key8=0:0
266 Key9=65307:27
267 Key10=124:124
268 Key11=64:64
269 Key12=35:35
270 Key13=188:188
271 Key14=189:189
272 Key15=172:172
273 Key16=166:166
274 Key17=162:162
275 Key18=93:93
276 Key19=125:125
277 Key20=65105:180
278 Key21=65107:126
279 Key22=65288:8
280 Key23=65289:9
281 Key24=64:64
282 Key25=435:322
283 Key26=8364:8364
284 Key27=182:182
285 Key28=956:359
286 Key29=2299:8592
287 Key30=2302:8595
288 Key31=2301:8594
289 Key32=248:248
290 Key33=254:254
291 Key34=91:91
292 Key35=93:93
293 Key36=65293:13
294 Key37=65507:0
295 Key38=230:230
296 Key39=223:223
297 Key40=240:240
298 Key41=496:273
299 Key42=959:331
300 Key43=689:295
301 Key44=106:106
302 Key45=930:312
303 Key46=435:322
304 Key47=65105:180
305 Key48=123:123
306 Key49=172:172
307 Key50=65505:0
308 Key51=125:125
309 Key52=171:171
310 Key53=187:187
311 Key54=162:162
312 Key55=2770:8220
313 Key56=2771:8221
314 Key57=110:110
315 Key58=181:181
316 Key59=2211:0
317 Key60=183:183
318 Key61=65120:0
319 Key62=65506:0
320 Key63=65450:42
321 Key64=65513:0
322 Key65=32:32
323 Key66=65509:0
324 Key67=65470:0
325 Key68=65471:0
326 Key69=65472:0
327 Key70=65473:0
328 Key71=65474:0
329 Key72=65475:0
330 Key73=65476:0
331 Key74=65477:0
332 Key75=65478:0
333 Key76=65479:0
334 Key77=65407:0
335 Key78=65300:0
336 Key79=65429:0
337 Key80=65431:0
338 Key81=65434:0
339 Key82=65453:45
340 Key83=65430:0
341 Key84=65437:0
342 Key85=65432:0
343 Key86=65451:43
344 Key87=65436:0
345 Key88=65433:0
346 Key89=65435:0
347 Key90=65438:0
348 Key91=65439:0
349 Key92=0:0
350 Key93=65406:0
351 Key94=92:92
352 Key95=65480:0
353 Key96=65481:0
354 Key97=65360:0
355 Key98=65362:0
356 Key99=65365:0
357 Key100=65361:0
358 Key101=0:0
359 Key102=65363:0
360 Key103=65367:0
361 Key104=65364:0
362 Key105=65366:0
363 Key106=65379:0
364 Key107=65535:127
365 Key108=65421:13
366 Key109=65508:0
367 Key110=65299:0
368 Key111=0:0
369 Key112=65455:47
370 Key113=65027:0
371 Key114=0:0
372 Key115=0:0
373 Key116=0:0
374 Key117=0:0
375 Key118=0:0
376 Key119=0:0
377 Key120=0:0
378 Key121=0:0
379 Key122=0:0
380 Key123=0:0
381 Key124=65027:0
382 Key125=0:0
383 Key126=65469:61
384 Key127=0:0
385 Key128=0:0
386 Key129=0:0
387 Key130=0:0
388 Key131=0:0
389 Key132=0:0
390 Key133=0:0
391 Key134=0:0
392 Key135=0:0
393 Key136=0:0
394 Key137=0:0
395
396 [capslock]
397 Key8=0:0
398 Key9=65307:27
399 Key10=49:49
400 Key11=50:50
401 Key12=51:51
402 Key13=52:52
403 Key14=53:53
404 Key15=54:54
405 Key16=55:55
406 Key17=56:56
407 Key18=57:57
408 Key19=48:48
409 Key20=39:39
410 Key21=65106:94
411 Key22=65288:8
412 Key23=65289:9
413 Key24=81:81
414 Key25=87:87
415 Key26=69:69
416 Key27=82:82
417 Key28=84:84
418 Key29=90:90
419 Key30=85:85
420 Key31=73:73
421 Key32=79:79
422 Key33=80:80
423 Key34=200:200
424 Key35=65111:168
425 Key36=65293:13
426 Key37=65507:0
427 Key38=65:65
428 Key39=83:83
429 Key40=68:68
430 Key41=70:70
431 Key42=71:71
432 Key43=72:72
433 Key44=74:74
434 Key45=75:75
435 Key46=76:76
436 Key47=201:201
437 Key48=192:192
438 Key49=167:167
439 Key50=65505:0
440 Key51=36:36
441 Key52=89:89
442 Key53=88:88
443 Key54=67:67
444 Key55=86:86
445 Key56=66:66
446 Key57=78:78
447 Key58=77:77
448 Key59=44:44
449 Key60=46:46
450 Key61=45:45
451 Key62=65506:0
452 Key63=65450:42
453 Key64=65513:0
454 Key65=32:32
455 Key66=65509:0
456 Key67=65470:0
457 Key68=65471:0
458 Key69=65472:0
459 Key70=65473:0
460 Key71=65474:0
461 Key72=65475:0
462 Key73=65476:0
463 Key74=65477:0
464 Key75=65478:0
465 Key76=65479:0
466 Key77=65407:0
467 Key78=65300:0
468 Key79=65429:0
469 Key80=65431:0
470 Key81=65434:0
471 Key82=65453:45
472 Key83=65430:0
473 Key84=65437:0
474 Key85=65432:0
475 Key86=65451:43
476 Key87=65436:0
477 Key88=65433:0
478 Key89=65435:0
479 Key90=65438:0
480 Key91=65439:0
481 Key92=0:0
482 Key93=65406:0
483 Key94=60:60
484 Key95=65480:0
485 Key96=65481:0
486 Key97=65360:0
487 Key98=65362:0
488 Key99=65365:0
489 Key100=65361:0
490 Key101=0:0
491 Key102=65363:0
492 Key103=65367:0
493 Key104=65364:0
494 Key105=65366:0
495 Key106=65379:0
496 Key107=65535:127
497 Key108=65421:13
498 Key109=65508:0
499 Key110=65299:0
500 Key111=65377:0
501 Key112=65455:47
502 Key113=65027:0
503 Key114=0:0
504 Key115=0:0
505 Key116=0:0
506 Key117=0:0
507 Key118=0:0
508 Key119=0:0
509 Key120=0:0
510 Key121=0:0
511 Key122=0:0
512 Key123=0:0
513 Key124=65027:0
514 Key125=0:0
515 Key126=65469:61
516 Key127=0:0
517 Key128=0:0
518 Key129=0:0
519 Key130=0:0
520 Key131=0:0
521 Key132=0:0
522 Key133=0:0
523 Key134=0:0
524 Key135=0:0
525 Key136=0:0
526 Key137=0:0
527
528 [shiftcapslock]
529 Key8=0:0
530 Key9=65307:27
531 Key10=43:43
532 Key11=34:34
533 Key12=42:42
534 Key13=199:199
535 Key14=37:37
536 Key15=38:38
537 Key16=47:47
538 Key17=40:40
539 Key18=41:41
540 Key19=61:61
541 Key20=63:63
542 Key21=65104:96
543 Key22=65288:8
544 Key23=65056:0
545 Key24=113:113
546 Key25=119:119
547 Key26=101:101
548 Key27=114:114
549 Key28=116:116
550 Key29=122:122
551 Key30=117:117
552 Key31=105:105
553 Key32=111:111
554 Key33=112:112
555 Key34=220:220
556 Key35=33:33
557 Key36=65293:13
558 Key37=65507:0
559 Key38=97:97
560 Key39=115:115
561 Key40=100:100
562 Key41=102:102
563 Key42=103:103
564 Key43=104:104
565 Key44=106:106
566 Key45=107:107
567 Key46=108:108
568 Key47=214:214
569 Key48=196:196
570 Key49=176:176
571 Key50=65505:0
572 Key51=163:163
573 Key52=121:121
574 Key53=120:120
575 Key54=99:99
576 Key55=118:118
577 Key56=98:98
578 Key57=110:110
579 Key58=109:109
580 Key59=59:59
581 Key60=58:58
582 Key61=95:95
583 Key62=65506:0
584 Key63=65450:42
585 Key64=65511:0
586 Key65=32:32
587 Key66=65509:0
588 Key67=65470:0
589 Key68=65471:0
590 Key69=65472:0
591 Key70=65473:0
592 Key71=65474:0
593 Key72=65475:0
594 Key73=65476:0
595 Key74=65477:0
596 Key75=65478:0
597 Key76=65479:0
598 Key77=65273:0
599 Key78=65300:0
600 Key79=65463:55
601 Key80=65464:56
602 Key81=65465:57
603 Key82=65453:45
604 Key83=65460:52
605 Key84=65461:53
606 Key85=65462:54
607 Key86=65451:43
608 Key87=65457:49
609 Key88=65458:50
610 Key89=65459:51
611 Key90=65456:48
612 Key91=65454:46
613 Key92=0:0
614 Key93=65406:0
615 Key94=62:62
616 Key95=65480:0
617 Key96=65481:0
618 Key97=65360:0
619 Key98=65362:0
620 Key99=65365:0
621 Key100=65361:0
622 Key101=0:0
623 Key102=65363:0
624 Key103=65367:0
625 Key104=65364:0
626 Key105=65366:0
627 Key106=65379:0
628 Key107=65535:127
629 Key108=65421:13
630 Key109=65508:0
631 Key110=65299:0
632 Key111=65377:0
633 Key112=65455:47
634 Key113=65312:0
635 Key114=0:0
636 Key115=0:0
637 Key116=0:0
638 Key117=0:0
639 Key118=0:0
640 Key119=0:0
641 Key120=0:0
642 Key121=0:0
643 Key122=0:0
644 Key123=0:0
645 Key124=65027:0
646 Key125=65513:0
647 Key126=65469:61
648 Key127=65515:0
649 Key128=65517:0
650 Key129=0:0
651 Key130=0:0
652 Key131=0:0
653 Key132=0:0
654 Key133=0:0
655 Key134=0:0
656 Key135=0:0
657 Key136=0:0
658 Key137=0:0
119119 Key126=65469:61
120120 Key127=0:0
121121 Key128=0:0
122 Key129=0:0
122 Key129=65315:0
123123 Key130=0:0
124 Key131=0:0
124 Key131=65314:0
125125 Key132=0:0
126126 Key133=165:165
127127 Key134=0:0
251251 Key126=65469:61
252252 Key127=65515:0
253253 Key128=65517:0
254 Key129=0:0
254 Key129=65315:0
255255 Key130=0:0
256 Key131=0:0
256 Key131=65314:0
257257 Key132=0:0
258258 Key133=124:124
259259 Key134=0:0
383383 Key126=65469:61
384384 Key127=0:0
385385 Key128=0:0
386 Key129=0:0
386 Key129=65315:0
387387 Key130=0:0
388 Key131=0:0
388 Key131=65314:0
389389 Key132=0:0
390390 Key133=165:165
391391 Key134=0:0
515515 Key126=65469:61
516516 Key127=65515:0
517517 Key128=65517:0
518 Key129=0:0
518 Key129=65315:0
519519 Key130=0:0
520 Key131=0:0
520 Key131=65314:0
521521 Key132=0:0
522522 Key133=124:124
523523 Key134=0:0
647647 Key126=65469:61
648648 Key127=0:0
649649 Key128=0:0
650 Key129=0:0
650 Key129=65315:0
651651 Key130=0:0
652 Key131=0:0
652 Key131=65314:0
653653 Key132=0:0
654654 Key133=165:165
655655 Key134=0:0
779779 Key126=65469:61
780780 Key127=0:0
781781 Key128=0:0
782 Key129=0:0
782 Key129=65315:0
783783 Key130=0:0
784 Key131=0:0
784 Key131=65314:0
785785 Key132=0:0
786786 Key133=165:165
787787 Key134=0:0
911911 Key126=65469:61
912912 Key127=65515:0
913913 Key128=65517:0
914 Key129=0:0
914 Key129=65315:0
915915 Key130=0:0
916 Key131=0:0
916 Key131=65314:0
917917 Key132=0:0
918918 Key133=124:124
919919 Key134=0:0
10431043 Key126=65469:61
10441044 Key127=65515:0
10451045 Key128=65517:0
1046 Key129=0:0
1046 Key129=65315:0
10471047 Key130=0:0
1048 Key131=0:0
1048 Key131=65314:0
10491049 Key132=0:0
10501050 Key133=124:124
10511051 Key134=0:0
119119 Key126=65469:61
120120 Key127=0:0
121121 Key128=0:0
122 Key129=0:0
122 Key129=65315:0
123123 Key130=0:0
124 Key131=0:0
124 Key131=65314:0
125125 Key132=0:0
126126 Key133=165:165
127127 Key134=0:0
251251 Key126=65469:61
252252 Key127=65515:0
253253 Key128=65517:0
254 Key129=0:0
254 Key129=65315:0
255255 Key130=0:0
256 Key131=0:0
256 Key131=65314:0
257257 Key132=0:0
258258 Key133=124:124
259259 Key134=0:0
383383 Key126=65469:61
384384 Key127=0:0
385385 Key128=0:0
386 Key129=0:0
386 Key129=65315:0
387387 Key130=0:0
388 Key131=0:0
388 Key131=65314:0
389389 Key132=0:0
390390 Key133=165:165
391391 Key134=0:0
515515 Key126=65469:61
516516 Key127=65515:0
517517 Key128=65517:0
518 Key129=0:0
518 Key129=65315:0
519519 Key130=0:0
520 Key131=0:0
520 Key131=65314:0
521521 Key132=0:0
522522 Key133=124:124
523523 Key134=0:0
647647 Key126=65469:61
648648 Key127=0:0
649649 Key128=0:0
650 Key129=0:0
650 Key129=65315:0
651651 Key130=0:0
652 Key131=0:0
652 Key131=65314:0
653653 Key132=0:0
654654 Key133=165:165
655655 Key134=0:0
779779 Key126=65469:61
780780 Key127=0:0
781781 Key128=0:0
782 Key129=0:0
782 Key129=65315:0
783783 Key130=0:0
784 Key131=0:0
784 Key131=65314:0
785785 Key132=0:0
786786 Key133=165:165
787787 Key134=0:0
911911 Key126=65469:61
912912 Key127=65515:0
913913 Key128=65517:0
914 Key129=0:0
914 Key129=65315:0
915915 Key130=0:0
916 Key131=0:0
916 Key131=65314:0
917917 Key132=0:0
918918 Key133=124:124
919919 Key134=0:0
10431043 Key126=65469:61
10441044 Key127=65515:0
10451045 Key128=65517:0
1046 Key129=0:0
1046 Key129=65315:0
10471047 Key130=0:0
1048 Key131=0:0
1048 Key131=65314:0
10491049 Key132=0:0
10501050 Key133=124:124
10511051 Key134=0:0
119119 Key126=65469:61
120120 Key127=0:0
121121 Key128=0:0
122 Key129=0:0
122 Key129=65315:0
123123 Key130=0:0
124 Key131=0:0
124 Key131=65314:0
125125 Key132=0:0
126126 Key133=165:165
127127 Key134=0:0
251251 Key126=65469:61
252252 Key127=65515:0
253253 Key128=65517:0
254 Key129=0:0
254 Key129=65315:0
255255 Key130=0:0
256 Key131=0:0
256 Key131=65314:0
257257 Key132=0:0
258258 Key133=124:124
259259 Key134=0:0
383383 Key126=65469:61
384384 Key127=0:0
385385 Key128=0:0
386 Key129=0:0
386 Key129=65315:0
387387 Key130=0:0
388 Key131=0:0
388 Key131=65314:0
389389 Key132=0:0
390390 Key133=165:165
391391 Key134=0:0
515515 Key126=65469:61
516516 Key127=65515:0
517517 Key128=65517:0
518 Key129=0:0
518 Key129=65315:0
519519 Key130=0:0
520 Key131=0:0
520 Key131=65314:0
521521 Key132=0:0
522522 Key133=124:124
523523 Key134=0:0
647647 Key126=65469:61
648648 Key127=0:0
649649 Key128=0:0
650 Key129=0:0
650 Key129=65315:0
651651 Key130=0:0
652 Key131=0:0
652 Key131=65314:0
653653 Key132=0:0
654654 Key133=165:165
655655 Key134=0:0
779779 Key126=65469:61
780780 Key127=0:0
781781 Key128=0:0
782 Key129=0:0
782 Key129=65315:0
783783 Key130=0:0
784 Key131=0:0
784 Key131=65314:0
785785 Key132=0:0
786786 Key133=165:165
787787 Key134=0:0
911911 Key126=65469:61
912912 Key127=65515:0
913913 Key128=65517:0
914 Key129=0:0
914 Key129=65315:0
915915 Key130=0:0
916 Key131=0:0
916 Key131=65314:0
917917 Key132=0:0
918918 Key133=124:124
919919 Key134=0:0
10431043 Key126=65469:61
10441044 Key127=65515:0
10451045 Key128=65517:0
1046 Key129=0:0
1046 Key129=65315:0
10471047 Key130=0:0
1048 Key131=0:0
1048 Key131=65314:0
10491049 Key132=0:0
10501050 Key133=124:124
10511051 Key134=0:0
0 EXTRA_DIST = xrdp-sesman
0 EXTRA_DIST = \
1 xrdp-sesman.common \
2 xrdp-sesman.other \
3 xrdp-sesman.password-auth
4
5 CLEANFILES = xrdp-sesman
16
27 if SESMAN_NOPAM
38 PAMFILE =
1318 endif
1419 endif
1520
16 pamddir=$(sysconfdir)/pam.d
21 pamddir = $(sysconfdir)/pam.d
1722
1823 pamd_DATA = \
1924 $(PAMFILE)
25
26 xrdp-sesman:
27 if test -e /etc/pam.d/password-auth; then \
28 pamrules=xrdp-sesman.password-auth; \
29 else \
30 if test -e /etc/pam.d/common-auth; then \
31 pamrules=xrdp-sesman.common; \
32 else \
33 pamrules=xrdp-sesman.other; \
34 fi; \
35 fi; \
36 $(LN_S) $(srcdir)/$$pamrules $@
+0
-5
instfiles/pam.d/xrdp-sesman less more
0 #%PAM-1.0
1 @include common-auth
2 @include common-account
3 @include common-session
4 @include common-password
0 #%PAM-1.0
1 @include common-auth
2 @include common-account
3 @include common-session
0 #%PAM-1.0
1 auth include password-auth
2 account include password-auth
3 session include password-auth
0 EXTRA_DIST = default.pa
1 pulsedir=$(sysconfdir)/xrdp/pulse
2 pulse_DATA = default.pa
0 pulsedir = $(sysconfdir)/xrdp/pulse
1 dist_pulse_DATA = default.pa
0 EXTRA_DIST = xrdp
1 startscriptdir=$(sysconfdir)/rc.d
2 startscript_DATA = xrdp
3
0 startscriptdir = $(sysconfdir)/rc.d
1 dist_startscript_SCRIPTS = xrdp
00 #!/bin/sh
1 #
2 # Copyright (c) 1992-2015 The FreeBSD Project. All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
6 # are met:
7 # 1. Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # 2. Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
12 #
13 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 # SUCH DAMAGE.
124 #
225 # $FreeBSD$
326 #
3760 if [ "${rc_arg}" = "stop" ] ; then
3861 xrdp_daemons=$(reverse_list ${xrdp_daemons})
3962 fi
40 # Generate rsakeys.ini on start
41 if [ "${rc_arg}" = "start" -a ! -f %%PREFIX%%/etc/xrdp/rsakeys.ini ] ; then
42 %%PREFIX%%/bin/xrdp-keygen xrdp %%PREFIX%%/etc/xrdp/rsakeys.ini
43 fi
4463
4564 # Apply to all the daemons.
4665 for name in ${xrdp_daemons}; do
66 [Service]
77 Type=forking
88 PIDFile=/var/run/xrdp-sesman.pid
9 EnvironmentFile=/etc/sysconfig/xrdp
9 EnvironmentFile=-/etc/sysconfig/xrdp
10 EnvironmentFile=-/etc/default/xrdp
1011 ExecStart=/usr/sbin/xrdp-sesman $SESMAN_OPTIONS
1112 ExecStop=/usr/sbin/xrdp-sesman $SESMAN_OPTIONS --kill
1213
55 [Service]
66 Type=forking
77 PIDFile=/var/run/xrdp.pid
8 EnvironmentFile=/etc/sysconfig/xrdp
9 ExecStart=/usr/sbin/xrdp $XRDP_OPTIONS --nodaemon
8 EnvironmentFile=-/etc/sysconfig/xrdp
9 EnvironmentFile=-/etc/default/xrdp
10 ExecStart=/usr/sbin/xrdp $XRDP_OPTIONS
1011 ExecStop=/usr/sbin/xrdp $XRDP_OPTIONS --kill
1112
1213 [Install]
00
1 AM_CFLAGS = \
1 AM_CPPFLAGS = \
22 -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
33 -DXRDP_SBIN_PATH=\"${sbindir}\" \
44 -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
5 -DXRDP_PID_PATH=\"${localstatedir}/run\"
6
7 INCLUDES = \
5 -DXRDP_PID_PATH=\"${localstatedir}/run\" \
86 -I$(top_srcdir)/common
97
108 bin_PROGRAMS = \
1412
1513 xrdp_keygen_LDADD = \
1614 $(top_builddir)/common/libcommon.la
15
16 xrdpsysconfdir = $(sysconfdir)/xrdp
17
18 install-data-hook:
19 umask 077 && \
20 ./xrdp-keygen xrdp $(DESTDIR)$(xrdpsysconfdir)/rsakeys.ini
21
22 uninstall-hook:
23 rm -f $(DESTDIR)$(xrdpsysconfdir)/rsakeys.ini
3333 /* this is the signature size in bytes */
3434 #define TSSK_KEY_LENGTH 64
3535
36 /* default to 512 bit key size, can set changed, set */
37 static int g_key_size_bits = 512;
36 /* default to 2048 bit key size, can set changed, set */
37 static int g_key_size_bits = 2048;
3838
3939 static tui8 g_exponent[4] =
4040 {
194194 static int APP_CC
195195 out_params(void)
196196 {
197 g_writeln("");
197 g_writeln("%s", "");
198198 g_writeln("xrdp rsa key gen utility examples");
199199 g_writeln(" xrdp-keygen xrdp ['path and file name' | auto] [512 or 2048]");
200200 g_writeln(" xrdp-keygen test");
201 g_writeln("");
201 g_writeln("%s", "");
202202 return 0;
203203 }
204204
350350 }
351351
352352 g_writeln("saving to %s", filename);
353 g_writeln("");
353 g_writeln("%s", "");
354354
355355 if (g_file_exist(filename))
356356 {
410410 d_len = n_len;
411411 sign_len = 64;
412412 error = 0;
413 g_writeln("");
413 g_writeln("%s", "");
414414 g_writeln("Generating %d bit rsa key...", g_key_size_bits);
415 g_writeln("");
415 g_writeln("%s", "");
416416
417417 if (error == 0)
418418 {
419419 error = ssl_gen_key_xrdp1(g_key_size_bits, e_data, e_len, n_data, n_len,
420420 d_data, d_len);
421
422421 if (error != 0)
423422 {
424423 g_writeln("error %d in key_gen, ssl_gen_key_xrdp1", error);
428427 if (error == 0)
429428 {
430429 g_writeln("ssl_gen_key_xrdp1 ok");
431 g_writeln("");
430 g_writeln("%s", "");
432431 error = sign_key(e_data, e_len, n_data, n_len, sign_data, sign_len);
433432
434433 if (error != 0)
588587 }
589588 else if (g_strcasecmp(argv[1], "test") == 0)
590589 {
591 g_writeln("");
590 g_writeln("%s", "");
592591 g_writeln("testing 512 bit key");
593592 key_test512();
594 g_writeln("");
593 g_writeln("%s", "");
595594 g_writeln("testing 2048 bit key");
596595 key_test2048();
597596 return 0;
0 *~
1 aclocal.m4
2 AUTHORS
3 autom4te.cache/
4 ChangeLog
5 config_ac.h
6 config_ac-h.in
7 config.c
8 config.guess
9 config.log
10 config.status
11 config.sub
12 configure
13 compile
14 depcomp
15 .deps/
16 install-sh
17 *.la
18 .libs
19 libtool
20 *.lo
21 ltmain.sh
22 Makefile
23 Makefile.in
24 missing
25 NEWS
26 *.o
27 README
28 stamp-h1
29 rfxcodectest
30 .dirstamp
+0
-12
librfxcodec/Makefile less more
0
1 all: allmake
2
3 allmake:
4 cd src; $(MAKE) $(MFLAGS)
5 cd tests; $(MAKE) $(MFLAGS)
6
7 clean: allclean
8
9 allclean:
10 cd src; $(MAKE) clean
11 cd tests; $(MAKE) clean
0 EXTRA_DIST = bootstrap readme.txt
1
2 SUBDIRS = \
3 src \
4 tests
5
0 # AC_PROG_NASM
1 # --------------------------
2 # Check that NASM exists and determine flags
3 AC_DEFUN([AC_PROG_NASM],[
4
5 AC_CHECK_PROGS(NASM, [nasm nasmw yasm])
6 test -z "$NASM" && AC_MSG_ERROR([no nasm (Netwide Assembler) found])
7
8 AC_MSG_CHECKING([for object file format of host system])
9 case "$host_os" in
10 cygwin* | mingw* | pw32* | interix*)
11 case "$host_cpu" in
12 x86_64)
13 objfmt='Win64-COFF'
14 ;;
15 *)
16 objfmt='Win32-COFF'
17 ;;
18 esac
19 ;;
20 msdosdjgpp* | go32*)
21 objfmt='COFF'
22 ;;
23 os2-emx*) # not tested
24 objfmt='MSOMF' # obj
25 ;;
26 linux*coff* | linux*oldld*)
27 objfmt='COFF' # ???
28 ;;
29 linux*aout*)
30 objfmt='a.out'
31 ;;
32 linux*)
33 case "$host_cpu" in
34 x86_64)
35 objfmt='ELF64'
36 ;;
37 *)
38 objfmt='ELF'
39 ;;
40 esac
41 ;;
42 freebsd* | netbsd* | openbsd*)
43 if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
44 objfmt='BSD-a.out'
45 else
46 case "$host_cpu" in
47 x86_64 | amd64)
48 objfmt='ELF64'
49 ;;
50 *)
51 objfmt='ELF'
52 ;;
53 esac
54 fi
55 ;;
56 solaris* | sunos* | sysv* | sco*)
57 case "$host_cpu" in
58 x86_64)
59 objfmt='ELF64'
60 ;;
61 *)
62 objfmt='ELF'
63 ;;
64 esac
65 ;;
66 darwin* | rhapsody* | nextstep* | openstep* | macos*)
67 case "$host_cpu" in
68 x86_64)
69 objfmt='Mach-O64'
70 ;;
71 *)
72 objfmt='Mach-O'
73 ;;
74 esac
75 ;;
76 *)
77 objfmt='ELF ?'
78 ;;
79 esac
80
81 AC_MSG_RESULT([$objfmt])
82 if test "$objfmt" = 'ELF ?'; then
83 objfmt='ELF'
84 AC_MSG_WARN([unexpected host system. assumed that the format is $objfmt.])
85 fi
86
87 AC_MSG_CHECKING([for object file format specifier (NAFLAGS) ])
88 case "$objfmt" in
89 MSOMF) NAFLAGS='-fobj -DOBJ32';;
90 Win32-COFF) NAFLAGS='-fwin32 -DWIN32';;
91 Win64-COFF) NAFLAGS='-fwin64 -DWIN64 -D__x86_64__';;
92 COFF) NAFLAGS='-fcoff -DCOFF';;
93 a.out) NAFLAGS='-faout -DAOUT';;
94 BSD-a.out) NAFLAGS='-faoutb -DAOUT';;
95 ELF) NAFLAGS='-felf -DELF';;
96 ELF64) NAFLAGS='-felf64 -DELF -D__x86_64__';;
97 RDF) NAFLAGS='-frdf -DRDF';;
98 Mach-O) NAFLAGS='-fmacho -DMACHO';;
99 Mach-O64) NAFLAGS='-fmacho64 -DMACHO -D__x86_64__';;
100 esac
101 AC_MSG_RESULT([$NAFLAGS])
102 AC_SUBST([NAFLAGS])
103
104 AC_MSG_CHECKING([whether the assembler ($NASM $NAFLAGS) works])
105 cat > conftest.asm <<EOF
106 [%line __oline__ "configure"
107 section .text
108 global _main,main
109 _main:
110 main: xor eax,eax
111 ret
112 ]EOF
113 try_nasm='$NASM $NAFLAGS -o conftest.o conftest.asm'
114 if AC_TRY_EVAL(try_nasm) && test -s conftest.o; then
115 AC_MSG_RESULT(yes)
116 else
117 echo "configure: failed program was:" >&AC_FD_CC
118 cat conftest.asm >&AC_FD_CC
119 rm -rf conftest*
120 AC_MSG_RESULT(no)
121 AC_MSG_ERROR([installation or configuration problem: assembler cannot create object files.])
122 fi
123
124 AC_MSG_CHECKING([whether the linker accepts assembler output])
125 try_nasm='${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.o $LIBS 1>&AC_FD_CC'
126 if AC_TRY_EVAL(try_nasm) && test -s conftest${ac_exeext}; then
127 rm -rf conftest*
128 AC_MSG_RESULT(yes)
129 else
130 rm -rf conftest*
131 AC_MSG_RESULT(no)
132 AC_MSG_ERROR([configuration problem: maybe object file format mismatch.])
133 fi
134
135 ])
136
0 #!/bin/sh
1
2 which autoconf
3 if ! test $? -eq 0
4 then
5 echo "error, install autoconf"
6 exit 1
7 fi
8
9 which automake
10 if ! test $? -eq 0
11 then
12 echo "error, install automake"
13 exit 1
14 fi
15
16 which libtool || which libtoolize
17 if ! test $? -eq 0
18 then
19 echo "error, install libtool"
20 exit 1
21 fi
22
23 which pkg-config
24 if ! test $? -eq 0
25 then
26 echo "error, install pkg-config"
27 exit 1
28 fi
29
30 touch configure.ac
31 touch NEWS
32 touch AUTHORS
33 touch README
34 touch ChangeLog
35 autoreconf -fvi
0 # Process this file with autoconf to produce a configure script
1
2 AC_PREREQ(2.59)
3 AC_INIT([rfxcodec], [0.1.0], [jay.sorg@gmail.com])
4 AC_CONFIG_HEADERS(config_ac.h:config_ac-h.in)
5 AM_INIT_AUTOMAKE([1.6 foreign])
6 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
7 AC_PROG_CC
8 AC_C_CONST
9 AC_PROG_LIBTOOL
10
11 AM_CONDITIONAL(GOT_PREFIX, test "x${prefix}" != "xNONE"])
12
13 if test "x${prefix}" = "xNONE" ; then
14 sysconfdir="/etc";
15 fi
16
17 # SIMD is optional
18 AC_ARG_WITH([simd],
19 AC_HELP_STRING([--without-simd],[Omit SIMD extensions.]))
20 if test "x${with_simd}" != "xno"; then
21 # Check if we're on a supported CPU
22 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
23 case "$host_cpu" in
24 x86_64 | amd64)
25 AC_MSG_RESULT([yes (x86_64)])
26 AC_PROG_NASM
27 simd_arch=x86_64
28 ;;
29 i*86 | x86 | ia32)
30 AC_MSG_RESULT([yes (i386)])
31 AC_PROG_NASM
32 simd_arch=i386
33 ;;
34 *)
35 AC_MSG_RESULT([no ("$host_cpu")])
36 AC_MSG_WARN([SIMD support not available for this CPU. Performance will suffer.])
37 with_simd=no;
38 ;;
39 esac
40 if test "x${with_simd}" != "xno"; then
41 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
42 fi
43 fi
44
45 AM_CONDITIONAL(WITH_SIMD_AMD64, [test x$simd_arch = xx86_64])
46 AM_CONDITIONAL(WITH_SIMD_X86, [test x$simd_arch = xi386])
47
48 AC_CONFIG_FILES([Makefile
49 src/Makefile
50 tests/Makefile
51 ])
52
53 AC_OUTPUT
54
0 /**
1 * RFX codec
2 *
3 * Copyright 2015 Jay Sorg <jay.sorg@gmail.com>
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 #ifndef __RFXCODEC_COMMON_H
19 #define __RFXCODEC_COMMON_H
20
21 #define RFX_FORMAT_BGRA 0
22 #define RFX_FORMAT_RGBA 1
23 #define RFX_FORMAT_BGR 2
24 #define RFX_FORMAT_RGB 3
25 #define RFX_FORMAT_YUV 4 /* YUV444 linear tiled mode */
26
27 #define RFX_FLAGS_NONE 0 /* default RFX_FLAGS_RLGR3 and RFX_FLAGS_SAFE */
28
29 #define RFX_FLAGS_SAFE 0 /* default */
30 #define RFX_FLAGS_OPT1 (1 << 3)
31 #define RFX_FLAGS_OPT2 (1 << 4)
32 #define RFX_FLAGS_NOACCEL (1 << 6)
33
34 #define RFX_FLAGS_RLGR3 0 /* default */
35 #define RFX_FLAGS_RLGR1 1
36
37 #define RFX_FLAGS_ALPHAV1 1 /* used in flags for rfxcodec_encode */
38
39 #endif
0 /**
1 * RFX codec decoder
2 *
3 * Copyright 2014-2015 Jay Sorg <jay.sorg@gmail.com>
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 #ifndef __RFXCODEC_DECODE_H
19 #define __RFXCODEC_DECODE_H
20
21 #include <rfxcodec_common.h>
22
23 int
24 rfxcodec_decode_create(int width, int height, int format, int flags,
25 void **handle);
26 int
27 rfxcodec_decode_destroy(void *handle);
28 int
29 rfxcodec_decode(void *handle, char *cdata, int cdata_bytes,
30 char *data, int width, int height, int stride_bytes);
31
32 #endif
00 /**
11 * RFX codec encoder
22 *
3 * Copyright 2014 Jay Sorg <jay.sorg@gmail.com>
3 * Copyright 2014-2015 Jay Sorg <jay.sorg@gmail.com>
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
1818 #ifndef __RFXCODEC_ENCODE_H
1919 #define __RFXCODEC_ENCODE_H
2020
21 #define RFX_FORMAT_BGRA 0
22 #define RFX_FORMAT_RGBA 1
23 #define RFX_FORMAT_BGR 2
24 #define RFX_FORMAT_RGB 3
25 #define RFX_FORMAT_YUV 4 /* YUV444 linear tiled mode */
26
27 #define RFX_FLAGS_NONE 0 /* default RFX_FLAGS_RLGR3 and RFX_FLAGS_SAFE */
28
29 #define RFX_FLAGS_RLGR3 0 /* default */
30 #define RFX_FLAGS_RLGR1 1
31
32 #define RFX_FLAGS_SAFE 0 /* default */
33 #define RFX_FLAGS_OPT1 (1 << 3)
34 #define RFX_FLAGS_OPT2 (1 << 4)
35 #define RFX_FLAGS_NOACCEL (1 << 6)
21 #include <rfxcodec_common.h>
3622
3723 struct rfx_rect
3824 {
4632 {
4733 int x; /* multiple of 64 */
4834 int y; /* multiple of 64 */
49 int cx; /* must be 64 */
50 int cy; /* must be 64 */
35 int cx; /* must be 64 or less */
36 int cy; /* must be 64 or less */
5137 int quant_y;
5238 int quant_cb;
5339 int quant_cr;
5642 void *
5743 rfxcodec_encode_create(int width, int height, int format, int flags);
5844 int
59 rfxcodec_encode_destroy(void * handle);
60 /* quants, 10 ints per set, should be num_quants * 10 ints in quants)
45 rfxcodec_encode_create_ex(int width, int height, int format, int flags,
46 void **handle);
47 int
48 rfxcodec_encode_destroy(void *handle);
49 /* quants, 5 ints per set, should be num_quants * 5 chars in quants)
50 * each char is 2 quant values
6151 * quantizer order is
6252 * 0 - LL3
6353 * 1 - LH3
7262 int
7363 rfxcodec_encode(void *handle, char *cdata, int *cdata_bytes,
7464 char *buf, int width, int height, int stride_bytes,
75 struct rfx_rect *region, int num_region,
76 struct rfx_tile *tiles, int num_tiles,
77 const int *quants, int num_quants);
65 const struct rfx_rect *region, int num_region,
66 const struct rfx_tile *tiles, int num_tiles,
67 const char *quants, int num_quants);
68 int
69 rfxcodec_encode_ex(void *handle, char *cdata, int *cdata_bytes,
70 char *buf, int width, int height, int stride_bytes,
71 const struct rfx_rect *region, int num_region,
72 const struct rfx_tile *tiles, int num_tiles,
73 const char *quants, int num_quants, int flags);
7874
7975 #endif
+0
-48
librfxcodec/src/Makefile less more
0
1 OBJS = rfxencode.o rfxcompose.o rfxencode_tile.o rfxencode_dwt.o \
2 rfxencode_quantization.o rfxencode_differential.o \
3 rfxencode_rlgr1.o rfxencode_rlgr3.o
4
5 #OBJS += cpuid_x86.o rfxrlgr1_x86.o rfxrlgr3_x86.o rfxdwt_x86_sse2.o
6 #OBJS += cpuid_amd64.o rfxrlgr1_amd64.o rfxrlgr3_amd64.o rfxdwt_amd64_sse2.o
7
8 CFLAGS = $(PROFIL) -g -O2 -Wall -fPIC -I../include
9 #-DRFX_USE_ACCEL_X86
10 #-DRFX_USE_ACCEL_AMD64
11
12 LDFLAGS =
13
14 LIBS =
15
16 all: librfxencode.so
17
18 librfxencode.so: $(OBJS) Makefile
19 $(CC) -shared -o librfxencode.so $(LDFLAGS) $(OBJS) $(LIBS)
20 $(AR) -rv librfxencode.a $(OBJS)
21
22 cpuid_x86.o: x86/cpuid_x86.asm
23 yasm -f elf32 -g dwarf2 x86/cpuid_x86.asm
24
25 rfxrlgr1_x86.o: x86/rfxrlgr1_x86.asm
26 yasm -f elf32 -g dwarf2 x86/rfxrlgr1_x86.asm
27
28 rfxrlgr3_x86.o: x86/rfxrlgr3_x86.asm
29 yasm -f elf32 -g dwarf2 x86/rfxrlgr3_x86.asm
30
31 rfxdwt_x86_sse2.o: x86/rfxdwt_x86_sse2.asm
32 yasm -f elf32 -g dwarf2 x86/rfxdwt_x86_sse2.asm
33
34 cpuid_amd64.o: amd64/cpuid_amd64.asm
35 yasm -f elf64 -g dwarf2 amd64/cpuid_amd64.asm
36
37 rfxrlgr1_amd64.o: amd64/rfxrlgr1_amd64.asm
38 yasm -f elf64 -g dwarf2 amd64/rfxrlgr1_amd64.asm
39
40 rfxrlgr3_amd64.o: amd64/rfxrlgr3_amd64.asm
41 yasm -f elf64 -g dwarf2 amd64/rfxrlgr3_amd64.asm
42
43 rfxdwt_amd64_sse2.o: amd64/rfxdwt_amd64_sse2.asm
44 yasm -f elf64 -g dwarf2 amd64/rfxdwt_amd64_sse2.asm
45
46 clean:
47 rm -f $(OBJS) librfxencode.so librfxencode.a
0 EXTRA_DIST =
1
2 EXTRA_DEFINES =
3 EXTRA_INCLUDES =
4 EXTRA_LIBS =
5 EXTRA_FLAGS =
6 EXTRA_SRC =
7 EXTRA_ENCODE_SRC =
8
9 if WITH_SIMD_AMD64
10 EXTRA_ENCODE_SRC += amd64/cpuid_amd64.asm \
11 amd64/rfxcodec_encode_diff_rlgr1_amd64_sse2.asm \
12 amd64/rfxcodec_encode_diff_rlgr3_amd64_sse2.asm \
13 amd64/rfxcodec_encode_dwt_shift_amd64_sse2.asm \
14 amd64/rfxcodec_encode_dwt_shift_amd64_sse41.asm
15 EXTRA_DEFINES += -DSIMD_USE_ACCEL=1 -DRFX_USE_ACCEL_AMD64=1
16 endif
17
18 if WITH_SIMD_X86
19 EXTRA_ENCODE_SRC += x86/cpuid_x86.asm \
20 x86/rfxcodec_encode_diff_rlgr1_x86_sse2.asm \
21 x86/rfxcodec_encode_diff_rlgr3_x86_sse2.asm \
22 x86/rfxcodec_encode_dwt_shift_x86_sse2.asm \
23 x86/rfxcodec_encode_dwt_shift_x86_sse41.asm
24 EXTRA_DEFINES += -DSIMD_USE_ACCEL=1 -DRFX_USE_ACCEL_X86=1
25 endif
26
27 if GOT_PREFIX
28 EXTRA_INCLUDES += -I$(prefix)/include
29 EXTRA_FLAGS += -L$(prefix)/lib -Wl,-rpath -Wl,$(prefix)/lib
30 endif
31
32 AM_CFLAGS = -I../include $(EXTRA_DEFINES)
33
34 INCLUDES = $(EXTRA_INCLUDES)
35
36 lib_LTLIBRARIES = librfxencode.la
37
38 librfxencode_la_LDFLAGS = $(EXTRA_FLAGS)
39
40
41 librfxencode_ladir = $(moduledir)
42
43 librfxencode_la_SOURCES = rfxencode.c \
44 rfxcompose.c rfxencode_tile.c rfxencode_dwt.c \
45 rfxencode_quantization.c rfxencode_differential.c \
46 rfxencode_rlgr1.c rfxencode_rlgr3.c rfxencode_alpha.c $(EXTRA_ENCODE_SRC)
47
48 .asm.lo:
49 $(LIBTOOL) --mode=compile --tag NASM $(srcdir)/nasm_lt.sh $(NASM) $(NAFLAGS) -I$(srcdir) -I. $< -o $@
50
51 librfxencode_la_LIBADD =
52
53 include_HEADERS = ../include/rfxcodec_encode.h
54
1212 ;int
1313 ;cpuid_amd64(int eax_in, int ecx_in, int *eax, int *ebx, int *ecx, int *edx)
1414
15 %ifidn __OUTPUT_FORMAT__,elf64
1516 PROC cpuid_amd64
17 %else
18 PROC _cpuid_amd64
19 %endif
1620 ; save registers
1721 push rbx
18
22
1923 push rdx
2024 push rcx
2125 push r8
3236 mov [rdi], ebx
3337 pop rdi
3438 mov [rdi], eax
35 mov eax, 0
39 mov rax, 0
3640 ; restore registers
3741 pop rbx
38 ret;
42 ret
3943 align 16
4044
00 /*
1 Copyright 2014 Jay Sorg
1 Copyright 2014-2015 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
2525
2626 int
2727 cpuid_amd64(int eax_in, int ecx_in, int *eax, int *ebx, int *ecx, int *edx);
28
2829 int
29 dwt_shift_amd64_sse2(const int *quantization_values, uint8 *data,
30 sint16 *dwt_buffer1, sint16 *dwt_buffer);
30 rfxcodec_encode_dwt_shift_amd64_sse2(const char *qtable,
31 unsigned char *data,
32 short *dwt_buffer1,
33 short *dwt_buffer);
3134 int
32 diff_rlgr1_amd64(sint16 *co, int num_co, uint8 *dst, int dst_bytes);
35 rfxcodec_encode_dwt_shift_amd64_sse41(const char *qtable,
36 unsigned char *data,
37 short *dwt_buffer1,
38 short *dwt_buffer);
3339 int
34 diff_rlgr3_amd64(sint16 *co, int num_co, uint8 *dst, int dst_bytes);
40 rfxcodec_encode_diff_rlgr1_amd64_sse2(short *co,
41 void *dst, int dst_bytes);
42 int
43 rfxcodec_encode_diff_rlgr3_amd64_sse2(short *co,
44 void *dst, int dst_bytes);
45
46 int
47 rfxcodec_decode_rlgr1_diff_amd64_sse2(void *data, int data_bytes,
48 short *out_data);
49 int
50 rfxcodec_decode_rlgr3_diff_amd64_sse2(void *data, int data_bytes,
51 short *out_data);
52 int
53 rfxcodec_decode_shift_idwt_amd64_sse2(char *qtable, short *src, short *dst);
54 int
55 rfxcodec_decode_yuv2rgb_amd64_sse2(short *ydata, short *udata, short *vdata,
56 unsigned int *rgbdata, int stride);
57 int
58 rfxcodec_decode_yuva2argb_amd64_sse2(short *ydata, short *udata,
59 short *vdata, char *adata,
60 unsigned int *rgbdata, int stride);
3561
3662 #endif
3763
0
1 section .data
2 const1 times 8 dw 1
3
4 section .text
5
6 %macro PROC 1
7 align 16
8 global %1
9 %1:
10 %endmacro
11
12 ;The first six integer or pointer arguments are passed in registers
13 ;RDI, RSI, RDX, RCX, R8, and R9
14
15 ;int
16 ;rfxcodec_encode_diff_rlgr1_amd64_sse2(short *co,
17 ; void *dst, int dst_bytes);
18
19 %ifidn __OUTPUT_FORMAT__,elf64
20 PROC rfxcodec_encode_diff_rlgr1_amd64_sse2
21 %else
22 PROC _rfxcodec_encode_diff_rlgr1_amd64_sse2
23 %endif
24 ; save registers
25 push rbx
26
27 mov rax, 0
28 ; restore registers
29 pop rbx
30 ret
31 align 16
32
0
1 section .data
2 const1 times 8 dw 1
3
4 %macro PROC 1
5 align 16
6 global %1
7 %1:
8 %endmacro
9
10 ;int
11 ;rfxcodec_encode_diff_rlgr3_amd64_sse2(short *co,
12 ; void *dst, int dst_bytes);
13
14 %ifidn __OUTPUT_FORMAT__,elf64
15 PROC rfxcodec_encode_diff_rlgr3_amd64_sse2
16 %else
17 PROC _rfxcodec_encode_diff_rlgr3_amd64_sse2
18 %endif
19 ; save registers
20 push rbx
21 mov rax, 0
22 pop rbx
23 ret
24 align 16
25
0 ;
1 ;Copyright 2016 Jay Sorg
2 ;
3 ;Permission to use, copy, modify, distribute, and sell this software and its
4 ;documentation for any purpose is hereby granted without fee, provided that
5 ;the above copyright notice appear in all copies and that both that
6 ;copyright notice and this permission notice appear in supporting
7 ;documentation.
8 ;
9 ;The above copyright notice and this permission notice shall be included in
10 ;all copies or substantial portions of the Software.
11 ;
12 ;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 ;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 ;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 ;OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
16 ;AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17 ;CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 ;
19 ;amd64 asm dwt
20
21 section .data
22 align 16
23 cw128 times 8 dw 128
24 cdFFFF times 4 dd 65535
25 ; these are 1 << (factor - 1) 0 to 15 is factor
26 cwa0 times 8 dw 0 ; 0
27 cwa1 times 8 dw 1 ; 1
28 cwa2 times 8 dw 2 ; 2
29 cwa4 times 8 dw 4 ; 3
30 cwa8 times 8 dw 8 ; 4
31 cwa16 times 8 dw 16 ; 5
32 cwa32 times 8 dw 32 ; 6
33 cwa64 times 8 dw 64 ; 7
34 cwa128 times 8 dw 128 ; 8
35 cwa256 times 8 dw 256 ; 9
36 cwa512 times 8 dw 512 ; 10
37 cwa1024 times 8 dw 1024 ; 11
38 cwa2048 times 8 dw 2048 ; 12
39 cwa4096 times 8 dw 4096 ; 13
40 cwa8192 times 8 dw 8192 ; 14
41 cwa16384 times 8 dw 16384 ; 15
42
43 section .text
44
45 %macro PROC 1
46 align 16
47 global %1
48 %1:
49 %endmacro
50
51 ;******************************************************************************
52 ; source 16 bit signed, 16 pixel width
53 rfx_dwt_2d_encode_block_horiz_16_16:
54 mov ecx, 8
55 loop1a:
56 ; pre / post
57 movdqa xmm1, [rsi] ; src[2n]
58 movdqa xmm2, [rsi + 16]
59 movdqa xmm6, xmm1
60 movdqa xmm7, xmm2
61 pand xmm1, [rel cdFFFF]
62 pand xmm2, [rel cdFFFF]
63 pslld xmm1, 16
64 pslld xmm2, 16
65 psrad xmm1, 16
66 psrad xmm2, 16
67 packssdw xmm1, xmm2
68 movdqa xmm2, xmm6 ; src[2n + 1]
69 movdqa xmm3, xmm7
70 psrldq xmm2, 2
71 psrldq xmm3, 2
72 pand xmm2, [rel cdFFFF]
73 pand xmm3, [rel cdFFFF]
74 pslld xmm2, 16
75 pslld xmm3, 16
76 psrad xmm2, 16
77 psrad xmm3, 16
78 packssdw xmm2, xmm3
79 movdqa xmm3, xmm6 ; src[2n + 2]
80 movdqa xmm4, xmm7
81 psrldq xmm3, 4
82 psrldq xmm4, 4
83 movd eax, xmm7
84 movd xmm5, eax
85 pslldq xmm5, 12
86 por xmm3, xmm5
87 movdqa xmm5, xmm7
88 psrldq xmm5, 12
89 pslldq xmm5, 12
90 por xmm4, xmm5
91 pand xmm3, [rel cdFFFF]
92 pand xmm4, [rel cdFFFF]
93 pslld xmm3, 16
94 pslld xmm4, 16
95 psrad xmm3, 16
96 psrad xmm4, 16
97 packssdw xmm3, xmm4
98 movdqa xmm4, xmm1
99 movdqa xmm5, xmm2
100 movdqa xmm6, xmm3
101 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
102 paddw xmm4, xmm6
103 psraw xmm4, 1
104 psubw xmm5, xmm4
105 psraw xmm5, 1
106 movdqa xmm6, xmm5 ; out hi
107 paddw xmm6, xmm8
108 psraw xmm6, xmm9
109 movdqa [rdi], xmm6
110 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
111 movdqa xmm7, xmm5
112 movd eax, xmm7
113 pslldq xmm7, 2
114 and eax, 0xFFFF
115 movd xmm6, eax
116 por xmm7, xmm6
117 paddw xmm5, xmm7
118 psraw xmm5, 1
119 paddw xmm5, xmm1
120
121 movdqa xmm6, xmm5 ; out lo
122 paddw xmm6, xmm10
123 psraw xmm6, xmm11
124 movdqa [rdx], xmm6
125
126 ; move right
127 lea rsi, [rsi + 16 * 2]
128 lea rdi, [rdi + 8 * 2]
129 lea rdx, [rdx + 8 * 2]
130
131 ; move left
132 lea rsi, [rsi - 16 * 2]
133 lea rdi, [rdi - 8 * 2]
134 lea rdx, [rdx - 8 * 2]
135
136 ; move down
137 lea rsi, [rsi + 16 * 2]
138 lea rdi, [rdi + 8 * 2]
139 lea rdx, [rdx + 8 * 2]
140
141 dec ecx
142 jnz loop1a
143
144 ret
145
146 ;******************************************************************************
147 ; source 16 bit signed, 16 pixel width
148 rfx_dwt_2d_encode_block_verti_16_16:
149 mov ecx, 2
150 loop1b:
151 ; pre
152 movdqa xmm1, [rsi] ; src[2n]
153 movdqa xmm2, [rsi + 16 * 2] ; src[2n + 1]
154 movdqa xmm3, [rsi + 16 * 2 * 2] ; src[2n + 2]
155 movdqa xmm4, xmm1
156 movdqa xmm5, xmm2
157 movdqa xmm6, xmm3
158 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
159 paddw xmm4, xmm6
160 psraw xmm4, 1
161 psubw xmm5, xmm4
162 psraw xmm5, 1
163 movdqa [rdi], xmm5 ; out hi
164 movdqa xmm6, xmm5 ; save hi
165 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
166 paddw xmm5, xmm1
167 movdqa [rdx], xmm5 ; out lo
168 movdqa xmm7, xmm6 ; save hi
169 ; move down
170 lea rsi, [rsi + 16 * 2 * 2] ; 2 rows
171 lea rdi, [rdi + 16 * 2] ; 1 row
172 lea rdx, [rdx + 16 * 2] ; 1 row
173
174 ; loop
175 shl ecx, 16
176 mov cx, 6
177 loop2b:
178 movdqa xmm1, xmm3 ; src[2n]
179 movdqa xmm2, [rsi + 16 * 2] ; src[2n + 1]
180 movdqa xmm3, [rsi + 16 * 2 * 2] ; src[2n + 2]
181 movdqa xmm4, xmm1
182 movdqa xmm5, xmm2
183 movdqa xmm6, xmm3
184 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
185 paddw xmm4, xmm6
186 psraw xmm4, 1
187 psubw xmm5, xmm4
188 psraw xmm5, 1
189 movdqa [rdi], xmm5 ; out hi
190 movdqa xmm6, xmm5 ; save hi
191 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
192 paddw xmm5, xmm7
193 psraw xmm5, 1
194 paddw xmm5, xmm1
195 movdqa [rdx], xmm5 ; out lo
196 movdqa xmm7, xmm6 ; save hi
197 ; move down
198 lea rsi, [rsi + 16 * 2 * 2] ; 2 rows
199 lea rdi, [rdi + 16 * 2] ; 1 row
200 lea rdx, [rdx + 16 * 2] ; 1 row
201
202 dec cx
203 jnz loop2b
204 shr ecx, 16
205
206 ; post
207 movdqa xmm1, xmm3 ; src[2n]
208 movdqa xmm2, [rsi + 16 * 2] ; src[2n + 1]
209 movdqa xmm4, xmm1
210 movdqa xmm5, xmm2
211 movdqa xmm6, xmm3
212 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
213 paddw xmm4, xmm6
214 psraw xmm4, 1
215 psubw xmm5, xmm4
216 psraw xmm5, 1
217 movdqa [rdi], xmm5 ; out hi
218 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
219 paddw xmm5, xmm7
220 psraw xmm5, 1
221 paddw xmm5, xmm1
222 movdqa [rdx], xmm5 ; out lo
223 ; move down
224 lea rsi, [rsi + 16 * 2 * 2] ; 2 row
225 lea rdi, [rdi + 16 * 2] ; 1 row
226 lea rdx, [rdx + 16 * 2] ; 1 row
227
228 ; move up
229 lea rsi, [rsi - 16 * 16 * 2]
230 lea rdi, [rdi - 8 * 16 * 2]
231 lea rdx, [rdx - 8 * 16 * 2]
232
233 ; move right
234 lea rsi, [rsi + 16]
235 lea rdi, [rdi + 16]
236 lea rdx, [rdx + 16]
237
238 dec ecx
239 jnz loop1b
240
241 ret
242
243 ;******************************************************************************
244 ; source 16 bit signed, 32 pixel width
245 rfx_dwt_2d_encode_block_horiz_16_32:
246 mov ecx, 16
247 loop1c:
248 ; pre
249 movdqa xmm1, [rsi] ; src[2n]
250 movdqa xmm2, [rsi + 16]
251 movdqa xmm6, xmm1
252 movdqa xmm7, xmm2
253 pand xmm1, [rel cdFFFF]
254 pand xmm2, [rel cdFFFF]
255 pslld xmm1, 16
256 pslld xmm2, 16
257 psrad xmm1, 16
258 psrad xmm2, 16
259 packssdw xmm1, xmm2
260 movdqa xmm2, xmm6 ; src[2n + 1]
261 movdqa xmm3, xmm7
262 psrldq xmm2, 2
263 psrldq xmm3, 2
264 pand xmm2, [rel cdFFFF]
265 pand xmm3, [rel cdFFFF]
266 pslld xmm2, 16
267 pslld xmm3, 16
268 psrad xmm2, 16
269 psrad xmm3, 16
270 packssdw xmm2, xmm3
271 movdqa xmm3, xmm6 ; src[2n + 2]
272 movdqa xmm4, xmm7
273 psrldq xmm3, 4
274 psrldq xmm4, 4
275 movd eax, xmm7
276 movd xmm5, eax
277 pslldq xmm5, 12
278 por xmm3, xmm5
279 mov eax, [rsi + 32]
280 movd xmm5, eax
281 pslldq xmm5, 12
282 por xmm4, xmm5
283 pand xmm3, [rel cdFFFF]
284 pand xmm4, [rel cdFFFF]
285 pslld xmm3, 16
286 pslld xmm4, 16
287 psrad xmm3, 16
288 psrad xmm4, 16
289 packssdw xmm3, xmm4
290 movdqa xmm4, xmm1
291 movdqa xmm5, xmm2
292 movdqa xmm6, xmm3
293 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
294 paddw xmm4, xmm6
295 psraw xmm4, 1
296 psubw xmm5, xmm4
297 psraw xmm5, 1
298
299 movdqa xmm6, xmm5 ; out hi
300 paddw xmm6, xmm8
301 psraw xmm6, xmm9
302 movdqa [rdi], xmm6
303 movdqa xmm2, xmm5 ; save hi
304
305 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
306 movdqa xmm7, xmm5
307 movd eax, xmm7
308 pslldq xmm7, 2
309 and eax, 0xFFFF
310 movd xmm6, eax
311 por xmm7, xmm6
312 paddw xmm5, xmm7
313 psraw xmm5, 1
314 paddw xmm5, xmm1
315
316 psrldq xmm2, 14
317 movd ebx, xmm2 ; save hi
318
319 movdqa xmm6, xmm5 ; out lo
320 paddw xmm6, xmm10
321 psraw xmm6, xmm11
322 movdqa [rdx], xmm6
323
324 ; move right
325 lea rsi, [rsi + 16 * 2]
326 lea rdi, [rdi + 8 * 2]
327 lea rdx, [rdx + 8 * 2]
328
329 ; post
330 movdqa xmm1, [rsi] ; src[2n]
331 movdqa xmm2, [rsi + 16]
332 movdqa xmm6, xmm1
333 movdqa xmm7, xmm2
334 pand xmm1, [rel cdFFFF]
335 pand xmm2, [rel cdFFFF]
336 pslld xmm1, 16
337 pslld xmm2, 16
338 psrad xmm1, 16
339 psrad xmm2, 16
340 packssdw xmm1, xmm2
341 movdqa xmm2, xmm6 ; src[2n + 1]
342 movdqa xmm3, xmm7
343 psrldq xmm2, 2
344 psrldq xmm3, 2
345 pand xmm2, [rel cdFFFF]
346 pand xmm3, [rel cdFFFF]
347 pslld xmm2, 16
348 pslld xmm3, 16
349 psrad xmm2, 16
350 psrad xmm3, 16
351 packssdw xmm2, xmm3
352 movdqa xmm3, xmm6 ; src[2n + 2]
353 movdqa xmm4, xmm7
354 psrldq xmm3, 4
355 psrldq xmm4, 4
356 movd eax, xmm7
357 movd xmm5, eax
358 pslldq xmm5, 12
359 por xmm3, xmm5
360 movdqa xmm5, xmm7
361 psrldq xmm5, 12
362 pslldq xmm5, 12
363 por xmm4, xmm5
364 pand xmm3, [rel cdFFFF]
365 pand xmm4, [rel cdFFFF]
366 pslld xmm3, 16
367 pslld xmm4, 16
368 psrad xmm3, 16
369 psrad xmm4, 16
370 packssdw xmm3, xmm4
371 movdqa xmm4, xmm1
372 movdqa xmm5, xmm2
373 movdqa xmm6, xmm3
374 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
375 paddw xmm4, xmm6
376 psraw xmm4, 1
377 psubw xmm5, xmm4
378 psraw xmm5, 1
379
380 movdqa xmm6, xmm5 ; out hi
381 paddw xmm6, xmm8
382 psraw xmm6, xmm9
383 movdqa [rdi], xmm6
384
385 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
386 movdqa xmm7, xmm5
387 pslldq xmm7, 2
388 movd xmm6, ebx
389 por xmm7, xmm6
390 paddw xmm5, xmm7
391 psraw xmm5, 1
392 paddw xmm5, xmm1
393
394 movdqa xmm6, xmm5 ; out lo
395 paddw xmm6, xmm10
396 psraw xmm6, xmm11
397 movdqa [rdx], xmm6
398
399 ; move right
400 lea rsi, [rsi + 16 * 2]
401 lea rdi, [rdi + 8 * 2]
402 lea rdx, [rdx + 8 * 2]
403
404 ; move left
405 lea rsi, [rsi - 32 * 2]
406 lea rdi, [rdi - 16 * 2]
407 lea rdx, [rdx - 16 * 2]
408
409 ; move down
410 lea rsi, [rsi + 32 * 2]
411 lea rdi, [rdi + 16 * 2]
412 lea rdx, [rdx + 16 * 2]
413
414 dec ecx
415 jnz loop1c
416
417 ret
418
419 ;******************************************************************************
420 ; source 16 bit signed, 32 pixel width
421 rfx_dwt_2d_encode_block_horiz_16_32_no_lo:
422 mov ecx, 16
423 loop1c1:
424 ; pre
425 movdqa xmm1, [rsi] ; src[2n]
426 movdqa xmm2, [rsi + 16]
427 movdqa xmm6, xmm1
428 movdqa xmm7, xmm2
429 pand xmm1, [rel cdFFFF]
430 pand xmm2, [rel cdFFFF]
431 pslld xmm1, 16
432 pslld xmm2, 16
433 psrad xmm1, 16
434 psrad xmm2, 16
435 packssdw xmm1, xmm2
436 movdqa xmm2, xmm6 ; src[2n + 1]
437 movdqa xmm3, xmm7
438 psrldq xmm2, 2
439 psrldq xmm3, 2
440 pand xmm2, [rel cdFFFF]
441 pand xmm3, [rel cdFFFF]
442 pslld xmm2, 16
443 pslld xmm3, 16
444 psrad xmm2, 16
445 psrad xmm3, 16
446 packssdw xmm2, xmm3
447 movdqa xmm3, xmm6 ; src[2n + 2]
448 movdqa xmm4, xmm7
449 psrldq xmm3, 4
450 psrldq xmm4, 4
451 movd eax, xmm7
452 movd xmm5, eax
453 pslldq xmm5, 12
454 por xmm3, xmm5
455 mov eax, [rsi + 32]
456 movd xmm5, eax
457 pslldq xmm5, 12
458 por xmm4, xmm5
459 pand xmm3, [rel cdFFFF]
460 pand xmm4, [rel cdFFFF]
461 pslld xmm3, 16
462 pslld xmm4, 16
463 psrad xmm3, 16
464 psrad xmm4, 16
465 packssdw xmm3, xmm4
466 movdqa xmm4, xmm1
467 movdqa xmm5, xmm2
468 movdqa xmm6, xmm3
469 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
470 paddw xmm4, xmm6
471 psraw xmm4, 1
472 psubw xmm5, xmm4
473 psraw xmm5, 1
474
475 movdqa xmm6, xmm5 ; out hi
476 paddw xmm6, xmm8
477 psraw xmm6, xmm9
478 movdqa [rdi], xmm6
479 movdqa xmm2, xmm5 ; save hi
480
481 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
482 movdqa xmm7, xmm5
483 movd eax, xmm7
484 pslldq xmm7, 2
485 and eax, 0xFFFF
486 movd xmm6, eax
487 por xmm7, xmm6
488 paddw xmm5, xmm7
489 psraw xmm5, 1
490 paddw xmm5, xmm1
491
492 psrldq xmm2, 14
493 movd ebx, xmm2 ; save hi
494
495 movdqa [rdx], xmm5 ; out lo
496
497 ; move right
498 lea rsi, [rsi + 16 * 2]
499 lea rdi, [rdi + 8 * 2]
500 lea rdx, [rdx + 8 * 2]
501
502 ; post
503 movdqa xmm1, [rsi] ; src[2n]
504 movdqa xmm2, [rsi + 16]
505 movdqa xmm6, xmm1
506 movdqa xmm7, xmm2
507 pand xmm1, [rel cdFFFF]
508 pand xmm2, [rel cdFFFF]
509 pslld xmm1, 16
510 pslld xmm2, 16
511 psrad xmm1, 16
512 psrad xmm2, 16
513 packssdw xmm1, xmm2
514 movdqa xmm2, xmm6 ; src[2n + 1]
515 movdqa xmm3, xmm7
516 psrldq xmm2, 2
517 psrldq xmm3, 2
518 pand xmm2, [rel cdFFFF]
519 pand xmm3, [rel cdFFFF]
520 pslld xmm2, 16
521 pslld xmm3, 16
522 psrad xmm2, 16
523 psrad xmm3, 16
524 packssdw xmm2, xmm3
525 movdqa xmm3, xmm6 ; src[2n + 2]
526 movdqa xmm4, xmm7
527 psrldq xmm3, 4
528 psrldq xmm4, 4
529 movd eax, xmm7
530 movd xmm5, eax
531 pslldq xmm5, 12
532 por xmm3, xmm5
533 movdqa xmm5, xmm7
534 psrldq xmm5, 12
535 pslldq xmm5, 12
536 por xmm4, xmm5
537 pand xmm3, [rel cdFFFF]
538 pand xmm4, [rel cdFFFF]
539 pslld xmm3, 16
540 pslld xmm4, 16
541 psrad xmm3, 16
542 psrad xmm4, 16
543 packssdw xmm3, xmm4
544 movdqa xmm4, xmm1
545 movdqa xmm5, xmm2
546 movdqa xmm6, xmm3
547 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
548 paddw xmm4, xmm6
549 psraw xmm4, 1
550 psubw xmm5, xmm4
551 psraw xmm5, 1
552
553 movdqa xmm6, xmm5 ; out hi
554 paddw xmm6, xmm8
555 psraw xmm6, xmm9
556 movdqa [rdi], xmm6
557
558 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
559 movdqa xmm7, xmm5
560 pslldq xmm7, 2
561 movd xmm6, ebx
562 por xmm7, xmm6
563 paddw xmm5, xmm7
564 psraw xmm5, 1
565 paddw xmm5, xmm1
566
567 movdqa [rdx], xmm5 ; out lo
568
569 ; move right
570 lea rsi, [rsi + 16 * 2]
571 lea rdi, [rdi + 8 * 2]
572 lea rdx, [rdx + 8 * 2]
573
574 ; move left
575 lea rsi, [rsi - 32 * 2]
576 lea rdi, [rdi - 16 * 2]
577 lea rdx, [rdx - 16 * 2]
578
579 ; move down
580 lea rsi, [rsi + 32 * 2]
581 lea rdi, [rdi + 16 * 2]
582 lea rdx, [rdx + 16 * 2]
583
584 dec ecx
585 jnz loop1c1
586
587 ret
588
589 ;******************************************************************************
590 ; source 16 bit signed, 32 pixel width
591 rfx_dwt_2d_encode_block_verti_16_32:
592 mov ecx, 4
593 loop1d:
594 ; pre
595 movdqa xmm1, [rsi] ; src[2n]
596 movdqa xmm2, [rsi + 32 * 2] ; src[2n + 1]
597 movdqa xmm3, [rsi + 32 * 2 * 2] ; src[2n + 2]
598 movdqa xmm4, xmm1
599 movdqa xmm5, xmm2
600 movdqa xmm6, xmm3
601 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
602 paddw xmm4, xmm6
603 psraw xmm4, 1
604 psubw xmm5, xmm4
605 psraw xmm5, 1
606 movdqa [rdi], xmm5 ; out hi
607 movdqa xmm6, xmm5 ; save hi
608 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
609 paddw xmm5, xmm1
610 movdqa [rdx], xmm5 ; out lo
611 movdqa xmm7, xmm6 ; save hi
612 ; move down
613 lea rsi, [rsi + 32 * 2 * 2] ; 2 rows
614 lea rdi, [rdi + 32 * 2] ; 1 row
615 lea rdx, [rdx + 32 * 2] ; 1 row
616
617 ; loop
618 shl ecx, 16
619 mov cx, 14
620 loop2d:
621 movdqa xmm1, xmm3 ; src[2n]
622 movdqa xmm2, [rsi + 32 * 2] ; src[2n + 1]
623 movdqa xmm3, [rsi + 32 * 2 * 2] ; src[2n + 2]
624 movdqa xmm4, xmm1
625 movdqa xmm5, xmm2
626 movdqa xmm6, xmm3
627 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
628 paddw xmm4, xmm6
629 psraw xmm4, 1
630 psubw xmm5, xmm4
631 psraw xmm5, 1
632 movdqa [rdi], xmm5 ; out hi
633 movdqa xmm6, xmm5 ; save hi
634 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
635 paddw xmm5, xmm7
636 psraw xmm5, 1
637 paddw xmm5, xmm1
638 movdqa [rdx], xmm5 ; out lo
639 movdqa xmm7, xmm6 ; save hi
640 ; move down
641 lea rsi, [rsi + 32 * 2 * 2] ; 2 rows
642 lea rdi, [rdi + 32 * 2] ; 1 row
643 lea rdx, [rdx + 32 * 2] ; 1 row
644
645 dec cx
646 jnz loop2d
647 shr ecx, 16
648
649 ; post
650 movdqa xmm1, xmm3 ; src[2n]
651 movdqa xmm2, [rsi + 32 * 2] ; src[2n + 1]
652 movdqa xmm4, xmm1
653 movdqa xmm5, xmm2
654 movdqa xmm6, xmm3
655 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
656 paddw xmm4, xmm6
657 psraw xmm4, 1
658 psubw xmm5, xmm4
659 psraw xmm5, 1
660 movdqa [rdi], xmm5 ; out hi
661 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
662 paddw xmm5, xmm7
663 psraw xmm5, 1
664 paddw xmm5, xmm1
665 movdqa [rdx], xmm5 ; out lo
666 ; move down
667 lea rsi, [rsi + 32 * 2 * 2] ; 2 row
668 lea rdi, [rdi + 32 * 2] ; 1 row
669 lea rdx, [rdx + 32 * 2] ; 1 row
670
671 ; move up
672 lea rsi, [rsi - 32 * 32 * 2]
673 lea rdi, [rdi - 16 * 32 * 2]
674 lea rdx, [rdx - 16 * 32 * 2]
675
676 ; move right
677 lea rsi, [rsi + 16]
678 lea rdi, [rdi + 16]
679 lea rdx, [rdx + 16]
680
681 dec ecx
682 jnz loop1d
683
684 ret
685
686 ;******************************************************************************
687 ; source 16 bit signed, 64 pixel width
688 rfx_dwt_2d_encode_block_horiz_16_64:
689 mov ecx, 32
690 loop1e:
691 ; pre
692 movdqa xmm1, [rsi] ; src[2n]
693 movdqa xmm2, [rsi + 16]
694 movdqa xmm6, xmm1
695 movdqa xmm7, xmm2
696 pand xmm1, [rel cdFFFF]
697 pand xmm2, [rel cdFFFF]
698 pslld xmm1, 16
699 pslld xmm2, 16
700 psrad xmm1, 16
701 psrad xmm2, 16
702 packssdw xmm1, xmm2
703 movdqa xmm2, xmm6 ; src[2n + 1]
704 movdqa xmm3, xmm7
705 psrldq xmm2, 2
706 psrldq xmm3, 2
707 pand xmm2, [rel cdFFFF]
708 pand xmm3, [rel cdFFFF]
709 pslld xmm2, 16
710 pslld xmm3, 16
711 psrad xmm2, 16
712 psrad xmm3, 16
713 packssdw xmm2, xmm3
714 movdqa xmm3, xmm6 ; src[2n + 2]
715 movdqa xmm4, xmm7
716 psrldq xmm3, 4
717 psrldq xmm4, 4
718 movd eax, xmm7
719 movd xmm5, eax
720 pslldq xmm5, 12
721 por xmm3, xmm5
722 mov eax, [rsi + 32]
723 movd xmm5, eax
724 pslldq xmm5, 12
725 por xmm4, xmm5
726 pand xmm3, [rel cdFFFF]
727 pand xmm4, [rel cdFFFF]
728 pslld xmm3, 16
729 pslld xmm4, 16
730 psrad xmm3, 16
731 psrad xmm4, 16
732 packssdw xmm3, xmm4
733 movdqa xmm4, xmm1
734 movdqa xmm5, xmm2
735 movdqa xmm6, xmm3
736 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
737 paddw xmm4, xmm6
738 psraw xmm4, 1
739 psubw xmm5, xmm4
740 psraw xmm5, 1
741
742 movdqa xmm6, xmm5 ; out hi
743 paddw xmm6, xmm8
744 psraw xmm6, xmm9
745 movdqa [rdi], xmm6
746 movdqa xmm2, xmm5 ; save hi
747
748 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
749 movdqa xmm7, xmm5
750 movd eax, xmm7
751 pslldq xmm7, 2
752 and eax, 0xFFFF
753 movd xmm6, eax
754 por xmm7, xmm6
755 paddw xmm5, xmm7
756 psraw xmm5, 1
757 paddw xmm5, xmm1
758
759 psrldq xmm2, 14
760 movd ebx, xmm2 ; save hi
761
762 movdqa xmm6, xmm5 ; out lo
763 paddw xmm6, xmm10
764 psraw xmm6, xmm11
765 movdqa [rdx], xmm6
766
767 ; move right
768 lea rsi, [rsi + 16 * 2]
769 lea rdi, [rdi + 8 * 2]
770 lea rdx, [rdx + 8 * 2]
771
772 ; loop
773 shl ecx, 16
774 mov cx, 2
775 loop2e:
776 movdqa xmm1, [rsi] ; src[2n]
777 movdqa xmm2, [rsi + 16]
778 movdqa xmm6, xmm1
779 movdqa xmm7, xmm2
780 pand xmm1, [rel cdFFFF]
781 pand xmm2, [rel cdFFFF]
782 pslld xmm1, 16
783 pslld xmm2, 16
784 psrad xmm1, 16
785 psrad xmm2, 16
786 packssdw xmm1, xmm2
787 movdqa xmm2, xmm6 ; src[2n + 1]
788 movdqa xmm3, xmm7
789 psrldq xmm2, 2
790 psrldq xmm3, 2
791 pand xmm2, [rel cdFFFF]
792 pand xmm3, [rel cdFFFF]
793 pslld xmm2, 16
794 pslld xmm3, 16
795 psrad xmm2, 16
796 psrad xmm3, 16
797 packssdw xmm2, xmm3
798 movdqa xmm3, xmm6 ; src[2n + 2]
799 movdqa xmm4, xmm7
800 psrldq xmm3, 4
801 psrldq xmm4, 4
802 movd eax, xmm7
803 movd xmm5, eax
804 pslldq xmm5, 12
805 por xmm3, xmm5
806 mov eax, [rsi + 32]
807 movd xmm5, eax
808 pslldq xmm5, 12
809 por xmm4, xmm5
810 pand xmm3, [rel cdFFFF]
811 pand xmm4, [rel cdFFFF]
812 pslld xmm3, 16
813 pslld xmm4, 16
814 psrad xmm3, 16
815 psrad xmm4, 16
816 packssdw xmm3, xmm4
817 movdqa xmm4, xmm1
818 movdqa xmm5, xmm2
819 movdqa xmm6, xmm3
820 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
821 paddw xmm4, xmm6
822 psraw xmm4, 1
823 psubw xmm5, xmm4
824 psraw xmm5, 1
825
826 movdqa xmm6, xmm5 ; out hi
827 paddw xmm6, xmm8
828 psraw xmm6, xmm9
829 movdqa [rdi], xmm6
830 movdqa xmm2, xmm5 ; save hi
831
832 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
833 movdqa xmm7, xmm5
834 pslldq xmm7, 2
835 movd xmm6, ebx
836 por xmm7, xmm6
837 paddw xmm5, xmm7
838 psraw xmm5, 1
839 paddw xmm5, xmm1
840
841 psrldq xmm2, 14
842 movd ebx, xmm2 ; save hi
843
844 movdqa xmm6, xmm5 ; out lo
845 paddw xmm6, xmm10
846 psraw xmm6, xmm11
847 movdqa [rdx], xmm6
848
849 ; move right
850 lea rsi, [rsi + 16 * 2]
851 lea rdi, [rdi + 8 * 2]
852 lea rdx, [rdx + 8 * 2]
853
854 dec cx
855 jnz loop2e
856 shr ecx, 16
857
858 ; post
859 movdqa xmm1, [rsi] ; src[2n]
860 movdqa xmm2, [rsi + 16]
861 movdqa xmm6, xmm1
862 movdqa xmm7, xmm2
863 pand xmm1, [rel cdFFFF]
864 pand xmm2, [rel cdFFFF]
865 pslld xmm1, 16
866 pslld xmm2, 16
867 psrad xmm1, 16
868 psrad xmm2, 16
869 packssdw xmm1, xmm2
870 movdqa xmm2, xmm6 ; src[2n + 1]
871 movdqa xmm3, xmm7
872 psrldq xmm2, 2
873 psrldq xmm3, 2
874 pand xmm2, [rel cdFFFF]
875 pand xmm3, [rel cdFFFF]
876 pslld xmm2, 16
877 pslld xmm3, 16
878 psrad xmm2, 16
879 psrad xmm3, 16
880 packssdw xmm2, xmm3
881 movdqa xmm3, xmm6 ; src[2n + 2]
882 movdqa xmm4, xmm7
883 psrldq xmm3, 4
884 psrldq xmm4, 4
885 movd eax, xmm7
886 movd xmm5, eax
887 pslldq xmm5, 12
888 por xmm3, xmm5
889 movdqa xmm5, xmm7
890 psrldq xmm5, 12
891 pslldq xmm5, 12
892 por xmm4, xmm5
893 pand xmm3, [rel cdFFFF]
894 pand xmm4, [rel cdFFFF]
895 pslld xmm3, 16
896 pslld xmm4, 16
897 psrad xmm3, 16
898 psrad xmm4, 16
899 packssdw xmm3, xmm4
900 movdqa xmm4, xmm1
901 movdqa xmm5, xmm2
902 movdqa xmm6, xmm3
903 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
904 paddw xmm4, xmm6
905 psraw xmm4, 1
906 psubw xmm5, xmm4
907 psraw xmm5, 1
908
909 movdqa xmm6, xmm5 ; out hi
910 paddw xmm6, xmm8
911 psraw xmm6, xmm9
912 movdqa [rdi], xmm6
913
914 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
915 movdqa xmm7, xmm5
916 pslldq xmm7, 2
917 movd xmm6, ebx
918 por xmm7, xmm6
919 paddw xmm5, xmm7
920 psraw xmm5, 1
921 paddw xmm5, xmm1
922
923 movdqa xmm6, xmm5 ; out lo
924 paddw xmm6, xmm10
925 psraw xmm6, xmm11
926 movdqa [rdx], xmm6
927
928 ; move right
929 lea rsi, [rsi + 16 * 2]
930 lea rdi, [rdi + 8 * 2]
931 lea rdx, [rdx + 8 * 2]
932
933 ; move left
934 lea rsi, [rsi - 64 * 2]
935 lea rdi, [rdi - 32 * 2]
936 lea rdx, [rdx - 32 * 2]
937
938 ; move down
939 lea rsi, [rsi + 64 * 2]
940 lea rdi, [rdi + 32 * 2]
941 lea rdx, [rdx + 32 * 2]
942
943 dec ecx
944 jnz loop1e
945
946 ret
947
948 ;******************************************************************************
949 ; source 16 bit signed, 64 pixel width
950 rfx_dwt_2d_encode_block_horiz_16_64_no_lo:
951 mov ecx, 32
952 loop1e1:
953 ; pre
954 movdqa xmm1, [rsi] ; src[2n]
955 movdqa xmm2, [rsi + 16]
956 movdqa xmm6, xmm1
957 movdqa xmm7, xmm2
958 pand xmm1, [rel cdFFFF]
959 pand xmm2, [rel cdFFFF]
960 pslld xmm1, 16
961 pslld xmm2, 16
962 psrad xmm1, 16
963 psrad xmm2, 16
964 packssdw xmm1, xmm2
965 movdqa xmm2, xmm6 ; src[2n + 1]
966 movdqa xmm3, xmm7
967 psrldq xmm2, 2
968 psrldq xmm3, 2
969 pand xmm2, [rel cdFFFF]
970 pand xmm3, [rel cdFFFF]
971 pslld xmm2, 16
972 pslld xmm3, 16
973 psrad xmm2, 16
974 psrad xmm3, 16
975 packssdw xmm2, xmm3
976 movdqa xmm3, xmm6 ; src[2n + 2]
977 movdqa xmm4, xmm7
978 psrldq xmm3, 4
979 psrldq xmm4, 4
980 movd eax, xmm7
981 movd xmm5, eax
982 pslldq xmm5, 12
983 por xmm3, xmm5
984 mov eax, [rsi + 32]
985 movd xmm5, eax
986 pslldq xmm5, 12
987 por xmm4, xmm5
988 pand xmm3, [rel cdFFFF]
989 pand xmm4, [rel cdFFFF]
990 pslld xmm3, 16
991 pslld xmm4, 16
992 psrad xmm3, 16
993 psrad xmm4, 16
994 packssdw xmm3, xmm4
995 movdqa xmm4, xmm1
996 movdqa xmm5, xmm2
997 movdqa xmm6, xmm3
998 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
999 paddw xmm4, xmm6
1000 psraw xmm4, 1
1001 psubw xmm5, xmm4
1002 psraw xmm5, 1
1003
1004 movdqa xmm6, xmm5 ; out hi
1005 paddw xmm6, xmm8
1006 psraw xmm6, xmm9
1007 movdqa [rdi], xmm6
1008 movdqa xmm2, xmm5 ; save hi
1009
1010 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1011 movdqa xmm7, xmm5
1012 movd eax, xmm7
1013 pslldq xmm7, 2
1014 and eax, 0xFFFF
1015 movd xmm6, eax
1016 por xmm7, xmm6
1017 paddw xmm5, xmm7
1018 psraw xmm5, 1
1019 paddw xmm5, xmm1
1020
1021 psrldq xmm2, 14
1022 movd ebx, xmm2 ; save hi
1023
1024 movdqa [rdx], xmm5 ; out lo
1025
1026 ; move right
1027 lea rsi, [rsi + 16 * 2]
1028 lea rdi, [rdi + 8 * 2]
1029 lea rdx, [rdx + 8 * 2]
1030
1031 ; loop
1032 shl ecx, 16
1033 mov cx, 2
1034 loop2e1:
1035 movdqa xmm1, [rsi] ; src[2n]
1036 movdqa xmm2, [rsi + 16]
1037 movdqa xmm6, xmm1
1038 movdqa xmm7, xmm2
1039 pand xmm1, [rel cdFFFF]
1040 pand xmm2, [rel cdFFFF]
1041 pslld xmm1, 16
1042 pslld xmm2, 16
1043 psrad xmm1, 16
1044 psrad xmm2, 16
1045 packssdw xmm1, xmm2
1046 movdqa xmm2, xmm6 ; src[2n + 1]
1047 movdqa xmm3, xmm7
1048 psrldq xmm2, 2
1049 psrldq xmm3, 2
1050 pand xmm2, [rel cdFFFF]
1051 pand xmm3, [rel cdFFFF]
1052 pslld xmm2, 16
1053 pslld xmm3, 16
1054 psrad xmm2, 16
1055 psrad xmm3, 16
1056 packssdw xmm2, xmm3
1057 movdqa xmm3, xmm6 ; src[2n + 2]
1058 movdqa xmm4, xmm7
1059 psrldq xmm3, 4
1060 psrldq xmm4, 4
1061 movd eax, xmm7
1062 movd xmm5, eax
1063 pslldq xmm5, 12
1064 por xmm3, xmm5
1065 mov eax, [rsi + 32]
1066 movd xmm5, eax
1067 pslldq xmm5, 12
1068 por xmm4, xmm5
1069 pand xmm3, [rel cdFFFF]
1070 pand xmm4, [rel cdFFFF]
1071 pslld xmm3, 16
1072 pslld xmm4, 16
1073 psrad xmm3, 16
1074 psrad xmm4, 16
1075 packssdw xmm3, xmm4
1076 movdqa xmm4, xmm1
1077 movdqa xmm5, xmm2
1078 movdqa xmm6, xmm3
1079 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1080 paddw xmm4, xmm6
1081 psraw xmm4, 1
1082 psubw xmm5, xmm4
1083 psraw xmm5, 1
1084
1085 movdqa xmm6, xmm5 ; out hi
1086 paddw xmm6, xmm8
1087 psraw xmm6, xmm9
1088 movdqa [rdi], xmm6
1089 movdqa xmm2, xmm5 ; save hi
1090
1091 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1092 movdqa xmm7, xmm5
1093 pslldq xmm7, 2
1094 movd xmm6, ebx
1095 por xmm7, xmm6
1096 paddw xmm5, xmm7
1097 psraw xmm5, 1
1098 paddw xmm5, xmm1
1099
1100 psrldq xmm2, 14
1101 movd ebx, xmm2 ; save hi
1102
1103 movdqa [rdx], xmm5 ; out lo
1104
1105 ; move right
1106 lea rsi, [rsi + 16 * 2]
1107 lea rdi, [rdi + 8 * 2]
1108 lea rdx, [rdx + 8 * 2]
1109
1110 dec cx
1111 jnz loop2e1
1112 shr ecx, 16
1113
1114 ; post
1115 movdqa xmm1, [rsi] ; src[2n]
1116 movdqa xmm2, [rsi + 16]
1117 movdqa xmm6, xmm1
1118 movdqa xmm7, xmm2
1119 pand xmm1, [rel cdFFFF]
1120 pand xmm2, [rel cdFFFF]
1121 pslld xmm1, 16
1122 pslld xmm2, 16
1123 psrad xmm1, 16
1124 psrad xmm2, 16
1125 packssdw xmm1, xmm2
1126 movdqa xmm2, xmm6 ; src[2n + 1]
1127 movdqa xmm3, xmm7
1128 psrldq xmm2, 2
1129 psrldq xmm3, 2
1130 pand xmm2, [rel cdFFFF]
1131 pand xmm3, [rel cdFFFF]
1132 pslld xmm2, 16
1133 pslld xmm3, 16
1134 psrad xmm2, 16
1135 psrad xmm3, 16
1136 packssdw xmm2, xmm3
1137 movdqa xmm3, xmm6 ; src[2n + 2]
1138 movdqa xmm4, xmm7
1139 psrldq xmm3, 4
1140 psrldq xmm4, 4
1141 movd eax, xmm7
1142 movd xmm5, eax
1143 pslldq xmm5, 12
1144 por xmm3, xmm5
1145 movdqa xmm5, xmm7
1146 psrldq xmm5, 12
1147 pslldq xmm5, 12
1148 por xmm4, xmm5
1149 pand xmm3, [rel cdFFFF]
1150 pand xmm4, [rel cdFFFF]
1151 pslld xmm3, 16
1152 pslld xmm4, 16
1153 psrad xmm3, 16
1154 psrad xmm4, 16
1155 packssdw xmm3, xmm4
1156 movdqa xmm4, xmm1
1157 movdqa xmm5, xmm2
1158 movdqa xmm6, xmm3
1159 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1160 paddw xmm4, xmm6
1161 psraw xmm4, 1
1162 psubw xmm5, xmm4
1163 psraw xmm5, 1
1164
1165 movdqa xmm6, xmm5 ; out hi
1166 paddw xmm6, xmm8
1167 psraw xmm6, xmm9
1168 movdqa [rdi], xmm6
1169
1170 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1171 movdqa xmm7, xmm5
1172 pslldq xmm7, 2
1173 movd xmm6, ebx
1174 por xmm7, xmm6
1175 paddw xmm5, xmm7
1176 psraw xmm5, 1
1177 paddw xmm5, xmm1
1178
1179 movdqa [rdx], xmm5 ; out lo
1180
1181 ; move right
1182 lea rsi, [rsi + 16 * 2]
1183 lea rdi, [rdi + 8 * 2]
1184 lea rdx, [rdx + 8 * 2]
1185
1186 ; move left
1187 lea rsi, [rsi - 64 * 2]
1188 lea rdi, [rdi - 32 * 2]
1189 lea rdx, [rdx - 32 * 2]
1190
1191 ; move down
1192 lea rsi, [rsi + 64 * 2]
1193 lea rdi, [rdi + 32 * 2]
1194 lea rdx, [rdx + 32 * 2]
1195
1196 dec ecx
1197 jnz loop1e1
1198
1199 ret
1200
1201 ;******************************************************************************
1202 ; source 8 bit unsigned, 64 pixel width
1203 rfx_dwt_2d_encode_block_verti_8_64:
1204 mov ecx, 8
1205 loop1f:
1206 ; pre
1207 movq xmm1, [rsi] ; src[2n]
1208 movq xmm2, [rsi + 64 * 1] ; src[2n + 1]
1209 movq xmm3, [rsi + 64 * 1 * 2] ; src[2n + 2]
1210 punpcklbw xmm1, xmm0
1211 punpcklbw xmm2, xmm0
1212 punpcklbw xmm3, xmm0
1213 psubw xmm1, [rel cw128]
1214 psubw xmm2, [rel cw128]
1215 psubw xmm3, [rel cw128]
1216 psllw xmm1, 5
1217 psllw xmm2, 5
1218 psllw xmm3, 5
1219 movdqa xmm4, xmm1
1220 movdqa xmm5, xmm2
1221 movdqa xmm6, xmm3
1222 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1223 paddw xmm4, xmm6
1224 psraw xmm4, 1
1225 psubw xmm5, xmm4
1226 psraw xmm5, 1
1227 movdqa [rdi], xmm5 ; out hi
1228 movdqa xmm6, xmm5 ; save hi
1229 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1230 paddw xmm5, xmm1
1231 movdqa [rdx], xmm5 ; out lo
1232 movdqa xmm7, xmm6 ; save hi
1233 ; move down
1234 lea rsi, [rsi + 64 * 1 * 2] ; 2 rows
1235 lea rdi, [rdi + 64 * 2] ; 1 row
1236 lea rdx, [rdx + 64 * 2] ; 1 row
1237
1238 ; loop
1239 shl ecx, 16
1240 mov cx, 30
1241 loop2f:
1242 movdqa xmm1, xmm3 ; src[2n]
1243 movq xmm2, [rsi + 64 * 1] ; src[2n + 1]
1244 movq xmm3, [rsi + 64 * 1 * 2] ; src[2n + 2]
1245 punpcklbw xmm2, xmm0
1246 punpcklbw xmm3, xmm0
1247 psubw xmm2, [rel cw128]
1248 psubw xmm3, [rel cw128]
1249 psllw xmm2, 5
1250 psllw xmm3, 5
1251 movdqa xmm4, xmm1
1252 movdqa xmm5, xmm2
1253 movdqa xmm6, xmm3
1254 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1255 paddw xmm4, xmm6
1256 psraw xmm4, 1
1257 psubw xmm5, xmm4
1258 psraw xmm5, 1
1259 movdqa [rdi], xmm5 ; out hi
1260 movdqa xmm6, xmm5 ; save hi
1261 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1262 paddw xmm5, xmm7
1263 psraw xmm5, 1
1264 paddw xmm5, xmm1
1265 movdqa [rdx], xmm5 ; out lo
1266 movdqa xmm7, xmm6 ; save hi
1267 ; move down
1268 lea rsi, [rsi + 64 * 1 * 2] ; 2 rows
1269 lea rdi, [rdi + 64 * 2] ; 1 row
1270 lea rdx, [rdx + 64 * 2] ; 1 row
1271
1272 dec cx
1273 jnz loop2f
1274 shr ecx, 16
1275
1276 ; post
1277 movdqa xmm1, xmm3 ; src[2n]
1278 movq xmm2, [rsi + 64 * 1] ; src[2n + 1]
1279 punpcklbw xmm2, xmm0
1280 psubw xmm2, [rel cw128]
1281 psllw xmm2, 5
1282 movdqa xmm4, xmm1
1283 movdqa xmm5, xmm2
1284 movdqa xmm6, xmm3
1285 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1286 paddw xmm4, xmm6
1287 psraw xmm4, 1
1288 psubw xmm5, xmm4
1289 psraw xmm5, 1
1290 movdqa [rdi], xmm5 ; out hi
1291 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1292 paddw xmm5, xmm7
1293 psraw xmm5, 1
1294 paddw xmm5, xmm1
1295 movdqa [rdx], xmm5 ; out lo
1296 ; move down
1297 lea rsi, [rsi + 64 * 1 * 2] ; 2 rows
1298 lea rdi, [rdi + 64 * 2] ; 1 row
1299 lea rdx, [rdx + 64 * 2] ; 1 row
1300
1301 ; move up
1302 lea rsi, [rsi - 64 * 1 * 64]
1303 lea rdi, [rdi - 32 * 64 * 2]
1304 lea rdx, [rdx - 32 * 64 * 2]
1305
1306 ; move right
1307 lea rsi, [rsi + 8]
1308 lea rdi, [rdi + 16]
1309 lea rdx, [rdx + 16]
1310
1311 dec ecx
1312 jnz loop1f
1313
1314 ret
1315
1316 set_quants_hi:
1317 sub rax, 6 - 5
1318 movd xmm9, eax
1319 imul rax, 16
1320 lea rdx, [rel cwa0]
1321 add rdx, rax
1322 movdqa xmm8, [rdx]
1323 ret
1324
1325 set_quants_lo:
1326 sub rax, 6 - 5
1327 movd xmm11, eax
1328 imul rax, 16
1329 lea rdx, [rel cwa0]
1330 add rdx, rax
1331 movdqa xmm10, [rdx]
1332 ret
1333
1334 ;The first six integer or pointer arguments are passed in registers
1335 ;RDI, RSI, RDX, RCX, R8, and R9
1336
1337 ;int
1338 ;rfxcodec_encode_dwt_shift_amd64_sse2(const char *qtable,
1339 ; unsigned char *in_buffer,
1340 ; short *out_buffer,
1341 ; short *work_buffer);
1342
1343 ;******************************************************************************
1344 %ifidn __OUTPUT_FORMAT__,elf64
1345 PROC rfxcodec_encode_dwt_shift_amd64_sse2
1346 %else
1347 PROC _rfxcodec_encode_dwt_shift_amd64_sse2
1348 %endif
1349 ; save registers
1350 push rbx
1351 push rdx
1352 push rcx
1353 push rsi
1354 push rdi
1355 pxor xmm0, xmm0
1356
1357 ; verical DWT to work buffer, level 1
1358 mov rsi, [rsp + 8] ; src
1359 mov rdi, [rsp + 16] ; dst hi
1360 lea rdi, [rdi + 64 * 32 * 2] ; dst hi
1361 mov rdx, [rsp + 16] ; dst lo
1362 call rfx_dwt_2d_encode_block_verti_8_64
1363
1364 ; horizontal DWT to out buffer, level 1, part 1
1365 xor rax, rax
1366 mov rdx, [rsp]
1367 mov al, [rdx + 4]
1368 and al, 0xF
1369 call set_quants_hi
1370 mov rsi, [rsp + 16] ; src
1371 mov rdi, [rsp + 24] ; dst hi - HL1
1372 mov rdx, [rsp + 24] ; dst lo - LL1
1373 lea rdx, [rdx + 32 * 32 * 6] ; dst lo - LL1
1374 call rfx_dwt_2d_encode_block_horiz_16_64_no_lo
1375
1376 ; horizontal DWT to out buffer, level 1, part 2
1377 xor rax, rax
1378 mov rdx, [rsp]
1379 mov al, [rdx + 4]
1380 shr al, 4
1381 call set_quants_hi
1382 xor rax, rax
1383 mov rdx, [rsp]
1384 mov al, [rdx + 3]
1385 shr al, 4
1386 call set_quants_lo
1387 mov rsi, [rsp + 16] ; src
1388 lea rsi, [rsi + 64 * 32 * 2] ; src
1389 mov rdi, [rsp + 24] ; dst hi - HH1
1390 lea rdi, [rdi + 32 * 32 * 4] ; dst hi - HH1
1391 mov rdx, [rsp + 24] ; dst lo - LH1
1392 lea rdx, [rdx + 32 * 32 * 2] ; dst lo - LH1
1393 call rfx_dwt_2d_encode_block_horiz_16_64
1394
1395 ; verical DWT to work buffer, level 2
1396 mov rsi, [rsp + 24] ; src
1397 lea rsi, [rsi + 32 * 32 * 6] ; src
1398 mov rdi, [rsp + 16] ; dst hi
1399 lea rdi, [rdi + 32 * 16 * 2] ; dst hi
1400 mov rdx, [rsp + 16] ; dst lo
1401 call rfx_dwt_2d_encode_block_verti_16_32
1402
1403 ; horizontal DWT to out buffer, level 2, part 1
1404 xor rax, rax
1405 mov rdx, [rsp]
1406 mov al, [rdx + 2]
1407 shr al, 4
1408 call set_quants_hi
1409 mov rsi, [rsp + 16] ; src
1410 ; 32 * 32 * 6 + 16 * 16 * 0 = 6144
1411 mov rdi, [rsp + 24] ; dst hi - HL2
1412 lea rdi, [rdi + 6144] ; dst hi - HL2
1413 ; 32 * 32 * 6 + 16 * 16 * 6 = 7680
1414 mov rdx, [rsp + 24] ; dst lo - LL2
1415 lea rdx, [rdx + 7680] ; dst lo - LL2
1416 call rfx_dwt_2d_encode_block_horiz_16_32_no_lo
1417
1418 ; horizontal DWT to out buffer, level 2, part 2
1419 xor rax, rax
1420 mov rdx, [rsp]
1421 mov al, [rdx + 3]
1422 and al, 0xF
1423 call set_quants_hi
1424 xor rax, rax
1425 mov rdx, [rsp]
1426 mov al, [rdx + 2]
1427 and al, 0xF
1428 call set_quants_lo
1429 mov rsi, [rsp + 16] ; src
1430 lea rsi, [rsi + 32 * 16 * 2] ; src
1431 ; 32 * 32 * 6 + 16 * 16 * 4 = 7168
1432 mov rdi, [rsp + 24] ; dst hi - HH2
1433 lea rdi, [rdi + 7168] ; dst hi - HH2
1434 ; 32 * 32 * 6 + 16 * 16 * 2 = 6656
1435 mov rdx, [rsp + 24] ; dst lo - LH2
1436 lea rdx, [rdx + 6656] ; dst lo - LH2
1437 call rfx_dwt_2d_encode_block_horiz_16_32
1438
1439 ; verical DWT to work buffer, level 3
1440 ; 32 * 32 * 6 + 16 * 16 * 6 = 7680
1441 mov rsi, [rsp + 24] ; src
1442 lea rsi, [rsi + 7680] ; src
1443 mov rdi, [rsp + 16] ; dst hi
1444 lea rdi, [rdi + 16 * 8 * 2] ; dst hi
1445 mov rdx, [rsp + 16] ; dst lo
1446 call rfx_dwt_2d_encode_block_verti_16_16
1447
1448 ; horizontal DWT to out buffer, level 3, part 1
1449 xor rax, rax
1450 mov rdx, [rsp]
1451 mov al, [rdx + 1]
1452 and al, 0xF
1453 call set_quants_hi
1454 xor rax, rax
1455 mov rdx, [rsp]
1456 mov al, [rdx + 0]
1457 and al, 0xF
1458 call set_quants_lo
1459 mov rsi, [rsp + 16] ; src
1460 ; 32 * 32 * 6 + 16 * 16 * 6 + 8 * 8 * 0 = 7680
1461 mov rdi, [rsp + 24] ; dst hi - HL3
1462 lea rdi, [rdi + 7680] ; dst hi - HL3
1463 ; 32 * 32 * 6 + 16 * 16 * 6 + 8 * 8 * 6 = 8064
1464 mov rdx, [rsp + 24] ; dst lo - LL3
1465 lea rdx, [rdx + 8064] ; dst lo - LL3
1466 call rfx_dwt_2d_encode_block_horiz_16_16
1467
1468 ; horizontal DWT to out buffer, level 3, part 2
1469 xor rax, rax
1470 mov rdx, [rsp]
1471 mov al, [rdx + 1]
1472 shr al, 4
1473 call set_quants_hi
1474 xor rax, rax
1475 mov rdx, [rsp]
1476 mov al, [rdx + 0]
1477 shr al, 4
1478 call set_quants_lo
1479 mov rsi, [rsp + 16] ; src
1480 lea rsi, [rsi + 16 * 8 * 2] ; src
1481 ; 32 * 32 * 6 + 16 * 16 * 6 + 8 * 8 * 4 = 7936
1482 mov rdi, [rsp + 24] ; dst hi - HH3
1483 lea rdi, [rdi + 7936] ; dst hi - HH3
1484 ; 32 * 32 * 6 + 16 * 16 * 6 + 8 * 8 * 2 = 7808
1485 mov rdx, [rsp + 24] ; dst lo - LH3
1486 lea rdx, [rdx + 7808] ; dst lo - LH3
1487 call rfx_dwt_2d_encode_block_horiz_16_16
1488
1489 mov rax, 0
1490 ; restore registers
1491 pop rdi
1492 pop rsi
1493 pop rcx
1494 pop rdx
1495 pop rbx
1496 ret
1497 align 16
1498
0 ;
1 ;Copyright 2016 Jay Sorg
2 ;
3 ;Permission to use, copy, modify, distribute, and sell this software and its
4 ;documentation for any purpose is hereby granted without fee, provided that
5 ;the above copyright notice appear in all copies and that both that
6 ;copyright notice and this permission notice appear in supporting
7 ;documentation.
8 ;
9 ;The above copyright notice and this permission notice shall be included in
10 ;all copies or substantial portions of the Software.
11 ;
12 ;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 ;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 ;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 ;OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
16 ;AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17 ;CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 ;
19 ;amd64 asm dwt
20
21 section .data
22 align 16
23 cw128 times 8 dw 128
24 cdFFFF times 4 dd 65535
25 ; these are 1 << (factor - 1) 0 to 15 is factor
26 cwa0 times 8 dw 0 ; 0
27 cwa1 times 8 dw 1 ; 1
28 cwa2 times 8 dw 2 ; 2
29 cwa4 times 8 dw 4 ; 3
30 cwa8 times 8 dw 8 ; 4
31 cwa16 times 8 dw 16 ; 5
32 cwa32 times 8 dw 32 ; 6
33 cwa64 times 8 dw 64 ; 7
34 cwa128 times 8 dw 128 ; 8
35 cwa256 times 8 dw 256 ; 9
36 cwa512 times 8 dw 512 ; 10
37 cwa1024 times 8 dw 1024 ; 11
38 cwa2048 times 8 dw 2048 ; 12
39 cwa4096 times 8 dw 4096 ; 13
40 cwa8192 times 8 dw 8192 ; 14
41 cwa16384 times 8 dw 16384 ; 15
42
43 section .text
44
45 %macro PROC 1
46 align 16
47 global %1
48 %1:
49 %endmacro
50
51 ;******************************************************************************
52 ; source 16 bit signed, 16 pixel width
53 rfx_dwt_2d_encode_block_horiz_16_16:
54 mov ecx, 8
55 loop1a:
56 ; pre / post
57 movdqa xmm1, [rsi] ; src[2n]
58 movdqa xmm2, [rsi + 16]
59 movdqa xmm6, xmm1
60 movdqa xmm7, xmm2
61 pand xmm1, [rel cdFFFF]
62 pand xmm2, [rel cdFFFF]
63 packusdw xmm1, xmm2
64 movdqa xmm2, xmm6 ; src[2n + 1]
65 movdqa xmm3, xmm7
66 psrldq xmm2, 2
67 psrldq xmm3, 2
68 pand xmm2, [rel cdFFFF]
69 pand xmm3, [rel cdFFFF]
70 packusdw xmm2, xmm3
71 movdqa xmm3, xmm6 ; src[2n + 2]
72 movdqa xmm4, xmm7
73 psrldq xmm3, 4
74 psrldq xmm4, 4
75 movd eax, xmm7
76 movd xmm5, eax
77 pslldq xmm5, 12
78 por xmm3, xmm5
79 movdqa xmm5, xmm7
80 psrldq xmm5, 12
81 pslldq xmm5, 12
82 por xmm4, xmm5
83 pand xmm3, [rel cdFFFF]
84 pand xmm4, [rel cdFFFF]
85 packusdw xmm3, xmm4
86 movdqa xmm4, xmm1
87 movdqa xmm5, xmm2
88 movdqa xmm6, xmm3
89 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
90 paddw xmm4, xmm6
91 psraw xmm4, 1
92 psubw xmm5, xmm4
93 psraw xmm5, 1
94 movdqa xmm6, xmm5 ; out hi
95 paddw xmm6, xmm8
96 psraw xmm6, xmm9
97 movdqa [rdi], xmm6
98 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
99 movdqa xmm7, xmm5
100 movd eax, xmm7
101 pslldq xmm7, 2
102 and eax, 0xFFFF
103 movd xmm6, eax
104 por xmm7, xmm6
105 paddw xmm5, xmm7
106 psraw xmm5, 1
107 paddw xmm5, xmm1
108
109 movdqa xmm6, xmm5 ; out lo
110 paddw xmm6, xmm10
111 psraw xmm6, xmm11
112 movdqa [rdx], xmm6
113
114 ; move right
115 lea rsi, [rsi + 16 * 2]
116 lea rdi, [rdi + 8 * 2]
117 lea rdx, [rdx + 8 * 2]
118
119 ; move left
120 lea rsi, [rsi - 16 * 2]
121 lea rdi, [rdi - 8 * 2]
122 lea rdx, [rdx - 8 * 2]
123
124 ; move down
125 lea rsi, [rsi + 16 * 2]
126 lea rdi, [rdi + 8 * 2]
127 lea rdx, [rdx + 8 * 2]
128
129 dec ecx
130 jnz loop1a
131
132 ret
133
134 ;******************************************************************************
135 ; source 16 bit signed, 16 pixel width
136 rfx_dwt_2d_encode_block_verti_16_16:
137 mov ecx, 2
138 loop1b:
139 ; pre
140 movdqa xmm1, [rsi] ; src[2n]
141 movdqa xmm2, [rsi + 16 * 2] ; src[2n + 1]
142 movdqa xmm3, [rsi + 16 * 2 * 2] ; src[2n + 2]
143 movdqa xmm4, xmm1
144 movdqa xmm5, xmm2
145 movdqa xmm6, xmm3
146 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
147 paddw xmm4, xmm6
148 psraw xmm4, 1
149 psubw xmm5, xmm4
150 psraw xmm5, 1
151 movdqa [rdi], xmm5 ; out hi
152 movdqa xmm6, xmm5 ; save hi
153 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
154 paddw xmm5, xmm1
155 movdqa [rdx], xmm5 ; out lo
156 movdqa xmm7, xmm6 ; save hi
157 ; move down
158 lea rsi, [rsi + 16 * 2 * 2] ; 2 rows
159 lea rdi, [rdi + 16 * 2] ; 1 row
160 lea rdx, [rdx + 16 * 2] ; 1 row
161
162 ; loop
163 shl ecx, 16
164 mov cx, 6
165 loop2b:
166 movdqa xmm1, xmm3 ; src[2n]
167 movdqa xmm2, [rsi + 16 * 2] ; src[2n + 1]
168 movdqa xmm3, [rsi + 16 * 2 * 2] ; src[2n + 2]
169 movdqa xmm4, xmm1
170 movdqa xmm5, xmm2
171 movdqa xmm6, xmm3
172 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
173 paddw xmm4, xmm6
174 psraw xmm4, 1
175 psubw xmm5, xmm4
176 psraw xmm5, 1
177 movdqa [rdi], xmm5 ; out hi
178 movdqa xmm6, xmm5 ; save hi
179 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
180 paddw xmm5, xmm7
181 psraw xmm5, 1
182 paddw xmm5, xmm1
183 movdqa [rdx], xmm5 ; out lo
184 movdqa xmm7, xmm6 ; save hi
185 ; move down
186 lea rsi, [rsi + 16 * 2 * 2] ; 2 rows
187 lea rdi, [rdi + 16 * 2] ; 1 row
188 lea rdx, [rdx + 16 * 2] ; 1 row
189
190 dec cx
191 jnz loop2b
192 shr ecx, 16
193
194 ; post
195 movdqa xmm1, xmm3 ; src[2n]
196 movdqa xmm2, [rsi + 16 * 2] ; src[2n + 1]
197 movdqa xmm4, xmm1
198 movdqa xmm5, xmm2
199 movdqa xmm6, xmm3
200 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
201 paddw xmm4, xmm6
202 psraw xmm4, 1
203 psubw xmm5, xmm4
204 psraw xmm5, 1
205 movdqa [rdi], xmm5 ; out hi
206 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
207 paddw xmm5, xmm7
208 psraw xmm5, 1
209 paddw xmm5, xmm1
210 movdqa [rdx], xmm5 ; out lo
211 ; move down
212 lea rsi, [rsi + 16 * 2 * 2] ; 2 row
213 lea rdi, [rdi + 16 * 2] ; 1 row
214 lea rdx, [rdx + 16 * 2] ; 1 row
215
216 ; move up
217 lea rsi, [rsi - 16 * 16 * 2]
218 lea rdi, [rdi - 8 * 16 * 2]
219 lea rdx, [rdx - 8 * 16 * 2]
220
221 ; move right
222 lea rsi, [rsi + 16]
223 lea rdi, [rdi + 16]
224 lea rdx, [rdx + 16]
225
226 dec ecx
227 jnz loop1b
228
229 ret
230
231 ;******************************************************************************
232 ; source 16 bit signed, 32 pixel width
233 rfx_dwt_2d_encode_block_horiz_16_32:
234 mov ecx, 16
235 loop1c:
236 ; pre
237 movdqa xmm1, [rsi] ; src[2n]
238 movdqa xmm2, [rsi + 16]
239 movdqa xmm6, xmm1
240 movdqa xmm7, xmm2
241 pand xmm1, [rel cdFFFF]
242 pand xmm2, [rel cdFFFF]
243 packusdw xmm1, xmm2
244 movdqa xmm2, xmm6 ; src[2n + 1]
245 movdqa xmm3, xmm7
246 psrldq xmm2, 2
247 psrldq xmm3, 2
248 pand xmm2, [rel cdFFFF]
249 pand xmm3, [rel cdFFFF]
250 packusdw xmm2, xmm3
251 movdqa xmm3, xmm6 ; src[2n + 2]
252 movdqa xmm4, xmm7
253 psrldq xmm3, 4
254 psrldq xmm4, 4
255 movd eax, xmm7
256 movd xmm5, eax
257 pslldq xmm5, 12
258 por xmm3, xmm5
259 mov eax, [rsi + 32]
260 movd xmm5, eax
261 pslldq xmm5, 12
262 por xmm4, xmm5
263 pand xmm3, [rel cdFFFF]
264 pand xmm4, [rel cdFFFF]
265 packusdw xmm3, xmm4
266 movdqa xmm4, xmm1
267 movdqa xmm5, xmm2
268 movdqa xmm6, xmm3
269 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
270 paddw xmm4, xmm6
271 psraw xmm4, 1
272 psubw xmm5, xmm4
273 psraw xmm5, 1
274
275 movdqa xmm6, xmm5 ; out hi
276 paddw xmm6, xmm8
277 psraw xmm6, xmm9
278 movdqa [rdi], xmm6
279 movdqa xmm2, xmm5 ; save hi
280
281 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
282 movdqa xmm7, xmm5
283 movd eax, xmm7
284 pslldq xmm7, 2
285 and eax, 0xFFFF
286 movd xmm6, eax
287 por xmm7, xmm6
288 paddw xmm5, xmm7
289 psraw xmm5, 1
290 paddw xmm5, xmm1
291
292 psrldq xmm2, 14
293 movd ebx, xmm2 ; save hi
294
295 movdqa xmm6, xmm5 ; out lo
296 paddw xmm6, xmm10
297 psraw xmm6, xmm11
298 movdqa [rdx], xmm6
299
300 ; move right
301 lea rsi, [rsi + 16 * 2]
302 lea rdi, [rdi + 8 * 2]
303 lea rdx, [rdx + 8 * 2]
304
305 ; post
306 movdqa xmm1, [rsi] ; src[2n]
307 movdqa xmm2, [rsi + 16]
308 movdqa xmm6, xmm1
309 movdqa xmm7, xmm2
310 pand xmm1, [rel cdFFFF]
311 pand xmm2, [rel cdFFFF]
312 packusdw xmm1, xmm2
313 movdqa xmm2, xmm6 ; src[2n + 1]
314 movdqa xmm3, xmm7
315 psrldq xmm2, 2
316 psrldq xmm3, 2
317 pand xmm2, [rel cdFFFF]
318 pand xmm3, [rel cdFFFF]
319 packusdw xmm2, xmm3
320 movdqa xmm3, xmm6 ; src[2n + 2]
321 movdqa xmm4, xmm7
322 psrldq xmm3, 4
323 psrldq xmm4, 4
324 movd eax, xmm7
325 movd xmm5, eax
326 pslldq xmm5, 12
327 por xmm3, xmm5
328 movdqa xmm5, xmm7
329 psrldq xmm5, 12
330 pslldq xmm5, 12
331 por xmm4, xmm5
332 pand xmm3, [rel cdFFFF]
333 pand xmm4, [rel cdFFFF]
334 packusdw xmm3, xmm4
335 movdqa xmm4, xmm1
336 movdqa xmm5, xmm2
337 movdqa xmm6, xmm3
338 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
339 paddw xmm4, xmm6
340 psraw xmm4, 1
341 psubw xmm5, xmm4
342 psraw xmm5, 1
343
344 movdqa xmm6, xmm5 ; out hi
345 paddw xmm6, xmm8
346 psraw xmm6, xmm9
347 movdqa [rdi], xmm6
348
349 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
350 movdqa xmm7, xmm5
351 pslldq xmm7, 2
352 movd xmm6, ebx
353 por xmm7, xmm6
354 paddw xmm5, xmm7
355 psraw xmm5, 1
356 paddw xmm5, xmm1
357
358 movdqa xmm6, xmm5 ; out lo
359 paddw xmm6, xmm10
360 psraw xmm6, xmm11
361 movdqa [rdx], xmm6
362
363 ; move right
364 lea rsi, [rsi + 16 * 2]
365 lea rdi, [rdi + 8 * 2]
366 lea rdx, [rdx + 8 * 2]
367
368 ; move left
369 lea rsi, [rsi - 32 * 2]
370 lea rdi, [rdi - 16 * 2]
371 lea rdx, [rdx - 16 * 2]
372
373 ; move down
374 lea rsi, [rsi + 32 * 2]
375 lea rdi, [rdi + 16 * 2]
376 lea rdx, [rdx + 16 * 2]
377
378 dec ecx
379 jnz loop1c
380
381 ret
382
383 ;******************************************************************************
384 ; source 16 bit signed, 32 pixel width
385 rfx_dwt_2d_encode_block_horiz_16_32_no_lo:
386 mov ecx, 16
387 loop1c1:
388 ; pre
389 movdqa xmm1, [rsi] ; src[2n]
390 movdqa xmm2, [rsi + 16]
391 movdqa xmm6, xmm1
392 movdqa xmm7, xmm2
393 pand xmm1, [rel cdFFFF]
394 pand xmm2, [rel cdFFFF]
395 packusdw xmm1, xmm2
396 movdqa xmm2, xmm6 ; src[2n + 1]
397 movdqa xmm3, xmm7
398 psrldq xmm2, 2
399 psrldq xmm3, 2
400 pand xmm2, [rel cdFFFF]
401 pand xmm3, [rel cdFFFF]
402 packusdw xmm2, xmm3
403 movdqa xmm3, xmm6 ; src[2n + 2]
404 movdqa xmm4, xmm7
405 psrldq xmm3, 4
406 psrldq xmm4, 4
407 movd eax, xmm7
408 movd xmm5, eax
409 pslldq xmm5, 12
410 por xmm3, xmm5
411 mov eax, [rsi + 32]
412 movd xmm5, eax
413 pslldq xmm5, 12
414 por xmm4, xmm5
415 pand xmm3, [rel cdFFFF]
416 pand xmm4, [rel cdFFFF]
417 packusdw xmm3, xmm4
418 movdqa xmm4, xmm1
419 movdqa xmm5, xmm2
420 movdqa xmm6, xmm3
421 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
422 paddw xmm4, xmm6
423 psraw xmm4, 1
424 psubw xmm5, xmm4
425 psraw xmm5, 1
426
427 movdqa xmm6, xmm5 ; out hi
428 paddw xmm6, xmm8
429 psraw xmm6, xmm9
430 movdqa [rdi], xmm6
431 movdqa xmm2, xmm5 ; save hi
432
433 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
434 movdqa xmm7, xmm5
435 movd eax, xmm7
436 pslldq xmm7, 2
437 and eax, 0xFFFF
438 movd xmm6, eax
439 por xmm7, xmm6
440 paddw xmm5, xmm7
441 psraw xmm5, 1
442 paddw xmm5, xmm1
443
444 psrldq xmm2, 14
445 movd ebx, xmm2 ; save hi
446
447 movdqa [rdx], xmm5 ; out lo
448
449 ; move right
450 lea rsi, [rsi + 16 * 2]
451 lea rdi, [rdi + 8 * 2]
452 lea rdx, [rdx + 8 * 2]
453
454 ; post
455 movdqa xmm1, [rsi] ; src[2n]
456 movdqa xmm2, [rsi + 16]
457 movdqa xmm6, xmm1
458 movdqa xmm7, xmm2
459 pand xmm1, [rel cdFFFF]
460 pand xmm2, [rel cdFFFF]
461 packusdw xmm1, xmm2
462 movdqa xmm2, xmm6 ; src[2n + 1]
463 movdqa xmm3, xmm7
464 psrldq xmm2, 2
465 psrldq xmm3, 2
466 pand xmm2, [rel cdFFFF]
467 pand xmm3, [rel cdFFFF]
468 packusdw xmm2, xmm3
469 movdqa xmm3, xmm6 ; src[2n + 2]
470 movdqa xmm4, xmm7
471 psrldq xmm3, 4
472 psrldq xmm4, 4
473 movd eax, xmm7
474 movd xmm5, eax
475 pslldq xmm5, 12
476 por xmm3, xmm5
477 movdqa xmm5, xmm7
478 psrldq xmm5, 12
479 pslldq xmm5, 12
480 por xmm4, xmm5
481 pand xmm3, [rel cdFFFF]
482 pand xmm4, [rel cdFFFF]
483 packusdw xmm3, xmm4
484 movdqa xmm4, xmm1
485 movdqa xmm5, xmm2
486 movdqa xmm6, xmm3
487 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
488 paddw xmm4, xmm6
489 psraw xmm4, 1
490 psubw xmm5, xmm4
491 psraw xmm5, 1
492
493 movdqa xmm6, xmm5 ; out hi
494 paddw xmm6, xmm8
495 psraw xmm6, xmm9
496 movdqa [rdi], xmm6
497
498 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
499 movdqa xmm7, xmm5
500 pslldq xmm7, 2
501 movd xmm6, ebx
502 por xmm7, xmm6
503 paddw xmm5, xmm7
504 psraw xmm5, 1
505 paddw xmm5, xmm1
506
507 movdqa [rdx], xmm5 ; out lo
508
509 ; move right
510 lea rsi, [rsi + 16 * 2]
511 lea rdi, [rdi + 8 * 2]
512 lea rdx, [rdx + 8 * 2]
513
514 ; move left
515 lea rsi, [rsi - 32 * 2]
516 lea rdi, [rdi - 16 * 2]
517 lea rdx, [rdx - 16 * 2]
518
519 ; move down
520 lea rsi, [rsi + 32 * 2]
521 lea rdi, [rdi + 16 * 2]
522 lea rdx, [rdx + 16 * 2]
523
524 dec ecx
525 jnz loop1c1
526
527 ret
528
529 ;******************************************************************************
530 ; source 16 bit signed, 32 pixel width
531 rfx_dwt_2d_encode_block_verti_16_32:
532 mov ecx, 4
533 loop1d:
534 ; pre
535 movdqa xmm1, [rsi] ; src[2n]
536 movdqa xmm2, [rsi + 32 * 2] ; src[2n + 1]
537 movdqa xmm3, [rsi + 32 * 2 * 2] ; src[2n + 2]
538 movdqa xmm4, xmm1
539 movdqa xmm5, xmm2
540 movdqa xmm6, xmm3
541 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
542 paddw xmm4, xmm6
543 psraw xmm4, 1
544 psubw xmm5, xmm4
545 psraw xmm5, 1
546 movdqa [rdi], xmm5 ; out hi
547 movdqa xmm6, xmm5 ; save hi
548 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
549 paddw xmm5, xmm1
550 movdqa [rdx], xmm5 ; out lo
551 movdqa xmm7, xmm6 ; save hi
552 ; move down
553 lea rsi, [rsi + 32 * 2 * 2] ; 2 rows
554 lea rdi, [rdi + 32 * 2] ; 1 row
555 lea rdx, [rdx + 32 * 2] ; 1 row
556
557 ; loop
558 shl ecx, 16
559 mov cx, 14
560 loop2d:
561 movdqa xmm1, xmm3 ; src[2n]
562 movdqa xmm2, [rsi + 32 * 2] ; src[2n + 1]
563 movdqa xmm3, [rsi + 32 * 2 * 2] ; src[2n + 2]
564 movdqa xmm4, xmm1
565 movdqa xmm5, xmm2
566 movdqa xmm6, xmm3
567 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
568 paddw xmm4, xmm6
569 psraw xmm4, 1
570 psubw xmm5, xmm4
571 psraw xmm5, 1
572 movdqa [rdi], xmm5 ; out hi
573 movdqa xmm6, xmm5 ; save hi
574 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
575 paddw xmm5, xmm7
576 psraw xmm5, 1
577 paddw xmm5, xmm1
578 movdqa [rdx], xmm5 ; out lo
579 movdqa xmm7, xmm6 ; save hi
580 ; move down
581 lea rsi, [rsi + 32 * 2 * 2] ; 2 rows
582 lea rdi, [rdi + 32 * 2] ; 1 row
583 lea rdx, [rdx + 32 * 2] ; 1 row
584
585 dec cx
586 jnz loop2d
587 shr ecx, 16
588
589 ; post
590 movdqa xmm1, xmm3 ; src[2n]
591 movdqa xmm2, [rsi + 32 * 2] ; src[2n + 1]
592 movdqa xmm4, xmm1
593 movdqa xmm5, xmm2
594 movdqa xmm6, xmm3
595 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
596 paddw xmm4, xmm6
597 psraw xmm4, 1
598 psubw xmm5, xmm4
599 psraw xmm5, 1
600 movdqa [rdi], xmm5 ; out hi
601 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
602 paddw xmm5, xmm7
603 psraw xmm5, 1
604 paddw xmm5, xmm1
605 movdqa [rdx], xmm5 ; out lo
606 ; move down
607 lea rsi, [rsi + 32 * 2 * 2] ; 2 row
608 lea rdi, [rdi + 32 * 2] ; 1 row
609 lea rdx, [rdx + 32 * 2] ; 1 row
610
611 ; move up
612 lea rsi, [rsi - 32 * 32 * 2]
613 lea rdi, [rdi - 16 * 32 * 2]
614 lea rdx, [rdx - 16 * 32 * 2]
615
616 ; move right
617 lea rsi, [rsi + 16]
618 lea rdi, [rdi + 16]
619 lea rdx, [rdx + 16]
620
621 dec ecx
622 jnz loop1d
623
624 ret
625
626 ;******************************************************************************
627 ; source 16 bit signed, 64 pixel width
628 rfx_dwt_2d_encode_block_horiz_16_64:
629 mov ecx, 32
630 loop1e:
631 ; pre
632 movdqa xmm1, [rsi] ; src[2n]
633 movdqa xmm2, [rsi + 16]
634 movdqa xmm6, xmm1
635 movdqa xmm7, xmm2
636 pand xmm1, [rel cdFFFF]
637 pand xmm2, [rel cdFFFF]
638 packusdw xmm1, xmm2
639 movdqa xmm2, xmm6 ; src[2n + 1]
640 movdqa xmm3, xmm7
641 psrldq xmm2, 2
642 psrldq xmm3, 2
643 pand xmm2, [rel cdFFFF]
644 pand xmm3, [rel cdFFFF]
645 packusdw xmm2, xmm3
646 movdqa xmm3, xmm6 ; src[2n + 2]
647 movdqa xmm4, xmm7
648 psrldq xmm3, 4
649 psrldq xmm4, 4
650 movd eax, xmm7
651 movd xmm5, eax
652 pslldq xmm5, 12
653 por xmm3, xmm5
654 mov eax, [rsi + 32]
655 movd xmm5, eax
656 pslldq xmm5, 12
657 por xmm4, xmm5
658 pand xmm3, [rel cdFFFF]
659 pand xmm4, [rel cdFFFF]
660 packusdw xmm3, xmm4
661 movdqa xmm4, xmm1
662 movdqa xmm5, xmm2
663 movdqa xmm6, xmm3
664 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
665 paddw xmm4, xmm6
666 psraw xmm4, 1
667 psubw xmm5, xmm4
668 psraw xmm5, 1
669
670 movdqa xmm6, xmm5 ; out hi
671 paddw xmm6, xmm8
672 psraw xmm6, xmm9
673 movdqa [rdi], xmm6
674 movdqa xmm2, xmm5 ; save hi
675
676 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
677 movdqa xmm7, xmm5
678 movd eax, xmm7
679 pslldq xmm7, 2
680 and eax, 0xFFFF
681 movd xmm6, eax
682 por xmm7, xmm6
683 paddw xmm5, xmm7
684 psraw xmm5, 1
685 paddw xmm5, xmm1
686
687 psrldq xmm2, 14
688 movd ebx, xmm2 ; save hi
689
690 movdqa xmm6, xmm5 ; out lo
691 paddw xmm6, xmm10
692 psraw xmm6, xmm11
693 movdqa [rdx], xmm6
694
695 ; move right
696 lea rsi, [rsi + 16 * 2]
697 lea rdi, [rdi + 8 * 2]
698 lea rdx, [rdx + 8 * 2]
699
700 ; loop
701 shl ecx, 16
702 mov cx, 2
703 loop2e:
704 movdqa xmm1, [rsi] ; src[2n]
705 movdqa xmm2, [rsi + 16]
706 movdqa xmm6, xmm1
707 movdqa xmm7, xmm2
708 pand xmm1, [rel cdFFFF]
709 pand xmm2, [rel cdFFFF]
710 packusdw xmm1, xmm2
711 movdqa xmm2, xmm6 ; src[2n + 1]
712 movdqa xmm3, xmm7
713 psrldq xmm2, 2
714 psrldq xmm3, 2
715 pand xmm2, [rel cdFFFF]
716 pand xmm3, [rel cdFFFF]
717 packusdw xmm2, xmm3
718 movdqa xmm3, xmm6 ; src[2n + 2]
719 movdqa xmm4, xmm7
720 psrldq xmm3, 4
721 psrldq xmm4, 4
722 movd eax, xmm7
723 movd xmm5, eax
724 pslldq xmm5, 12
725 por xmm3, xmm5
726 mov eax, [rsi + 32]
727 movd xmm5, eax
728 pslldq xmm5, 12
729 por xmm4, xmm5
730 pand xmm3, [rel cdFFFF]
731 pand xmm4, [rel cdFFFF]
732 packusdw xmm3, xmm4
733 movdqa xmm4, xmm1
734 movdqa xmm5, xmm2
735 movdqa xmm6, xmm3
736 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
737 paddw xmm4, xmm6
738 psraw xmm4, 1
739 psubw xmm5, xmm4
740 psraw xmm5, 1
741
742 movdqa xmm6, xmm5 ; out hi
743 paddw xmm6, xmm8
744 psraw xmm6, xmm9
745 movdqa [rdi], xmm6
746 movdqa xmm2, xmm5 ; save hi
747
748 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
749 movdqa xmm7, xmm5
750 pslldq xmm7, 2
751 movd xmm6, ebx
752 por xmm7, xmm6
753 paddw xmm5, xmm7
754 psraw xmm5, 1
755 paddw xmm5, xmm1
756
757 psrldq xmm2, 14
758 movd ebx, xmm2 ; save hi
759
760 movdqa xmm6, xmm5 ; out lo
761 paddw xmm6, xmm10
762 psraw xmm6, xmm11
763 movdqa [rdx], xmm6
764
765 ; move right
766 lea rsi, [rsi + 16 * 2]
767 lea rdi, [rdi + 8 * 2]
768 lea rdx, [rdx + 8 * 2]
769
770 dec cx
771 jnz loop2e
772 shr ecx, 16
773
774 ; post
775 movdqa xmm1, [rsi] ; src[2n]
776 movdqa xmm2, [rsi + 16]
777 movdqa xmm6, xmm1
778 movdqa xmm7, xmm2
779 pand xmm1, [rel cdFFFF]
780 pand xmm2, [rel cdFFFF]
781 packusdw xmm1, xmm2
782 movdqa xmm2, xmm6 ; src[2n + 1]
783 movdqa xmm3, xmm7
784 psrldq xmm2, 2
785 psrldq xmm3, 2
786 pand xmm2, [rel cdFFFF]
787 pand xmm3, [rel cdFFFF]
788 packusdw xmm2, xmm3
789 movdqa xmm3, xmm6 ; src[2n + 2]
790 movdqa xmm4, xmm7
791 psrldq xmm3, 4
792 psrldq xmm4, 4
793 movd eax, xmm7
794 movd xmm5, eax
795 pslldq xmm5, 12
796 por xmm3, xmm5
797 movdqa xmm5, xmm7
798 psrldq xmm5, 12
799 pslldq xmm5, 12
800 por xmm4, xmm5
801 pand xmm3, [rel cdFFFF]
802 pand xmm4, [rel cdFFFF]
803 packusdw xmm3, xmm4
804 movdqa xmm4, xmm1
805 movdqa xmm5, xmm2
806 movdqa xmm6, xmm3
807 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
808 paddw xmm4, xmm6
809 psraw xmm4, 1
810 psubw xmm5, xmm4
811 psraw xmm5, 1
812
813 movdqa xmm6, xmm5 ; out hi
814 paddw xmm6, xmm8
815 psraw xmm6, xmm9
816 movdqa [rdi], xmm6
817
818 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
819 movdqa xmm7, xmm5
820 pslldq xmm7, 2
821 movd xmm6, ebx
822 por xmm7, xmm6
823 paddw xmm5, xmm7
824 psraw xmm5, 1
825 paddw xmm5, xmm1
826
827 movdqa xmm6, xmm5 ; out lo
828 paddw xmm6, xmm10
829 psraw xmm6, xmm11
830 movdqa [rdx], xmm6
831
832 ; move right
833 lea rsi, [rsi + 16 * 2]
834 lea rdi, [rdi + 8 * 2]
835 lea rdx, [rdx + 8 * 2]
836
837 ; move left
838 lea rsi, [rsi - 64 * 2]
839 lea rdi, [rdi - 32 * 2]
840 lea rdx, [rdx - 32 * 2]
841
842 ; move down
843 lea rsi, [rsi + 64 * 2]
844 lea rdi, [rdi + 32 * 2]
845 lea rdx, [rdx + 32 * 2]
846
847 dec ecx
848 jnz loop1e
849
850 ret
851
852 ;******************************************************************************
853 ; source 16 bit signed, 64 pixel width
854 rfx_dwt_2d_encode_block_horiz_16_64_no_lo:
855 mov ecx, 32
856 loop1e1:
857 ; pre
858 movdqa xmm1, [rsi] ; src[2n]
859 movdqa xmm2, [rsi + 16]
860 movdqa xmm6, xmm1
861 movdqa xmm7, xmm2
862 pand xmm1, [rel cdFFFF]
863 pand xmm2, [rel cdFFFF]
864 packusdw xmm1, xmm2
865 movdqa xmm2, xmm6 ; src[2n + 1]
866 movdqa xmm3, xmm7
867 psrldq xmm2, 2
868 psrldq xmm3, 2
869 pand xmm2, [rel cdFFFF]
870 pand xmm3, [rel cdFFFF]
871 packusdw xmm2, xmm3
872 movdqa xmm3, xmm6 ; src[2n + 2]
873 movdqa xmm4, xmm7
874 psrldq xmm3, 4
875 psrldq xmm4, 4
876 movd eax, xmm7
877 movd xmm5, eax
878 pslldq xmm5, 12
879 por xmm3, xmm5
880 mov eax, [rsi + 32]
881 movd xmm5, eax
882 pslldq xmm5, 12
883 por xmm4, xmm5
884 pand xmm3, [rel cdFFFF]
885 pand xmm4, [rel cdFFFF]
886 packusdw xmm3, xmm4
887 movdqa xmm4, xmm1
888 movdqa xmm5, xmm2
889 movdqa xmm6, xmm3
890 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
891 paddw xmm4, xmm6
892 psraw xmm4, 1
893 psubw xmm5, xmm4
894 psraw xmm5, 1
895
896 movdqa xmm6, xmm5 ; out hi
897 paddw xmm6, xmm8
898 psraw xmm6, xmm9
899 movdqa [rdi], xmm6
900 movdqa xmm2, xmm5 ; save hi
901
902 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
903 movdqa xmm7, xmm5
904 movd eax, xmm7
905 pslldq xmm7, 2
906 and eax, 0xFFFF
907 movd xmm6, eax
908 por xmm7, xmm6
909 paddw xmm5, xmm7
910 psraw xmm5, 1
911 paddw xmm5, xmm1
912
913 psrldq xmm2, 14
914 movd ebx, xmm2 ; save hi
915
916 movdqa [rdx], xmm5 ; out lo
917
918 ; move right
919 lea rsi, [rsi + 16 * 2]
920 lea rdi, [rdi + 8 * 2]
921 lea rdx, [rdx + 8 * 2]
922
923 ; loop
924 shl ecx, 16
925 mov cx, 2
926 loop2e1:
927 movdqa xmm1, [rsi] ; src[2n]
928 movdqa xmm2, [rsi + 16]
929 movdqa xmm6, xmm1
930 movdqa xmm7, xmm2
931 pand xmm1, [rel cdFFFF]
932 pand xmm2, [rel cdFFFF]
933 packusdw xmm1, xmm2
934 movdqa xmm2, xmm6 ; src[2n + 1]
935 movdqa xmm3, xmm7
936 psrldq xmm2, 2
937 psrldq xmm3, 2
938 pand xmm2, [rel cdFFFF]
939 pand xmm3, [rel cdFFFF]
940 packusdw xmm2, xmm3
941 movdqa xmm3, xmm6 ; src[2n + 2]
942 movdqa xmm4, xmm7
943 psrldq xmm3, 4
944 psrldq xmm4, 4
945 movd eax, xmm7
946 movd xmm5, eax
947 pslldq xmm5, 12
948 por xmm3, xmm5
949 mov eax, [rsi + 32]
950 movd xmm5, eax
951 pslldq xmm5, 12
952 por xmm4, xmm5
953 pand xmm3, [rel cdFFFF]
954 pand xmm4, [rel cdFFFF]
955 packusdw xmm3, xmm4
956 movdqa xmm4, xmm1
957 movdqa xmm5, xmm2
958 movdqa xmm6, xmm3
959 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
960 paddw xmm4, xmm6
961 psraw xmm4, 1
962 psubw xmm5, xmm4
963 psraw xmm5, 1
964
965 movdqa xmm6, xmm5 ; out hi
966 paddw xmm6, xmm8
967 psraw xmm6, xmm9
968 movdqa [rdi], xmm6
969 movdqa xmm2, xmm5 ; save hi
970
971 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
972 movdqa xmm7, xmm5
973 pslldq xmm7, 2
974 movd xmm6, ebx
975 por xmm7, xmm6
976 paddw xmm5, xmm7
977 psraw xmm5, 1
978 paddw xmm5, xmm1
979
980 psrldq xmm2, 14
981 movd ebx, xmm2 ; save hi
982
983 movdqa [rdx], xmm5 ; out lo
984
985 ; move right
986 lea rsi, [rsi + 16 * 2]
987 lea rdi, [rdi + 8 * 2]
988 lea rdx, [rdx + 8 * 2]
989
990 dec cx
991 jnz loop2e1
992 shr ecx, 16
993
994 ; post
995 movdqa xmm1, [rsi] ; src[2n]
996 movdqa xmm2, [rsi + 16]
997 movdqa xmm6, xmm1
998 movdqa xmm7, xmm2
999 pand xmm1, [rel cdFFFF]
1000 pand xmm2, [rel cdFFFF]
1001 packusdw xmm1, xmm2
1002 movdqa xmm2, xmm6 ; src[2n + 1]
1003 movdqa xmm3, xmm7
1004 psrldq xmm2, 2
1005 psrldq xmm3, 2
1006 pand xmm2, [rel cdFFFF]
1007 pand xmm3, [rel cdFFFF]
1008 packusdw xmm2, xmm3
1009 movdqa xmm3, xmm6 ; src[2n + 2]
1010 movdqa xmm4, xmm7
1011 psrldq xmm3, 4
1012 psrldq xmm4, 4
1013 movd eax, xmm7
1014 movd xmm5, eax
1015 pslldq xmm5, 12
1016 por xmm3, xmm5
1017 movdqa xmm5, xmm7
1018 psrldq xmm5, 12
1019 pslldq xmm5, 12
1020 por xmm4, xmm5
1021 pand xmm3, [rel cdFFFF]
1022 pand xmm4, [rel cdFFFF]
1023 packusdw xmm3, xmm4
1024 movdqa xmm4, xmm1
1025 movdqa xmm5, xmm2
1026 movdqa xmm6, xmm3
1027 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1028 paddw xmm4, xmm6
1029 psraw xmm4, 1
1030 psubw xmm5, xmm4
1031 psraw xmm5, 1
1032
1033 movdqa xmm6, xmm5 ; out hi
1034 paddw xmm6, xmm8
1035 psraw xmm6, xmm9
1036 movdqa [rdi], xmm6
1037
1038 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1039 movdqa xmm7, xmm5
1040 pslldq xmm7, 2
1041 movd xmm6, ebx
1042 por xmm7, xmm6
1043 paddw xmm5, xmm7
1044 psraw xmm5, 1
1045 paddw xmm5, xmm1
1046
1047 movdqa [rdx], xmm5 ; out lo
1048
1049 ; move right
1050 lea rsi, [rsi + 16 * 2]
1051 lea rdi, [rdi + 8 * 2]
1052 lea rdx, [rdx + 8 * 2]
1053
1054 ; move left
1055 lea rsi, [rsi - 64 * 2]
1056 lea rdi, [rdi - 32 * 2]
1057 lea rdx, [rdx - 32 * 2]
1058
1059 ; move down
1060 lea rsi, [rsi + 64 * 2]
1061 lea rdi, [rdi + 32 * 2]
1062 lea rdx, [rdx + 32 * 2]
1063
1064 dec ecx
1065 jnz loop1e1
1066
1067 ret
1068
1069 ;******************************************************************************
1070 ; source 8 bit unsigned, 64 pixel width
1071 rfx_dwt_2d_encode_block_verti_8_64:
1072 mov ecx, 8
1073 loop1f:
1074 ; pre
1075 movq xmm1, [rsi] ; src[2n]
1076 movq xmm2, [rsi + 64 * 1] ; src[2n + 1]
1077 movq xmm3, [rsi + 64 * 1 * 2] ; src[2n + 2]
1078 punpcklbw xmm1, xmm0
1079 punpcklbw xmm2, xmm0
1080 punpcklbw xmm3, xmm0
1081 psubw xmm1, [rel cw128]
1082 psubw xmm2, [rel cw128]
1083 psubw xmm3, [rel cw128]
1084 psllw xmm1, 5
1085 psllw xmm2, 5
1086 psllw xmm3, 5
1087 movdqa xmm4, xmm1
1088 movdqa xmm5, xmm2
1089 movdqa xmm6, xmm3
1090 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1091 paddw xmm4, xmm6
1092 psraw xmm4, 1
1093 psubw xmm5, xmm4
1094 psraw xmm5, 1
1095 movdqa [rdi], xmm5 ; out hi
1096 movdqa xmm6, xmm5 ; save hi
1097 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1098 paddw xmm5, xmm1
1099 movdqa [rdx], xmm5 ; out lo
1100 movdqa xmm7, xmm6 ; save hi
1101 ; move down
1102 lea rsi, [rsi + 64 * 1 * 2] ; 2 rows
1103 lea rdi, [rdi + 64 * 2] ; 1 row
1104 lea rdx, [rdx + 64 * 2] ; 1 row
1105
1106 ; loop
1107 shl ecx, 16
1108 mov cx, 30
1109 loop2f:
1110 movdqa xmm1, xmm3 ; src[2n]
1111 movq xmm2, [rsi + 64 * 1] ; src[2n + 1]
1112 movq xmm3, [rsi + 64 * 1 * 2] ; src[2n + 2]
1113 punpcklbw xmm2, xmm0
1114 punpcklbw xmm3, xmm0
1115 psubw xmm2, [rel cw128]
1116 psubw xmm3, [rel cw128]
1117 psllw xmm2, 5
1118 psllw xmm3, 5
1119 movdqa xmm4, xmm1
1120 movdqa xmm5, xmm2
1121 movdqa xmm6, xmm3
1122 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1123 paddw xmm4, xmm6
1124 psraw xmm4, 1
1125 psubw xmm5, xmm4
1126 psraw xmm5, 1
1127 movdqa [rdi], xmm5 ; out hi
1128 movdqa xmm6, xmm5 ; save hi
1129 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1130 paddw xmm5, xmm7
1131 psraw xmm5, 1
1132 paddw xmm5, xmm1
1133 movdqa [rdx], xmm5 ; out lo
1134 movdqa xmm7, xmm6 ; save hi
1135 ; move down
1136 lea rsi, [rsi + 64 * 1 * 2] ; 2 rows
1137 lea rdi, [rdi + 64 * 2] ; 1 row
1138 lea rdx, [rdx + 64 * 2] ; 1 row
1139
1140 dec cx
1141 jnz loop2f
1142 shr ecx, 16
1143
1144 ; post
1145 movdqa xmm1, xmm3 ; src[2n]
1146 movq xmm2, [rsi + 64 * 1] ; src[2n + 1]
1147 punpcklbw xmm2, xmm0
1148 psubw xmm2, [rel cw128]
1149 psllw xmm2, 5
1150 movdqa xmm4, xmm1
1151 movdqa xmm5, xmm2
1152 movdqa xmm6, xmm3
1153 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1154 paddw xmm4, xmm6
1155 psraw xmm4, 1
1156 psubw xmm5, xmm4
1157 psraw xmm5, 1
1158 movdqa [rdi], xmm5 ; out hi
1159 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1160 paddw xmm5, xmm7
1161 psraw xmm5, 1
1162 paddw xmm5, xmm1
1163 movdqa [rdx], xmm5 ; out lo
1164 ; move down
1165 lea rsi, [rsi + 64 * 1 * 2] ; 2 rows
1166 lea rdi, [rdi + 64 * 2] ; 1 row
1167 lea rdx, [rdx + 64 * 2] ; 1 row
1168
1169 ; move up
1170 lea rsi, [rsi - 64 * 1 * 64]
1171 lea rdi, [rdi - 32 * 64 * 2]
1172 lea rdx, [rdx - 32 * 64 * 2]
1173
1174 ; move right
1175 lea rsi, [rsi + 8]
1176 lea rdi, [rdi + 16]
1177 lea rdx, [rdx + 16]
1178
1179 dec ecx
1180 jnz loop1f
1181
1182 ret
1183
1184 set_quants_hi:
1185 sub rax, 6 - 5
1186 movd xmm9, eax
1187 imul rax, 16
1188 lea rdx, [rel cwa0]
1189 add rdx, rax
1190 movdqa xmm8, [rdx]
1191 ret
1192
1193 set_quants_lo:
1194 sub rax, 6 - 5
1195 movd xmm11, eax
1196 imul rax, 16
1197 lea rdx, [rel cwa0]
1198 add rdx, rax
1199 movdqa xmm10, [rdx]
1200 ret
1201
1202 ;The first six integer or pointer arguments are passed in registers
1203 ;RDI, RSI, RDX, RCX, R8, and R9
1204
1205 ;int
1206 ;rfxcodec_encode_dwt_shift_amd64_sse41(const char *qtable,
1207 ; unsigned char *in_buffer,
1208 ; short *out_buffer,
1209 ; short *work_buffer);
1210
1211 ;******************************************************************************
1212 %ifidn __OUTPUT_FORMAT__,elf64
1213 PROC rfxcodec_encode_dwt_shift_amd64_sse41
1214 %else
1215 PROC _rfxcodec_encode_dwt_shift_amd64_sse41
1216 %endif
1217 ; save registers
1218 push rbx
1219 push rdx
1220 push rcx
1221 push rsi
1222 push rdi
1223 pxor xmm0, xmm0
1224
1225 ; verical DWT to work buffer, level 1
1226 mov rsi, [rsp + 8] ; src
1227 mov rdi, [rsp + 16] ; dst hi
1228 lea rdi, [rdi + 64 * 32 * 2] ; dst hi
1229 mov rdx, [rsp + 16] ; dst lo
1230 call rfx_dwt_2d_encode_block_verti_8_64
1231
1232 ; horizontal DWT to out buffer, level 1, part 1
1233 xor rax, rax
1234 mov rdx, [rsp]
1235 mov al, [rdx + 4]
1236 and al, 0xF
1237 call set_quants_hi
1238 mov rsi, [rsp + 16] ; src
1239 mov rdi, [rsp + 24] ; dst hi - HL1
1240 mov rdx, [rsp + 24] ; dst lo - LL1
1241 lea rdx, [rdx + 32 * 32 * 6] ; dst lo - LL1
1242 call rfx_dwt_2d_encode_block_horiz_16_64_no_lo
1243
1244 ; horizontal DWT to out buffer, level 1, part 2
1245 xor rax, rax
1246 mov rdx, [rsp]
1247 mov al, [rdx + 4]
1248 shr al, 4
1249 call set_quants_hi
1250 xor rax, rax
1251 mov rdx, [rsp]
1252 mov al, [rdx + 3]
1253 shr al, 4
1254 call set_quants_lo
1255 mov rsi, [rsp + 16] ; src
1256 lea rsi, [rsi + 64 * 32 * 2] ; src
1257 mov rdi, [rsp + 24] ; dst hi - HH1
1258 lea rdi, [rdi + 32 * 32 * 4] ; dst hi - HH1
1259 mov rdx, [rsp + 24] ; dst lo - LH1
1260 lea rdx, [rdx + 32 * 32 * 2] ; dst lo - LH1
1261 call rfx_dwt_2d_encode_block_horiz_16_64
1262
1263 ; verical DWT to work buffer, level 2
1264 mov rsi, [rsp + 24] ; src
1265 lea rsi, [rsi + 32 * 32 * 6] ; src
1266 mov rdi, [rsp + 16] ; dst hi
1267 lea rdi, [rdi + 32 * 16 * 2] ; dst hi
1268 mov rdx, [rsp + 16] ; dst lo
1269 call rfx_dwt_2d_encode_block_verti_16_32
1270
1271 ; horizontal DWT to out buffer, level 2, part 1
1272 xor rax, rax
1273 mov rdx, [rsp]
1274 mov al, [rdx + 2]
1275 shr al, 4
1276 call set_quants_hi
1277 mov rsi, [rsp + 16] ; src
1278 ; 32 * 32 * 6 + 16 * 16 * 0 = 6144
1279 mov rdi, [rsp + 24] ; dst hi - HL2
1280 lea rdi, [rdi + 6144] ; dst hi - HL2
1281 ; 32 * 32 * 6 + 16 * 16 * 6 = 7680
1282 mov rdx, [rsp + 24] ; dst lo - LL2
1283 lea rdx, [rdx + 7680] ; dst lo - LL2
1284 call rfx_dwt_2d_encode_block_horiz_16_32_no_lo
1285
1286 ; horizontal DWT to out buffer, level 2, part 2
1287 xor rax, rax
1288 mov rdx, [rsp]
1289 mov al, [rdx + 3]
1290 and al, 0xF
1291 call set_quants_hi
1292 xor rax, rax
1293 mov rdx, [rsp]
1294 mov al, [rdx + 2]
1295 and al, 0xF
1296 call set_quants_lo
1297 mov rsi, [rsp + 16] ; src
1298 lea rsi, [rsi + 32 * 16 * 2] ; src
1299 ; 32 * 32 * 6 + 16 * 16 * 4 = 7168
1300 mov rdi, [rsp + 24] ; dst hi - HH2
1301 lea rdi, [rdi + 7168] ; dst hi - HH2
1302 ; 32 * 32 * 6 + 16 * 16 * 2 = 6656
1303 mov rdx, [rsp + 24] ; dst lo - LH2
1304 lea rdx, [rdx + 6656] ; dst lo - LH2
1305 call rfx_dwt_2d_encode_block_horiz_16_32
1306
1307 ; verical DWT to work buffer, level 3
1308 ; 32 * 32 * 6 + 16 * 16 * 6 = 7680
1309 mov rsi, [rsp + 24] ; src
1310 lea rsi, [rsi + 7680] ; src
1311 mov rdi, [rsp + 16] ; dst hi
1312 lea rdi, [rdi + 16 * 8 * 2] ; dst hi
1313 mov rdx, [rsp + 16] ; dst lo
1314 call rfx_dwt_2d_encode_block_verti_16_16
1315
1316 ; horizontal DWT to out buffer, level 3, part 1
1317 xor rax, rax
1318 mov rdx, [rsp]
1319 mov al, [rdx + 1]
1320 and al, 0xF
1321 call set_quants_hi
1322 xor rax, rax
1323 mov rdx, [rsp]
1324 mov al, [rdx + 0]
1325 and al, 0xF
1326 call set_quants_lo
1327 mov rsi, [rsp + 16] ; src
1328 ; 32 * 32 * 6 + 16 * 16 * 6 + 8 * 8 * 0 = 7680
1329 mov rdi, [rsp + 24] ; dst hi - HL3
1330 lea rdi, [rdi + 7680] ; dst hi - HL3
1331 ; 32 * 32 * 6 + 16 * 16 * 6 + 8 * 8 * 6 = 8064
1332 mov rdx, [rsp + 24] ; dst lo - LL3
1333 lea rdx, [rdx + 8064] ; dst lo - LL3
1334 call rfx_dwt_2d_encode_block_horiz_16_16
1335
1336 ; horizontal DWT to out buffer, level 3, part 2
1337 xor rax, rax
1338 mov rdx, [rsp]
1339 mov al, [rdx + 1]
1340 shr al, 4
1341 call set_quants_hi
1342 xor rax, rax
1343 mov rdx, [rsp]
1344 mov al, [rdx + 0]
1345 shr al, 4
1346 call set_quants_lo
1347 mov rsi, [rsp + 16] ; src
1348 lea rsi, [rsi + 16 * 8 * 2] ; src
1349 ; 32 * 32 * 6 + 16 * 16 * 6 + 8 * 8 * 4 = 7936
1350 mov rdi, [rsp + 24] ; dst hi - HH3
1351 lea rdi, [rdi + 7936] ; dst hi - HH3
1352 ; 32 * 32 * 6 + 16 * 16 * 6 + 8 * 8 * 2 = 7808
1353 mov rdx, [rsp + 24] ; dst lo - LH3
1354 lea rdx, [rdx + 7808] ; dst lo - LH3
1355 call rfx_dwt_2d_encode_block_horiz_16_16
1356
1357 mov rax, 0
1358 ; restore registers
1359 pop rdi
1360 pop rsi
1361 pop rcx
1362 pop rdx
1363 pop rbx
1364 ret
1365 align 16
1366
+0
-22
librfxcodec/src/amd64/rfxdwt_amd64_sse2.asm less more
0
1 section .data
2 const1 times 8 dw 1
3
4 %macro PROC 1
5 align 16
6 global %1
7 %1:
8 %endmacro
9
10 ;int
11 ;dwt_shift_amd64_sse2(const int *quantization_values, uint8 *data,
12 ; sint16 *dwt_buffer1, sint16 *dwt_buffer);
13
14 PROC dwt_shift_amd64_sse2
15 ; save registers
16 push rbx
17 mov rax, 0
18 pop rbx
19 ret
20 align 16
21
+0
-21
librfxcodec/src/amd64/rfxrlgr1_amd64.asm less more
0
1 section .data
2 const1 times 8 dw 1
3
4 %macro PROC 1
5 align 16
6 global %1
7 %1:
8 %endmacro
9
10 ;int
11 ;diff_rlgr1_amd64(sint16 *co, int num_co, uint8 *dst, int dst_bytes);
12
13 PROC diff_rlgr1_amd64
14 ; save registers
15 push rbx
16 mov rax, 0
17 pop rbx
18 ret
19 align 16
20
+0
-21
librfxcodec/src/amd64/rfxrlgr3_amd64.asm less more
0
1 section .data
2 const1 times 8 dw 1
3
4 %macro PROC 1
5 align 16
6 global %1
7 %1:
8 %endmacro
9
10 ;int
11 ;diff_rlgr3_amd64(sint16 *co, int num_co, uint8 *dst, int dst_bytes);
12
13 PROC diff_rlgr3_amd64
14 ; save registers
15 push rbx
16 mov rax, 0
17 pop rbx
18 ret
19 align 16
20
0 #! /bin/sh
1 command=""
2 infile=""
3 o_opt=no
4 pic=no
5 while [ $# -gt 0 ]; do
6 case "$1" in
7 -DPIC|-fPIC|-fpic|-Kpic|-KPIC)
8 if [ "$pic" != "yes" ] ; then
9 command="$command -DPIC"
10 pic=yes
11 fi
12 ;;
13 -f|-fbin|-faout|-faoutb|-fcoff|-felf|-felf64|-fas86| \
14 -fobj|-fwin32|-fwin64|-frdf|-fieee|-fmacho|-fmacho64)
15 # it's a file format specifier for nasm.
16 command="$command $1"
17 ;;
18 -f*)
19 # maybe a code-generation flag for gcc.
20 ;;
21 -[Ii]*)
22 incdir=`echo "$1" | sed 's/^-[Ii]//'`
23 if [ "x$incdir" = x -a "x$2" != x ] ; then
24 case "$2" in
25 -*) ;;
26 *) incdir="$2"; shift;;
27 esac
28 fi
29 if [ "x$incdir" != x ] ; then
30 # In the case of NASM, the trailing slash is necessary.
31 incdir=`echo "$incdir" | sed 's%/*$%/%'`
32 command="$command -I$incdir"
33 fi
34 ;;
35 -o*)
36 o_opt=yes
37 command="$command $1"
38 ;;
39 *.asm)
40 infile=$1
41 command="$command $1"
42 ;;
43 *)
44 command="$command $1"
45 ;;
46 esac
47 shift
48 done
49 if [ "$o_opt" != yes ] ; then
50 # By default, NASM creates an output file
51 # in the same directory as the input file.
52 outfile="-o `echo $infile | sed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.o"
53 command="$command $outfile"
54 fi
55 echo $command
56 exec $command
00 /**
11 * RFX codec
22 *
3 * Copyright 2014 Jay Sorg <jay.sorg@gmail.com>
3 * Copyright 2014-2015 Jay Sorg <jay.sorg@gmail.com>
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
2121 #define MIN(_val1, _val2) (_val1) < (_val2) ? (_val1) : (_val2)
2222 #define MAX(_val1, _val2) (_val1) > (_val2) ? (_val1) : (_val2)
2323 #define MINMAX(_v, _l, _h) ((_v) < (_l) ? (_l) : ((_v) > (_h) ? (_h) : (_v)))
24
25 #define DWT_FACTOR 5
2426
2527 typedef signed char sint8;
2628 typedef unsigned char uint8;
22 * RemoteFX Codec Library
33 *
44 * Copyright 2011 Vic Lee
5 * Copyright 2015 Jay Sorg <jay.sorg@gmail.com>
56 *
67 * Licensed under the Apache License, Version 2.0 (the "License");
78 * you may not use this file except in compliance with the License.
2728 #include "rfxconstants.h"
2829 #include "rfxencode_tile.h"
2930
31 #define LLOG_LEVEL 1
32 #define LLOGLN(_level, _args) \
33 do { if (_level < LLOG_LEVEL) { printf _args ; printf("\n"); } } while (0)
34
3035 /*
3136 * LL3, LH3, HL3, HH3, LH2, HL2, HH2, LH1, HL1, HH1
3237 */
33 static const int g_rfx_default_quantization_values[] =
34 {
35 6, 6, 6, 6, 7, 7, 8, 8, 8, 9
38 static const unsigned char g_rfx_default_quantization_values[] =
39 {
40 0x66, 0x66, 0x77, 0x88, 0x98
3641 };
3742
3843 /******************************************************************************/
6469 stream_write_uint16(s, WBT_CONTEXT); /* CodecChannelT.blockType */
6570 stream_write_uint32(s, 13); /* CodecChannelT.blockLen */
6671 stream_write_uint8(s, 1); /* CodecChannelT.codecId */
67 stream_write_uint8(s, 0); /* CodecChannelT.channelId */
72 stream_write_uint8(s, 255); /* CodecChannelT.channelId */
6873 stream_write_uint8(s, 0); /* ctxId */
6974 stream_write_uint16(s, CT_TILE_64x64); /* tileSize */
7075
167172 /******************************************************************************/
168173 static int
169174 rfx_compose_message_region(struct rfxencode* enc, STREAM* s,
170 struct rfx_rect *regions, int num_regions)
175 const struct rfx_rect *regions, int num_regions)
171176 {
172177 int size;
173178 int i;
199204 static int
200205 rfx_compose_message_tile_yuv(struct rfxencode *enc, STREAM *s,
201206 char *tile_data, int tile_width, int tile_height,
202 int stride_bytes, const int *quantVals,
207 int stride_bytes, const char *quantVals,
203208 int quantIdxY, int quantIdxCb, int quantIdxCr,
204209 int xIdx, int yIdx)
205210 {
220225 stream_seek(s, 6); /* YLen, CbLen, CrLen */
221226 if (rfx_encode_yuv(enc, tile_data, tile_width, tile_height,
222227 stride_bytes,
223 quantVals + quantIdxY * 10,
224 quantVals + quantIdxCb * 10,
225 quantVals + quantIdxCr * 10,
228 quantVals + quantIdxY * 5,
229 quantVals + quantIdxCb * 5,
230 quantVals + quantIdxCr * 5,
226231 s, &YLen, &CbLen, &CrLen) != 0)
227232 {
228233 return 1;
240245
241246 /******************************************************************************/
242247 static int
248 rfx_compose_message_tile_yuva(struct rfxencode *enc, STREAM *s,
249 char *tile_data, int tile_width, int tile_height,
250 int stride_bytes, const char *quantVals,
251 int quantIdxY, int quantIdxCb, int quantIdxCr,
252 int xIdx, int yIdx)
253 {
254 int YLen = 0;
255 int CbLen = 0;
256 int CrLen = 0;
257 int ALen = 0;
258 int start_pos;
259 int end_pos;
260
261 start_pos = stream_get_pos(s);
262 stream_write_uint16(s, CBT_TILE); /* BlockT.blockType */
263 stream_seek_uint32(s); /* set BlockT.blockLen later */
264 stream_write_uint8(s, quantIdxY);
265 stream_write_uint8(s, quantIdxCb);
266 stream_write_uint8(s, quantIdxCr);
267 stream_write_uint16(s, xIdx);
268 stream_write_uint16(s, yIdx);
269 stream_seek(s, 8); /* YLen, CbLen, CrLen, ALen */
270 if (rfx_encode_yuva(enc, tile_data, tile_width, tile_height,
271 stride_bytes,
272 quantVals + quantIdxY * 5,
273 quantVals + quantIdxCb * 5,
274 quantVals + quantIdxCr * 5,
275 s, &YLen, &CbLen, &CrLen, &ALen) != 0)
276 {
277 return 1;
278 }
279 end_pos = stream_get_pos(s);
280 stream_set_pos(s, start_pos + 2);
281 stream_write_uint32(s, 19 + YLen + CbLen + CrLen + ALen); /* BlockT.blockLen */
282 stream_set_pos(s, start_pos + 13);
283 stream_write_uint16(s, YLen);
284 stream_write_uint16(s, CbLen);
285 stream_write_uint16(s, CrLen);
286 stream_write_uint16(s, ALen);
287 stream_set_pos(s, end_pos);
288 return 0;
289 }
290
291 /******************************************************************************/
292 static int
243293 rfx_compose_message_tile_rgb(struct rfxencode *enc, STREAM *s,
244294 char *tile_data, int tile_width, int tile_height,
245 int stride_bytes, const int *quantVals,
295 int stride_bytes, const char *quantVals,
246296 int quantIdxY, int quantIdxCb, int quantIdxCr,
247297 int xIdx, int yIdx)
248298 {
263313 stream_seek(s, 6); /* YLen, CbLen, CrLen */
264314 if (rfx_encode_rgb(enc, tile_data, tile_width, tile_height,
265315 stride_bytes,
266 quantVals + quantIdxY * 10,
267 quantVals + quantIdxCb * 10,
268 quantVals + quantIdxCr * 10,
316 quantVals + quantIdxY * 5,
317 quantVals + quantIdxCb * 5,
318 quantVals + quantIdxCr * 5,
269319 s, &YLen, &CbLen, &CrLen) != 0)
270320 {
271321 return 1;
283333
284334 /******************************************************************************/
285335 static int
336 rfx_compose_message_tile_argb(struct rfxencode *enc, STREAM *s,
337 char *tile_data, int tile_width, int tile_height,
338 int stride_bytes, const char *quantVals,
339 int quantIdxY, int quantIdxCb, int quantIdxCr,
340 int xIdx, int yIdx)
341 {
342 int YLen = 0;
343 int CbLen = 0;
344 int CrLen = 0;
345 int ALen = 0;
346 int start_pos;
347 int end_pos;
348
349 LLOGLN(10, ("rfx_compose_message_tile_argb:"));
350 start_pos = stream_get_pos(s);
351 stream_write_uint16(s, CBT_TILE); /* BlockT.blockType */
352 stream_seek_uint32(s); /* set BlockT.blockLen later */
353 stream_write_uint8(s, quantIdxY);
354 stream_write_uint8(s, quantIdxCb);
355 stream_write_uint8(s, quantIdxCr);
356 stream_write_uint16(s, xIdx);
357 stream_write_uint16(s, yIdx);
358 stream_seek(s, 8); /* YLen, CbLen, CrLen, ALen */
359 if (rfx_encode_argb(enc, tile_data, tile_width, tile_height,
360 stride_bytes,
361 quantVals + quantIdxY * 5,
362 quantVals + quantIdxCb * 5,
363 quantVals + quantIdxCr * 5,
364 s, &YLen, &CbLen, &CrLen, &ALen) != 0)
365 {
366 LLOGLN(10, ("rfx_compose_message_tile_argb: rfx_encode_argb failed"));
367 return 1;
368 }
369 end_pos = stream_get_pos(s);
370 stream_set_pos(s, start_pos + 2);
371 stream_write_uint32(s, 19 + YLen + CbLen + CrLen + ALen); /* BlockT.blockLen */
372 stream_set_pos(s, start_pos + 13);
373 stream_write_uint16(s, YLen);
374 stream_write_uint16(s, CbLen);
375 stream_write_uint16(s, CrLen);
376 stream_write_uint16(s, ALen);
377 stream_set_pos(s, end_pos);
378 return 0;
379 }
380
381 /******************************************************************************/
382 static int
286383 rfx_compose_message_tileset(struct rfxencode* enc, STREAM* s,
287384 char* buf, int width, int height,
288385 int stride_bytes,
289 struct rfx_tile *tiles, int num_tiles,
290 const int *quants, int num_quants)
386 const struct rfx_tile *tiles, int num_tiles,
387 const char *quants, int num_quants,
388 int flags)
291389 {
292390 int size;
293391 int start_pos;
294392 int end_pos;
295393 int index;
296394 int numQuants;
297 const int *quantVals;
298 const int *quantValsPtr;
395 const char *quantVals;
299396 int quantIdxY;
300397 int quantIdxCb;
301398 int quantIdxCr;
307404 int cy;
308405 char *tile_data;
309406
407 LLOGLN(10, ("rfx_compose_message_tileset:"));
310408 if (quants == 0)
311409 {
312410 numQuants = 1;
313 quantVals = g_rfx_default_quantization_values;
411 quantVals = (const char *) g_rfx_default_quantization_values;
314412 }
315413 else
316414 {
320418 numTiles = num_tiles;
321419 size = 22 + numQuants * 5;
322420 start_pos = stream_get_pos(s);
323 stream_write_uint16(s, WBT_EXTENSION); /* CodecChannelT.blockType */
421 if (flags & RFX_FLAGS_ALPHAV1)
422 {
423 LLOGLN(10, ("rfx_compose_message_tileset: RFX_FLAGS_ALPHAV1 set"));
424 stream_write_uint16(s, WBT_EXTENSION_PLUS); /* CodecChannelT.blockType */
425 }
426 else
427 {
428 stream_write_uint16(s, WBT_EXTENSION); /* CodecChannelT.blockType */
429 }
324430 stream_seek_uint32(s); /* set CodecChannelT.blockLen later */
325431 stream_write_uint8(s, 1); /* CodecChannelT.codecId */
326432 stream_write_uint8(s, 0); /* CodecChannelT.channelId */
331437 stream_write_uint8(s, 0x40); /* tileSize */
332438 stream_write_uint16(s, numTiles); /* numTiles */
333439 stream_seek_uint32(s); /* set tilesDataSize later */
334 quantValsPtr = quantVals;
335 for (index = 0; index < numQuants * 5; index++)
336 {
337 stream_write_uint8(s, quantValsPtr[0] + (quantValsPtr[1] << 4));
338 quantValsPtr += 2;
339 }
440 memcpy(s->p, quantVals, numQuants * 5);
441 s->p += numQuants * 5;
340442 end_pos = stream_get_pos(s);
341443 if (enc->format == RFX_FORMAT_YUV)
342444 {
343 for (index = 0; index < numTiles; index++)
445 if (flags & RFX_FLAGS_ALPHAV1)
344446 {
345 x = tiles[index].x;
346 y = tiles[index].y;
347 cx = tiles[index].cx;
348 cy = tiles[index].cy;
349 quantIdxY = tiles[index].quant_y;
350 quantIdxCb = tiles[index].quant_cb;
351 quantIdxCr = tiles[index].quant_cr;
352 tile_data = buf + (y << 8) * (stride_bytes >> 8) + (x << 8);
353 if (rfx_compose_message_tile_yuv(enc, s,
354 tile_data, cx, cy, stride_bytes,
355 quantVals,
356 quantIdxY, quantIdxCb, quantIdxCr,
357 x / 64, y / 64) != 0)
447 for (index = 0; index < numTiles; index++)
358448 {
359 return 1;
449 x = tiles[index].x;
450 y = tiles[index].y;
451 cx = tiles[index].cx;
452 cy = tiles[index].cy;
453 quantIdxY = tiles[index].quant_y;
454 quantIdxCb = tiles[index].quant_cb;
455 quantIdxCr = tiles[index].quant_cr;
456 tile_data = buf + (y << 8) * (stride_bytes >> 8) + (x << 8);
457 if (rfx_compose_message_tile_yuva(enc, s,
458 tile_data, cx, cy, stride_bytes,
459 quantVals,
460 quantIdxY, quantIdxCb, quantIdxCr,
461 x / 64, y / 64) != 0)
462 {
463 return 1;
464 }
360465 }
361466 }
467 else
468 {
469 for (index = 0; index < numTiles; index++)
470 {
471 x = tiles[index].x;
472 y = tiles[index].y;
473 cx = tiles[index].cx;
474 cy = tiles[index].cy;
475 quantIdxY = tiles[index].quant_y;
476 quantIdxCb = tiles[index].quant_cb;
477 quantIdxCr = tiles[index].quant_cr;
478 tile_data = buf + (y << 8) * (stride_bytes >> 8) + (x << 8);
479 if (rfx_compose_message_tile_yuv(enc, s,
480 tile_data, cx, cy, stride_bytes,
481 quantVals,
482 quantIdxY, quantIdxCb, quantIdxCr,
483 x / 64, y / 64) != 0)
484 {
485 return 1;
486 }
487 }
488 }
362489 }
363490 else
364491 {
365 for (index = 0; index < numTiles; index++)
492 if (flags & RFX_FLAGS_ALPHAV1)
366493 {
367 x = tiles[index].x;
368 y = tiles[index].y;
369 cx = tiles[index].cx;
370 cy = tiles[index].cy;
371 quantIdxY = tiles[index].quant_y;
372 quantIdxCb = tiles[index].quant_cb;
373 quantIdxCr = tiles[index].quant_cr;
374 tile_data = buf + y * stride_bytes + x * (enc->bits_per_pixel / 8);
375 if (rfx_compose_message_tile_rgb(enc, s,
376 tile_data, cx, cy, stride_bytes,
377 quantVals,
378 quantIdxY, quantIdxCb, quantIdxCr,
379 x / 64, y / 64) != 0)
494 for (index = 0; index < numTiles; index++)
380495 {
381 return 1;
496 x = tiles[index].x;
497 y = tiles[index].y;
498 cx = tiles[index].cx;
499 cy = tiles[index].cy;
500 quantIdxY = tiles[index].quant_y;
501 quantIdxCb = tiles[index].quant_cb;
502 quantIdxCr = tiles[index].quant_cr;
503 tile_data = buf + y * stride_bytes + x * (enc->bits_per_pixel / 8);
504 if (rfx_compose_message_tile_argb(enc, s,
505 tile_data, cx, cy, stride_bytes,
506 quantVals,
507 quantIdxY, quantIdxCb, quantIdxCr,
508 x / 64, y / 64) != 0)
509 {
510 return 1;
511 }
512 }
513 }
514 else
515 {
516 for (index = 0; index < numTiles; index++)
517 {
518 x = tiles[index].x;
519 y = tiles[index].y;
520 cx = tiles[index].cx;
521 cy = tiles[index].cy;
522 quantIdxY = tiles[index].quant_y;
523 quantIdxCb = tiles[index].quant_cb;
524 quantIdxCr = tiles[index].quant_cr;
525 tile_data = buf + y * stride_bytes + x * (enc->bits_per_pixel / 8);
526 if (rfx_compose_message_tile_rgb(enc, s,
527 tile_data, cx, cy, stride_bytes,
528 quantVals,
529 quantIdxY, quantIdxCb, quantIdxCr,
530 x / 64, y / 64) != 0)
531 {
532 return 1;
533 }
382534 }
383535 }
384536 }
411563 /******************************************************************************/
412564 int
413565 rfx_compose_message_data(struct rfxencode* enc, STREAM* s,
414 struct rfx_rect *regions, int num_regions,
566 const struct rfx_rect *regions, int num_regions,
415567 char *buf, int width, int height, int stride_bytes,
416 struct rfx_tile *tiles, int num_tiles,
417 const int *quants, int num_quants)
568 const struct rfx_tile *tiles, int num_tiles,
569 const char *quants, int num_quants, int flags)
418570 {
419571 if (rfx_compose_message_frame_begin(enc, s) != 0)
420572 {
425577 return 1;
426578 }
427579 if (rfx_compose_message_tileset(enc, s, buf, width, height, stride_bytes,
428 tiles, num_tiles, quants, num_quants) != 0)
580 tiles, num_tiles, quants, num_quants,
581 flags) != 0)
429582 {
430583 return 1;
431584 }
00 /**
11 * RFX codec encoder
22 *
3 * Copyright 2014 Jay Sorg <jay.sorg@gmail.com>
3 * Copyright 2014-2015 Jay Sorg <jay.sorg@gmail.com>
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
2424 rfx_compose_message_header(struct rfxencode* enc, STREAM* s);
2525 int
2626 rfx_compose_message_data(struct rfxencode* enc, STREAM* s,
27 struct rfx_rect *regions, int num_regions,
27 const struct rfx_rect *regions, int num_regions,
2828 char *buf, int width, int height, int stride_bytes,
29 struct rfx_tile *tiles, int num_tiles,
30 const int *quants, int num_quants);
29 const struct rfx_tile *tiles, int num_tiles,
30 const char *quants, int num_quants, int flags);
3131
3232 #endif
3838 #define WBT_FRAME_END 0xCCC5
3939 #define WBT_REGION 0xCCC6
4040 #define WBT_EXTENSION 0xCCC7
41 #define WBT_EXTENSION_PLUS 0xDDD7
4142 #define CBT_REGION 0xCAC1
4243 #define CBT_TILESET 0xCAC2
4344 #define CBT_TILE 0xCAC3
00 /**
11 * RFX codec encoder
22 *
3 * Copyright 2014 Jay Sorg <jay.sorg@gmail.com>
3 * Copyright 2014-2015 Jay Sorg <jay.sorg@gmail.com>
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
3636 #endif
3737
3838 /******************************************************************************/
39 void *
40 rfxcodec_encode_create(int width, int height, int format, int flags)
39 int
40 rfxcodec_encode_create_ex(int width, int height, int format, int flags,
41 void **handle)
4142 {
4243 struct rfxencode *enc;
4344 int ax;
4849 enc = (struct rfxencode *) malloc(sizeof(struct rfxencode));
4950 if (enc == 0)
5051 {
51 return 0;
52 return 1;
5253 }
5354 memset(enc, 0, sizeof(struct rfxencode));
55
56 enc->dwt_buffer = (sint16*)(((size_t)(enc->dwt_buffer_a)) & ~15);
57 enc->dwt_buffer1 = (sint16*)(((size_t)(enc->dwt_buffer1_a)) & ~15);
58 enc->dwt_buffer2 = (sint16*)(((size_t)(enc->dwt_buffer2_a)) & ~15);
59
5460 #if defined(RFX_USE_ACCEL_X86)
5561 cpuid_x86(1, 0, &ax, &bx, &cx, &dx);
5662 #elif defined(RFX_USE_ACCEL_AMD64)
114120 {
115121 enc->mode = RLGR1;
116122 }
117 switch (format)
123 switch (format)
118124 {
119125 case RFX_FORMAT_BGRA:
120126 enc->bits_per_pixel = 32;
133139 break;
134140 default:
135141 free(enc);
136 return NULL;
142 return 2;
137143 }
138144 enc->format = format;
139145 /* assign encoding functions */
141147 {
142148 if (enc->mode == RLGR3)
143149 {
150 printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr3\n");
144151 enc->rfx_encode = rfx_encode_component_rlgr3; /* rfxencode_tile.c */
145152 }
146153 else
147154 {
155 printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr1\n");
148156 enc->rfx_encode = rfx_encode_component_rlgr1; /* rfxencode_tile.c */
149157 }
150158 }
151159 else
152160 {
153161 #if defined(RFX_USE_ACCEL_X86)
154 if (enc->mode == RLGR3)
155 {
156 enc->rfx_encode = rfx_encode_component_rlgr3_x86_sse2; /* rfxencode_tile.c */
162 if (enc->got_sse41)
163 {
164 if (enc->mode == RLGR3)
165 {
166 printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr3_x86_sse41\n");
167 enc->rfx_encode = rfx_encode_component_rlgr3_x86_sse41; /* rfxencode_tile.c */
168 }
169 else
170 {
171 printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr1_x86_sse41\n");
172 enc->rfx_encode = rfx_encode_component_rlgr1_x86_sse41; /* rfxencode_tile.c */
173 }
174 }
175 else if (enc->got_sse2)
176 {
177 if (enc->mode == RLGR3)
178 {
179 printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr3_x86_sse2\n");
180 enc->rfx_encode = rfx_encode_component_rlgr3_x86_sse2; /* rfxencode_tile.c */
181 }
182 else
183 {
184 printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr1_x86_sse2\n");
185 enc->rfx_encode = rfx_encode_component_rlgr1_x86_sse2; /* rfxencode_tile.c */
186 }
157187 }
158188 else
159189 {
160 enc->rfx_encode = rfx_encode_component_rlgr1_x86_sse2; /* rfxencode_tile.c */
190 if (enc->mode == RLGR3)
191 {
192 printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr3\n");
193 enc->rfx_encode = rfx_encode_component_rlgr3; /* rfxencode_tile.c */
194 }
195 else
196 {
197 printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr1\n");
198 enc->rfx_encode = rfx_encode_component_rlgr1; /* rfxencode_tile.c */
199 }
161200 }
162201 #elif defined(RFX_USE_ACCEL_AMD64)
163 if (enc->mode == RLGR3)
164 {
165 enc->rfx_encode = rfx_encode_component_rlgr3_amd64_sse2; /* rfxencode_tile.c */
202 if (enc->got_sse41)
203 {
204 if (enc->mode == RLGR3)
205 {
206 printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr3_amd64_sse41\n");
207 enc->rfx_encode = rfx_encode_component_rlgr3_amd64_sse41; /* rfxencode_tile.c */
208 }
209 else
210 {
211 printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr1_amd64_sse41\n");
212 enc->rfx_encode = rfx_encode_component_rlgr1_amd64_sse41; /* rfxencode_tile.c */
213 }
214 }
215 else if (enc->got_sse2)
216 {
217 if (enc->mode == RLGR3)
218 {
219 printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr3_amd64_sse2\n");
220 enc->rfx_encode = rfx_encode_component_rlgr3_amd64_sse2; /* rfxencode_tile.c */
221 }
222 else
223 {
224 printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr1_amd64_sse2\n");
225 enc->rfx_encode = rfx_encode_component_rlgr1_amd64_sse2; /* rfxencode_tile.c */
226 }
166227 }
167228 else
168229 {
169 enc->rfx_encode = rfx_encode_component_rlgr1_amd64_sse2; /* rfxencode_tile.c */
230 if (enc->mode == RLGR3)
231 {
232 printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr3\n");
233 enc->rfx_encode = rfx_encode_component_rlgr3; /* rfxencode_tile.c */
234 }
235 else
236 {
237 printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr1\n");
238 enc->rfx_encode = rfx_encode_component_rlgr1; /* rfxencode_tile.c */
239 }
170240 }
171241 #else
172242 if (enc->mode == RLGR3)
173243 {
244 printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr3\n");
174245 enc->rfx_encode = rfx_encode_component_rlgr3; /* rfxencode_tile.c */
175246 }
176247 else
177248 {
249 printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr1\n");
178250 enc->rfx_encode = rfx_encode_component_rlgr1; /* rfxencode_tile.c */
179251 }
180252 #endif
185257 if (bx == 0)
186258 {
187259 }
188 return enc;
260 *handle = enc;
261 return 0;
262 }
263
264 /******************************************************************************/
265 void *
266 rfxcodec_encode_create(int width, int height, int format, int flags)
267 {
268 int error;
269 void *handle;
270
271 error = rfxcodec_encode_create_ex(width, height, format, flags, &handle);
272 if (error == 0)
273 {
274 return handle;
275 }
276 return 0;
189277 }
190278
191279 /******************************************************************************/
200288 return 0;
201289 }
202290 free(enc);
291 return 0;
292 }
293
294 /******************************************************************************/
295 int
296 rfxcodec_encode_ex(void *handle, char *cdata, int *cdata_bytes,
297 char *buf, int width, int height, int stride_bytes,
298 const struct rfx_rect *regions, int num_regions,
299 const struct rfx_tile *tiles, int num_tiles,
300 const char *quants, int num_quants, int flags)
301 {
302 struct rfxencode *enc;
303 STREAM s;
304
305 enc = (struct rfxencode *) handle;
306
307 s.data = (uint8 *) cdata;
308 s.p = s.data;
309 s.size = *cdata_bytes;
310
311 /* Only the first frame should send the RemoteFX header */
312 if ((enc->frame_idx == 0) && (enc->header_processed == 0))
313 {
314 if (rfx_compose_message_header(enc, &s) != 0)
315 {
316 return 1;
317 }
318 }
319 if (rfx_compose_message_data(enc, &s, regions, num_regions,
320 buf, width, height, stride_bytes,
321 tiles, num_tiles, quants, num_quants,
322 flags) != 0)
323 {
324 return 1;
325 }
326 *cdata_bytes = (int) (s.p - s.data);
203327 return 0;
204328 }
205329
207331 int
208332 rfxcodec_encode(void *handle, char *cdata, int *cdata_bytes,
209333 char *buf, int width, int height, int stride_bytes,
210 struct rfx_rect *regions, int num_regions,
211 struct rfx_tile *tiles, int num_tiles,
212 const int *quants, int num_quants)
213 {
214 struct rfxencode *enc;
215 STREAM s;
216
217 enc = (struct rfxencode *) handle;
218
219 s.data = (uint8 *) cdata;
220 s.p = s.data;
221 s.size = *cdata_bytes;
222
223 /* Only the first frame should send the RemoteFX header */
224 if ((enc->frame_idx == 0) && (enc->header_processed == 0))
225 {
226 if (rfx_compose_message_header(enc, &s) != 0)
227 {
228 return 1;
229 }
230 }
231 if (rfx_compose_message_data(enc, &s, regions, num_regions,
232 buf, width, height, stride_bytes,
233 tiles, num_tiles, quants, num_quants) != 0)
234 {
235 return 1;
236 }
237 *cdata_bytes = (int) (s.p - s.data);
238 return 0;
239 }
334 const struct rfx_rect *regions, int num_regions,
335 const struct rfx_tile *tiles, int num_tiles,
336 const char *quants, int num_quants)
337 {
338 return rfxcodec_encode_ex(handle, cdata, cdata_bytes, buf, width, height,
339 stride_bytes, regions, num_regions, tiles,
340 num_tiles, quants, num_quants, 0);
341 }
342
00 /**
11 * RFX codec encoder
22 *
3 * Copyright 2014 Jay Sorg <jay.sorg@gmail.com>
3 * Copyright 2014-2015 Jay Sorg <jay.sorg@gmail.com>
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
2020
2121 struct rfxencode;
2222
23 typedef int (*rfx_encode_proc)(struct rfxencode *enc,
24 const int *quantization_values,
23 typedef int (*rfx_encode_proc)(struct rfxencode *enc, const char *qtable,
2524 uint8 *data, uint8 *buffer,
2625 int buffer_size, int *size);
2726
3837 int format;
3938 int pad0[7];
4039
40 uint8 a_buffer[4096];
4141 uint8 y_r_buffer[4096];
42 uint8 cb_g_buffer[4096];
43 uint8 cr_b_buffer[4096];
44
45 sint16 dwt_buffer[4096];
46 sint16 dwt_buffer1[4096];
47
42 uint8 u_g_buffer[4096];
43 uint8 v_b_buffer[4096];
44 uint8 pad1[16];
45 sint16 dwt_buffer_a[4096];
46 sint16 dwt_buffer1_a[4096];
47 sint16 dwt_buffer2_a[4096];
48 uint8 pad2[16];
49 sint16* dwt_buffer;
50 sint16* dwt_buffer1;
51 sint16* dwt_buffer2;
4852 rfx_encode_proc rfx_encode;
4953
5054 int got_sse2;
5559 int got_popcnt;
5660 int got_lzcnt;
5761 int got_neon;
58
5962 };
6063
6164 #endif
0 /**
1 * librfxcodec: A Remote Desktop Protocol client.
2 * RemoteFX Codec Library
3 *
4 * Copyright 2015 Jay Sorg <jay.sorg@gmail.com>
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22
23 #include <rfxcodec_encode.h>
24
25 #include "rfxcommon.h"
26 #include "rfxencode.h"
27 #include "rfxconstants.h"
28 #include "rfxencode_tile.h"
29
30 #define LLOG_LEVEL 1
31 #define LLOGLN(_level, _args) \
32 do { if (_level < LLOG_LEVEL) { printf _args ; printf("\n"); } } while (0)
33
34 #if 1
35 /*****************************************************************************/
36 static int
37 fdelta(char *in_plane, char *out_plane, int cx, int cy)
38 {
39 char delta;
40 char *src8;
41 char *dst8;
42 int index;
43 int jndex;
44
45 memcpy(out_plane, in_plane, cx);
46 src8 = in_plane;
47 dst8 = out_plane;
48 for (jndex = 1; jndex < cy; jndex++)
49 {
50 for (index = 0; index < cx; index++)
51 {
52 delta = src8[cx] - src8[0];
53 if (delta & 0x80)
54 {
55 delta = (((~delta) + 1) << 1) - 1;
56 }
57 else
58 {
59 delta = delta << 1;
60 }
61 dst8[cx] = delta;
62 src8++;
63 dst8++;
64 }
65 }
66 return 0;
67 }
68 #endif
69
70 #if 0
71 /*****************************************************************************/
72 #define DELTA_ONE \
73 do { \
74 delta = src8[cx] - src8[0]; \
75 is_neg = (delta >> 7) & 1; \
76 dst8[cx] = (((delta ^ -is_neg) + is_neg) << 1) - is_neg; \
77 src8++; \
78 dst8++; \
79 } while (0)
80
81 /*****************************************************************************/
82 static int
83 fdelta(char *in_plane, char *out_plane, int cx, int cy)
84 {
85 char delta;
86 char is_neg;
87 char *src8;
88 char *dst8;
89 char *src8_end;
90
91 memcpy(out_plane, in_plane, cx);
92 src8 = in_plane;
93 dst8 = out_plane;
94 src8_end = src8 + (cx * cy - cx);
95 while (src8 + 8 <= src8_end)
96 {
97 DELTA_ONE;
98 DELTA_ONE;
99 DELTA_ONE;
100 DELTA_ONE;
101 DELTA_ONE;
102 DELTA_ONE;
103 DELTA_ONE;
104 DELTA_ONE;
105 }
106 while (src8 < src8_end)
107 {
108 DELTA_ONE;
109 }
110 return 0;
111 }
112 #endif
113
114 /*****************************************************************************/
115 static int
116 fout(int collen, int replen, char *colptr, STREAM *s)
117 {
118 int code;
119 int lcollen;
120 int lreplen;
121 int cont;
122
123 LLOGLN(10, ("fout: collen %d replen %d", collen, replen));
124 cont = collen > 13;
125 while (cont)
126 {
127 lcollen = collen;
128 if (lcollen > 15)
129 {
130 lcollen = 15;
131 }
132 code = lcollen << 4;
133 stream_write_uint8(s, code);
134 memcpy(s->p, colptr, lcollen);
135 s->p += lcollen;
136 colptr += lcollen;
137 collen -= lcollen;
138 cont = collen > 13;
139 }
140 cont = (collen > 0) || (replen > 0);
141 while (cont)
142 {
143 lreplen = replen;
144 if ((collen == 0) && (lreplen > 15))
145 {
146 /* big run */
147 if (lreplen > 47)
148 {
149 lreplen = 47;
150 }
151 LLOGLN(10, ("fout: big run lreplen %d", lreplen));
152 replen -= lreplen;
153 code = ((lreplen & 0xF) << 4) | ((lreplen & 0xF0) >> 4);
154 stream_write_uint8(s, code);
155 colptr += lreplen;
156 }
157 else
158 {
159 if (lreplen > 15)
160 {
161 lreplen = 15;
162 }
163 replen -= lreplen;
164 if (lreplen < 3)
165 {
166 collen += lreplen;
167 lreplen = 0;
168 }
169 code = (collen << 4) | lreplen;
170 stream_write_uint8(s, code);
171 memcpy(s->p, colptr, collen);
172 s->p += collen;
173 colptr += collen + lreplen;
174 collen = 0;
175 }
176 cont = replen > 0;
177 }
178 return 0;
179 }
180
181 /*****************************************************************************/
182 static int
183 fpack(char *plane, int cx, int cy, STREAM *s)
184 {
185 char *ptr8;
186 char *colptr;
187 char *lend;
188 uint8 *holdp;
189 int jndex;
190 int collen;
191 int replen;
192
193 LLOGLN(10, ("fpack:"));
194 holdp = s->p;
195 for (jndex = 0; jndex < cy; jndex++)
196 {
197 LLOGLN(10, ("line start line %d cx %d cy %d", jndex, cx, cy));
198 ptr8 = (char *) (plane + jndex * cx);
199 lend = ptr8 + (cx - 1);
200 colptr = ptr8;
201 if (colptr[0] == 0)
202 {
203 collen = 0;
204 replen = 1;
205 }
206 else
207 {
208 collen = 1;
209 replen = 0;
210 }
211 while (ptr8 < lend)
212 {
213 if (ptr8[0] == ptr8[1])
214 {
215 replen++;
216 }
217 else
218 {
219 if (replen > 0)
220 {
221 if (replen < 3)
222 {
223 collen += replen + 1;
224 replen = 0;
225 }
226 else
227 {
228 fout(collen, replen, colptr, s);
229 colptr = ptr8 + 1;
230 replen = 0;
231 collen = 1;
232 }
233 }
234 else
235 {
236 collen++;
237 }
238 }
239 ptr8++;
240 }
241 /* end of line */
242 fout(collen, replen, colptr, s);
243 }
244 return (int) (s->p - holdp);
245 }
246
247 /*****************************************************************************/
248 int
249 rfx_encode_plane(struct rfxencode *enc, uint8 *plane, int cx, int cy,
250 STREAM *s)
251 {
252 char *org_plane;
253 char *delta_plane;
254 int bytes;
255 uint8 *holdp;
256
257 org_plane = (char *) plane;
258 delta_plane = (char *) (enc->dwt_buffer1);
259 fdelta(org_plane, delta_plane, cx, cy);
260 holdp = s->p;
261 stream_write_uint8(s, 0x10); /* flags, RLE */
262 bytes = fpack(delta_plane, cx, cy, s);
263 if (bytes > cx * cy)
264 {
265 LLOGLN(10, ("rfx_encode_plane: too big bytes %d", bytes));
266 s->p = holdp;
267 stream_write_uint8(s, 0); /* flags */
268 memcpy(s->p, plane, cx * cy);
269 s->p += cx * cy;
270 stream_write_uint8(s, 0); /* pad if not RLE */
271 bytes = cx * cy + 2;
272 }
273 else
274 {
275 LLOGLN(10, ("rfx_encode_plane: ok bytes %d", bytes));
276 }
277 return bytes;
278 }
0 /**
1 * librfxcodec: A Remote Desktop Protocol client.
2 * RemoteFX Codec Library
3 *
4 * Copyright 2015 Jay Sorg <jay.sorg@gmail.com>
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 #ifndef __RFXCODEC_ENCODE_ALPHA_H
20 #define __RFXCODEC_ENCODE_ALPHA_H
21
22 int
23 rfx_encode_plane(struct rfxencode *enc, uint8 *plane, int cx, int cy,
24 STREAM *s);
25
26 #endif
27
22 * RemoteFX Codec Library - DWT
33 *
44 * Copyright 2011 Vic Lee
5 * Copyright 2014 Jay Sorg <jay.sorg@gmail.com>
5 * Copyright 2014-2015 Jay Sorg <jay.sorg@gmail.com>
66 *
77 * Licensed under the Apache License, Version 2.0 (the "License");
88 * you may not use this file except in compliance with the License.
150150 {
151151 uint8 *src;
152152 sint16 *l, *h;
153 sint16 s1, s2, s3;
153154 int total_width;
154155 int x, y;
155156 int n;
165166 l = dwt + x;
166167 h = l + subband_width * total_width;
167168 src = in_buffer + x;
168 *h = ((src[total_width] - 128) - (((src[0] - 128) + (src[2 * total_width] - 128)) >> 1)) >> 1;
169 *l = (src[0] - 128) + *h;
169 s1 = (src[total_width] - 128) << DWT_FACTOR;
170 s2 = (src[0] - 128) << DWT_FACTOR;
171 s3 = (src[2 * total_width] - 128) << DWT_FACTOR;
172 *h = (s1 - ((s2 + s3) >> 1)) >> 1;
173 s1 = (src[0] - 128) << DWT_FACTOR;
174 *l = s1 + *h;
170175
171176 /* loop */
172177 for (n = 1; n < subband_width - 1; n++)
175180 l = dwt + n * total_width + x;
176181 h = l + subband_width * total_width;
177182 src = in_buffer + y * total_width + x;
178 *h = ((src[total_width] - 128) - (((src[0] - 128) + (src[2 * total_width] - 128)) >> 1)) >> 1;
179 *l = (src[0] - 128) + ((*(h - total_width) + *h) >> 1);
183 s1 = (src[total_width] - 128) << DWT_FACTOR;
184 s2 = (src[0] - 128) << DWT_FACTOR;
185 s3 = (src[2 * total_width] - 128) << DWT_FACTOR;
186 *h = (s1 - ((s2 + s3) >> 1)) >> 1;
187 s1 = (src[0] - 128) << DWT_FACTOR;
188 *l = s1 + ((*(h - total_width) + *h) >> 1);
180189 }
181190
182191 /* post */
185194 l = dwt + n * total_width + x;
186195 h = l + subband_width * total_width;
187196 src = in_buffer + y * total_width + x;
188 *h = ((src[total_width] - 128) - (((src[0] - 128) + (src[0] - 128)) >> 1)) >> 1;
189 *l = (src[0] - 128) + ((*(h - total_width) + *h) >> 1);
197 s1 = (src[total_width] - 128) << DWT_FACTOR;
198 s2 = (src[0] - 128) << DWT_FACTOR;
199 s3 = (src[0] - 128) << DWT_FACTOR;
200 *h = (s1 - ((s2 + s3) >> 1)) >> 1;
201 s1 = (src[0] - 128) << DWT_FACTOR;
202 *l = s1 + ((*(h - total_width) + *h) >> 1);
190203
191204 }
192205
00 /**
11 * RFX codec encoder
22 *
3 * Copyright 2014 Jay Sorg <jay.sorg@gmail.com>
3 * Copyright 2014-2015 Jay Sorg <jay.sorg@gmail.com>
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
22 * RemoteFX Codec Library - Quantization
33 *
44 * Copyright 2011 Vic Lee
5 * Copyright 2014 Jay Sorg <jay.sorg@gmail.com>
5 * Copyright 2014-2015 Jay Sorg <jay.sorg@gmail.com>
66 *
77 * Licensed under the Apache License, Version 2.0 (the "License");
88 * you may not use this file except in compliance with the License.
8787 }
8888 #endif
8989
90 #if 1
90 #if 0
9191 /******************************************************************************/
9292 static int
9393 rfx_quantization_encode_block(sint16* buffer, int buffer_size, uint32 factor)
109109 }
110110 #endif
111111
112 #if 1
113 /******************************************************************************/
114 static int
115 rfx_quantization_encode_block(sint16* buffer, int buffer_size, uint32 factor)
116 {
117 sint16* dst;
118 sint16 half;
119
120 factor += DWT_FACTOR;
121 if (factor == 0)
122 {
123 return 1;
124 }
125 half = (1 << (factor - 1));
126 for (dst = buffer; buffer_size > 0; dst++, buffer_size--)
127 {
128 *dst = (*dst + half) >> factor;
129 }
130 return 0;
131 }
132 #endif
133
112134 /******************************************************************************/
113135 int
114 rfx_quantization_encode(sint16* buffer, const int* quantization_values)
136 rfx_quantization_encode(sint16* buffer, const char* qtable)
115137 {
116 rfx_quantization_encode_block(buffer, 1024, quantization_values[8] - 6); /* HL1 */
117 rfx_quantization_encode_block(buffer + 1024, 1024, quantization_values[7] - 6); /* LH1 */
118 rfx_quantization_encode_block(buffer + 2048, 1024, quantization_values[9] - 6); /* HH1 */
119 rfx_quantization_encode_block(buffer + 3072, 256, quantization_values[5] - 6); /* HL2 */
120 rfx_quantization_encode_block(buffer + 3328, 256, quantization_values[4] - 6); /* LH2 */
121 rfx_quantization_encode_block(buffer + 3584, 256, quantization_values[6] - 6); /* HH2 */
122 rfx_quantization_encode_block(buffer + 3840, 64, quantization_values[2] - 6); /* HL3 */
123 rfx_quantization_encode_block(buffer + 3904, 64, quantization_values[1] - 6); /* LH3 */
124 rfx_quantization_encode_block(buffer + 3968, 64, quantization_values[3] - 6); /* HH3 */
125 rfx_quantization_encode_block(buffer + 4032, 64, quantization_values[0] - 6); /* LL3 */
138 uint32 factor;
139
140 factor = ((qtable[4] >> 0) & 0xf) - 6;
141 rfx_quantization_encode_block(buffer, 1024, factor); /* HL1 */
142 factor = ((qtable[3] >> 4) & 0xf) - 6;
143 rfx_quantization_encode_block(buffer + 1024, 1024, factor); /* LH1 */
144 factor = ((qtable[4] >> 4) & 0xf) - 6;
145 rfx_quantization_encode_block(buffer + 2048, 1024, factor); /* HH1 */
146 factor = ((qtable[2] >> 4) & 0xf) - 6;
147 rfx_quantization_encode_block(buffer + 3072, 256, factor); /* HL2 */
148 factor = ((qtable[2] >> 0) & 0xf) - 6;
149 rfx_quantization_encode_block(buffer + 3328, 256, factor); /* LH2 */
150 factor = ((qtable[3] >> 0) & 0xf) - 6;
151 rfx_quantization_encode_block(buffer + 3584, 256, factor); /* HH2 */
152 factor = ((qtable[1] >> 0) & 0xf) - 6;
153 rfx_quantization_encode_block(buffer + 3840, 64, factor); /* HL3 */
154 factor = ((qtable[0] >> 4) & 0xf) - 6;
155 rfx_quantization_encode_block(buffer + 3904, 64, factor); /* LH3 */
156 factor = ((qtable[1] >> 4) & 0xf) - 6;
157 rfx_quantization_encode_block(buffer + 3968, 64, factor); /* HH3 */
158 factor = ((qtable[0] >> 0) & 0xf) - 6;
159 rfx_quantization_encode_block(buffer + 4032, 64, factor); /* LL3 */
126160 return 0;
127161 }
128162
2222 #include "rfxcommon.h"
2323
2424 int
25 rfx_quantization_encode(sint16* buffer, const int* quantization_values);
25 rfx_quantization_encode(sint16 *buffer, const char *quantization_values);
2626
2727 #endif /* __RFX_QUANTIZATION_H */
123123 } while (0)
124124
125125 int
126 rfx_rlgr1_encode(const sint16* data, int data_size, uint8* buffer, int buffer_size)
126 rfx_rlgr1_encode(const sint16* data, uint8* buffer, int buffer_size)
127127 {
128128 int k;
129129 int kp;
136136 int sign;
137137 int processed_size;
138138 int lmag;
139 int data_size;
139140
140141 RFX_BITSTREAM bs;
141142
149150 krp = 1 << LSGR;
150151
151152 /* process all the input coefficients */
153 data_size = 4096;
152154 while (data_size > 0)
153155 {
154156 if (k)
2222 #include "rfxcommon.h"
2323
2424 int
25 rfx_rlgr1_encode(const sint16* data, int data_size, uint8* buffer, int buffer_size);
25 rfx_rlgr1_encode(const sint16* data, uint8* buffer, int buffer_size);
2626
2727 #endif /* __RFX_RLGR_H */
123123 } while (0)
124124
125125 int
126 rfx_rlgr3_encode(const sint16* data, int data_size, uint8* buffer, int buffer_size)
126 rfx_rlgr3_encode(const sint16* data, uint8* buffer, int buffer_size)
127127 {
128128 int k;
129129 int kp;
136136 int sign;
137137 int processed_size;
138138 int lmag;
139 int data_size;
139140
140141 RFX_BITSTREAM bs;
141142
152153 krp = 1 << LSGR;
153154
154155 /* process all the input coefficients */
156 data_size = 4096;
155157 while (data_size > 0)
156158 {
157159 if (k)
2222 #include "rfxcommon.h"
2323
2424 int
25 rfx_rlgr3_encode(const sint16* data, int data_size, uint8* buffer, int buffer_size);
25 rfx_rlgr3_encode(const sint16* data, uint8* buffer, int buffer_size);
2626
2727 #endif /* __RFX_RLGR_H */
22 * RemoteFX Codec Library - Encode
33 *
44 * Copyright 2011 Vic Lee
5 * Copyright 2014 Jay Sorg <jay.sorg@gmail.com>
5 * Copyright 2014-2015 Jay Sorg <jay.sorg@gmail.com>
66 *
77 * Licensed under the Apache License, Version 2.0 (the "License");
88 * you may not use this file except in compliance with the License.
3232 #include "rfxencode_differential.h"
3333 #include "rfxencode_rlgr1.h"
3434 #include "rfxencode_rlgr3.h"
35 #include "rfxencode_alpha.h"
3536
3637 #ifdef RFX_USE_ACCEL_X86
3738 #include "x86/funcs_x86.h"
5758 uint8 r;
5859 uint8 g;
5960 uint8 b;
60
61 uint8 *lr_buf;
62 uint8 *lg_buf;
63 uint8 *lb_buf;
64
65 LLOGLN(10, ("rfx_encode_format_rgb: pixel_format %d", pixel_format));
66 b = 0;
67 g = 0;
68 r = 0;
6169 switch (pixel_format)
6270 {
6371 case RFX_FORMAT_BGRA:
6472 for (y = 0; y < height; y++)
6573 {
6674 src = (uint8*) (rgb_data + y * stride_bytes);
75 lr_buf = r_buf + y * 64;
76 lg_buf = g_buf + y * 64;
77 lb_buf = b_buf + y * 64;
6778 for (x = 0; x < width; x++)
6879 {
6980 b = *src++;
70 *b_buf++ = b;
81 *lb_buf++ = b;
7182 g = *src++;
72 *g_buf++ = g;
83 *lg_buf++ = g;
7384 r = *src++;
74 *r_buf++ = r;
85 *lr_buf++ = r;
7586 src++;
7687 }
88 while (x < 64)
89 {
90 *lr_buf++ = r;
91 *lg_buf++ = g;
92 *lb_buf++ = r;
93 x++;
94 }
95 }
96 while (y < 64)
97 {
98 lr_buf = r_buf + y * 64;
99 lg_buf = g_buf + y * 64;
100 lb_buf = b_buf + y * 64;
101 memcpy(lr_buf, lr_buf - 64, 64);
102 memcpy(lg_buf, lg_buf - 64, 64);
103 memcpy(lb_buf, lb_buf - 64, 64);
104 y++;
77105 }
78106 break;
79107 case RFX_FORMAT_RGBA:
80108 for (y = 0; y < height; y++)
81109 {
82110 src = (uint8*) (rgb_data + y * stride_bytes);
111 lr_buf = r_buf + y * 64;
112 lg_buf = g_buf + y * 64;
113 lb_buf = b_buf + y * 64;
83114 for (x = 0; x < width; x++)
84115 {
85116 r = *src++;
86 *r_buf++ = r;
117 *lr_buf++ = r;
87118 g = *src++;
88 *g_buf++ = g;
119 *lg_buf++ = g;
89120 b = *src++;
90 *b_buf++ = b;
121 *lb_buf++ = b;
91122 src++;
92123 }
124 while (x < 64)
125 {
126 *lr_buf++ = r;
127 *lg_buf++ = g;
128 *lb_buf++ = b;
129 x++;
130 }
131 }
132 while (y < 64)
133 {
134 lr_buf = r_buf + y * 64;
135 lg_buf = g_buf + y * 64;
136 lb_buf = b_buf + y * 64;
137 memcpy(lr_buf, lr_buf - 64, 64);
138 memcpy(lg_buf, lg_buf - 64, 64);
139 memcpy(lb_buf, lb_buf - 64, 64);
140 y++;
93141 }
94142 break;
95143 case RFX_FORMAT_BGR:
96144 for (y = 0; y < height; y++)
97145 {
98146 src = (uint8*) (rgb_data + y * stride_bytes);
147 lr_buf = r_buf + y * 64;
148 lg_buf = g_buf + y * 64;
149 lb_buf = b_buf + y * 64;
99150 for (x = 0; x < width; x++)
100151 {
101152 b = *src++;
102 *b_buf++ = b;
153 *lb_buf++ = b;
103154 g = *src++;
104 *g_buf++ = g;
155 *lg_buf++ = g;
105156 r = *src++;
106 *r_buf++ = r;
107 }
157 *lr_buf++ = r;
158 }
159 while (x < 64)
160 {
161 *lr_buf++ = r;
162 *lg_buf++ = g;
163 *lb_buf++ = b;
164 x++;
165 }
166 }
167 while (y < 64)
168 {
169 lr_buf = r_buf + y * 64;
170 lg_buf = g_buf + y * 64;
171 lb_buf = b_buf + y * 64;
172 memcpy(lr_buf, lr_buf - 64, 64);
173 memcpy(lg_buf, lg_buf - 64, 64);
174 memcpy(lb_buf, lb_buf - 64, 64);
175 y++;
108176 }
109177 break;
110178 case RFX_FORMAT_RGB:
111179 for (y = 0; y < height; y++)
112180 {
113181 src = (uint8*) (rgb_data + y * stride_bytes);
182 lr_buf = r_buf + y * 64;
183 lg_buf = g_buf + y * 64;
184 lb_buf = b_buf + y * 64;
114185 for (x = 0; x < width; x++)
115186 {
116187 r = *src++;
117 *r_buf++ = r;
188 *lr_buf++ = r;
118189 g = *src++;
119 *g_buf++ = g;
190 *lg_buf++ = g;
120191 b = *src++;
121 *b_buf++ = b;
122 }
192 *lb_buf++ = b;
193 }
194 while (x < 64)
195 {
196 *lr_buf++ = r;
197 *lg_buf++ = g;
198 *lb_buf++ = b;
199 x++;
200 }
201 }
202 while (y < 64)
203 {
204 lr_buf = r_buf + y * 64;
205 lg_buf = g_buf + y * 64;
206 lb_buf = b_buf + y * 64;
207 memcpy(lr_buf, lr_buf - 64, 64);
208 memcpy(lg_buf, lg_buf - 64, 64);
209 memcpy(lb_buf, lb_buf - 64, 64);
210 y++;
211 }
212 break;
213 }
214 return 0;
215 }
216
217 /******************************************************************************/
218 static int
219 rfx_encode_format_argb(char *argb_data, int width, int height,
220 int stride_bytes, int pixel_format,
221 uint8 *a_buf, uint8 *r_buf, uint8 *g_buf, uint8 *b_buf)
222 {
223 int x;
224 int y;
225 const uint8 *src;
226 uint8 a;
227 uint8 r;
228 uint8 g;
229 uint8 b;
230 uint8 *la_buf;
231 uint8 *lr_buf;
232 uint8 *lg_buf;
233 uint8 *lb_buf;
234
235 LLOGLN(10, ("rfx_encode_format_argb: pixel_format %d", pixel_format));
236 b = 0;
237 g = 0;
238 r = 0;
239 a = 0;
240 switch (pixel_format)
241 {
242 case RFX_FORMAT_BGRA:
243 for (y = 0; y < height; y++)
244 {
245 src = (uint8*) (argb_data + y * stride_bytes);
246 la_buf = a_buf + y * 64;
247 lr_buf = r_buf + y * 64;
248 lg_buf = g_buf + y * 64;
249 lb_buf = b_buf + y * 64;
250 for (x = 0; x < width; x++)
251 {
252 b = *src++;
253 *lb_buf++ = b;
254 g = *src++;
255 *lg_buf++ = g;
256 r = *src++;
257 *lr_buf++ = r;
258 a = *src++;
259 *la_buf++ = a;
260 }
261 while (x < 64)
262 {
263 *la_buf++ = a;
264 *lr_buf++ = r;
265 *lg_buf++ = g;
266 *lb_buf++ = r;
267 x++;
268 }
269 }
270 while (y < 64)
271 {
272 la_buf = a_buf + y * 64;
273 lr_buf = r_buf + y * 64;
274 lg_buf = g_buf + y * 64;
275 lb_buf = b_buf + y * 64;
276 memcpy(la_buf, la_buf - 64, 64);
277 memcpy(lr_buf, lr_buf - 64, 64);
278 memcpy(lg_buf, lg_buf - 64, 64);
279 memcpy(lb_buf, lb_buf - 64, 64);
280 y++;
281 }
282 break;
283 case RFX_FORMAT_RGBA:
284 for (y = 0; y < height; y++)
285 {
286 src = (uint8*) (argb_data + y * stride_bytes);
287 la_buf = a_buf + y * 64;
288 lr_buf = r_buf + y * 64;
289 lg_buf = g_buf + y * 64;
290 lb_buf = b_buf + y * 64;
291 for (x = 0; x < width; x++)
292 {
293 r = *src++;
294 *lr_buf++ = r;
295 g = *src++;
296 *lg_buf++ = g;
297 b = *src++;
298 *lb_buf++ = b;
299 a = *src++;
300 *la_buf++ = a;
301 }
302 while (x < 64)
303 {
304 *la_buf++ = a;
305 *lr_buf++ = r;
306 *lg_buf++ = g;
307 *lb_buf++ = b;
308 x++;
309 }
310 }
311 while (y < 64)
312 {
313 la_buf = a_buf + y * 64;
314 lr_buf = r_buf + y * 64;
315 lg_buf = g_buf + y * 64;
316 lb_buf = b_buf + y * 64;
317 memcpy(la_buf, la_buf - 64, 64);
318 memcpy(lr_buf, lr_buf - 64, 64);
319 memcpy(lg_buf, lg_buf - 64, 64);
320 memcpy(lb_buf, lb_buf - 64, 64);
321 y++;
322 }
323 break;
324 case RFX_FORMAT_BGR:
325 for (y = 0; y < height; y++)
326 {
327 src = (uint8*) (argb_data + y * stride_bytes);
328 lr_buf = r_buf + y * 64;
329 lg_buf = g_buf + y * 64;
330 lb_buf = b_buf + y * 64;
331 for (x = 0; x < width; x++)
332 {
333 b = *src++;
334 *lb_buf++ = b;
335 g = *src++;
336 *lg_buf++ = g;
337 r = *src++;
338 *lr_buf++ = r;
339 }
340 while (x < 64)
341 {
342 *lr_buf++ = r;
343 *lg_buf++ = g;
344 *lb_buf++ = b;
345 x++;
346 }
347 }
348 while (y < 64)
349 {
350 lr_buf = r_buf + y * 64;
351 lg_buf = g_buf + y * 64;
352 lb_buf = b_buf + y * 64;
353 memcpy(lr_buf, lr_buf - 64, 64);
354 memcpy(lg_buf, lg_buf - 64, 64);
355 memcpy(lb_buf, lb_buf - 64, 64);
356 y++;
357 }
358 break;
359 case RFX_FORMAT_RGB:
360 for (y = 0; y < height; y++)
361 {
362 src = (uint8*) (argb_data + y * stride_bytes);
363 lr_buf = r_buf + y * 64;
364 lg_buf = g_buf + y * 64;
365 lb_buf = b_buf + y * 64;
366 for (x = 0; x < width; x++)
367 {
368 r = *src++;
369 *lr_buf++ = r;
370 g = *src++;
371 *lg_buf++ = g;
372 b = *src++;
373 *lb_buf++ = b;
374 }
375 while (x < 64)
376 {
377 *lr_buf++ = r;
378 *lg_buf++ = g;
379 *lb_buf++ = b;
380 x++;
381 }
382 }
383 while (y < 64)
384 {
385 lr_buf = r_buf + y * 64;
386 lg_buf = g_buf + y * 64;
387 lb_buf = b_buf + y * 64;
388 memcpy(lr_buf, lr_buf - 64, 64);
389 memcpy(lg_buf, lg_buf - 64, 64);
390 memcpy(lb_buf, lb_buf - 64, 64);
391 y++;
123392 }
124393 break;
125394 }
138407 -11071 -21736 32807
139408 32756 -27429 -5327 */
140409 static int
141 rfx_encode_rgb_to_ycbcr(uint8 *y_r_buf, uint8 *cb_g_buf, uint8 *cr_b_buf)
410 rfx_encode_rgb_to_yuv(uint8 *y_r_buf, uint8 *u_g_buf, uint8 *v_b_buf)
142411 {
143412 int i;
144413 sint32 r, g, b;
145 sint32 y, cb, cr;
414 sint32 y, u, v;
146415
147416 for (i = 0; i < 4096; i++)
148417 {
149418 r = y_r_buf[i];
150 g = cb_g_buf[i];
151 b = cr_b_buf[i];
152
153 y = (r * 19595 + g * 38470 + b * 7471) >> 16;
154 cb = (r * -11071 + g * -21736 + b * 32807) >> 16;
155 cr = (r * 32756 + g * -27429 + b * -5327) >> 16;
419 g = u_g_buf[i];
420 b = v_b_buf[i];
421
422 y = (r * 19595 + g * 38470 + b * 7471) >> 16;
423 u = (r * -11071 + g * -21736 + b * 32807) >> 16;
424 v = (r * 32756 + g * -27429 + b * -5327) >> 16;
156425
157426 y_r_buf[i] = MINMAX(y, 0, 255);
158 cb_g_buf[i] = MINMAX(cb + 128, 0, 255);
159 cr_b_buf[i] = MINMAX(cr + 128, 0, 255);
160
161 }
162 return 0;
163 }
164
165 /******************************************************************************/
166 int
167 rfx_encode_component_rlgr1(struct rfxencode *enc, const int *quantization_values,
427 u_g_buf[i] = MINMAX(u + 128, 0, 255);
428 v_b_buf[i] = MINMAX(v + 128, 0, 255);
429
430 }
431 return 0;
432 }
433
434 /******************************************************************************/
435 int
436 rfx_encode_component_rlgr1(struct rfxencode *enc, const char *qtable,
168437 uint8 *data, uint8 *buffer, int buffer_size, int *size)
169438 {
439 LLOGLN(10, ("rfx_encode_component_rlgr1:"));
170440 if (rfx_dwt_2d_encode(data, enc->dwt_buffer1, enc->dwt_buffer) != 0)
171441 {
172442 return 1;
173443 }
174 if (rfx_quantization_encode(enc->dwt_buffer1, quantization_values) != 0)
175 {
176 return 1;
177 }
178 if (rfx_differential_encode(enc->dwt_buffer1 + 4032, 64) != 0)
179 {
180 return 1;
181 }
182 *size = rfx_rlgr1_encode(enc->dwt_buffer1, 4096, buffer, buffer_size);
183 return 0;
184 }
185
186 /******************************************************************************/
187 int
188 rfx_encode_component_rlgr3(struct rfxencode *enc, const int *quantization_values,
444 if (rfx_quantization_encode(enc->dwt_buffer1, qtable) != 0)
445 {
446 return 1;
447 }
448 if (rfx_differential_encode(enc->dwt_buffer1 + 4032, 64) != 0)
449 {
450 return 1;
451 }
452 *size = rfx_rlgr1_encode(enc->dwt_buffer1, buffer, buffer_size);
453 return 0;
454 }
455
456 /******************************************************************************/
457 int
458 rfx_encode_component_rlgr3(struct rfxencode *enc, const char *qtable,
189459 uint8 *data, uint8 *buffer, int buffer_size, int *size)
190460 {
461 LLOGLN(10, ("rfx_encode_component_rlgr3:"));
191462 if (rfx_dwt_2d_encode(data, enc->dwt_buffer1, enc->dwt_buffer) != 0)
192463 {
193464 return 1;
194465 }
195 if (rfx_quantization_encode(enc->dwt_buffer1, quantization_values) != 0)
196 {
197 return 1;
198 }
199 if (rfx_differential_encode(enc->dwt_buffer1 + 4032, 64) != 0)
200 {
201 return 1;
202 }
203 *size = rfx_rlgr3_encode(enc->dwt_buffer1, 4096, buffer, buffer_size);
204 return 0;
205 }
206
207 /******************************************************************************/
208 int
209 rfx_encode_component_rlgr1_x86_sse2(struct rfxencode *enc,
210 const int *quantization_values,
466 if (rfx_quantization_encode(enc->dwt_buffer1, qtable) != 0)
467 {
468 return 1;
469 }
470 if (rfx_differential_encode(enc->dwt_buffer1 + 4032, 64) != 0)
471 {
472 return 1;
473 }
474 *size = rfx_rlgr3_encode(enc->dwt_buffer1, buffer, buffer_size);
475 return 0;
476 }
477
478 /******************************************************************************/
479 int
480 rfx_encode_component_rlgr1_x86_sse2(struct rfxencode *enc, const char *qtable,
211481 uint8 *data,
212482 uint8 *buffer, int buffer_size, int *size)
213483 {
214484 LLOGLN(10, ("rfx_encode_component_rlgr1_x86_sse2:"));
215485 #if defined(RFX_USE_ACCEL_X86)
216 if (dwt_shift_x86_sse2(quantization_values, data, enc->dwt_buffer1,
217 enc->dwt_buffer) != 0)
218 {
219 return 1;
220 }
221 *size = diff_rlgr1_x86(enc->dwt_buffer1, 4096, buffer, buffer_size);
222 #endif
223 return 0;
224 }
225
226 /******************************************************************************/
227 int
228 rfx_encode_component_rlgr3_x86_sse2(struct rfxencode *enc,
229 const int *quantization_values,
486 if (rfxcodec_encode_dwt_shift_x86_sse2(qtable, data, enc->dwt_buffer1,
487 enc->dwt_buffer) != 0)
488 {
489 return 1;
490 }
491 //*size = rfxcodec_encode_diff_rlgr1_x86_sse2(enc->dwt_buffer1,
492 // buffer, buffer_size);
493 if (rfx_differential_encode(enc->dwt_buffer1 + 4032, 64) != 0)
494 {
495 return 1;
496 }
497 *size = rfx_rlgr1_encode(enc->dwt_buffer1, buffer, buffer_size);
498 #endif
499 return 0;
500 }
501
502 /******************************************************************************/
503 int
504 rfx_encode_component_rlgr3_x86_sse2(struct rfxencode *enc, const char *qtable,
230505 uint8 *data,
231506 uint8 *buffer, int buffer_size, int *size)
232507 {
233508 LLOGLN(10, ("rfx_encode_component_rlgr3_x86_sse2:"));
234509 #if defined(RFX_USE_ACCEL_X86)
235 if (dwt_shift_x86_sse2(quantization_values, data, enc->dwt_buffer1,
236 enc->dwt_buffer) != 0)
237 {
238 return 1;
239 }
240 *size = diff_rlgr3_x86(enc->dwt_buffer1, 4096, buffer, buffer_size);
241 #endif
242 return 0;
243 }
244
245 /******************************************************************************/
246 int
247 rfx_encode_component_rlgr1_amd64_sse2(struct rfxencode *enc,
248 const int *quantization_values,
510 if (rfxcodec_encode_dwt_shift_x86_sse2(qtable, data, enc->dwt_buffer1,
511 enc->dwt_buffer) != 0)
512 {
513 return 1;
514 }
515 //*size = rfxcodec_encode_diff_rlgr3_x86_sse2(enc->dwt_buffer1,
516 // buffer, buffer_size);
517 if (rfx_differential_encode(enc->dwt_buffer1 + 4032, 64) != 0)
518 {
519 return 1;
520 }
521 *size = rfx_rlgr3_encode(enc->dwt_buffer1, buffer, buffer_size);
522 #endif
523 return 0;
524 }
525
526 /******************************************************************************/
527 int
528 rfx_encode_component_rlgr1_x86_sse41(struct rfxencode *enc, const char *qtable,
529 uint8 *data,
530 uint8 *buffer, int buffer_size, int *size)
531 {
532 LLOGLN(10, ("rfx_encode_component_rlgr1_x86_sse41:"));
533 #if defined(RFX_USE_ACCEL_X86)
534 if (rfxcodec_encode_dwt_shift_x86_sse41(qtable, data, enc->dwt_buffer1,
535 enc->dwt_buffer) != 0)
536 {
537 return 1;
538 }
539 //*size = rfxcodec_encode_diff_rlgr1_x86_sse2(enc->dwt_buffer1,
540 // buffer, buffer_size);
541 if (rfx_differential_encode(enc->dwt_buffer1 + 4032, 64) != 0)
542 {
543 return 1;
544 }
545 *size = rfx_rlgr1_encode(enc->dwt_buffer1, buffer, buffer_size);
546 #endif
547 return 0;
548 }
549
550 /******************************************************************************/
551 int
552 rfx_encode_component_rlgr3_x86_sse41(struct rfxencode *enc, const char *qtable,
553 uint8 *data,
554 uint8 *buffer, int buffer_size, int *size)
555 {
556 LLOGLN(10, ("rfx_encode_component_rlgr3_x86_sse41:"));
557 #if defined(RFX_USE_ACCEL_X86)
558 if (rfxcodec_encode_dwt_shift_x86_sse41(qtable, data, enc->dwt_buffer1,
559 enc->dwt_buffer) != 0)
560 {
561 return 1;
562 }
563 //*size = rfxcodec_encode_diff_rlgr3_x86_sse(enc->dwt_buffer1,
564 // buffer, buffer_size);
565 if (rfx_differential_encode(enc->dwt_buffer1 + 4032, 64) != 0)
566 {
567 return 1;
568 }
569 *size = rfx_rlgr3_encode(enc->dwt_buffer1, buffer, buffer_size);
570 #endif
571 return 0;
572 }
573
574 /******************************************************************************/
575 int
576 rfx_encode_component_rlgr1_amd64_sse2(struct rfxencode *enc, const char *qtable,
249577 uint8 *data,
250578 uint8 *buffer, int buffer_size, int *size)
251579 {
252580 LLOGLN(10, ("rfx_encode_component_rlgr1_amd64_sse2:"));
253581 #if defined(RFX_USE_ACCEL_AMD64)
254 if (dwt_shift_amd64_sse2(quantization_values, data, enc->dwt_buffer1,
255 enc->dwt_buffer) != 0)
256 {
257 return 1;
258 }
259 *size = diff_rlgr1_amd64(enc->dwt_buffer1, 4096, buffer, buffer_size);
260 #endif
261 return 0;
262 }
263
264 /******************************************************************************/
265 int
266 rfx_encode_component_rlgr3_amd64_sse2(struct rfxencode *enc,
267 const int *quantization_values,
582 if (rfxcodec_encode_dwt_shift_amd64_sse2(qtable, data, enc->dwt_buffer1,
583 enc->dwt_buffer) != 0)
584 {
585 return 1;
586 }
587 //*size = rfxcodec_encode_diff_rlgr1_amd64_sse2(enc->dwt_buffer1,
588 // buffer, buffer_size);
589 if (rfx_differential_encode(enc->dwt_buffer1 + 4032, 64) != 0)
590 {
591 return 1;
592 }
593 *size = rfx_rlgr1_encode(enc->dwt_buffer1, buffer, buffer_size);
594 #endif
595 return 0;
596 }
597
598 /******************************************************************************/
599 int
600 rfx_encode_component_rlgr3_amd64_sse2(struct rfxencode *enc, const char *qtable,
268601 uint8 *data,
269602 uint8 *buffer, int buffer_size, int *size)
270603 {
271604 LLOGLN(10, ("rfx_encode_component_rlgr3_amd64_sse2:"));
272605 #if defined(RFX_USE_ACCEL_AMD64)
273 if (dwt_shift_amd64_sse2(quantization_values, data, enc->dwt_buffer1,
274 enc->dwt_buffer) != 0)
275 {
276 return 1;
277 }
278 *size = diff_rlgr3_amd64(enc->dwt_buffer1, 4096, buffer, buffer_size);
606 if (rfxcodec_encode_dwt_shift_amd64_sse2(qtable, data, enc->dwt_buffer1,
607 enc->dwt_buffer) != 0)
608 {
609 return 1;
610 }
611 //*size = rfxcodec_encode_diff_rlgr3_amd64_sse2(enc->dwt_buffer1,
612 // buffer, buffer_size);
613 if (rfx_differential_encode(enc->dwt_buffer1 + 4032, 64) != 0)
614 {
615 return 1;
616 }
617 *size = rfx_rlgr3_encode(enc->dwt_buffer1, buffer, buffer_size);
618 #endif
619 return 0;
620 }
621
622 /******************************************************************************/
623 int
624 rfx_encode_component_rlgr1_amd64_sse41(struct rfxencode *enc, const char *qtable,
625 uint8 *data,
626 uint8 *buffer, int buffer_size, int *size)
627 {
628 LLOGLN(10, ("rfx_encode_component_rlgr1_amd64_sse2:"));
629 #if defined(RFX_USE_ACCEL_AMD64)
630 if (rfxcodec_encode_dwt_shift_amd64_sse41(qtable, data, enc->dwt_buffer1,
631 enc->dwt_buffer) != 0)
632 {
633 return 1;
634 }
635 //*size = rfxcodec_encode_diff_rlgr1_amd64_sse2(enc->dwt_buffer1,
636 // buffer, buffer_size);
637 if (rfx_differential_encode(enc->dwt_buffer1 + 4032, 64) != 0)
638 {
639 return 1;
640 }
641 *size = rfx_rlgr1_encode(enc->dwt_buffer1, buffer, buffer_size);
642 #endif
643 return 0;
644 }
645
646 /******************************************************************************/
647 int
648 rfx_encode_component_rlgr3_amd64_sse41(struct rfxencode *enc, const char *qtable,
649 uint8 *data,
650 uint8 *buffer, int buffer_size, int *size)
651 {
652 LLOGLN(10, ("rfx_encode_component_rlgr3_amd64_sse2:"));
653 #if defined(RFX_USE_ACCEL_AMD64)
654 if (rfxcodec_encode_dwt_shift_amd64_sse41(qtable, data, enc->dwt_buffer1,
655 enc->dwt_buffer) != 0)
656 {
657 return 1;
658 }
659 //*size = rfxcodec_encode_diff_rlgr3_amd64_sse2(enc->dwt_buffer1,
660 // buffer, buffer_size);
661 if (rfx_differential_encode(enc->dwt_buffer1 + 4032, 64) != 0)
662 {
663 return 1;
664 }
665 *size = rfx_rlgr3_encode(enc->dwt_buffer1, buffer, buffer_size);
279666 #endif
280667 return 0;
281668 }
284671 int
285672 rfx_encode_rgb(struct rfxencode *enc, char *rgb_data,
286673 int width, int height, int stride_bytes,
287 const int *y_quants, const int *cb_quants, const int *cr_quants,
288 STREAM *data_out, int *y_size, int *cb_size, int *cr_size)
674 const char *y_quants, const char *u_quants,
675 const char *v_quants,
676 STREAM *data_out, int *y_size, int *u_size, int *v_size)
289677 {
290678 uint8 *y_r_buffer;
291 uint8 *cb_g_buffer;
292 uint8 *cr_b_buffer;
679 uint8 *u_g_buffer;
680 uint8 *v_b_buffer;
293681
294682 y_r_buffer = enc->y_r_buffer;
295 cb_g_buffer = enc->cb_g_buffer;
296 cr_b_buffer = enc->cr_b_buffer;
683 u_g_buffer = enc->u_g_buffer;
684 v_b_buffer = enc->v_b_buffer;
297685 if (rfx_encode_format_rgb(rgb_data, width, height, stride_bytes,
298686 enc->format,
299 y_r_buffer, cb_g_buffer, cr_b_buffer) != 0)
300 {
301 return 1;
302 }
303 if (rfx_encode_rgb_to_ycbcr(y_r_buffer, cb_g_buffer, cr_b_buffer) != 0)
687 y_r_buffer, u_g_buffer, v_b_buffer) != 0)
688 {
689 return 1;
690 }
691 if (rfx_encode_rgb_to_yuv(y_r_buffer, u_g_buffer, v_b_buffer) != 0)
304692 {
305693 return 1;
306694 }
313701 }
314702 LLOGLN(10, ("rfx_encode_rgb: y_size %d", *y_size));
315703 stream_seek(data_out, *y_size);
316 if (enc->rfx_encode(enc, cb_quants, cb_g_buffer,
317 stream_get_tail(data_out),
318 stream_get_left(data_out),
319 cb_size) != 0)
320 {
321 return 1;
322 }
323 LLOGLN(10, ("rfx_encode_rgb: cb_size %d", *cb_size));
324 stream_seek(data_out, *cb_size);
325 if (enc->rfx_encode(enc, cr_quants, cr_b_buffer,
326 stream_get_tail(data_out),
327 stream_get_left(data_out),
328 cr_size) != 0)
329 {
330 return 1;
331 }
332 LLOGLN(10, ("rfx_encode_rgb: cr_size %d", *cr_size));
333 stream_seek(data_out, *cr_size);
704 if (enc->rfx_encode(enc, u_quants, u_g_buffer,
705 stream_get_tail(data_out),
706 stream_get_left(data_out),
707 u_size) != 0)
708 {
709 return 1;
710 }
711 LLOGLN(10, ("rfx_encode_rgb: u_size %d", *u_size));
712 stream_seek(data_out, *u_size);
713 if (enc->rfx_encode(enc, v_quants, v_b_buffer,
714 stream_get_tail(data_out),
715 stream_get_left(data_out),
716 v_size) != 0)
717 {
718 return 1;
719 }
720 LLOGLN(10, ("rfx_encode_rgb: v_size %d", *v_size));
721 stream_seek(data_out, *v_size);
722 return 0;
723 }
724
725 /******************************************************************************/
726 int
727 rfx_encode_argb(struct rfxencode *enc, char *rgb_data,
728 int width, int height, int stride_bytes,
729 const char *y_quants, const char *u_quants,
730 const char *v_quants,
731 STREAM *data_out, int *y_size, int *u_size,
732 int *v_size, int *a_size)
733 {
734 uint8 *a_buffer;
735 uint8 *y_r_buffer;
736 uint8 *u_g_buffer;
737 uint8 *v_b_buffer;
738
739 LLOGLN(10, ("rfx_encode_argb:"));
740 a_buffer = enc->a_buffer;
741 y_r_buffer = enc->y_r_buffer;
742 u_g_buffer = enc->u_g_buffer;
743 v_b_buffer = enc->v_b_buffer;
744 if (rfx_encode_format_argb(rgb_data, width, height, stride_bytes,
745 enc->format,
746 a_buffer, y_r_buffer,
747 u_g_buffer, v_b_buffer) != 0)
748 {
749 return 1;
750 }
751 if (rfx_encode_rgb_to_yuv(y_r_buffer, u_g_buffer, v_b_buffer) != 0)
752 {
753 return 1;
754 }
755 if (enc->rfx_encode(enc, y_quants, y_r_buffer,
756 stream_get_tail(data_out),
757 stream_get_left(data_out),
758 y_size) != 0)
759 {
760 return 1;
761 }
762 LLOGLN(10, ("rfx_encode_rgb: y_size %d", *y_size));
763 stream_seek(data_out, *y_size);
764 if (enc->rfx_encode(enc, u_quants, u_g_buffer,
765 stream_get_tail(data_out),
766 stream_get_left(data_out),
767 u_size) != 0)
768 {
769 return 1;
770 }
771 LLOGLN(10, ("rfx_encode_rgb: u_size %d", *u_size));
772 stream_seek(data_out, *u_size);
773 if (enc->rfx_encode(enc, v_quants, v_b_buffer,
774 stream_get_tail(data_out),
775 stream_get_left(data_out),
776 v_size) != 0)
777 {
778 return 1;
779 }
780 LLOGLN(10, ("rfx_encode_rgb: v_size %d", *v_size));
781 stream_seek(data_out, *v_size);
782 *a_size = rfx_encode_plane(enc, a_buffer, 64, 64, data_out);
334783 return 0;
335784 }
336785
338787 int
339788 rfx_encode_yuv(struct rfxencode *enc, char *yuv_data,
340789 int width, int height, int stride_bytes,
341 const int *y_quants, const int *u_quants, const int *v_quants,
790 const char *y_quants, const char *u_quants,
791 const char *v_quants,
342792 STREAM *data_out, int *y_size, int *u_size, int *v_size)
343793 {
344794 uint8 *y_buffer;
374824 stream_seek(data_out, *v_size);
375825 return 0;
376826 }
827
828 /******************************************************************************/
829 int
830 rfx_encode_yuva(struct rfxencode *enc, char *yuva_data,
831 int width, int height, int stride_bytes,
832 const char *y_quants, const char *u_quants,
833 const char *v_quants,
834 STREAM *data_out, int *y_size, int *u_size,
835 int *v_size, int *a_size)
836 {
837 uint8 *y_buffer;
838 uint8 *u_buffer;
839 uint8 *v_buffer;
840 uint8 *a_buffer;
841
842 y_buffer = (uint8 *) yuva_data;
843 u_buffer = (uint8 *) (yuva_data + RFX_YUV_BTES);
844 v_buffer = (uint8 *) (yuva_data + RFX_YUV_BTES * 2);
845 a_buffer = (uint8 *) (yuva_data + RFX_YUV_BTES * 3);
846 if (enc->rfx_encode(enc, y_quants, y_buffer,
847 stream_get_tail(data_out),
848 stream_get_left(data_out),
849 y_size) != 0)
850 {
851 return 1;
852 }
853 stream_seek(data_out, *y_size);
854 if (enc->rfx_encode(enc, u_quants, u_buffer,
855 stream_get_tail(data_out),
856 stream_get_left(data_out),
857 u_size) != 0)
858 {
859 return 1;
860 }
861 stream_seek(data_out, *u_size);
862 if (enc->rfx_encode(enc, v_quants, v_buffer,
863 stream_get_tail(data_out),
864 stream_get_left(data_out),
865 v_size) != 0)
866 {
867 return 1;
868 }
869 stream_seek(data_out, *v_size);
870 *a_size = rfx_encode_plane(enc, a_buffer, 64, 64, data_out);
871 return 0;
872 }
873
22 * RemoteFX Codec Library - Encode
33 *
44 * Copyright 2011 Vic Lee
5 * Copyright 2014 Jay Sorg <jay.sorg@gmail.com>
5 * Copyright 2014-2015 Jay Sorg <jay.sorg@gmail.com>
66 *
77 * Licensed under the Apache License, Version 2.0 (the "License");
88 * you may not use this file except in compliance with the License.
2626 #define RFX_YUV_BTES (64 * 64)
2727
2828 int
29 rfx_encode_component_rlgr1(struct rfxencode *enc,
30 const int *quantization_values,
29 rfx_encode_component_rlgr1(struct rfxencode *enc, const char *qtable,
3130 uint8 *data,
3231 uint8 *buffer, int buffer_size, int *size);
3332 int
34 rfx_encode_component_rlgr3(struct rfxencode *enc,
35 const int *quantization_values,
33 rfx_encode_component_rlgr3(struct rfxencode *enc, const char *qtable,
3634 uint8 *data,
3735 uint8 *buffer, int buffer_size, int *size);
3836 int
39 rfx_encode_component_rlgr1_x86_sse2(struct rfxencode *enc,
40 const int *quantization_values,
37 rfx_encode_rgb(struct rfxencode *enc, char *rgb_data,
38 int width, int height, int stride_bytes,
39 const char *y_quants, const char *u_quants,
40 const char *v_quants,
41 STREAM *data_out, int *y_size, int *cb_size, int *cr_size);
42 int
43 rfx_encode_argb(struct rfxencode *enc, char *argb_data,
44 int width, int height, int stride_bytes,
45 const char *y_quants, const char *cb_quants,
46 const char *cr_quants,
47 STREAM *data_out, int *y_size, int *u_size,
48 int *v_size, int *a_size);
49 int
50 rfx_encode_yuv(struct rfxencode *enc, char *yuv_data,
51 int width, int height, int stride_bytes,
52 const char *y_quants, const char *u_quants,
53 const char *v_quants,
54 STREAM *data_out, int *y_size, int *u_size, int *v_size);
55 int
56 rfx_encode_yuva(struct rfxencode *enc, char *yuv_data,
57 int width, int height, int stride_bytes,
58 const char *y_quants, const char *u_quants,
59 const char *v_quants,
60 STREAM *data_out, int *y_size, int *u_size,
61 int *v_size, int *a_size);
62
63 int
64 rfx_encode_component_rlgr1_x86_sse2(struct rfxencode *enc, const char *qtable,
4165 uint8 *data,
4266 uint8 *buffer, int buffer_size, int *size);
4367 int
44 rfx_encode_component_rlgr3_x86_sse2(struct rfxencode *enc,
45 const int *quantization_values,
68 rfx_encode_component_rlgr3_x86_sse2(struct rfxencode *enc, const char *qtable,
4669 uint8 *data,
4770 uint8 *buffer, int buffer_size, int *size);
4871 int
49 rfx_encode_component_rlgr1_amd64_sse2(struct rfxencode *enc,
50 const int *quantization_values,
72 rfx_encode_component_rlgr1_x86_sse41(struct rfxencode *enc, const char *qtable,
73 uint8 *data,
74 uint8 *buffer, int buffer_size, int *size);
75 int
76 rfx_encode_component_rlgr3_x86_sse41(struct rfxencode *enc, const char *qtable,
77 uint8 *data,
78 uint8 *buffer, int buffer_size, int *size);
79 int
80 rfx_encode_component_rlgr1_amd64_sse2(struct rfxencode *enc, const char *qtable,
5181 uint8 *data,
5282 uint8 *buffer, int buffer_size, int *size);
5383 int
54 rfx_encode_component_rlgr3_amd64_sse2(struct rfxencode *enc,
55 const int *quantization_values,
84 rfx_encode_component_rlgr3_amd64_sse2(struct rfxencode *enc, const char *qtable,
5685 uint8 *data,
5786 uint8 *buffer, int buffer_size, int *size);
5887 int
59 rfx_encode_rgb(struct rfxencode *enc, char *rgb_data,
60 int width, int height, int stride_bytes,
61 const int *y_quants, const int *cb_quants, const int *cr_quants,
62 STREAM *data_out, int *y_size, int *cb_size, int *cr_size);
88 rfx_encode_component_rlgr1_amd64_sse41(struct rfxencode *enc, const char *qtable,
89 uint8 *data,
90 uint8 *buffer, int buffer_size, int *size);
6391 int
64 rfx_encode_yuv(struct rfxencode *enc, char *yuv_data,
65 int width, int height, int stride_bytes,
66 const int *y_quants, const int *u_quants, const int *v_quants,
67 STREAM *data_out, int *y_size, int *u_size, int *v_size);
92 rfx_encode_component_rlgr3_amd64_sse41(struct rfxencode *enc, const char *qtable,
93 uint8 *data,
94 uint8 *buffer, int buffer_size, int *size);
6895
6996 #endif
99 ;int
1010 ;cpuid_x86(int eax_in, int ecx_in, int *eax, int *ebx, int *ecx, int *edx)
1111
12 %ifidn __OUTPUT_FORMAT__,elf
1213 PROC cpuid_x86
14 %else
15 PROC _cpuid_x86
16 %endif
1317 ; save registers
1418 push ebx
1519 push ecx
00 /*
1 Copyright 2014 Jay Sorg
1 Copyright 2014-2015 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
2525
2626 int
2727 cpuid_x86(int eax_in, int ecx_in, int *eax, int *ebx, int *ecx, int *edx);
28
2829 int
29 dwt_shift_x86_sse2(const int *quantization_values, uint8 *data,
30 sint16 *dwt_buffer1, sint16 *dwt_buffer);
30 rfxcodec_encode_dwt_shift_x86_sse2(const char *qtable,
31 unsigned char *data,
32 short *dwt_buffer1,
33 short *dwt_buffer);
3134 int
32 diff_rlgr1_x86(sint16 *co, int num_co, uint8 *dst, int dst_bytes);
35 rfxcodec_encode_diff_rlgr1_x86_sse2(short *co,
36 void *dst, int dst_bytes);
3337 int
34 diff_rlgr3_x86(sint16 *co, int num_co, uint8 *dst, int dst_bytes);
38 rfxcodec_encode_diff_rlgr3_x86_sse2(short *co,
39 void *dst, int dst_bytes);
40
41 int
42 rfxcodec_decode_rlgr1_diff_x86_sse2(void *data, int data_bytes,
43 short *out_data);
44 int
45 rfxcodec_decode_rlgr3_diff_x86_sse2(void *data, int data_bytes,
46 short *out_data);
47 int
48 rfxcodec_decode_shift_idwt_x86_sse2(const char *qtable, short *src, short *dst);
49 int
50 rfxcodec_decode_yuv2rgb_x86_sse2(short *ydata, short *udata, short *vdata,
51 unsigned int *rgbdata, int stride);
52 int
53 rfxcodec_decode_yuva2argb_x86_sse2(short *ydata, short *udata,
54 short *vdata, char *adata,
55 unsigned int *rgbdata, int stride);
3556
3657 #endif
3758
+0
-0
librfxcodec/src/x86/readme.txt less more
(Empty file)
0
1 section .data
2 const1 times 8 dw 1
3
4 %macro PROC 1
5 align 16
6 global %1
7 %1:
8 %endmacro
9
10 ;int
11 ;rfxcodec_encode_diff_rlgr1_x86_sse2(short *co,
12 ; void *dst, int dst_bytes);
13
14 %ifidn __OUTPUT_FORMAT__,elf
15 PROC rfxcodec_encode_diff_rlgr1_x86_sse2
16 %else
17 PROC _rfxcodec_encode_diff_rlgr1_x86_sse2
18 %endif
19 push ebx
20 push esi
21 push edi
22
23 mov eax, 0
24 pop edi
25 pop esi
26 pop ebx
27 ret
28 align 16
29
0
1 section .data
2 const1 times 8 dw 1
3
4 %macro PROC 1
5 align 16
6 global %1
7 %1:
8 %endmacro
9
10 ;int
11 ;rfxcodec_encode_diff_rlgr3_x86_sse2(short *co,
12 ; void *dst, int dst_bytes);
13
14 %ifidn __OUTPUT_FORMAT__,elf
15 PROC rfxcodec_encode_diff_rlgr3_x86_sse2
16 %else
17 PROC _rfxcodec_encode_diff_rlgr3_x86_sse2
18 %endif
19 push ebx
20 push esi
21 push edi
22
23 mov eax, 0
24 pop edi
25 pop esi
26 pop ebx
27 ret
28 align 16
29
0 ;
1 ;Copyright 2016 Jay Sorg
2 ;
3 ;Permission to use, copy, modify, distribute, and sell this software and its
4 ;documentation for any purpose is hereby granted without fee, provided that
5 ;the above copyright notice appear in all copies and that both that
6 ;copyright notice and this permission notice appear in supporting
7 ;documentation.
8 ;
9 ;The above copyright notice and this permission notice shall be included in
10 ;all copies or substantial portions of the Software.
11 ;
12 ;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 ;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 ;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 ;OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
16 ;AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17 ;CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 ;
19 ;x86 asm dwt
20
21 section .data
22 align 16
23 cw128 times 8 dw 128
24 cdFFFF times 4 dd 65535
25 ; these are 1 << (factor - 1) 0 to 15 is factor
26 cwa0 times 8 dw 0 ; 0
27 cwa1 times 8 dw 1 ; 1
28 cwa2 times 8 dw 2 ; 2
29 cwa4 times 8 dw 4 ; 3
30 cwa8 times 8 dw 8 ; 4
31 cwa16 times 8 dw 16 ; 5
32 cwa32 times 8 dw 32 ; 6
33 cwa64 times 8 dw 64 ; 7
34 cwa128 times 8 dw 128 ; 8
35 cwa256 times 8 dw 256 ; 9
36 cwa512 times 8 dw 512 ; 10
37 cwa1024 times 8 dw 1024 ; 11
38 cwa2048 times 8 dw 2048 ; 12
39 cwa4096 times 8 dw 4096 ; 13
40 cwa8192 times 8 dw 8192 ; 14
41 cwa16384 times 8 dw 16384 ; 15
42
43 section .text
44
45 %macro PROC 1
46 align 16
47 global %1
48 %1:
49 %endmacro
50
51 %define LHI_ADD [esp + 1 * 16 + 4]
52 %define LHI_SFT [esp + 2 * 16 + 4]
53 %define LLO_ADD [esp + 3 * 16 + 4]
54 %define LLO_SFT [esp + 4 * 16 + 4]
55
56 ;******************************************************************************
57 ; source 16 bit signed, 16 pixel width
58 rfx_dwt_2d_encode_block_horiz_16_16:
59 mov ecx, 8
60 loop1a:
61 ; pre / post
62 movdqa xmm1, [esi] ; src[2n]
63 movdqa xmm2, [esi + 16]
64 movdqa xmm6, xmm1
65 movdqa xmm7, xmm2
66 pand xmm1, [cdFFFF]
67 pand xmm2, [cdFFFF]
68 pslld xmm1, 16
69 pslld xmm2, 16
70 psrad xmm1, 16
71 psrad xmm2, 16
72 packssdw xmm1, xmm2
73 movdqa xmm2, xmm6 ; src[2n + 1]
74 movdqa xmm3, xmm7
75 psrldq xmm2, 2
76 psrldq xmm3, 2
77 pand xmm2, [cdFFFF]
78 pand xmm3, [cdFFFF]
79 pslld xmm2, 16
80 pslld xmm3, 16
81 psrad xmm2, 16
82 psrad xmm3, 16
83 packssdw xmm2, xmm3
84 movdqa xmm3, xmm6 ; src[2n + 2]
85 movdqa xmm4, xmm7
86 psrldq xmm3, 4
87 psrldq xmm4, 4
88 movd eax, xmm7
89 movd xmm5, eax
90 pslldq xmm5, 12
91 por xmm3, xmm5
92 movdqa xmm5, xmm7
93 psrldq xmm5, 12
94 pslldq xmm5, 12
95 por xmm4, xmm5
96 pand xmm3, [cdFFFF]
97 pand xmm4, [cdFFFF]
98 pslld xmm3, 16
99 pslld xmm4, 16
100 psrad xmm3, 16
101 psrad xmm4, 16
102 packssdw xmm3, xmm4
103 movdqa xmm4, xmm1
104 movdqa xmm5, xmm2
105 movdqa xmm6, xmm3
106 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
107 paddw xmm4, xmm6
108 psraw xmm4, 1
109 psubw xmm5, xmm4
110 psraw xmm5, 1
111 movdqa xmm6, xmm5 ; out hi
112 paddw xmm6, LHI_ADD
113 psraw xmm6, LHI_SFT
114 movdqa [edi], xmm6
115 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
116 movdqa xmm7, xmm5
117 movd eax, xmm7
118 pslldq xmm7, 2
119 and eax, 0xFFFF
120 movd xmm6, eax
121 por xmm7, xmm6
122 paddw xmm5, xmm7
123 psraw xmm5, 1
124 paddw xmm5, xmm1
125
126 movdqa xmm6, xmm5 ; out lo
127 paddw xmm6, LLO_ADD
128 psraw xmm6, LLO_SFT
129 movdqa [edx], xmm6
130
131 ; move right
132 lea esi, [esi + 16 * 2]
133 lea edi, [edi + 8 * 2]
134 lea edx, [edx + 8 * 2]
135
136 ; move left
137 lea esi, [esi - 16 * 2]
138 lea edi, [edi - 8 * 2]
139 lea edx, [edx - 8 * 2]
140
141 ; move down
142 lea esi, [esi + 16 * 2]
143 lea edi, [edi + 8 * 2]
144 lea edx, [edx + 8 * 2]
145
146 dec ecx
147 jnz loop1a
148
149 ret
150
151 ;******************************************************************************
152 ; source 16 bit signed, 16 pixel width
153 rfx_dwt_2d_encode_block_verti_16_16:
154 mov ecx, 2
155 loop1b:
156 ; pre
157 movdqa xmm1, [esi] ; src[2n]
158 movdqa xmm2, [esi + 16 * 2] ; src[2n + 1]
159 movdqa xmm3, [esi + 16 * 2 * 2] ; src[2n + 2]
160 movdqa xmm4, xmm1
161 movdqa xmm5, xmm2
162 movdqa xmm6, xmm3
163 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
164 paddw xmm4, xmm6
165 psraw xmm4, 1
166 psubw xmm5, xmm4
167 psraw xmm5, 1
168 movdqa [edi], xmm5 ; out hi
169 movdqa xmm6, xmm5 ; save hi
170 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
171 paddw xmm5, xmm1
172 movdqa [edx], xmm5 ; out lo
173 movdqa xmm7, xmm6 ; save hi
174 ; move down
175 lea esi, [esi + 16 * 2 * 2] ; 2 rows
176 lea edi, [edi + 16 * 2] ; 1 row
177 lea edx, [edx + 16 * 2] ; 1 row
178
179 ; loop
180 shl ecx, 16
181 mov cx, 6
182 loop2b:
183 movdqa xmm1, xmm3 ; src[2n]
184 movdqa xmm2, [esi + 16 * 2] ; src[2n + 1]
185 movdqa xmm3, [esi + 16 * 2 * 2] ; src[2n + 2]
186 movdqa xmm4, xmm1
187 movdqa xmm5, xmm2
188 movdqa xmm6, xmm3
189 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
190 paddw xmm4, xmm6
191 psraw xmm4, 1
192 psubw xmm5, xmm4
193 psraw xmm5, 1
194 movdqa [edi], xmm5 ; out hi
195 movdqa xmm6, xmm5 ; save hi
196 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
197 paddw xmm5, xmm7
198 psraw xmm5, 1
199 paddw xmm5, xmm1
200 movdqa [edx], xmm5 ; out lo
201 movdqa xmm7, xmm6 ; save hi
202 ; move down
203 lea esi, [esi + 16 * 2 * 2] ; 2 rows
204 lea edi, [edi + 16 * 2] ; 1 row
205 lea edx, [edx + 16 * 2] ; 1 row
206
207 dec cx
208 jnz loop2b
209 shr ecx, 16
210
211 ; post
212 movdqa xmm1, xmm3 ; src[2n]
213 movdqa xmm2, [esi + 16 * 2] ; src[2n + 1]
214 movdqa xmm4, xmm1
215 movdqa xmm5, xmm2
216 movdqa xmm6, xmm3
217 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
218 paddw xmm4, xmm6
219 psraw xmm4, 1
220 psubw xmm5, xmm4
221 psraw xmm5, 1
222 movdqa [edi], xmm5 ; out hi
223 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
224 paddw xmm5, xmm7
225 psraw xmm5, 1
226 paddw xmm5, xmm1
227 movdqa [edx], xmm5 ; out lo
228 ; move down
229 lea esi, [esi + 16 * 2 * 2] ; 2 row
230 lea edi, [edi + 16 * 2] ; 1 row
231 lea edx, [edx + 16 * 2] ; 1 row
232
233 ; move up
234 lea esi, [esi - 16 * 16 * 2]
235 lea edi, [edi - 8 * 16 * 2]
236 lea edx, [edx - 8 * 16 * 2]
237
238 ; move right
239 lea esi, [esi + 16]
240 lea edi, [edi + 16]
241 lea edx, [edx + 16]
242
243 dec ecx
244 jnz loop1b
245
246 ret
247
248 ;******************************************************************************
249 ; source 16 bit signed, 32 pixel width
250 rfx_dwt_2d_encode_block_horiz_16_32:
251 mov ecx, 16
252 loop1c:
253 ; pre
254 movdqa xmm1, [esi] ; src[2n]
255 movdqa xmm2, [esi + 16]
256 movdqa xmm6, xmm1
257 movdqa xmm7, xmm2
258 pand xmm1, [cdFFFF]
259 pand xmm2, [cdFFFF]
260 pslld xmm1, 16
261 pslld xmm2, 16
262 psrad xmm1, 16
263 psrad xmm2, 16
264 packssdw xmm1, xmm2
265 movdqa xmm2, xmm6 ; src[2n + 1]
266 movdqa xmm3, xmm7
267 psrldq xmm2, 2
268 psrldq xmm3, 2
269 pand xmm2, [cdFFFF]
270 pand xmm3, [cdFFFF]
271 pslld xmm2, 16
272 pslld xmm3, 16
273 psrad xmm2, 16
274 psrad xmm3, 16
275 packssdw xmm2, xmm3
276 movdqa xmm3, xmm6 ; src[2n + 2]
277 movdqa xmm4, xmm7
278 psrldq xmm3, 4
279 psrldq xmm4, 4
280 movd eax, xmm7
281 movd xmm5, eax
282 pslldq xmm5, 12
283 por xmm3, xmm5
284 mov eax, [esi + 32]
285 movd xmm5, eax
286 pslldq xmm5, 12
287 por xmm4, xmm5
288 pand xmm3, [cdFFFF]
289 pand xmm4, [cdFFFF]
290 pslld xmm3, 16
291 pslld xmm4, 16
292 psrad xmm3, 16
293 psrad xmm4, 16
294 packssdw xmm3, xmm4
295 movdqa xmm4, xmm1
296 movdqa xmm5, xmm2
297 movdqa xmm6, xmm3
298 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
299 paddw xmm4, xmm6
300 psraw xmm4, 1
301 psubw xmm5, xmm4
302 psraw xmm5, 1
303
304 movdqa xmm6, xmm5 ; out hi
305 paddw xmm6, LHI_ADD
306 psraw xmm6, LHI_SFT
307 movdqa [edi], xmm6
308 movdqa xmm2, xmm5 ; save hi
309
310 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
311 movdqa xmm7, xmm5
312 movd eax, xmm7
313 pslldq xmm7, 2
314 and eax, 0xFFFF
315 movd xmm6, eax
316 por xmm7, xmm6
317 paddw xmm5, xmm7
318 psraw xmm5, 1
319 paddw xmm5, xmm1
320
321 psrldq xmm2, 14
322 movd ebx, xmm2 ; save hi
323
324 movdqa xmm6, xmm5 ; out lo
325 paddw xmm6, LLO_ADD
326 psraw xmm6, LLO_SFT
327 movdqa [edx], xmm6
328
329 ; move right
330 lea esi, [esi + 16 * 2]
331 lea edi, [edi + 8 * 2]
332 lea edx, [edx + 8 * 2]
333
334 ; post
335 movdqa xmm1, [esi] ; src[2n]
336 movdqa xmm2, [esi + 16]
337 movdqa xmm6, xmm1
338 movdqa xmm7, xmm2
339 pand xmm1, [cdFFFF]
340 pand xmm2, [cdFFFF]
341 pslld xmm1, 16
342 pslld xmm2, 16
343 psrad xmm1, 16
344 psrad xmm2, 16
345 packssdw xmm1, xmm2
346 movdqa xmm2, xmm6 ; src[2n + 1]
347 movdqa xmm3, xmm7
348 psrldq xmm2, 2
349 psrldq xmm3, 2
350 pand xmm2, [cdFFFF]
351 pand xmm3, [cdFFFF]
352 pslld xmm2, 16
353 pslld xmm3, 16
354 psrad xmm2, 16
355 psrad xmm3, 16
356 packssdw xmm2, xmm3
357 movdqa xmm3, xmm6 ; src[2n + 2]
358 movdqa xmm4, xmm7
359 psrldq xmm3, 4
360 psrldq xmm4, 4
361 movd eax, xmm7
362 movd xmm5, eax
363 pslldq xmm5, 12
364 por xmm3, xmm5
365 movdqa xmm5, xmm7
366 psrldq xmm5, 12
367 pslldq xmm5, 12
368 por xmm4, xmm5
369 pand xmm3, [cdFFFF]
370 pand xmm4, [cdFFFF]
371 pslld xmm3, 16
372 pslld xmm4, 16
373 psrad xmm3, 16
374 psrad xmm4, 16
375 packssdw xmm3, xmm4
376 movdqa xmm4, xmm1
377 movdqa xmm5, xmm2
378 movdqa xmm6, xmm3
379 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
380 paddw xmm4, xmm6
381 psraw xmm4, 1
382 psubw xmm5, xmm4
383 psraw xmm5, 1
384
385 movdqa xmm6, xmm5 ; out hi
386 paddw xmm6, LHI_ADD
387 psraw xmm6, LHI_SFT
388 movdqa [edi], xmm6
389
390 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
391 movdqa xmm7, xmm5
392 pslldq xmm7, 2
393 movd xmm6, ebx
394 por xmm7, xmm6
395 paddw xmm5, xmm7
396 psraw xmm5, 1
397 paddw xmm5, xmm1
398
399 movdqa xmm6, xmm5 ; out lo
400 paddw xmm6, LLO_ADD
401 psraw xmm6, LLO_SFT
402 movdqa [edx], xmm6
403
404 ; move right
405 lea esi, [esi + 16 * 2]
406 lea edi, [edi + 8 * 2]
407 lea edx, [edx + 8 * 2]
408
409 ; move left
410 lea esi, [esi - 32 * 2]
411 lea edi, [edi - 16 * 2]
412 lea edx, [edx - 16 * 2]
413
414 ; move down
415 lea esi, [esi + 32 * 2]
416 lea edi, [edi + 16 * 2]
417 lea edx, [edx + 16 * 2]
418
419 dec ecx
420 jnz loop1c
421
422 ret
423
424 ;******************************************************************************
425 ; source 16 bit signed, 32 pixel width
426 rfx_dwt_2d_encode_block_horiz_16_32_no_lo:
427 mov ecx, 16
428 loop1c1:
429 ; pre
430 movdqa xmm1, [esi] ; src[2n]
431 movdqa xmm2, [esi + 16]
432 movdqa xmm6, xmm1
433 movdqa xmm7, xmm2
434 pand xmm1, [cdFFFF]
435 pand xmm2, [cdFFFF]
436 pslld xmm1, 16
437 pslld xmm2, 16
438 psrad xmm1, 16
439 psrad xmm2, 16
440 packssdw xmm1, xmm2
441 movdqa xmm2, xmm6 ; src[2n + 1]
442 movdqa xmm3, xmm7
443 psrldq xmm2, 2
444 psrldq xmm3, 2
445 pand xmm2, [cdFFFF]
446 pand xmm3, [cdFFFF]
447 pslld xmm2, 16
448 pslld xmm3, 16
449 psrad xmm2, 16
450 psrad xmm3, 16
451 packssdw xmm2, xmm3
452 movdqa xmm3, xmm6 ; src[2n + 2]
453 movdqa xmm4, xmm7
454 psrldq xmm3, 4
455 psrldq xmm4, 4
456 movd eax, xmm7
457 movd xmm5, eax
458 pslldq xmm5, 12
459 por xmm3, xmm5
460 mov eax, [esi + 32]
461 movd xmm5, eax
462 pslldq xmm5, 12
463 por xmm4, xmm5
464 pand xmm3, [cdFFFF]
465 pand xmm4, [cdFFFF]
466 pslld xmm3, 16
467 pslld xmm4, 16
468 psrad xmm3, 16
469 psrad xmm4, 16
470 packssdw xmm3, xmm4
471 movdqa xmm4, xmm1
472 movdqa xmm5, xmm2
473 movdqa xmm6, xmm3
474 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
475 paddw xmm4, xmm6
476 psraw xmm4, 1
477 psubw xmm5, xmm4
478 psraw xmm5, 1
479
480 movdqa xmm6, xmm5 ; out hi
481 paddw xmm6, LHI_ADD
482 psraw xmm6, LHI_SFT
483 movdqa [edi], xmm6
484 movdqa xmm2, xmm5 ; save hi
485
486 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
487 movdqa xmm7, xmm5
488 movd eax, xmm7
489 pslldq xmm7, 2
490 and eax, 0xFFFF
491 movd xmm6, eax
492 por xmm7, xmm6
493 paddw xmm5, xmm7
494 psraw xmm5, 1
495 paddw xmm5, xmm1
496
497 psrldq xmm2, 14
498 movd ebx, xmm2 ; save hi
499
500 movdqa [edx], xmm5 ; out lo
501
502 ; move right
503 lea esi, [esi + 16 * 2]
504 lea edi, [edi + 8 * 2]
505 lea edx, [edx + 8 * 2]
506
507 ; post
508 movdqa xmm1, [esi] ; src[2n]
509 movdqa xmm2, [esi + 16]
510 movdqa xmm6, xmm1
511 movdqa xmm7, xmm2
512 pand xmm1, [cdFFFF]
513 pand xmm2, [cdFFFF]
514 pslld xmm1, 16
515 pslld xmm2, 16
516 psrad xmm1, 16
517 psrad xmm2, 16
518 packssdw xmm1, xmm2
519 movdqa xmm2, xmm6 ; src[2n + 1]
520 movdqa xmm3, xmm7
521 psrldq xmm2, 2
522 psrldq xmm3, 2
523 pand xmm2, [cdFFFF]
524 pand xmm3, [cdFFFF]
525 pslld xmm2, 16
526 pslld xmm3, 16
527 psrad xmm2, 16
528 psrad xmm3, 16
529 packssdw xmm2, xmm3
530 movdqa xmm3, xmm6 ; src[2n + 2]
531 movdqa xmm4, xmm7
532 psrldq xmm3, 4
533 psrldq xmm4, 4
534 movd eax, xmm7
535 movd xmm5, eax
536 pslldq xmm5, 12
537 por xmm3, xmm5
538 movdqa xmm5, xmm7
539 psrldq xmm5, 12
540 pslldq xmm5, 12
541 por xmm4, xmm5
542 pand xmm3, [cdFFFF]
543 pand xmm4, [cdFFFF]
544 pslld xmm3, 16
545 pslld xmm4, 16
546 psrad xmm3, 16
547 psrad xmm4, 16
548 packssdw xmm3, xmm4
549 movdqa xmm4, xmm1
550 movdqa xmm5, xmm2
551 movdqa xmm6, xmm3
552 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
553 paddw xmm4, xmm6
554 psraw xmm4, 1
555 psubw xmm5, xmm4
556 psraw xmm5, 1
557
558 movdqa xmm6, xmm5 ; out hi
559 paddw xmm6, LHI_ADD
560 psraw xmm6, LHI_SFT
561 movdqa [edi], xmm6
562
563 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
564 movdqa xmm7, xmm5
565 pslldq xmm7, 2
566 movd xmm6, ebx
567 por xmm7, xmm6
568 paddw xmm5, xmm7
569 psraw xmm5, 1
570 paddw xmm5, xmm1
571
572 movdqa [edx], xmm5 ; out lo
573
574 ; move right
575 lea esi, [esi + 16 * 2]
576 lea edi, [edi + 8 * 2]
577 lea edx, [edx + 8 * 2]
578
579 ; move left
580 lea esi, [esi - 32 * 2]
581 lea edi, [edi - 16 * 2]
582 lea edx, [edx - 16 * 2]
583
584 ; move down
585 lea esi, [esi + 32 * 2]
586 lea edi, [edi + 16 * 2]
587 lea edx, [edx + 16 * 2]
588
589 dec ecx
590 jnz loop1c1
591
592 ret
593
594 ;******************************************************************************
595 ; source 16 bit signed, 32 pixel width
596 rfx_dwt_2d_encode_block_verti_16_32:
597 mov ecx, 4
598 loop1d:
599 ; pre
600 movdqa xmm1, [esi] ; src[2n]
601 movdqa xmm2, [esi + 32 * 2] ; src[2n + 1]
602 movdqa xmm3, [esi + 32 * 2 * 2] ; src[2n + 2]
603 movdqa xmm4, xmm1
604 movdqa xmm5, xmm2
605 movdqa xmm6, xmm3
606 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
607 paddw xmm4, xmm6
608 psraw xmm4, 1
609 psubw xmm5, xmm4
610 psraw xmm5, 1
611 movdqa [edi], xmm5 ; out hi
612 movdqa xmm6, xmm5 ; save hi
613 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
614 paddw xmm5, xmm1
615 movdqa [edx], xmm5 ; out lo
616 movdqa xmm7, xmm6 ; save hi
617 ; move down
618 lea esi, [esi + 32 * 2 * 2] ; 2 rows
619 lea edi, [edi + 32 * 2] ; 1 row
620 lea edx, [edx + 32 * 2] ; 1 row
621
622 ; loop
623 shl ecx, 16
624 mov cx, 14
625 loop2d:
626 movdqa xmm1, xmm3 ; src[2n]
627 movdqa xmm2, [esi + 32 * 2] ; src[2n + 1]
628 movdqa xmm3, [esi + 32 * 2 * 2] ; src[2n + 2]
629 movdqa xmm4, xmm1
630 movdqa xmm5, xmm2
631 movdqa xmm6, xmm3
632 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
633 paddw xmm4, xmm6
634 psraw xmm4, 1
635 psubw xmm5, xmm4
636 psraw xmm5, 1
637 movdqa [edi], xmm5 ; out hi
638 movdqa xmm6, xmm5 ; save hi
639 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
640 paddw xmm5, xmm7
641 psraw xmm5, 1
642 paddw xmm5, xmm1
643 movdqa [edx], xmm5 ; out lo
644 movdqa xmm7, xmm6 ; save hi
645 ; move down
646 lea esi, [esi + 32 * 2 * 2] ; 2 rows
647 lea edi, [edi + 32 * 2] ; 1 row
648 lea edx, [edx + 32 * 2] ; 1 row
649
650 dec cx
651 jnz loop2d
652 shr ecx, 16
653
654 ; post
655 movdqa xmm1, xmm3 ; src[2n]
656 movdqa xmm2, [esi + 32 * 2] ; src[2n + 1]
657 movdqa xmm4, xmm1
658 movdqa xmm5, xmm2
659 movdqa xmm6, xmm3
660 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
661 paddw xmm4, xmm6
662 psraw xmm4, 1
663 psubw xmm5, xmm4
664 psraw xmm5, 1
665 movdqa [edi], xmm5 ; out hi
666 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
667 paddw xmm5, xmm7
668 psraw xmm5, 1
669 paddw xmm5, xmm1
670 movdqa [edx], xmm5 ; out lo
671 ; move down
672 lea esi, [esi + 32 * 2 * 2] ; 2 row
673 lea edi, [edi + 32 * 2] ; 1 row
674 lea edx, [edx + 32 * 2] ; 1 row
675
676 ; move up
677 lea esi, [esi - 32 * 32 * 2]
678 lea edi, [edi - 16 * 32 * 2]
679 lea edx, [edx - 16 * 32 * 2]
680
681 ; move right
682 lea esi, [esi + 16]
683 lea edi, [edi + 16]
684 lea edx, [edx + 16]
685
686 dec ecx
687 jnz loop1d
688
689 ret
690
691 ;******************************************************************************
692 ; source 16 bit signed, 64 pixel width
693 rfx_dwt_2d_encode_block_horiz_16_64:
694 mov ecx, 32
695 loop1e:
696 ; pre
697 movdqa xmm1, [esi] ; src[2n]
698 movdqa xmm2, [esi + 16]
699 movdqa xmm6, xmm1
700 movdqa xmm7, xmm2
701 pand xmm1, [cdFFFF]
702 pand xmm2, [cdFFFF]
703 pslld xmm1, 16
704 pslld xmm2, 16
705 psrad xmm1, 16
706 psrad xmm2, 16
707 packssdw xmm1, xmm2
708 movdqa xmm2, xmm6 ; src[2n + 1]
709 movdqa xmm3, xmm7
710 psrldq xmm2, 2
711 psrldq xmm3, 2
712 pand xmm2, [cdFFFF]
713 pand xmm3, [cdFFFF]
714 pslld xmm2, 16
715 pslld xmm3, 16
716 psrad xmm2, 16
717 psrad xmm3, 16
718 packssdw xmm2, xmm3
719 movdqa xmm3, xmm6 ; src[2n + 2]
720 movdqa xmm4, xmm7
721 psrldq xmm3, 4
722 psrldq xmm4, 4
723 movd eax, xmm7
724 movd xmm5, eax
725 pslldq xmm5, 12
726 por xmm3, xmm5
727 mov eax, [esi + 32]
728 movd xmm5, eax
729 pslldq xmm5, 12
730 por xmm4, xmm5
731 pand xmm3, [cdFFFF]
732 pand xmm4, [cdFFFF]
733 pslld xmm3, 16
734 pslld xmm4, 16
735 psrad xmm3, 16
736 psrad xmm4, 16
737 packssdw xmm3, xmm4
738 movdqa xmm4, xmm1
739 movdqa xmm5, xmm2
740 movdqa xmm6, xmm3
741 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
742 paddw xmm4, xmm6
743 psraw xmm4, 1
744 psubw xmm5, xmm4
745 psraw xmm5, 1
746
747 movdqa xmm6, xmm5 ; out hi
748 paddw xmm6, LHI_ADD
749 psraw xmm6, LHI_SFT
750 movdqa [edi], xmm6
751 movdqa xmm2, xmm5 ; save hi
752
753 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
754 movdqa xmm7, xmm5
755 movd eax, xmm7
756 pslldq xmm7, 2
757 and eax, 0xFFFF
758 movd xmm6, eax
759 por xmm7, xmm6
760 paddw xmm5, xmm7
761 psraw xmm5, 1
762 paddw xmm5, xmm1
763
764 psrldq xmm2, 14
765 movd ebx, xmm2 ; save hi
766
767 movdqa xmm6, xmm5 ; out lo
768 paddw xmm6, LLO_ADD
769 psraw xmm6, LLO_SFT
770 movdqa [edx], xmm6
771
772 ; move right
773 lea esi, [esi + 16 * 2]
774 lea edi, [edi + 8 * 2]
775 lea edx, [edx + 8 * 2]
776
777 ; loop
778 shl ecx, 16
779 mov cx, 2
780 loop2e:
781 movdqa xmm1, [esi] ; src[2n]
782 movdqa xmm2, [esi + 16]
783 movdqa xmm6, xmm1
784 movdqa xmm7, xmm2
785 pand xmm1, [cdFFFF]
786 pand xmm2, [cdFFFF]
787 pslld xmm1, 16
788 pslld xmm2, 16
789 psrad xmm1, 16
790 psrad xmm2, 16
791 packssdw xmm1, xmm2
792 movdqa xmm2, xmm6 ; src[2n + 1]
793 movdqa xmm3, xmm7
794 psrldq xmm2, 2
795 psrldq xmm3, 2
796 pand xmm2, [cdFFFF]
797 pand xmm3, [cdFFFF]
798 pslld xmm2, 16
799 pslld xmm3, 16
800 psrad xmm2, 16
801 psrad xmm3, 16
802 packssdw xmm2, xmm3
803 movdqa xmm3, xmm6 ; src[2n + 2]
804 movdqa xmm4, xmm7
805 psrldq xmm3, 4
806 psrldq xmm4, 4
807 movd eax, xmm7
808 movd xmm5, eax
809 pslldq xmm5, 12
810 por xmm3, xmm5
811 mov eax, [esi + 32]
812 movd xmm5, eax
813 pslldq xmm5, 12
814 por xmm4, xmm5
815 pand xmm3, [cdFFFF]
816 pand xmm4, [cdFFFF]
817 pslld xmm3, 16
818 pslld xmm4, 16
819 psrad xmm3, 16
820 psrad xmm4, 16
821 packssdw xmm3, xmm4
822 movdqa xmm4, xmm1
823 movdqa xmm5, xmm2
824 movdqa xmm6, xmm3
825 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
826 paddw xmm4, xmm6
827 psraw xmm4, 1
828 psubw xmm5, xmm4
829 psraw xmm5, 1
830
831 movdqa xmm6, xmm5 ; out hi
832 paddw xmm6, LHI_ADD
833 psraw xmm6, LHI_SFT
834 movdqa [edi], xmm6
835 movdqa xmm2, xmm5 ; save hi
836
837 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
838 movdqa xmm7, xmm5
839 pslldq xmm7, 2
840 movd xmm6, ebx
841 por xmm7, xmm6
842 paddw xmm5, xmm7
843 psraw xmm5, 1
844 paddw xmm5, xmm1
845
846 psrldq xmm2, 14
847 movd ebx, xmm2 ; save hi
848
849 movdqa xmm6, xmm5 ; out lo
850 paddw xmm6, LLO_ADD
851 psraw xmm6, LLO_SFT
852 movdqa [edx], xmm6
853
854 ; move right
855 lea esi, [esi + 16 * 2]
856 lea edi, [edi + 8 * 2]
857 lea edx, [edx + 8 * 2]
858
859 dec cx
860 jnz loop2e
861 shr ecx, 16
862
863 ; post
864 movdqa xmm1, [esi] ; src[2n]
865 movdqa xmm2, [esi + 16]
866 movdqa xmm6, xmm1
867 movdqa xmm7, xmm2
868 pand xmm1, [cdFFFF]
869 pand xmm2, [cdFFFF]
870 pslld xmm1, 16
871 pslld xmm2, 16
872 psrad xmm1, 16
873 psrad xmm2, 16
874 packssdw xmm1, xmm2
875 movdqa xmm2, xmm6 ; src[2n + 1]
876 movdqa xmm3, xmm7
877 psrldq xmm2, 2
878 psrldq xmm3, 2
879 pand xmm2, [cdFFFF]
880 pand xmm3, [cdFFFF]
881 pslld xmm2, 16
882 pslld xmm3, 16
883 psrad xmm2, 16
884 psrad xmm3, 16
885 packssdw xmm2, xmm3
886 movdqa xmm3, xmm6 ; src[2n + 2]
887 movdqa xmm4, xmm7
888 psrldq xmm3, 4
889 psrldq xmm4, 4
890 movd eax, xmm7
891 movd xmm5, eax
892 pslldq xmm5, 12
893 por xmm3, xmm5
894 movdqa xmm5, xmm7
895 psrldq xmm5, 12
896 pslldq xmm5, 12
897 por xmm4, xmm5
898 pand xmm3, [cdFFFF]
899 pand xmm4, [cdFFFF]
900 pslld xmm3, 16
901 pslld xmm4, 16
902 psrad xmm3, 16
903 psrad xmm4, 16
904 packssdw xmm3, xmm4
905 movdqa xmm4, xmm1
906 movdqa xmm5, xmm2
907 movdqa xmm6, xmm3
908 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
909 paddw xmm4, xmm6
910 psraw xmm4, 1
911 psubw xmm5, xmm4
912 psraw xmm5, 1
913
914 movdqa xmm6, xmm5 ; out hi
915 paddw xmm6, LHI_ADD
916 psraw xmm6, LHI_SFT
917 movdqa [edi], xmm6
918
919 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
920 movdqa xmm7, xmm5
921 pslldq xmm7, 2
922 movd xmm6, ebx
923 por xmm7, xmm6
924 paddw xmm5, xmm7
925 psraw xmm5, 1
926 paddw xmm5, xmm1
927
928 movdqa xmm6, xmm5 ; out lo
929 paddw xmm6, LLO_ADD
930 psraw xmm6, LLO_SFT
931 movdqa [edx], xmm6
932
933 ; move right
934 lea esi, [esi + 16 * 2]
935 lea edi, [edi + 8 * 2]
936 lea edx, [edx + 8 * 2]
937
938 ; move left
939 lea esi, [esi - 64 * 2]
940 lea edi, [edi - 32 * 2]
941 lea edx, [edx - 32 * 2]
942
943 ; move down
944 lea esi, [esi + 64 * 2]
945 lea edi, [edi + 32 * 2]
946 lea edx, [edx + 32 * 2]
947
948 dec ecx
949 jnz loop1e
950
951 ret
952
953 ;******************************************************************************
954 ; source 16 bit signed, 64 pixel width
955 rfx_dwt_2d_encode_block_horiz_16_64_no_lo:
956 mov ecx, 32
957 loop1e1:
958 ; pre
959 movdqa xmm1, [esi] ; src[2n]
960 movdqa xmm2, [esi + 16]
961 movdqa xmm6, xmm1
962 movdqa xmm7, xmm2
963 pand xmm1, [cdFFFF]
964 pand xmm2, [cdFFFF]
965 pslld xmm1, 16
966 pslld xmm2, 16
967 psrad xmm1, 16
968 psrad xmm2, 16
969 packssdw xmm1, xmm2
970 movdqa xmm2, xmm6 ; src[2n + 1]
971 movdqa xmm3, xmm7
972 psrldq xmm2, 2
973 psrldq xmm3, 2
974 pand xmm2, [cdFFFF]
975 pand xmm3, [cdFFFF]
976 pslld xmm2, 16
977 pslld xmm3, 16
978 psrad xmm2, 16
979 psrad xmm3, 16
980 packssdw xmm2, xmm3
981 movdqa xmm3, xmm6 ; src[2n + 2]
982 movdqa xmm4, xmm7
983 psrldq xmm3, 4
984 psrldq xmm4, 4
985 movd eax, xmm7
986 movd xmm5, eax
987 pslldq xmm5, 12
988 por xmm3, xmm5
989 mov eax, [esi + 32]
990 movd xmm5, eax
991 pslldq xmm5, 12
992 por xmm4, xmm5
993 pand xmm3, [cdFFFF]
994 pand xmm4, [cdFFFF]
995 pslld xmm3, 16
996 pslld xmm4, 16
997 psrad xmm3, 16
998 psrad xmm4, 16
999 packssdw xmm3, xmm4
1000 movdqa xmm4, xmm1
1001 movdqa xmm5, xmm2
1002 movdqa xmm6, xmm3
1003 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1004 paddw xmm4, xmm6
1005 psraw xmm4, 1
1006 psubw xmm5, xmm4
1007 psraw xmm5, 1
1008
1009 movdqa xmm6, xmm5 ; out hi
1010 paddw xmm6, LHI_ADD
1011 psraw xmm6, LHI_SFT
1012 movdqa [edi], xmm6
1013 movdqa xmm2, xmm5 ; save hi
1014
1015 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1016 movdqa xmm7, xmm5
1017 movd eax, xmm7
1018 pslldq xmm7, 2
1019 and eax, 0xFFFF
1020 movd xmm6, eax
1021 por xmm7, xmm6
1022 paddw xmm5, xmm7
1023 psraw xmm5, 1
1024 paddw xmm5, xmm1
1025
1026 psrldq xmm2, 14
1027 movd ebx, xmm2 ; save hi
1028
1029 movdqa [edx], xmm5 ; out lo
1030
1031 ; move right
1032 lea esi, [esi + 16 * 2]
1033 lea edi, [edi + 8 * 2]
1034 lea edx, [edx + 8 * 2]
1035
1036 ; loop
1037 shl ecx, 16
1038 mov cx, 2
1039 loop2e1:
1040 movdqa xmm1, [esi] ; src[2n]
1041 movdqa xmm2, [esi + 16]
1042 movdqa xmm6, xmm1
1043 movdqa xmm7, xmm2
1044 pand xmm1, [cdFFFF]
1045 pand xmm2, [cdFFFF]
1046 pslld xmm1, 16
1047 pslld xmm2, 16
1048 psrad xmm1, 16
1049 psrad xmm2, 16
1050 packssdw xmm1, xmm2
1051 movdqa xmm2, xmm6 ; src[2n + 1]
1052 movdqa xmm3, xmm7
1053 psrldq xmm2, 2
1054 psrldq xmm3, 2
1055 pand xmm2, [cdFFFF]
1056 pand xmm3, [cdFFFF]
1057 pslld xmm2, 16
1058 pslld xmm3, 16
1059 psrad xmm2, 16
1060 psrad xmm3, 16
1061 packssdw xmm2, xmm3
1062 movdqa xmm3, xmm6 ; src[2n + 2]
1063 movdqa xmm4, xmm7
1064 psrldq xmm3, 4
1065 psrldq xmm4, 4
1066 movd eax, xmm7
1067 movd xmm5, eax
1068 pslldq xmm5, 12
1069 por xmm3, xmm5
1070 mov eax, [esi + 32]
1071 movd xmm5, eax
1072 pslldq xmm5, 12
1073 por xmm4, xmm5
1074 pand xmm3, [cdFFFF]
1075 pand xmm4, [cdFFFF]
1076 pslld xmm3, 16
1077 pslld xmm4, 16
1078 psrad xmm3, 16
1079 psrad xmm4, 16
1080 packssdw xmm3, xmm4
1081 movdqa xmm4, xmm1
1082 movdqa xmm5, xmm2
1083 movdqa xmm6, xmm3
1084 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1085 paddw xmm4, xmm6
1086 psraw xmm4, 1
1087 psubw xmm5, xmm4
1088 psraw xmm5, 1
1089
1090 movdqa xmm6, xmm5 ; out hi
1091 paddw xmm6, LHI_ADD
1092 psraw xmm6, LHI_SFT
1093 movdqa [edi], xmm6
1094 movdqa xmm2, xmm5 ; save hi
1095
1096 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1097 movdqa xmm7, xmm5
1098 pslldq xmm7, 2
1099 movd xmm6, ebx
1100 por xmm7, xmm6
1101 paddw xmm5, xmm7
1102 psraw xmm5, 1
1103 paddw xmm5, xmm1
1104
1105 psrldq xmm2, 14
1106 movd ebx, xmm2 ; save hi
1107
1108 movdqa [edx], xmm5 ; out lo
1109
1110 ; move right
1111 lea esi, [esi + 16 * 2]
1112 lea edi, [edi + 8 * 2]
1113 lea edx, [edx + 8 * 2]
1114
1115 dec cx
1116 jnz loop2e1
1117 shr ecx, 16
1118
1119 ; post
1120 movdqa xmm1, [esi] ; src[2n]
1121 movdqa xmm2, [esi + 16]
1122 movdqa xmm6, xmm1
1123 movdqa xmm7, xmm2
1124 pand xmm1, [cdFFFF]
1125 pand xmm2, [cdFFFF]
1126 pslld xmm1, 16
1127 pslld xmm2, 16
1128 psrad xmm1, 16
1129 psrad xmm2, 16
1130 packssdw xmm1, xmm2
1131 movdqa xmm2, xmm6 ; src[2n + 1]
1132 movdqa xmm3, xmm7
1133 psrldq xmm2, 2
1134 psrldq xmm3, 2
1135 pand xmm2, [cdFFFF]
1136 pand xmm3, [cdFFFF]
1137 pslld xmm2, 16
1138 pslld xmm3, 16
1139 psrad xmm2, 16
1140 psrad xmm3, 16
1141 packssdw xmm2, xmm3
1142 movdqa xmm3, xmm6 ; src[2n + 2]
1143 movdqa xmm4, xmm7
1144 psrldq xmm3, 4
1145 psrldq xmm4, 4
1146 movd eax, xmm7
1147 movd xmm5, eax
1148 pslldq xmm5, 12
1149 por xmm3, xmm5
1150 movdqa xmm5, xmm7
1151 psrldq xmm5, 12
1152 pslldq xmm5, 12
1153 por xmm4, xmm5
1154 pand xmm3, [cdFFFF]
1155 pand xmm4, [cdFFFF]
1156 pslld xmm3, 16
1157 pslld xmm4, 16
1158 psrad xmm3, 16
1159 psrad xmm4, 16
1160 packssdw xmm3, xmm4
1161 movdqa xmm4, xmm1
1162 movdqa xmm5, xmm2
1163 movdqa xmm6, xmm3
1164 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1165 paddw xmm4, xmm6
1166 psraw xmm4, 1
1167 psubw xmm5, xmm4
1168 psraw xmm5, 1
1169
1170 movdqa xmm6, xmm5 ; out hi
1171 paddw xmm6, LHI_ADD
1172 psraw xmm6, LHI_SFT
1173 movdqa [edi], xmm6
1174
1175 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1176 movdqa xmm7, xmm5
1177 pslldq xmm7, 2
1178 movd xmm6, ebx
1179 por xmm7, xmm6
1180 paddw xmm5, xmm7
1181 psraw xmm5, 1
1182 paddw xmm5, xmm1
1183
1184 movdqa [edx], xmm5 ; out lo
1185
1186 ; move right
1187 lea esi, [esi + 16 * 2]
1188 lea edi, [edi + 8 * 2]
1189 lea edx, [edx + 8 * 2]
1190
1191 ; move left
1192 lea esi, [esi - 64 * 2]
1193 lea edi, [edi - 32 * 2]
1194 lea edx, [edx - 32 * 2]
1195
1196 ; move down
1197 lea esi, [esi + 64 * 2]
1198 lea edi, [edi + 32 * 2]
1199 lea edx, [edx + 32 * 2]
1200
1201 dec ecx
1202 jnz loop1e1
1203
1204 ret
1205
1206 ;******************************************************************************
1207 ; source 8 bit unsigned, 64 pixel width
1208 rfx_dwt_2d_encode_block_verti_8_64:
1209 mov ecx, 8
1210 loop1f:
1211 ; pre
1212 movq xmm1, [esi] ; src[2n]
1213 movq xmm2, [esi + 64 * 1] ; src[2n + 1]
1214 movq xmm3, [esi + 64 * 1 * 2] ; src[2n + 2]
1215 punpcklbw xmm1, xmm0
1216 punpcklbw xmm2, xmm0
1217 punpcklbw xmm3, xmm0
1218 psubw xmm1, [cw128]
1219 psubw xmm2, [cw128]
1220 psubw xmm3, [cw128]
1221 psllw xmm1, 5
1222 psllw xmm2, 5
1223 psllw xmm3, 5
1224 movdqa xmm4, xmm1
1225 movdqa xmm5, xmm2
1226 movdqa xmm6, xmm3
1227 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1228 paddw xmm4, xmm6
1229 psraw xmm4, 1
1230 psubw xmm5, xmm4
1231 psraw xmm5, 1
1232 movdqa [edi], xmm5 ; out hi
1233 movdqa xmm6, xmm5 ; save hi
1234 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1235 paddw xmm5, xmm1
1236 movdqa [edx], xmm5 ; out lo
1237 movdqa xmm7, xmm6 ; save hi
1238 ; move down
1239 lea esi, [esi + 64 * 1 * 2] ; 2 rows
1240 lea edi, [edi + 64 * 2] ; 1 row
1241 lea edx, [edx + 64 * 2] ; 1 row
1242
1243 ; loop
1244 shl ecx, 16
1245 mov cx, 30
1246 loop2f:
1247 movdqa xmm1, xmm3 ; src[2n]
1248 movq xmm2, [esi + 64 * 1] ; src[2n + 1]
1249 movq xmm3, [esi + 64 * 1 * 2] ; src[2n + 2]
1250 punpcklbw xmm2, xmm0
1251 punpcklbw xmm3, xmm0
1252 psubw xmm2, [cw128]
1253 psubw xmm3, [cw128]
1254 psllw xmm2, 5
1255 psllw xmm3, 5
1256 movdqa xmm4, xmm1
1257 movdqa xmm5, xmm2
1258 movdqa xmm6, xmm3
1259 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1260 paddw xmm4, xmm6
1261 psraw xmm4, 1
1262 psubw xmm5, xmm4
1263 psraw xmm5, 1
1264 movdqa [edi], xmm5 ; out hi
1265 movdqa xmm6, xmm5 ; save hi
1266 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1267 paddw xmm5, xmm7
1268 psraw xmm5, 1
1269 paddw xmm5, xmm1
1270 movdqa [edx], xmm5 ; out lo
1271 movdqa xmm7, xmm6 ; save hi
1272 ; move down
1273 lea esi, [esi + 64 * 1 * 2] ; 2 rows
1274 lea edi, [edi + 64 * 2] ; 1 row
1275 lea edx, [edx + 64 * 2] ; 1 row
1276
1277 dec cx
1278 jnz loop2f
1279 shr ecx, 16
1280
1281 ; post
1282 movdqa xmm1, xmm3 ; src[2n]
1283 movq xmm2, [esi + 64 * 1] ; src[2n + 1]
1284 punpcklbw xmm2, xmm0
1285 psubw xmm2, [cw128]
1286 psllw xmm2, 5
1287 movdqa xmm4, xmm1
1288 movdqa xmm5, xmm2
1289 movdqa xmm6, xmm3
1290 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1291 paddw xmm4, xmm6
1292 psraw xmm4, 1
1293 psubw xmm5, xmm4
1294 psraw xmm5, 1
1295 movdqa [edi], xmm5 ; out hi
1296 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1297 paddw xmm5, xmm7
1298 psraw xmm5, 1
1299 paddw xmm5, xmm1
1300 movdqa [edx], xmm5 ; out lo
1301 ; move down
1302 lea esi, [esi + 64 * 1 * 2] ; 2 rows
1303 lea edi, [edi + 64 * 2] ; 1 row
1304 lea edx, [edx + 64 * 2] ; 1 row
1305
1306 ; move up
1307 lea esi, [esi - 64 * 1 * 64]
1308 lea edi, [edi - 32 * 64 * 2]
1309 lea edx, [edx - 32 * 64 * 2]
1310
1311 ; move right
1312 lea esi, [esi + 8]
1313 lea edi, [edi + 16]
1314 lea edx, [edx + 16]
1315
1316 dec ecx
1317 jnz loop1f
1318
1319 ret
1320
1321 set_quants_hi:
1322 sub eax, 6 - 5
1323 movd xmm1, eax
1324 movdqa LHI_SFT, xmm1
1325 imul eax, 16
1326 lea edx, [cwa0]
1327 add edx, eax
1328 movdqa xmm1, [edx]
1329 movdqa LHI_ADD, xmm1
1330 ret
1331
1332 set_quants_lo:
1333 sub eax, 6 - 5
1334 movd xmm1, eax
1335 movdqa LLO_SFT, xmm1
1336 imul eax, 16
1337 lea edx, [cwa0]
1338 add edx, eax
1339 movdqa xmm1, [edx]
1340 movdqa LLO_ADD, xmm1
1341 ret
1342
1343 %define LQTABLE [esp + 144] ; qtable
1344 %define LIN_BUFFER [esp + 148] ; in_buffer
1345 %define LOUT_BUFFER [esp + 152] ; out_buffer
1346 %define LWORK_BUFFER [esp + 156] ; work_buffer
1347
1348 ;int
1349 ;rfxcodec_encode_dwt_shift_x86_sse2(const char *qtable,
1350 ; unsigned char *in_buffer,
1351 ; short *out_buffer,
1352 ; short *work_buffer);
1353
1354 ;******************************************************************************
1355 %ifidn __OUTPUT_FORMAT__,elf
1356 PROC rfxcodec_encode_dwt_shift_x86_sse2
1357 %else
1358 PROC _rfxcodec_encode_dwt_shift_x86_sse2
1359 %endif
1360 ; align stack
1361 mov eax, esp
1362 sub eax, 0x10
1363 and eax, 0x0F
1364 sub esp, eax
1365 push eax
1366 sub esp, 3 * 4
1367 sub esp, 4 * 4
1368 ; copy params to after align
1369 movdqu xmm0, [esp + eax + 4 * 4 + 3 * 4 + 4 + 4]
1370 movdqu [esp], xmm0
1371 ; save registers
1372 push ebx
1373 push esi
1374 push edi
1375 push ebp
1376 sub esp, 16 * 8
1377 pxor xmm0, xmm0
1378
1379 ; verical DWT to work buffer, level 1
1380 mov esi, LIN_BUFFER ; src
1381 mov edi, LWORK_BUFFER ; dst hi
1382 lea edi, [edi + 64 * 32 * 2] ; dst hi
1383 mov edx, LWORK_BUFFER ; dst lo
1384 call rfx_dwt_2d_encode_block_verti_8_64
1385
1386 ; horizontal DWT to out buffer, level 1, part 1
1387 xor eax, eax
1388 mov edx, LQTABLE
1389 mov al, [edx + 4]
1390 and al, 0xF
1391 call set_quants_hi
1392 mov esi, LWORK_BUFFER ; src
1393 mov edi, LOUT_BUFFER ; dst hi - HL1
1394 mov edx, LOUT_BUFFER ; dst lo - LL1
1395 lea edx, [edx + 32 * 32 * 6] ; dst lo - LL1
1396 call rfx_dwt_2d_encode_block_horiz_16_64_no_lo
1397
1398 ; horizontal DWT to out buffer, level 1, part 2
1399 xor eax, eax
1400 mov edx, LQTABLE
1401 mov al, [edx + 4]
1402 shr al, 4
1403 call set_quants_hi
1404 xor eax, eax
1405 mov edx, LQTABLE
1406 mov al, [edx + 3]
1407 shr al, 4
1408 call set_quants_lo
1409 mov esi, LWORK_BUFFER ; src
1410 lea esi, [esi + 64 * 32 * 2] ; src
1411 mov edi, LOUT_BUFFER ; dst hi - HH1
1412 lea edi, [edi + 32 * 32 * 4] ; dst hi - HH1
1413 mov edx, LOUT_BUFFER ; dst lo - LH1
1414 lea edx, [edx + 32 * 32 * 2] ; dst lo - LH1
1415 call rfx_dwt_2d_encode_block_horiz_16_64
1416
1417 ; verical DWT to work buffer, level 2
1418 mov esi, LOUT_BUFFER ; src
1419 lea esi, [esi + 32 * 32 * 6] ; src
1420 mov edi, LWORK_BUFFER ; dst hi
1421 lea edi, [edi + 32 * 16 * 2] ; dst hi
1422 mov edx, LWORK_BUFFER ; dst lo
1423 call rfx_dwt_2d_encode_block_verti_16_32
1424
1425 ; horizontal DWT to out buffer, level 2, part 1
1426 xor eax, eax
1427 mov edx, LQTABLE
1428 mov al, [edx + 2]
1429 shr al, 4
1430 call set_quants_hi
1431 mov esi, LWORK_BUFFER ; src
1432 ; 32 * 32 * 6 + 16 * 16 * 0 = 6144
1433 mov edi, LOUT_BUFFER ; dst hi - HL2
1434 lea edi, [edi + 6144] ; dst hi - HL2
1435 ; 32 * 32 * 6 + 16 * 16 * 6 = 7680
1436 mov edx, LOUT_BUFFER ; dst lo - LL2
1437 lea edx, [edx + 7680] ; dst lo - LL2
1438 call rfx_dwt_2d_encode_block_horiz_16_32_no_lo
1439
1440 ; horizontal DWT to out buffer, level 2, part 2
1441 xor eax, eax
1442 mov edx, LQTABLE
1443 mov al, [edx + 3]
1444 and al, 0xF
1445 call set_quants_hi
1446 xor eax, eax
1447 mov edx, LQTABLE
1448 mov al, [edx + 2]
1449 and al, 0xF
1450 call set_quants_lo
1451 mov esi, LWORK_BUFFER ; src
1452 lea esi, [esi + 32 * 16 * 2] ; src
1453 ; 32 * 32 * 6 + 16 * 16 * 4 = 7168
1454 mov edi, LOUT_BUFFER ; dst hi - HH2
1455 lea edi, [edi + 7168] ; dst hi - HH2
1456 ; 32 * 32 * 6 + 16 * 16 * 2 = 6656
1457 mov edx, LOUT_BUFFER ; dst lo - LH2
1458 lea edx, [edx + 6656] ; dst lo - LH2
1459 call rfx_dwt_2d_encode_block_horiz_16_32
1460
1461 ; verical DWT to work buffer, level 3
1462 ; 32 * 32 * 6 + 16 * 16 * 6 = 7680
1463 mov esi, LOUT_BUFFER ; src
1464 lea esi, [esi + 7680] ; src
1465 mov edi, LWORK_BUFFER ; dst hi
1466 lea edi, [edi + 16 * 8 * 2] ; dst hi
1467 mov edx, LWORK_BUFFER ; dst lo
1468 call rfx_dwt_2d_encode_block_verti_16_16
1469
1470 ; horizontal DWT to out buffer, level 3, part 1
1471 xor eax, eax
1472 mov edx, LQTABLE
1473 mov al, [edx + 1]
1474 and al, 0xF
1475 call set_quants_hi
1476 xor eax, eax
1477 mov edx, LQTABLE
1478 mov al, [edx + 0]
1479 and al, 0xF
1480 call set_quants_lo
1481 mov esi, LWORK_BUFFER ; src
1482 ; 32 * 32 * 6 + 16 * 16 * 6 + 8 * 8 * 0 = 7680
1483 mov edi, LOUT_BUFFER ; dst hi - HL3
1484 lea edi, [edi + 7680] ; dst hi - HL3
1485 ; 32 * 32 * 6 + 16 * 16 * 6 + 8 * 8 * 6 = 8064
1486 mov edx, LOUT_BUFFER ; dst lo - LL3
1487 lea edx, [edx + 8064] ; dst lo - LL3
1488 call rfx_dwt_2d_encode_block_horiz_16_16
1489
1490 ; horizontal DWT to out buffer, level 3, part 2
1491 xor eax, eax
1492 mov edx, LQTABLE
1493 mov al, [edx + 1]
1494 shr al, 4
1495 call set_quants_hi
1496 xor eax, eax
1497 mov edx, LQTABLE
1498 mov al, [edx + 0]
1499 shr al, 4
1500 call set_quants_lo
1501 mov esi, LWORK_BUFFER ; src
1502 lea esi, [esi + 16 * 8 * 2] ; src
1503 ; 32 * 32 * 6 + 16 * 16 * 6 + 8 * 8 * 4 = 7936
1504 mov edi, LOUT_BUFFER ; dst hi - HH3
1505 lea edi, [edi + 7936] ; dst hi - HH3
1506 ; 32 * 32 * 6 + 16 * 16 * 6 + 8 * 8 * 2 = 7808
1507 mov edx, LOUT_BUFFER ; dst lo - LH3
1508 lea edx, [edx + 7808] ; dst lo - LH3
1509 call rfx_dwt_2d_encode_block_horiz_16_16
1510
1511 ; quants
1512 add esp, 16 * 8
1513 ; restore registers
1514 pop ebp
1515 pop edi
1516 pop esi
1517 pop ebx
1518 ; params
1519 add esp, 3 * 4
1520 add esp, 4 * 4
1521 ; align
1522 pop eax
1523 add esp, eax
1524 ; return value
1525 mov eax, 0
1526 ret
1527 align 16
1528
0 ;
1 ;Copyright 2016 Jay Sorg
2 ;
3 ;Permission to use, copy, modify, distribute, and sell this software and its
4 ;documentation for any purpose is hereby granted without fee, provided that
5 ;the above copyright notice appear in all copies and that both that
6 ;copyright notice and this permission notice appear in supporting
7 ;documentation.
8 ;
9 ;The above copyright notice and this permission notice shall be included in
10 ;all copies or substantial portions of the Software.
11 ;
12 ;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 ;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 ;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 ;OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
16 ;AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17 ;CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 ;
19 ;x86 asm dwt
20
21 section .data
22 align 16
23 cw128 times 8 dw 128
24 cdFFFF times 4 dd 65535
25 ; these are 1 << (factor - 1) 0 to 15 is factor
26 cwa0 times 8 dw 0 ; 0
27 cwa1 times 8 dw 1 ; 1
28 cwa2 times 8 dw 2 ; 2
29 cwa4 times 8 dw 4 ; 3
30 cwa8 times 8 dw 8 ; 4
31 cwa16 times 8 dw 16 ; 5
32 cwa32 times 8 dw 32 ; 6
33 cwa64 times 8 dw 64 ; 7
34 cwa128 times 8 dw 128 ; 8
35 cwa256 times 8 dw 256 ; 9
36 cwa512 times 8 dw 512 ; 10
37 cwa1024 times 8 dw 1024 ; 11
38 cwa2048 times 8 dw 2048 ; 12
39 cwa4096 times 8 dw 4096 ; 13
40 cwa8192 times 8 dw 8192 ; 14
41 cwa16384 times 8 dw 16384 ; 15
42
43 section .text
44
45 %macro PROC 1
46 align 16
47 global %1
48 %1:
49 %endmacro
50
51 %define LHI_ADD [esp + 1 * 16 + 4]
52 %define LHI_SFT [esp + 2 * 16 + 4]
53 %define LLO_ADD [esp + 3 * 16 + 4]
54 %define LLO_SFT [esp + 4 * 16 + 4]
55
56 ;******************************************************************************
57 ; source 16 bit signed, 16 pixel width
58 rfx_dwt_2d_encode_block_horiz_16_16:
59 mov ecx, 8
60 loop1a:
61 ; pre / post
62 movdqa xmm1, [esi] ; src[2n]
63 movdqa xmm2, [esi + 16]
64 movdqa xmm6, xmm1
65 movdqa xmm7, xmm2
66 pand xmm1, [cdFFFF]
67 pand xmm2, [cdFFFF]
68 packusdw xmm1, xmm2
69 movdqa xmm2, xmm6 ; src[2n + 1]
70 movdqa xmm3, xmm7
71 psrldq xmm2, 2
72 psrldq xmm3, 2
73 pand xmm2, [cdFFFF]
74 pand xmm3, [cdFFFF]
75 packusdw xmm2, xmm3
76 movdqa xmm3, xmm6 ; src[2n + 2]
77 movdqa xmm4, xmm7
78 psrldq xmm3, 4
79 psrldq xmm4, 4
80 movd eax, xmm7
81 movd xmm5, eax
82 pslldq xmm5, 12
83 por xmm3, xmm5
84 movdqa xmm5, xmm7
85 psrldq xmm5, 12
86 pslldq xmm5, 12
87 por xmm4, xmm5
88 pand xmm3, [cdFFFF]
89 pand xmm4, [cdFFFF]
90 packusdw xmm3, xmm4
91 movdqa xmm4, xmm1
92 movdqa xmm5, xmm2
93 movdqa xmm6, xmm3
94 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
95 paddw xmm4, xmm6
96 psraw xmm4, 1
97 psubw xmm5, xmm4
98 psraw xmm5, 1
99 movdqa xmm6, xmm5 ; out hi
100 paddw xmm6, LHI_ADD
101 psraw xmm6, LHI_SFT
102 movdqa [edi], xmm6
103 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
104 movdqa xmm7, xmm5
105 movd eax, xmm7
106 pslldq xmm7, 2
107 and eax, 0xFFFF
108 movd xmm6, eax
109 por xmm7, xmm6
110 paddw xmm5, xmm7
111 psraw xmm5, 1
112 paddw xmm5, xmm1
113
114 movdqa xmm6, xmm5 ; out lo
115 paddw xmm6, LLO_ADD
116 psraw xmm6, LLO_SFT
117 movdqa [edx], xmm6
118
119 ; move right
120 lea esi, [esi + 16 * 2]
121 lea edi, [edi + 8 * 2]
122 lea edx, [edx + 8 * 2]
123
124 ; move left
125 lea esi, [esi - 16 * 2]
126 lea edi, [edi - 8 * 2]
127 lea edx, [edx - 8 * 2]
128
129 ; move down
130 lea esi, [esi + 16 * 2]
131 lea edi, [edi + 8 * 2]
132 lea edx, [edx + 8 * 2]
133
134 dec ecx
135 jnz loop1a
136
137 ret
138
139 ;******************************************************************************
140 ; source 16 bit signed, 16 pixel width
141 rfx_dwt_2d_encode_block_verti_16_16:
142 mov ecx, 2
143 loop1b:
144 ; pre
145 movdqa xmm1, [esi] ; src[2n]
146 movdqa xmm2, [esi + 16 * 2] ; src[2n + 1]
147 movdqa xmm3, [esi + 16 * 2 * 2] ; src[2n + 2]
148 movdqa xmm4, xmm1
149 movdqa xmm5, xmm2
150 movdqa xmm6, xmm3
151 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
152 paddw xmm4, xmm6
153 psraw xmm4, 1
154 psubw xmm5, xmm4
155 psraw xmm5, 1
156 movdqa [edi], xmm5 ; out hi
157 movdqa xmm6, xmm5 ; save hi
158 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
159 paddw xmm5, xmm1
160 movdqa [edx], xmm5 ; out lo
161 movdqa xmm7, xmm6 ; save hi
162 ; move down
163 lea esi, [esi + 16 * 2 * 2] ; 2 rows
164 lea edi, [edi + 16 * 2] ; 1 row
165 lea edx, [edx + 16 * 2] ; 1 row
166
167 ; loop
168 shl ecx, 16
169 mov cx, 6
170 loop2b:
171 movdqa xmm1, xmm3 ; src[2n]
172 movdqa xmm2, [esi + 16 * 2] ; src[2n + 1]
173 movdqa xmm3, [esi + 16 * 2 * 2] ; src[2n + 2]
174 movdqa xmm4, xmm1
175 movdqa xmm5, xmm2
176 movdqa xmm6, xmm3
177 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
178 paddw xmm4, xmm6
179 psraw xmm4, 1
180 psubw xmm5, xmm4
181 psraw xmm5, 1
182 movdqa [edi], xmm5 ; out hi
183 movdqa xmm6, xmm5 ; save hi
184 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
185 paddw xmm5, xmm7
186 psraw xmm5, 1
187 paddw xmm5, xmm1
188 movdqa [edx], xmm5 ; out lo
189 movdqa xmm7, xmm6 ; save hi
190 ; move down
191 lea esi, [esi + 16 * 2 * 2] ; 2 rows
192 lea edi, [edi + 16 * 2] ; 1 row
193 lea edx, [edx + 16 * 2] ; 1 row
194
195 dec cx
196 jnz loop2b
197 shr ecx, 16
198
199 ; post
200 movdqa xmm1, xmm3 ; src[2n]
201 movdqa xmm2, [esi + 16 * 2] ; src[2n + 1]
202 movdqa xmm4, xmm1
203 movdqa xmm5, xmm2
204 movdqa xmm6, xmm3
205 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
206 paddw xmm4, xmm6
207 psraw xmm4, 1
208 psubw xmm5, xmm4
209 psraw xmm5, 1
210 movdqa [edi], xmm5 ; out hi
211 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
212 paddw xmm5, xmm7
213 psraw xmm5, 1
214 paddw xmm5, xmm1
215 movdqa [edx], xmm5 ; out lo
216 ; move down
217 lea esi, [esi + 16 * 2 * 2] ; 2 row
218 lea edi, [edi + 16 * 2] ; 1 row
219 lea edx, [edx + 16 * 2] ; 1 row
220
221 ; move up
222 lea esi, [esi - 16 * 16 * 2]
223 lea edi, [edi - 8 * 16 * 2]
224 lea edx, [edx - 8 * 16 * 2]
225
226 ; move right
227 lea esi, [esi + 16]
228 lea edi, [edi + 16]
229 lea edx, [edx + 16]
230
231 dec ecx
232 jnz loop1b
233
234 ret
235
236 ;******************************************************************************
237 ; source 16 bit signed, 32 pixel width
238 rfx_dwt_2d_encode_block_horiz_16_32:
239 mov ecx, 16
240 loop1c:
241 ; pre
242 movdqa xmm1, [esi] ; src[2n]
243 movdqa xmm2, [esi + 16]
244 movdqa xmm6, xmm1
245 movdqa xmm7, xmm2
246 pand xmm1, [cdFFFF]
247 pand xmm2, [cdFFFF]
248 packusdw xmm1, xmm2
249 movdqa xmm2, xmm6 ; src[2n + 1]
250 movdqa xmm3, xmm7
251 psrldq xmm2, 2
252 psrldq xmm3, 2
253 pand xmm2, [cdFFFF]
254 pand xmm3, [cdFFFF]
255 packusdw xmm2, xmm3
256 movdqa xmm3, xmm6 ; src[2n + 2]
257 movdqa xmm4, xmm7
258 psrldq xmm3, 4
259 psrldq xmm4, 4
260 movd eax, xmm7
261 movd xmm5, eax
262 pslldq xmm5, 12
263 por xmm3, xmm5
264 mov eax, [esi + 32]
265 movd xmm5, eax
266 pslldq xmm5, 12
267 por xmm4, xmm5
268 pand xmm3, [cdFFFF]
269 pand xmm4, [cdFFFF]
270 packusdw xmm3, xmm4
271 movdqa xmm4, xmm1
272 movdqa xmm5, xmm2
273 movdqa xmm6, xmm3
274 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
275 paddw xmm4, xmm6
276 psraw xmm4, 1
277 psubw xmm5, xmm4
278 psraw xmm5, 1
279
280 movdqa xmm6, xmm5 ; out hi
281 paddw xmm6, LHI_ADD
282 psraw xmm6, LHI_SFT
283 movdqa [edi], xmm6
284 movdqa xmm2, xmm5 ; save hi
285
286 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
287 movdqa xmm7, xmm5
288 movd eax, xmm7
289 pslldq xmm7, 2
290 and eax, 0xFFFF
291 movd xmm6, eax
292 por xmm7, xmm6
293 paddw xmm5, xmm7
294 psraw xmm5, 1
295 paddw xmm5, xmm1
296
297 psrldq xmm2, 14
298 movd ebx, xmm2 ; save hi
299
300 movdqa xmm6, xmm5 ; out lo
301 paddw xmm6, LLO_ADD
302 psraw xmm6, LLO_SFT
303 movdqa [edx], xmm6
304
305 ; move right
306 lea esi, [esi + 16 * 2]
307 lea edi, [edi + 8 * 2]
308 lea edx, [edx + 8 * 2]
309
310 ; post
311 movdqa xmm1, [esi] ; src[2n]
312 movdqa xmm2, [esi + 16]
313 movdqa xmm6, xmm1
314 movdqa xmm7, xmm2
315 pand xmm1, [cdFFFF]
316 pand xmm2, [cdFFFF]
317 packusdw xmm1, xmm2
318 movdqa xmm2, xmm6 ; src[2n + 1]
319 movdqa xmm3, xmm7
320 psrldq xmm2, 2
321 psrldq xmm3, 2
322 pand xmm2, [cdFFFF]
323 pand xmm3, [cdFFFF]
324 packusdw xmm2, xmm3
325 movdqa xmm3, xmm6 ; src[2n + 2]
326 movdqa xmm4, xmm7
327 psrldq xmm3, 4
328 psrldq xmm4, 4
329 movd eax, xmm7
330 movd xmm5, eax
331 pslldq xmm5, 12
332 por xmm3, xmm5
333 movdqa xmm5, xmm7
334 psrldq xmm5, 12
335 pslldq xmm5, 12
336 por xmm4, xmm5
337 pand xmm3, [cdFFFF]
338 pand xmm4, [cdFFFF]
339 packusdw xmm3, xmm4
340 movdqa xmm4, xmm1
341 movdqa xmm5, xmm2
342 movdqa xmm6, xmm3
343 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
344 paddw xmm4, xmm6
345 psraw xmm4, 1
346 psubw xmm5, xmm4
347 psraw xmm5, 1
348
349 movdqa xmm6, xmm5 ; out hi
350 paddw xmm6, LHI_ADD
351 psraw xmm6, LHI_SFT
352 movdqa [edi], xmm6
353
354 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
355 movdqa xmm7, xmm5
356 pslldq xmm7, 2
357 movd xmm6, ebx
358 por xmm7, xmm6
359 paddw xmm5, xmm7
360 psraw xmm5, 1
361 paddw xmm5, xmm1
362
363 movdqa xmm6, xmm5 ; out lo
364 paddw xmm6, LLO_ADD
365 psraw xmm6, LLO_SFT
366 movdqa [edx], xmm6
367
368 ; move right
369 lea esi, [esi + 16 * 2]
370 lea edi, [edi + 8 * 2]
371 lea edx, [edx + 8 * 2]
372
373 ; move left
374 lea esi, [esi - 32 * 2]
375 lea edi, [edi - 16 * 2]
376 lea edx, [edx - 16 * 2]
377
378 ; move down
379 lea esi, [esi + 32 * 2]
380 lea edi, [edi + 16 * 2]
381 lea edx, [edx + 16 * 2]
382
383 dec ecx
384 jnz loop1c
385
386 ret
387
388 ;******************************************************************************
389 ; source 16 bit signed, 32 pixel width
390 rfx_dwt_2d_encode_block_horiz_16_32_no_lo:
391 mov ecx, 16
392 loop1c1:
393 ; pre
394 movdqa xmm1, [esi] ; src[2n]
395 movdqa xmm2, [esi + 16]
396 movdqa xmm6, xmm1
397 movdqa xmm7, xmm2
398 pand xmm1, [cdFFFF]
399 pand xmm2, [cdFFFF]
400 packusdw xmm1, xmm2
401 movdqa xmm2, xmm6 ; src[2n + 1]
402 movdqa xmm3, xmm7
403 psrldq xmm2, 2
404 psrldq xmm3, 2
405 pand xmm2, [cdFFFF]
406 pand xmm3, [cdFFFF]
407 packusdw xmm2, xmm3
408 movdqa xmm3, xmm6 ; src[2n + 2]
409 movdqa xmm4, xmm7
410 psrldq xmm3, 4
411 psrldq xmm4, 4
412 movd eax, xmm7
413 movd xmm5, eax
414 pslldq xmm5, 12
415 por xmm3, xmm5
416 mov eax, [esi + 32]
417 movd xmm5, eax
418 pslldq xmm5, 12
419 por xmm4, xmm5
420 pand xmm3, [cdFFFF]
421 pand xmm4, [cdFFFF]
422 packusdw xmm3, xmm4
423 movdqa xmm4, xmm1
424 movdqa xmm5, xmm2
425 movdqa xmm6, xmm3
426 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
427 paddw xmm4, xmm6
428 psraw xmm4, 1
429 psubw xmm5, xmm4
430 psraw xmm5, 1
431
432 movdqa xmm6, xmm5 ; out hi
433 paddw xmm6, LHI_ADD
434 psraw xmm6, LHI_SFT
435 movdqa [edi], xmm6
436 movdqa xmm2, xmm5 ; save hi
437
438 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
439 movdqa xmm7, xmm5
440 movd eax, xmm7
441 pslldq xmm7, 2
442 and eax, 0xFFFF
443 movd xmm6, eax
444 por xmm7, xmm6
445 paddw xmm5, xmm7
446 psraw xmm5, 1
447 paddw xmm5, xmm1
448
449 psrldq xmm2, 14
450 movd ebx, xmm2 ; save hi
451
452 movdqa [edx], xmm5 ; out lo
453
454 ; move right
455 lea esi, [esi + 16 * 2]
456 lea edi, [edi + 8 * 2]
457 lea edx, [edx + 8 * 2]
458
459 ; post
460 movdqa xmm1, [esi] ; src[2n]
461 movdqa xmm2, [esi + 16]
462 movdqa xmm6, xmm1
463 movdqa xmm7, xmm2
464 pand xmm1, [cdFFFF]
465 pand xmm2, [cdFFFF]
466 packusdw xmm1, xmm2
467 movdqa xmm2, xmm6 ; src[2n + 1]
468 movdqa xmm3, xmm7
469 psrldq xmm2, 2
470 psrldq xmm3, 2
471 pand xmm2, [cdFFFF]
472 pand xmm3, [cdFFFF]
473 packusdw xmm2, xmm3
474 movdqa xmm3, xmm6 ; src[2n + 2]
475 movdqa xmm4, xmm7
476 psrldq xmm3, 4
477 psrldq xmm4, 4
478 movd eax, xmm7
479 movd xmm5, eax
480 pslldq xmm5, 12
481 por xmm3, xmm5
482 movdqa xmm5, xmm7
483 psrldq xmm5, 12
484 pslldq xmm5, 12
485 por xmm4, xmm5
486 pand xmm3, [cdFFFF]
487 pand xmm4, [cdFFFF]
488 packusdw xmm3, xmm4
489 movdqa xmm4, xmm1
490 movdqa xmm5, xmm2
491 movdqa xmm6, xmm3
492 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
493 paddw xmm4, xmm6
494 psraw xmm4, 1
495 psubw xmm5, xmm4
496 psraw xmm5, 1
497
498 movdqa xmm6, xmm5 ; out hi
499 paddw xmm6, LHI_ADD
500 psraw xmm6, LHI_SFT
501 movdqa [edi], xmm6
502
503 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
504 movdqa xmm7, xmm5
505 pslldq xmm7, 2
506 movd xmm6, ebx
507 por xmm7, xmm6
508 paddw xmm5, xmm7
509 psraw xmm5, 1
510 paddw xmm5, xmm1
511
512 movdqa [edx], xmm5 ; out lo
513
514 ; move right
515 lea esi, [esi + 16 * 2]
516 lea edi, [edi + 8 * 2]
517 lea edx, [edx + 8 * 2]
518
519 ; move left
520 lea esi, [esi - 32 * 2]
521 lea edi, [edi - 16 * 2]
522 lea edx, [edx - 16 * 2]
523
524 ; move down
525 lea esi, [esi + 32 * 2]
526 lea edi, [edi + 16 * 2]
527 lea edx, [edx + 16 * 2]
528
529 dec ecx
530 jnz loop1c1
531
532 ret
533
534 ;******************************************************************************
535 ; source 16 bit signed, 32 pixel width
536 rfx_dwt_2d_encode_block_verti_16_32:
537 mov ecx, 4
538 loop1d:
539 ; pre
540 movdqa xmm1, [esi] ; src[2n]
541 movdqa xmm2, [esi + 32 * 2] ; src[2n + 1]
542 movdqa xmm3, [esi + 32 * 2 * 2] ; src[2n + 2]
543 movdqa xmm4, xmm1
544 movdqa xmm5, xmm2
545 movdqa xmm6, xmm3
546 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
547 paddw xmm4, xmm6
548 psraw xmm4, 1
549 psubw xmm5, xmm4
550 psraw xmm5, 1
551 movdqa [edi], xmm5 ; out hi
552 movdqa xmm6, xmm5 ; save hi
553 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
554 paddw xmm5, xmm1
555 movdqa [edx], xmm5 ; out lo
556 movdqa xmm7, xmm6 ; save hi
557 ; move down
558 lea esi, [esi + 32 * 2 * 2] ; 2 rows
559 lea edi, [edi + 32 * 2] ; 1 row
560 lea edx, [edx + 32 * 2] ; 1 row
561
562 ; loop
563 shl ecx, 16
564 mov cx, 14
565 loop2d:
566 movdqa xmm1, xmm3 ; src[2n]
567 movdqa xmm2, [esi + 32 * 2] ; src[2n + 1]
568 movdqa xmm3, [esi + 32 * 2 * 2] ; src[2n + 2]
569 movdqa xmm4, xmm1
570 movdqa xmm5, xmm2
571 movdqa xmm6, xmm3
572 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
573 paddw xmm4, xmm6
574 psraw xmm4, 1
575 psubw xmm5, xmm4
576 psraw xmm5, 1
577 movdqa [edi], xmm5 ; out hi
578 movdqa xmm6, xmm5 ; save hi
579 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
580 paddw xmm5, xmm7
581 psraw xmm5, 1
582 paddw xmm5, xmm1
583 movdqa [edx], xmm5 ; out lo
584 movdqa xmm7, xmm6 ; save hi
585 ; move down
586 lea esi, [esi + 32 * 2 * 2] ; 2 rows
587 lea edi, [edi + 32 * 2] ; 1 row
588 lea edx, [edx + 32 * 2] ; 1 row
589
590 dec cx
591 jnz loop2d
592 shr ecx, 16
593
594 ; post
595 movdqa xmm1, xmm3 ; src[2n]
596 movdqa xmm2, [esi + 32 * 2] ; src[2n + 1]
597 movdqa xmm4, xmm1
598 movdqa xmm5, xmm2
599 movdqa xmm6, xmm3
600 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
601 paddw xmm4, xmm6
602 psraw xmm4, 1
603 psubw xmm5, xmm4
604 psraw xmm5, 1
605 movdqa [edi], xmm5 ; out hi
606 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
607 paddw xmm5, xmm7
608 psraw xmm5, 1
609 paddw xmm5, xmm1
610 movdqa [edx], xmm5 ; out lo
611 ; move down
612 lea esi, [esi + 32 * 2 * 2] ; 2 row
613 lea edi, [edi + 32 * 2] ; 1 row
614 lea edx, [edx + 32 * 2] ; 1 row
615
616 ; move up
617 lea esi, [esi - 32 * 32 * 2]
618 lea edi, [edi - 16 * 32 * 2]
619 lea edx, [edx - 16 * 32 * 2]
620
621 ; move right
622 lea esi, [esi + 16]
623 lea edi, [edi + 16]
624 lea edx, [edx + 16]
625
626 dec ecx
627 jnz loop1d
628
629 ret
630
631 ;******************************************************************************
632 ; source 16 bit signed, 64 pixel width
633 rfx_dwt_2d_encode_block_horiz_16_64:
634 mov ecx, 32
635 loop1e:
636 ; pre
637 movdqa xmm1, [esi] ; src[2n]
638 movdqa xmm2, [esi + 16]
639 movdqa xmm6, xmm1
640 movdqa xmm7, xmm2
641 pand xmm1, [cdFFFF]
642 pand xmm2, [cdFFFF]
643 packusdw xmm1, xmm2
644 movdqa xmm2, xmm6 ; src[2n + 1]
645 movdqa xmm3, xmm7
646 psrldq xmm2, 2
647 psrldq xmm3, 2
648 pand xmm2, [cdFFFF]
649 pand xmm3, [cdFFFF]
650 packusdw xmm2, xmm3
651 movdqa xmm3, xmm6 ; src[2n + 2]
652 movdqa xmm4, xmm7
653 psrldq xmm3, 4
654 psrldq xmm4, 4
655 movd eax, xmm7
656 movd xmm5, eax
657 pslldq xmm5, 12
658 por xmm3, xmm5
659 mov eax, [esi + 32]
660 movd xmm5, eax
661 pslldq xmm5, 12
662 por xmm4, xmm5
663 pand xmm3, [cdFFFF]
664 pand xmm4, [cdFFFF]
665 packusdw xmm3, xmm4
666 movdqa xmm4, xmm1
667 movdqa xmm5, xmm2
668 movdqa xmm6, xmm3
669 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
670 paddw xmm4, xmm6
671 psraw xmm4, 1
672 psubw xmm5, xmm4
673 psraw xmm5, 1
674
675 movdqa xmm6, xmm5 ; out hi
676 paddw xmm6, LHI_ADD
677 psraw xmm6, LHI_SFT
678 movdqa [edi], xmm6
679 movdqa xmm2, xmm5 ; save hi
680
681 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
682 movdqa xmm7, xmm5
683 movd eax, xmm7
684 pslldq xmm7, 2
685 and eax, 0xFFFF
686 movd xmm6, eax
687 por xmm7, xmm6
688 paddw xmm5, xmm7
689 psraw xmm5, 1
690 paddw xmm5, xmm1
691
692 psrldq xmm2, 14
693 movd ebx, xmm2 ; save hi
694
695 movdqa xmm6, xmm5 ; out lo
696 paddw xmm6, LLO_ADD
697 psraw xmm6, LLO_SFT
698 movdqa [edx], xmm6
699
700 ; move right
701 lea esi, [esi + 16 * 2]
702 lea edi, [edi + 8 * 2]
703 lea edx, [edx + 8 * 2]
704
705 ; loop
706 shl ecx, 16
707 mov cx, 2
708 loop2e:
709 movdqa xmm1, [esi] ; src[2n]
710 movdqa xmm2, [esi + 16]
711 movdqa xmm6, xmm1
712 movdqa xmm7, xmm2
713 pand xmm1, [cdFFFF]
714 pand xmm2, [cdFFFF]
715 packusdw xmm1, xmm2
716 movdqa xmm2, xmm6 ; src[2n + 1]
717 movdqa xmm3, xmm7
718 psrldq xmm2, 2
719 psrldq xmm3, 2
720 pand xmm2, [cdFFFF]
721 pand xmm3, [cdFFFF]
722 packusdw xmm2, xmm3
723 movdqa xmm3, xmm6 ; src[2n + 2]
724 movdqa xmm4, xmm7
725 psrldq xmm3, 4
726 psrldq xmm4, 4
727 movd eax, xmm7
728 movd xmm5, eax
729 pslldq xmm5, 12
730 por xmm3, xmm5
731 mov eax, [esi + 32]
732 movd xmm5, eax
733 pslldq xmm5, 12
734 por xmm4, xmm5
735 pand xmm3, [cdFFFF]
736 pand xmm4, [cdFFFF]
737 packusdw xmm3, xmm4
738 movdqa xmm4, xmm1
739 movdqa xmm5, xmm2
740 movdqa xmm6, xmm3
741 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
742 paddw xmm4, xmm6
743 psraw xmm4, 1
744 psubw xmm5, xmm4
745 psraw xmm5, 1
746
747 movdqa xmm6, xmm5 ; out hi
748 paddw xmm6, LHI_ADD
749 psraw xmm6, LHI_SFT
750 movdqa [edi], xmm6
751 movdqa xmm2, xmm5 ; save hi
752
753 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
754 movdqa xmm7, xmm5
755 pslldq xmm7, 2
756 movd xmm6, ebx
757 por xmm7, xmm6
758 paddw xmm5, xmm7
759 psraw xmm5, 1
760 paddw xmm5, xmm1
761
762 psrldq xmm2, 14
763 movd ebx, xmm2 ; save hi
764
765 movdqa xmm6, xmm5 ; out lo
766 paddw xmm6, LLO_ADD
767 psraw xmm6, LLO_SFT
768 movdqa [edx], xmm6
769
770 ; move right
771 lea esi, [esi + 16 * 2]
772 lea edi, [edi + 8 * 2]
773 lea edx, [edx + 8 * 2]
774
775 dec cx
776 jnz loop2e
777 shr ecx, 16
778
779 ; post
780 movdqa xmm1, [esi] ; src[2n]
781 movdqa xmm2, [esi + 16]
782 movdqa xmm6, xmm1
783 movdqa xmm7, xmm2
784 pand xmm1, [cdFFFF]
785 pand xmm2, [cdFFFF]
786 packusdw xmm1, xmm2
787 movdqa xmm2, xmm6 ; src[2n + 1]
788 movdqa xmm3, xmm7
789 psrldq xmm2, 2
790 psrldq xmm3, 2
791 pand xmm2, [cdFFFF]
792 pand xmm3, [cdFFFF]
793 packusdw xmm2, xmm3
794 movdqa xmm3, xmm6 ; src[2n + 2]
795 movdqa xmm4, xmm7
796 psrldq xmm3, 4
797 psrldq xmm4, 4
798 movd eax, xmm7
799 movd xmm5, eax
800 pslldq xmm5, 12
801 por xmm3, xmm5
802 movdqa xmm5, xmm7
803 psrldq xmm5, 12
804 pslldq xmm5, 12
805 por xmm4, xmm5
806 pand xmm3, [cdFFFF]
807 pand xmm4, [cdFFFF]
808 packusdw xmm3, xmm4
809 movdqa xmm4, xmm1
810 movdqa xmm5, xmm2
811 movdqa xmm6, xmm3
812 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
813 paddw xmm4, xmm6
814 psraw xmm4, 1
815 psubw xmm5, xmm4
816 psraw xmm5, 1
817
818 movdqa xmm6, xmm5 ; out hi
819 paddw xmm6, LHI_ADD
820 psraw xmm6, LHI_SFT
821 movdqa [edi], xmm6
822
823 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
824 movdqa xmm7, xmm5
825 pslldq xmm7, 2
826 movd xmm6, ebx
827 por xmm7, xmm6
828 paddw xmm5, xmm7
829 psraw xmm5, 1
830 paddw xmm5, xmm1
831
832 movdqa xmm6, xmm5 ; out lo
833 paddw xmm6, LLO_ADD
834 psraw xmm6, LLO_SFT
835 movdqa [edx], xmm6
836
837 ; move right
838 lea esi, [esi + 16 * 2]
839 lea edi, [edi + 8 * 2]
840 lea edx, [edx + 8 * 2]
841
842 ; move left
843 lea esi, [esi - 64 * 2]
844 lea edi, [edi - 32 * 2]
845 lea edx, [edx - 32 * 2]
846
847 ; move down
848 lea esi, [esi + 64 * 2]
849 lea edi, [edi + 32 * 2]
850 lea edx, [edx + 32 * 2]
851
852 dec ecx
853 jnz loop1e
854
855 ret
856
857 ;******************************************************************************
858 ; source 16 bit signed, 64 pixel width
859 rfx_dwt_2d_encode_block_horiz_16_64_no_lo:
860 mov ecx, 32
861 loop1e1:
862 ; pre
863 movdqa xmm1, [esi] ; src[2n]
864 movdqa xmm2, [esi + 16]
865 movdqa xmm6, xmm1
866 movdqa xmm7, xmm2
867 pand xmm1, [cdFFFF]
868 pand xmm2, [cdFFFF]
869 packusdw xmm1, xmm2
870 movdqa xmm2, xmm6 ; src[2n + 1]
871 movdqa xmm3, xmm7
872 psrldq xmm2, 2
873 psrldq xmm3, 2
874 pand xmm2, [cdFFFF]
875 pand xmm3, [cdFFFF]
876 packusdw xmm2, xmm3
877 movdqa xmm3, xmm6 ; src[2n + 2]
878 movdqa xmm4, xmm7
879 psrldq xmm3, 4
880 psrldq xmm4, 4
881 movd eax, xmm7
882 movd xmm5, eax
883 pslldq xmm5, 12
884 por xmm3, xmm5
885 mov eax, [esi + 32]
886 movd xmm5, eax
887 pslldq xmm5, 12
888 por xmm4, xmm5
889 pand xmm3, [cdFFFF]
890 pand xmm4, [cdFFFF]
891 packusdw xmm3, xmm4
892 movdqa xmm4, xmm1
893 movdqa xmm5, xmm2
894 movdqa xmm6, xmm3
895 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
896 paddw xmm4, xmm6
897 psraw xmm4, 1
898 psubw xmm5, xmm4
899 psraw xmm5, 1
900
901 movdqa xmm6, xmm5 ; out hi
902 paddw xmm6, LHI_ADD
903 psraw xmm6, LHI_SFT
904 movdqa [edi], xmm6
905 movdqa xmm2, xmm5 ; save hi
906
907 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
908 movdqa xmm7, xmm5
909 movd eax, xmm7
910 pslldq xmm7, 2
911 and eax, 0xFFFF
912 movd xmm6, eax
913 por xmm7, xmm6
914 paddw xmm5, xmm7
915 psraw xmm5, 1
916 paddw xmm5, xmm1
917
918 psrldq xmm2, 14
919 movd ebx, xmm2 ; save hi
920
921 movdqa [edx], xmm5 ; out lo
922
923 ; move right
924 lea esi, [esi + 16 * 2]
925 lea edi, [edi + 8 * 2]
926 lea edx, [edx + 8 * 2]
927
928 ; loop
929 shl ecx, 16
930 mov cx, 2
931 loop2e1:
932 movdqa xmm1, [esi] ; src[2n]
933 movdqa xmm2, [esi + 16]
934 movdqa xmm6, xmm1
935 movdqa xmm7, xmm2
936 pand xmm1, [cdFFFF]
937 pand xmm2, [cdFFFF]
938 packusdw xmm1, xmm2
939 movdqa xmm2, xmm6 ; src[2n + 1]
940 movdqa xmm3, xmm7
941 psrldq xmm2, 2
942 psrldq xmm3, 2
943 pand xmm2, [cdFFFF]
944 pand xmm3, [cdFFFF]
945 packusdw xmm2, xmm3
946 movdqa xmm3, xmm6 ; src[2n + 2]
947 movdqa xmm4, xmm7
948 psrldq xmm3, 4
949 psrldq xmm4, 4
950 movd eax, xmm7
951 movd xmm5, eax
952 pslldq xmm5, 12
953 por xmm3, xmm5
954 mov eax, [esi + 32]
955 movd xmm5, eax
956 pslldq xmm5, 12
957 por xmm4, xmm5
958 pand xmm3, [cdFFFF]
959 pand xmm4, [cdFFFF]
960 packusdw xmm3, xmm4
961 movdqa xmm4, xmm1
962 movdqa xmm5, xmm2
963 movdqa xmm6, xmm3
964 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
965 paddw xmm4, xmm6
966 psraw xmm4, 1
967 psubw xmm5, xmm4
968 psraw xmm5, 1
969
970 movdqa xmm6, xmm5 ; out hi
971 paddw xmm6, LHI_ADD
972 psraw xmm6, LHI_SFT
973 movdqa [edi], xmm6
974 movdqa xmm2, xmm5 ; save hi
975
976 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
977 movdqa xmm7, xmm5
978 pslldq xmm7, 2
979 movd xmm6, ebx
980 por xmm7, xmm6
981 paddw xmm5, xmm7
982 psraw xmm5, 1
983 paddw xmm5, xmm1
984
985 psrldq xmm2, 14
986 movd ebx, xmm2 ; save hi
987
988 movdqa [edx], xmm5 ; out lo
989
990 ; move right
991 lea esi, [esi + 16 * 2]
992 lea edi, [edi + 8 * 2]
993 lea edx, [edx + 8 * 2]
994
995 dec cx
996 jnz loop2e1
997 shr ecx, 16
998
999 ; post
1000 movdqa xmm1, [esi] ; src[2n]
1001 movdqa xmm2, [esi + 16]
1002 movdqa xmm6, xmm1
1003 movdqa xmm7, xmm2
1004 pand xmm1, [cdFFFF]
1005 pand xmm2, [cdFFFF]
1006 packusdw xmm1, xmm2
1007 movdqa xmm2, xmm6 ; src[2n + 1]
1008 movdqa xmm3, xmm7
1009 psrldq xmm2, 2
1010 psrldq xmm3, 2
1011 pand xmm2, [cdFFFF]
1012 pand xmm3, [cdFFFF]
1013 packusdw xmm2, xmm3
1014 movdqa xmm3, xmm6 ; src[2n + 2]
1015 movdqa xmm4, xmm7
1016 psrldq xmm3, 4
1017 psrldq xmm4, 4
1018 movd eax, xmm7
1019 movd xmm5, eax
1020 pslldq xmm5, 12
1021 por xmm3, xmm5
1022 movdqa xmm5, xmm7
1023 psrldq xmm5, 12
1024 pslldq xmm5, 12
1025 por xmm4, xmm5
1026 pand xmm3, [cdFFFF]
1027 pand xmm4, [cdFFFF]
1028 packusdw xmm3, xmm4
1029 movdqa xmm4, xmm1
1030 movdqa xmm5, xmm2
1031 movdqa xmm6, xmm3
1032 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1033 paddw xmm4, xmm6
1034 psraw xmm4, 1
1035 psubw xmm5, xmm4
1036 psraw xmm5, 1
1037
1038 movdqa xmm6, xmm5 ; out hi
1039 paddw xmm6, LHI_ADD
1040 psraw xmm6, LHI_SFT
1041 movdqa [edi], xmm6
1042
1043 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1044 movdqa xmm7, xmm5
1045 pslldq xmm7, 2
1046 movd xmm6, ebx
1047 por xmm7, xmm6
1048 paddw xmm5, xmm7
1049 psraw xmm5, 1
1050 paddw xmm5, xmm1
1051
1052 movdqa [edx], xmm5 ; out lo
1053
1054 ; move right
1055 lea esi, [esi + 16 * 2]
1056 lea edi, [edi + 8 * 2]
1057 lea edx, [edx + 8 * 2]
1058
1059 ; move left
1060 lea esi, [esi - 64 * 2]
1061 lea edi, [edi - 32 * 2]
1062 lea edx, [edx - 32 * 2]
1063
1064 ; move down
1065 lea esi, [esi + 64 * 2]
1066 lea edi, [edi + 32 * 2]
1067 lea edx, [edx + 32 * 2]
1068
1069 dec ecx
1070 jnz loop1e1
1071
1072 ret
1073
1074 ;******************************************************************************
1075 ; source 8 bit unsigned, 64 pixel width
1076 rfx_dwt_2d_encode_block_verti_8_64:
1077 mov ecx, 8
1078 loop1f:
1079 ; pre
1080 movq xmm1, [esi] ; src[2n]
1081 movq xmm2, [esi + 64 * 1] ; src[2n + 1]
1082 movq xmm3, [esi + 64 * 1 * 2] ; src[2n + 2]
1083 punpcklbw xmm1, xmm0
1084 punpcklbw xmm2, xmm0
1085 punpcklbw xmm3, xmm0
1086 psubw xmm1, [cw128]
1087 psubw xmm2, [cw128]
1088 psubw xmm3, [cw128]
1089 psllw xmm1, 5
1090 psllw xmm2, 5
1091 psllw xmm3, 5
1092 movdqa xmm4, xmm1
1093 movdqa xmm5, xmm2
1094 movdqa xmm6, xmm3
1095 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1096 paddw xmm4, xmm6
1097 psraw xmm4, 1
1098 psubw xmm5, xmm4
1099 psraw xmm5, 1
1100 movdqa [edi], xmm5 ; out hi
1101 movdqa xmm6, xmm5 ; save hi
1102 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1103 paddw xmm5, xmm1
1104 movdqa [edx], xmm5 ; out lo
1105 movdqa xmm7, xmm6 ; save hi
1106 ; move down
1107 lea esi, [esi + 64 * 1 * 2] ; 2 rows
1108 lea edi, [edi + 64 * 2] ; 1 row
1109 lea edx, [edx + 64 * 2] ; 1 row
1110
1111 ; loop
1112 shl ecx, 16
1113 mov cx, 30
1114 loop2f:
1115 movdqa xmm1, xmm3 ; src[2n]
1116 movq xmm2, [esi + 64 * 1] ; src[2n + 1]
1117 movq xmm3, [esi + 64 * 1 * 2] ; src[2n + 2]
1118 punpcklbw xmm2, xmm0
1119 punpcklbw xmm3, xmm0
1120 psubw xmm2, [cw128]
1121 psubw xmm3, [cw128]
1122 psllw xmm2, 5
1123 psllw xmm3, 5
1124 movdqa xmm4, xmm1
1125 movdqa xmm5, xmm2
1126 movdqa xmm6, xmm3
1127 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1128 paddw xmm4, xmm6
1129 psraw xmm4, 1
1130 psubw xmm5, xmm4
1131 psraw xmm5, 1
1132 movdqa [edi], xmm5 ; out hi
1133 movdqa xmm6, xmm5 ; save hi
1134 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1135 paddw xmm5, xmm7
1136 psraw xmm5, 1
1137 paddw xmm5, xmm1
1138 movdqa [edx], xmm5 ; out lo
1139 movdqa xmm7, xmm6 ; save hi
1140 ; move down
1141 lea esi, [esi + 64 * 1 * 2] ; 2 rows
1142 lea edi, [edi + 64 * 2] ; 1 row
1143 lea edx, [edx + 64 * 2] ; 1 row
1144
1145 dec cx
1146 jnz loop2f
1147 shr ecx, 16
1148
1149 ; post
1150 movdqa xmm1, xmm3 ; src[2n]
1151 movq xmm2, [esi + 64 * 1] ; src[2n + 1]
1152 punpcklbw xmm2, xmm0
1153 psubw xmm2, [cw128]
1154 psllw xmm2, 5
1155 movdqa xmm4, xmm1
1156 movdqa xmm5, xmm2
1157 movdqa xmm6, xmm3
1158 ; h[n] = (src[2n + 1] - ((src[2n] + src[2n + 2]) >> 1)) >> 1
1159 paddw xmm4, xmm6
1160 psraw xmm4, 1
1161 psubw xmm5, xmm4
1162 psraw xmm5, 1
1163 movdqa [edi], xmm5 ; out hi
1164 ; l[n] = src[2n] + ((h[n - 1] + h[n]) >> 1)
1165 paddw xmm5, xmm7
1166 psraw xmm5, 1
1167 paddw xmm5, xmm1
1168 movdqa [edx], xmm5 ; out lo
1169 ; move down
1170 lea esi, [esi + 64 * 1 * 2] ; 2 rows
1171 lea edi, [edi + 64 * 2] ; 1 row
1172 lea edx, [edx + 64 * 2] ; 1 row
1173
1174 ; move up
1175 lea esi, [esi - 64 * 1 * 64]
1176 lea edi, [edi - 32 * 64 * 2]
1177 lea edx, [edx - 32 * 64 * 2]
1178
1179 ; move right
1180 lea esi, [esi + 8]
1181 lea edi, [edi + 16]
1182 lea edx, [edx + 16]
1183
1184 dec ecx
1185 jnz loop1f
1186
1187 ret
1188
1189 set_quants_hi:
1190 sub eax, 6 - 5
1191 movd xmm1, eax
1192 movdqa LHI_SFT, xmm1
1193 imul eax, 16
1194 lea edx, [cwa0]
1195 add edx, eax
1196 movdqa xmm1, [edx]
1197 movdqa LHI_ADD, xmm1
1198 ret
1199
1200 set_quants_lo:
1201 sub eax, 6 - 5
1202 movd xmm1, eax
1203 movdqa LLO_SFT, xmm1
1204 imul eax, 16
1205 lea edx, [cwa0]
1206 add edx, eax
1207 movdqa xmm1, [edx]
1208 movdqa LLO_ADD, xmm1
1209 ret
1210
1211 %define LQTABLE [esp + 144] ; qtable
1212 %define LIN_BUFFER [esp + 148] ; in_buffer
1213 %define LOUT_BUFFER [esp + 152] ; out_buffer
1214 %define LWORK_BUFFER [esp + 156] ; work_buffer
1215
1216 ;int
1217 ;rfxcodec_encode_dwt_shift_x86_sse41(const char *qtable,
1218 ; unsigned char *in_buffer,
1219 ; short *out_buffer,
1220 ; short *work_buffer);
1221
1222 ;******************************************************************************
1223 %ifidn __OUTPUT_FORMAT__,elf
1224 PROC rfxcodec_encode_dwt_shift_x86_sse41
1225 %else
1226 PROC _rfxcodec_encode_dwt_shift_x86_sse41
1227 %endif
1228 ; align stack
1229 mov eax, esp
1230 sub eax, 0x10
1231 and eax, 0x0F
1232 sub esp, eax
1233 push eax
1234 sub esp, 3 * 4
1235 sub esp, 4 * 4
1236 ; copy params to after align
1237 movdqu xmm0, [esp + eax + 4 * 4 + 3 * 4 + 4 + 4]
1238 movdqu [esp], xmm0
1239 ; save registers
1240 push ebx
1241 push esi
1242 push edi
1243 push ebp
1244 sub esp, 16 * 8
1245 pxor xmm0, xmm0
1246
1247 ; verical DWT to work buffer, level 1
1248 mov esi, LIN_BUFFER ; src
1249 mov edi, LWORK_BUFFER ; dst hi
1250 lea edi, [edi + 64 * 32 * 2] ; dst hi
1251 mov edx, LWORK_BUFFER ; dst lo
1252 call rfx_dwt_2d_encode_block_verti_8_64
1253
1254 ; horizontal DWT to out buffer, level 1, part 1
1255 xor eax, eax
1256 mov edx, LQTABLE
1257 mov al, [edx + 4]
1258 and al, 0xF
1259 call set_quants_hi
1260 mov esi, LWORK_BUFFER ; src
1261 mov edi, LOUT_BUFFER ; dst hi - HL1
1262 mov edx, LOUT_BUFFER ; dst lo - LL1
1263 lea edx, [edx + 32 * 32 * 6] ; dst lo - LL1
1264 call rfx_dwt_2d_encode_block_horiz_16_64_no_lo
1265
1266 ; horizontal DWT to out buffer, level 1, part 2
1267 xor eax, eax
1268 mov edx, LQTABLE
1269 mov al, [edx + 4]
1270 shr al, 4
1271 call set_quants_hi
1272 xor eax, eax
1273 mov edx, LQTABLE
1274 mov al, [edx + 3]
1275 shr al, 4
1276 call set_quants_lo
1277 mov esi, LWORK_BUFFER ; src
1278 lea esi, [esi + 64 * 32 * 2] ; src
1279 mov edi, LOUT_BUFFER ; dst hi - HH1
1280 lea edi, [edi + 32 * 32 * 4] ; dst hi - HH1
1281 mov edx, LOUT_BUFFER ; dst lo - LH1
1282 lea edx, [edx + 32 * 32 * 2] ; dst lo - LH1
1283 call rfx_dwt_2d_encode_block_horiz_16_64
1284
1285 ; verical DWT to work buffer, level 2
1286 mov esi, LOUT_BUFFER ; src
1287 lea esi, [esi + 32 * 32 * 6] ; src
1288 mov edi, LWORK_BUFFER ; dst hi
1289 lea edi, [edi + 32 * 16 * 2] ; dst hi
1290 mov edx, LWORK_BUFFER ; dst lo
1291 call rfx_dwt_2d_encode_block_verti_16_32
1292
1293 ; horizontal DWT to out buffer, level 2, part 1
1294 xor eax, eax
1295 mov edx, LQTABLE
1296 mov al, [edx + 2]
1297 shr al, 4
1298 call set_quants_hi
1299 mov esi, LWORK_BUFFER ; src
1300 ; 32 * 32 * 6 + 16 * 16 * 0 = 6144
1301 mov edi, LOUT_BUFFER ; dst hi - HL2
1302 lea edi, [edi + 6144] ; dst hi - HL2
1303 ; 32 * 32 * 6 + 16 * 16 * 6 = 7680
1304 mov edx, LOUT_BUFFER ; dst lo - LL2
1305 lea edx, [edx + 7680] ; dst lo - LL2
1306 call rfx_dwt_2d_encode_block_horiz_16_32_no_lo
1307
1308 ; horizontal DWT to out buffer, level 2, part 2
1309 xor eax, eax
1310 mov edx, LQTABLE
1311 mov al, [edx + 3]
1312 and al, 0xF
1313 call set_quants_hi
1314 xor eax, eax
1315 mov edx, LQTABLE
1316 mov al, [edx + 2]
1317 and al, 0xF
1318 call set_quants_lo
1319 mov esi, LWORK_BUFFER ; src
1320 lea esi, [esi + 32 * 16 * 2] ; src
1321 ; 32 * 32 * 6 + 16 * 16 * 4 = 7168
1322 mov edi, LOUT_BUFFER ; dst hi - HH2
1323 lea edi, [edi + 7168] ; dst hi - HH2
1324 ; 32 * 32 * 6 + 16 * 16 * 2 = 6656
1325 mov edx, LOUT_BUFFER ; dst lo - LH2
1326 lea edx, [edx + 6656] ; dst lo - LH2
1327 call rfx_dwt_2d_encode_block_horiz_16_32
1328
1329 ; verical DWT to work buffer, level 3
1330 ; 32 * 32 * 6 + 16 * 16 * 6 = 7680
1331 mov esi, LOUT_BUFFER ; src
1332 lea esi, [esi + 7680] ; src
1333 mov edi, LWORK_BUFFER ; dst hi
1334 lea edi, [edi + 16 * 8 * 2] ; dst hi
1335 mov edx, LWORK_BUFFER ; dst lo
1336 call rfx_dwt_2d_encode_block_verti_16_16
1337
1338 ; horizontal DWT to out buffer, level 3, part 1
1339 xor eax, eax
1340 mov edx, LQTABLE
1341 mov al, [edx + 1]
1342 and al, 0xF
1343 call set_quants_hi
1344 xor eax, eax
1345 mov edx, LQTABLE
1346 mov al, [edx + 0]
1347 and al, 0xF
1348 call set_quants_lo
1349 mov esi, LWORK_BUFFER ; src
1350 ; 32 * 32 * 6 + 16 * 16 * 6 + 8 * 8 * 0 = 7680
1351 mov edi, LOUT_BUFFER ; dst hi - HL3
1352 lea edi, [edi + 7680] ; dst hi - HL3
1353 ; 32 * 32 * 6 + 16 * 16 * 6 + 8 * 8 * 6 = 8064
1354 mov edx, LOUT_BUFFER ; dst lo - LL3
1355 lea edx, [edx + 8064] ; dst lo - LL3
1356 call rfx_dwt_2d_encode_block_horiz_16_16
1357
1358 ; horizontal DWT to out buffer, level 3, part 2
1359 xor eax, eax
1360 mov edx, LQTABLE
1361 mov al, [edx + 1]
1362 shr al, 4
1363 call set_quants_hi
1364 xor eax, eax
1365 mov edx, LQTABLE
1366 mov al, [edx + 0]
1367 shr al, 4
1368 call set_quants_lo
1369 mov esi, LWORK_BUFFER ; src
1370 lea esi, [esi + 16 * 8 * 2] ; src
1371 ; 32 * 32 * 6 + 16 * 16 * 6 + 8 * 8 * 4 = 7936
1372 mov edi, LOUT_BUFFER ; dst hi - HH3
1373 lea edi, [edi + 7936] ; dst hi - HH3
1374 ; 32 * 32 * 6 + 16 * 16 * 6 + 8 * 8 * 2 = 7808
1375 mov edx, LOUT_BUFFER ; dst lo - LH3
1376 lea edx, [edx + 7808] ; dst lo - LH3
1377 call rfx_dwt_2d_encode_block_horiz_16_16
1378
1379 ; quants
1380 add esp, 16 * 8
1381 ; restore registers
1382 pop ebp
1383 pop edi
1384 pop esi
1385 pop ebx
1386 ; params
1387 add esp, 3 * 4
1388 add esp, 4 * 4
1389 ; align
1390 pop eax
1391 add esp, eax
1392 ; return value
1393 mov eax, 0
1394 ret
1395 align 16
1396
+0
-26
librfxcodec/src/x86/rfxdwt_x86_sse2.asm less more
0
1 section .data
2 const1 times 8 dw 1
3
4 %macro PROC 1
5 align 16
6 global %1
7 %1:
8 %endmacro
9
10 ;int
11 ;dwt_shift_x86_sse2(const int *quantization_values, uint8 *data,
12 ; sint16 *dwt_buffer1, sint16 *dwt_buffer);
13
14 PROC dwt_shift_x86_sse2
15 push ebx
16 push esi
17 push edi
18
19 mov eax, 0
20 pop edi
21 pop esi
22 pop ebx
23 ret
24 align 16
25
+0
-25
librfxcodec/src/x86/rfxrlgr1_x86.asm less more
0
1 section .data
2 const1 times 8 dw 1
3
4 %macro PROC 1
5 align 16
6 global %1
7 %1:
8 %endmacro
9
10 ;int
11 ;diff_rlgr1_x86(sint16 *co, int num_co, uint8 *dst, int dst_bytes);
12
13 PROC diff_rlgr1_x86
14 push ebx
15 push esi
16 push edi
17
18 mov eax, 0
19 pop edi
20 pop esi
21 pop ebx
22 ret
23 align 16
24
+0
-25
librfxcodec/src/x86/rfxrlgr3_x86.asm less more
0
1 section .data
2 const1 times 8 dw 1
3
4 %macro PROC 1
5 align 16
6 global %1
7 %1:
8 %endmacro
9
10 ;int
11 ;diff_rlgr3_x86(sint16 *co, int num_co, uint8 *dst, int dst_bytes);
12
13 PROC diff_rlgr3_x86
14 push ebx
15 push esi
16 push edi
17
18 mov eax, 0
19 pop edi
20 pop esi
21 pop ebx
22 ret
23 align 16
24
+0
-22
librfxcodec/tests/Makefile less more
0
1 OBJS = rfxcodectest.o
2
3 CFLAGS = -g -O2 -Wall -fPIC -I../include
4
5 # this for linking to .so
6 #LDFLAGS = $(PROFIL) -L../src -Wl,-rpath=../src
7 # this if using .a
8 LDFLAGS = $(PROFIL)
9
10 # this for linking to .so
11 #LIBS = -lrfxencode
12 # this for using .a
13 LIBS = ../src/librfxencode.a
14
15 all: rfxcodectest
16
17 rfxcodectest: $(OBJS) Makefile
18 $(CC) -o rfxcodectest $(LDFLAGS) $(OBJS) $(LIBS)
19
20 clean:
21 rm -f $(OBJS) rfxcodectest
0
1 EXTRA_DIST = readme.txt
2
3 EXTRA_INCLUDES =
4 EXTRA_LIBS =
5 EXTRA_FLAGS =
6
7 if GOT_PREFIX
8 EXTRA_INCLUDES += -I$(prefix)/include
9 EXTRA_FLAGS += -L$(prefix)/lib -Wl,-rpath -Wl,$(prefix)/lib
10 endif
11
12 INCLUDES = \
13 -I$(top_srcdir)/include \
14 $(EXTRA_INCLUDES)
15
16 bin_PROGRAMS = rfxcodectest
17
18 rfxcodectest_SOURCES = rfxcodectest.c
19
20 rfxcodectest_LDADD = \
21 $(top_builddir)/src/librfxencode.la $(EXTRA_LIBS)
22
23 rfxcodectest_LDFLAGS = $(EXTRA_FLAGS)
24
00 /**
11 * RFX codec encoder test
22 *
3 * Copyright 2014 Jay Sorg <jay.sorg@gmail.com>
3 * Copyright 2014-2015 Jay Sorg <jay.sorg@gmail.com>
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
2626
2727 #include <rfxcodec_encode.h>
2828
29 static const int g_rfx_default_quantization_values[] =
29 static const unsigned char g_rfx_default_quantization_values[] =
3030 {
3131 /* LL3 LH3 HL3 HH3 LH2 HL2 HH2 LH1 HL1 HH1 */
32 6, 6, 6, 6, 7, 7, 8, 8, 8, 9,
33 9, 9, 9, 9, 10, 10, 12, 12, 12, 13
32 0x66, 0x66, 0x77, 0x88, 0x98,
33 0x99, 0x99, 0xaa, 0xcc, 0xdc
3434 };
3535
3636 /*****************************************************************************/
4545
4646 /******************************************************************************/
4747 static int
48 speed_random(int count, const int *quants)
48 speed_random(int count, const char *quants)
4949 {
5050 void *han;
5151 int error;
5555 char *cdata;
5656 char *buf;
5757 struct rfx_rect regions[1];
58 struct rfx_tile tiles[1];
58 struct rfx_tile tiles[2];
5959 int stime;
6060 int etime;
6161 int tiles_per_second;
6262 int num_regions;
6363 int num_tiles;
6464 int num_quants;
65 int flags;
6566
6667 printf("speed_random:\n");
67 han = rfxcodec_encode_create(1920, 1024, RFX_FORMAT_BGRA, RFX_FLAGS_RLGR1);
68 if (han == 0)
69 {
70 printf("speed_random: rfxcodec_encode_create failed\n");
71 return 1;
72 }
73 printf("speed_random: rfxcodec_encode_create ok\n");
74 cdata = (char *) malloc(64 * 64 * 4);
75 cdata_bytes = 64 * 64 * 4;
76 buf = (char *) malloc(64 * 64 * 4);
68 //flags = RFX_FLAGS_RLGR1 | RFX_FLAGS_NOACCEL;
69 flags = RFX_FLAGS_RLGR1;
70 //flags = RFX_FLAGS_RLGR3;
71 //flags = RFX_FLAGS_RLGR1 | RFX_FLAGS_ALPHAV1;
72 error = rfxcodec_encode_create_ex(1920, 1024, RFX_FORMAT_BGRA, flags, &han);
73 if (error != 0)
74 {
75 printf("speed_random: rfxcodec_encode_create_ex failed\n");
76 return 1;
77 }
78 printf("speed_random: rfxcodec_encode_create_ex ok\n");
79 cdata = (char *) malloc(128 * 64 * 4);
80 cdata_bytes = 128 * 64 * 4;
81 buf = (char *) malloc(128 * 64 * 4);
82 #if 1
7783 fd = open("/dev/urandom", O_RDONLY);
78 if (read(fd, buf, 64 * 64 * 4) != 64 * 64 * 4)
84 //fd = open("/dev/zero", O_RDONLY);
85 if (read(fd, buf, 128 * 64 * 4) != 128 * 64 * 4)
7986 {
8087 printf("speed_random: read error\n");
8188 }
8289 close(fd);
90 #else
91 memset(buf, 0x7f, 128 * 64 * 4);
92 #endif
8393 regions[0].x = 0;
8494 regions[0].y = 0;
85 regions[0].cx = 64;
95 regions[0].cx = 128;
8696 regions[0].cy = 64;
8797 num_regions = 1;
8898 tiles[0].x = 0;
92102 tiles[0].quant_y = 0;
93103 tiles[0].quant_cb = 0;
94104 tiles[0].quant_cr = 0;
105 tiles[1].x = 64;
106 tiles[1].y = 0;
107 tiles[1].cx = 64;
108 tiles[1].cy = 64;
109 tiles[1].quant_y = 0;
110 tiles[1].quant_cb = 0;
111 tiles[1].quant_cr = 0;
95112 num_tiles = 1;
96113 num_quants = 1;
97114 error = 0;
98115 stime = get_mstime();
116 flags = 0;
117 //flags = RFX_FLAGS_ALPHAV1;
99118 for (index = 0; index < count; index++)
100119 {
101 error = rfxcodec_encode(han, cdata, &cdata_bytes, buf, 64, 64, 64 * 4,
102 regions, num_regions, tiles, num_tiles,
103 quants, num_quants);
120 error = rfxcodec_encode_ex(han, cdata, &cdata_bytes, buf, 64, 64, 64 * 4,
121 regions, num_regions, tiles, num_tiles,
122 quants, num_quants, flags);
104123 if (error != 0)
105124 {
106125 break;
107126 }
108127 }
109128 etime = get_mstime();
110 tiles_per_second = count * 1000 / (etime - stime);
129 tiles_per_second = count * num_tiles * 1000 / (etime - stime + 1);
111130 printf("speed_random: cdata_bytes %d count %d ms time %d "
112131 "tiles_per_second %d\n",
113132 cdata_bytes, count, etime - stime, tiles_per_second);
220239 /******************************************************************************/
221240 static int
222241 encode_file(char *data, int width, int height, char *cdata, int *cdata_bytes,
223 const int *quants, int num_quants)
242 const char *quants, int num_quants)
224243 {
225244 int awidth;
226245 int aheight;
234253 void *han;
235254 struct rfx_rect regions[1];
236255
237 han = rfxcodec_encode_create(1920, 1024, RFX_FORMAT_BGRA, RFX_FLAGS_RLGR1);
238 if (han == 0)
239 {
240 printf("encode_file: rfxcodec_encode_create failed\n");
256 error = rfxcodec_encode_create_ex(1920, 1024, RFX_FORMAT_BGRA, RFX_FLAGS_RLGR1, &han);
257 if (error != 0)
258 {
259 printf("encode_file: rfxcodec_encode_create_ex failed\n");
241260 return 1;
242261 }
243262
268287 regions[0].cy = height;
269288 num_regions = 1;
270289
271 error = rfxcodec_encode(han, cdata, cdata_bytes, data, width, height, width * 4,
272 regions, num_regions, tiles, num_tiles,
273 quants, num_quants);
290 error = rfxcodec_encode_ex(han, cdata, cdata_bytes, data, width, height, width * 4,
291 regions, num_regions, tiles, num_tiles,
292 quants, num_quants, 0);
274293 if (error != 0)
275294 {
276295 printf("encode_file: rfxcodec_encode failed error %d\n", error);
286305
287306 /******************************************************************************/
288307 static int
289 read_file(int count, const int *quants, int num_quants,
308 read_file(int count, const char *quants, int num_quants,
290309 const char *in_file, const char *out_file)
291310 {
292311 int in_fd;
379398 int count;
380399 char in_file[256];
381400 char out_file[256];
382 const int *quants = g_rfx_default_quantization_values;
401 const char *quants = (const char *) g_rfx_default_quantization_values;
383402
384403 do_speed = 0;
385404 do_read = 0;
0 EXTRA_DIST = libxrdp.h libxrdpinc.h xrdp_orders_rail.h
1
20 EXTRA_DEFINES =
31 EXTRA_INCLUDES =
42 EXTRA_LIBS =
2725 endif
2826 endif
2927
30 if GOT_PREFIX
31 EXTRA_INCLUDES += -I$(prefix)/include
32 EXTRA_FLAGS += -L$(prefix)/lib -Wl,-rpath -Wl,$(prefix)/lib
33 endif
34
35 AM_CFLAGS = \
28 AM_CPPFLAGS = \
3629 -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
3730 -DXRDP_SBIN_PATH=\"${sbindir}\" \
3831 -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
3932 -DXRDP_PID_PATH=\"${localstatedir}/run\" \
40 $(EXTRA_DEFINES)
41
42 INCLUDES = \
33 $(EXTRA_DEFINES) \
4334 -I$(top_srcdir)/common \
4435 $(EXTRA_INCLUDES)
4536
46 lib_LTLIBRARIES = \
37 module_LTLIBRARIES = \
4738 libxrdp.la
4839
4940 libxrdp_la_SOURCES = \
5041 libxrdp.c \
42 libxrdp.h \
43 libxrdpinc.h \
44 xrdp_bitmap32_compress.c \
45 xrdp_bitmap_compress.c \
46 xrdp_caps.c \
5147 xrdp_channel.c \
48 xrdp_fastpath.c \
5249 xrdp_iso.c \
50 xrdp_jpeg_compress.c \
5351 xrdp_mcs.c \
52 xrdp_mppc_enc.c \
5453 xrdp_orders.c \
54 xrdp_orders_rail.c \
55 xrdp_orders_rail.h \
5556 xrdp_rdp.c \
56 xrdp_sec.c \
57 xrdp_bitmap_compress.c \
58 xrdp_bitmap32_compress.c \
59 xrdp_jpeg_compress.c \
60 xrdp_orders_rail.c \
61 xrdp_mppc_enc.c \
62 xrdp_fastpath.c \
63 xrdp_caps.c
57 xrdp_sec.c
6458
6559 libxrdp_la_LDFLAGS = \
6660 $(EXTRA_FLAGS)
6565
6666 /******************************************************************************/
6767 int EXPORT_CC
68 libxrdp_process_incomming(struct xrdp_session *session)
68 libxrdp_process_incoming(struct xrdp_session *session)
6969 {
7070 int rv;
7171
104104 }
105105
106106 /******************************************************************************/
107 /* only used durring connection */
107 /* only used during connection */
108108 struct stream * APP_CC
109109 libxrdp_force_read(struct trans* trans)
110110 {
252252 {
253253 /*This situation can happen and this is a workaround*/
254254 cont = 0;
255 g_writeln("Serious programming error we were locked in a deadly loop") ;
256 g_writeln("remaining :%d", s->end - s->next_packet);
255 g_writeln("Serious programming error: we were locked in a deadly loop");
256 g_writeln("Remaining: %d", (int) (s->end - s->next_packet));
257257 s->next_packet = 0;
258258 }
259259
970970 }
971971
972972 /* shut down the rdp client */
973 if (xrdp_rdp_send_deactive((struct xrdp_rdp *)session->rdp) != 0)
973 if (xrdp_rdp_send_deactivate((struct xrdp_rdp *)session->rdp) != 0)
974974 {
975975 return 1;
976976 }
10731073 }
10741074
10751075 /*****************************************************************************/
1076 /* returns a zero based index of the channel, -1 if error or it dosen't
1076 /* returns a zero based index of the channel, -1 if error or it doesn't
10771077 exist */
10781078 int EXPORT_CC
10791079 libxrdp_get_channel_id(struct xrdp_session *session, char *name)
12971297 struct stream ls;
12981298 struct stream *s;
12991299 struct xrdp_rdp *rdp;
1300 int rv;
13011300 int sec_bytes;
13021301 int rdp_bytes;
13031302 int max_bytes;
280280 char *outputBuffer; /* contains compressed data */
281281 char *outputBufferPlus;
282282 int historyOffset; /* next free slot in historyBuffer */
283 int buf_len; /* length of historyBuffer, protocol dependant */
283 int buf_len; /* length of historyBuffer, protocol dependent */
284284 int bytes_in_opb; /* compressed bytes available in outputBuffer */
285285 int flags; /* PACKET_COMPRESSED, PACKET_AT_FRONT, PACKET_FLUSHED etc */
286286 int flagsHold;
400400 int APP_CC
401401 xrdp_rdp_disconnect(struct xrdp_rdp *self);
402402 int APP_CC
403 xrdp_rdp_send_deactive(struct xrdp_rdp *self);
403 xrdp_rdp_send_deactivate(struct xrdp_rdp *self);
404404
405405 /* xrdp_orders.c */
406406 struct xrdp_orders * APP_CC
2626
2727 struct xrdp_brush
2828 {
29 int x_orgin;
30 int y_orgin;
29 int x_origin;
30 int y_origin;
3131 int style;
3232 char pattern[8];
3333 };
8282 int DEFAULT_CC
8383 libxrdp_disconnect(struct xrdp_session *session);
8484 int DEFAULT_CC
85 libxrdp_process_incomming(struct xrdp_session *session);
85 libxrdp_process_incoming(struct xrdp_session *session);
8686 int EXPORT_CC
8787 libxrdp_get_pdu_bytes(const char *aheader);
8888 struct stream * APP_CC
184184 i = MAX(i, 0);
185185 self->client_info.cache2_entries = i;
186186 in_uint16_le(s, self->client_info.cache2_size);
187 /* caceh 3 */
187 /* cache 3 */
188188 in_uint16_le(s, i);
189189 i = MIN(i, XRDP_MAX_BITMAP_CACHE_IDX);
190190 i = MAX(i, 0);
507507
508508 /*****************************************************************************/
509509 static int APP_CC
510 xrdp_caps_process_multifragmetupdate(struct xrdp_rdp *self, struct stream *s,
511 int len)
510 xrdp_caps_process_multifragmentupdate(struct xrdp_rdp *self, struct stream *s,
511 int len)
512512 {
513513 int MaxRequestSize;
514514
549549 in_uint16_le(s, num_caps);
550550 in_uint8s(s, 2); /* pad */
551551
552 if ((cap_len < 0) || (cap_len > 1024 * 1024))
553 {
554 return 1;
555 }
556
552557 for (index = 0; index < num_caps; index++)
553558 {
554559 p = s->p;
561566 in_uint16_le(s, len);
562567 if ((len < 4) || !s_check_rem(s, len - 4))
563568 {
564 g_writeln("xrdp_caps_process_confirm_active: error len %d", len, s->end - s->p);
569 g_writeln("xrdp_caps_process_confirm_active: error: len %d, "
570 "remaining %d", len, (int) (s->end - s->p));
565571 return 1;
566572 }
567573 len -= 4;
640646 xrdp_caps_process_window(self, s, len);
641647 break;
642648 case 0x001A: /* 26 CAPSETTYPE_MULTIFRAGMENTUPDATE */
643 xrdp_caps_process_multifragmetupdate(self, s, len);
649 xrdp_caps_process_multifragmentupdate(self, s, len);
644650 break;
645651 case RDP_CAPSET_BMPCODECS: /* 0x1d(29) */
646652 xrdp_caps_process_codecs(self, s, len);
172172
173173 /*****************************************************************************/
174174 /* returns error */
175 /* This is called from the secure layer to process an incomming non global
175 /* This is called from the secure layer to process an incoming non global
176176 channel packet.
177177 'chanid' passed in here is the mcs channel id so it MCS_GLOBAL_CHANNEL
178178 plus something. */
9696 }
9797
9898 /*****************************************************************************/
99 /* no fragmenation */
99 /* no fragmentation */
100100 int APP_CC
101101 xrdp_fastpath_init(struct xrdp_fastpath *self, struct stream *s)
102102 {
132132 }
133133
134134 /*****************************************************************************/
135 /* no fragmenation */
135 /* no fragmentation */
136136 int APP_CC
137137 xrdp_fastpath_send(struct xrdp_fastpath *self, struct stream *s)
138138 {
9898 default:
9999 if (self->requestedProtocol & PROTOCOL_SSL)
100100 {
101 /* thats a patch since we don't support CredSSP for now */
101 /* that's a patch since we don't support CredSSP for now */
102102 self->selectedProtocol = PROTOCOL_SSL;
103103 }
104104 else
354354 {
355355 text[cookie_index] = cc_type;
356356 cookie_index++;
357 if (cookie_index > 255)
358 {
359 cookie_index = 255;
360 }
357361 if ((s->p[0] == 0x0D) && (s->p[1] == 0x0A))
358362 {
359363 in_uint8s(s, 2);
360364 text[cookie_index] = 0;
361365 cookie_index = 0;
366 if (g_strlen(text) > 0)
367 {
368 }
362369 break;
363370 }
364371 in_uint8(s, cc_type);
219219 };
220220
221221 /*****************************************************************************/
222 /* called at begining */
222 /* called at beginning */
223223 static void DEFAULT_CC
224224 my_init_destination(j_compress_ptr cinfo)
225225 {
182182 }
183183 else
184184 {
185 log_message(LOG_LEVEL_DEBUG,"Recieved an unhandled appid:%d",appid);
185 log_message(LOG_LEVEL_DEBUG,"Received an unhandled appid:%d",appid);
186186 }
187187
188188 break;
760760 out_uint8(s, 0);
761761 if (self->mcs_layer->iso_layer->rdpNegData)
762762 {
763 /* ReqeustedProtocol */
763 /* RequestedProtocol */
764764 out_uint32_le(s, self->mcs_layer->iso_layer->requestedProtocol);
765765 }
766766 out_uint16_le(s, SEC_TAG_SRV_CHANNELS);
285285 }
286286
287287 /*****************************************************************************/
288 /* check if all coords are withing 256 bytes */
288 /* check if all coords are within 256 bytes */
289289 /* returns boolean */
290290 static int APP_CC
291291 xrdp_orders_send_delta(struct xrdp_orders *self, int *vals, int count)
10131013 brush = &blank_brush;
10141014 }
10151015
1016 if (brush->x_orgin != self->orders_state.pat_blt_brush.x_orgin)
1016 if (brush->x_origin != self->orders_state.pat_blt_brush.x_origin)
10171017 {
10181018 present |= 0x0080;
1019 out_uint8(self->out_s, brush->x_orgin);
1020 self->orders_state.pat_blt_brush.x_orgin = brush->x_orgin;
1021 }
1022
1023 if (brush->y_orgin != self->orders_state.pat_blt_brush.y_orgin)
1019 out_uint8(self->out_s, brush->x_origin);
1020 self->orders_state.pat_blt_brush.x_origin = brush->x_origin;
1021 }
1022
1023 if (brush->y_origin != self->orders_state.pat_blt_brush.y_origin)
10241024 {
10251025 present |= 0x0100;
1026 out_uint8(self->out_s, brush->y_orgin);
1027 self->orders_state.pat_blt_brush.y_orgin = brush->y_orgin;
1026 out_uint8(self->out_s, brush->y_origin);
1027 self->orders_state.pat_blt_brush.y_origin = brush->y_origin;
10281028 }
10291029
10301030 if (brush->style != self->orders_state.pat_blt_brush.style)
26402640 return 0;
26412641 }
26422642
2643 #if defined(XRDP_JPEG)
26432644 /*****************************************************************************/
26442645 static int
26452646 xrdp_orders_send_as_jpeg(struct xrdp_orders *self,
26622663
26632664 return 1;
26642665 }
2666 #endif
26652667
26662668 #if defined(XRDP_NEUTRINORDP)
26672669 /*****************************************************************************/
26922694 }
26932695 #endif
26942696
2697 #if defined(XRDP_JPEG) || defined(XRDP_NEUTRINORDP)
26952698 /*****************************************************************************/
26962699 static int APP_CC
26972700 xrdp_orders_out_v3(struct xrdp_orders *self, int cache_id, int cache_idx,
27182721 out_uint8(self->out_s, RDP_ORDER_BMPCACHE3); /* type */
27192722 /* cache index */
27202723 out_uint16_le(self->out_s, cache_idx);
2721 /* persistant cache key 1/2 */
2724 /* persistent cache key 1/2 */
27222725 out_uint32_le(self->out_s, 0);
27232726 out_uint32_le(self->out_s, 0);
27242727 /* bitmap data */
27322735 out_uint8a(self->out_s, buf, bufsize);
27332736 return 0;
27342737 }
2738 #endif
27352739
27362740 /*****************************************************************************/
27372741 /* secondary drawing order (bitmap v3) using remotefx compression */
27402744 int width, int height, int bpp, char *data,
27412745 int cache_id, int cache_idx, int hints)
27422746 {
2747 struct xrdp_client_info *ci;
2748 #if defined(XRDP_JPEG) || defined(XRDP_NEUTRINORDP)
2749 int bufsize;
2750 struct stream *xr_s; /* xrdp stream */
2751 #endif
2752 #if defined(XRDP_JPEG)
27432753 int e;
2744 int bufsize;
27452754 int quality;
2746 struct stream *xr_s; /* xrdp stream */
27472755 struct stream *temp_s; /* xrdp stream */
2748 struct xrdp_client_info *ci;
2756 #endif
27492757 #if defined(XRDP_NEUTRINORDP)
27502758 STREAM *fr_s; /* FreeRDP stream */
27512759 RFX_CONTEXT *context;
332332 order_size += 8 * window_state->num_visibility_rects;
333333 }
334334
335 if (order_size < 12)
336 {
337 /* no flags set */
338 return 0;
339 }
340
335341 if (xrdp_orders_check(self, order_size) != 0)
336342 {
337343 return 1;
9797 }
9898 else
9999 {
100 log_message(LOG_LEVEL_ALWAYS,"Warning: Your configured crypt level is"
101 "undefined 'high' will be used");
100 log_message(LOG_LEVEL_ALWAYS,"Warning: Your configured crypt level is "
101 "undefined, 'high' will be used");
102102 client_info->crypt_level = 3;
103103 }
104104 }
961961 static int APP_CC
962962 xrdp_rdp_process_screen_update(struct xrdp_rdp *self, struct stream *s)
963963 {
964 int op;
965964 int left;
966965 int top;
967966 int right;
969968 int cx;
970969 int cy;
971970
972 in_uint32_le(s, op);
971 in_uint8s(s, 4); /* op */
973972 in_uint16_le(s, left);
974973 in_uint16_le(s, top);
975974 in_uint16_le(s, right);
11281127 int APP_CC
11291128 xrdp_rdp_process_data(struct xrdp_rdp *self, struct stream *s)
11301129 {
1131 int len;
11321130 int data_type;
1133 int ctype;
1134 int clen;
11351131
11361132 in_uint8s(s, 6);
1137 in_uint16_le(s, len);
1133 in_uint8s(s, 2); /* len */
11381134 in_uint8(s, data_type);
1139 in_uint8(s, ctype);
1140 in_uint16_le(s, clen);
1135 in_uint8s(s, 1); /* ctype */
1136 in_uint8s(s, 2); /* clen */
11411137 DEBUG(("xrdp_rdp_process_data code %d", data_type));
11421138
11431139 switch (data_type)
11581154 xrdp_rdp_process_screen_update(self, s);
11591155 break;
11601156 case 35: /* 35(0x23) */
1161 /* 35 ?? this comes when minimuzing a full screen mstsc.exe 2600 */
1157 /* 35 ?? this comes when minimizing a full screen mstsc.exe 2600 */
11621158 /* I think this is saying the client no longer wants screen */
11631159 /* updates and it will issue a 33 above to catch up */
11641160 /* so minimized apps don't take bandwidth */
11961192
11971193 /*****************************************************************************/
11981194 int APP_CC
1199 xrdp_rdp_send_deactive(struct xrdp_rdp *self)
1195 xrdp_rdp_send_deactivate(struct xrdp_rdp *self)
12001196 {
12011197 struct stream *s;
12021198
1203 DEBUG(("in xrdp_rdp_send_deactive"));
1199 DEBUG(("in xrdp_rdp_send_deactivate"));
12041200 make_stream(s);
12051201 init_stream(s, 8192);
12061202
12071203 if (xrdp_rdp_init(self, s) != 0)
12081204 {
12091205 free_stream(s);
1210 DEBUG(("out xrdp_rdp_send_deactive error"));
1206 DEBUG(("out xrdp_rdp_send_deactivate error"));
12111207 return 1;
12121208 }
12131209
12161212 if (xrdp_rdp_send(self, s, RDP_PDU_DEACTIVATE) != 0)
12171213 {
12181214 free_stream(s);
1219 DEBUG(("out xrdp_rdp_send_deactive error"));
1215 DEBUG(("out xrdp_rdp_send_deactivate error"));
12201216 return 1;
12211217 }
12221218
12231219 free_stream(s);
1224 DEBUG(("out xrdp_rdp_send_deactive"));
1225 return 0;
1226 }
1220 DEBUG(("out xrdp_rdp_send_deactivate"));
1221 return 0;
1222 }
418418 }
419419 else
420420 {
421 LLOGLN(0, ("xrdp_load_keyboard_layout: error opening %d",
421 LLOGLN(0, ("xrdp_load_keyboard_layout: error opening %s",
422422 keyboard_cfg_file));
423423 }
424424 }
647647 int len_directory = 0;
648648 int len_ip = 0;
649649 int len_dll = 0;
650 int tzone = 0;
651650 char tmpdata[256];
652651
653652 /* initialize (zero out) local variables */
836835 {
837836 return 1;
838837 }
839 in_uint32_le(s, tzone); /* len of timezone */
838 in_uint8s(s, 4); /* len of timezone */
840839 in_uint8s(s, 62); /* skip */
841840 in_uint8s(s, 22); /* skip misc. */
842841 in_uint8s(s, 62); /* skip */
18131812 {
18141813 int num_channels;
18151814 int index;
1816 struct mcs_channel_item *channel_item;
18171815 struct xrdp_client_info *client_info = (struct xrdp_client_info *)NULL;
18181816
18191817 client_info = &(self->rdp_layer->client_info);
18741872 int y1;
18751873 int x2;
18761874 int y2;
1875 int got_primary;
18771876 struct xrdp_client_info *client_info = (struct xrdp_client_info *)NULL;
18781877
18791878 client_info = &(self->rdp_layer->client_info);
18801879
1881 DEBUG(("processing monitors data, allow_multimon is %d", client_info->multimon));
1880 LLOGLN(10, ("xrdp_sec_process_mcs_data_monitors: processing monitors data, allow_multimon is %d", client_info->multimon));
18821881 /* this is an option set in xrdp.ini */
18831882 if (client_info->multimon != 1) /* are multi-monitors allowed ? */
18841883 {
1885 DEBUG(("[INFO] xrdp_sec_process_mcs_data_monitors: multimon is not "
1884 LLOGLN(0, ("[INFO] xrdp_sec_process_mcs_data_monitors: multimon is not "
18861885 "allowed, skipping"));
18871886 return 0;
18881887 }
18901889 //verify flags - must be 0x0
18911890 if (flags != 0)
18921891 {
1893 DEBUG(("[ERROR] xrdp_sec_process_mcs_data_monitors: flags MUST be "
1892 LLOGLN(0, ("[ERROR] xrdp_sec_process_mcs_data_monitors: flags MUST be "
18941893 "zero, detected: %d", flags));
18951894 return 1;
18961895 }
18981897 //verify monitorCount - max 16
18991898 if (monitorCount > 16)
19001899 {
1901 DEBUG(("[ERROR] xrdp_sec_process_mcs_data_monitors: max allowed "
1900 LLOGLN(0, ("[ERROR] xrdp_sec_process_mcs_data_monitors: max allowed "
19021901 "monitors is 16, detected: %d", monitorCount));
19031902 return 1;
19041903 }
19051904
1906 g_writeln("monitorCount= %d", monitorCount); // for debugging only
1905 LLOGLN(10, ("xrdp_sec_process_mcs_data_monitors: monitorCount= %d", monitorCount));
19071906
19081907 client_info->monitorCount = monitorCount;
19091908
19111910 y1 = 0;
19121911 x2 = 0;
19131912 y2 = 0;
1913 got_primary = 0;
19141914 /* Add client_monitor_data to client_info struct, will later pass to X11rdp */
19151915 for (index = 0; index < monitorCount; index++)
19161916 {
19341934 y2 = MAX(y2, client_info->minfo[index].bottom);
19351935 }
19361936
1937 g_writeln("got a monitor: left= %d, top= %d, right= %d, bottom= %d, is_primary?= %d", client_info->minfo[index].left,
1938 client_info->minfo[index].top, client_info->minfo[index].right, client_info->minfo[index].bottom, client_info->minfo[index].is_primary);
1939 }
1940
1937 if (client_info->minfo[index].is_primary)
1938 {
1939 got_primary = 1;
1940 }
1941
1942 LLOGLN(10, ("xrdp_sec_process_mcs_data_monitors: got a monitor [%d]: left= %d, top= %d, right= %d, bottom= %d, is_primary?= %d",
1943 index,
1944 client_info->minfo[index].left,
1945 client_info->minfo[index].top,
1946 client_info->minfo[index].right,
1947 client_info->minfo[index].bottom,
1948 client_info->minfo[index].is_primary));
1949 }
1950
1951 if (!got_primary)
1952 {
1953 /* no primary monitor was set, choose the leftmost monitor as primary */
1954 for (index = 0; index < monitorCount; index++)
1955 {
1956 if (client_info->minfo[index].left == x1 &&
1957 client_info->minfo[index].top == y1)
1958 {
1959 client_info->minfo[index].is_primary = 1;
1960 break;
1961 }
1962 }
1963 }
1964
1965 /* set wm geometry */
19411966 if ((x2 > x1) && (y2 > y1))
19421967 {
19431968 client_info->width = (x2 - x1) + 1;
19441969 client_info->height = (y2 - y1) + 1;
1970 }
1971 /* make sure virtual desktop size is ok */
1972 if (client_info->width > 0x7FFE || client_info->width < 0xC8 ||
1973 client_info->height > 0x7FFE || client_info->height < 0xC8)
1974 {
1975 LLOGLN(0, ("[ERROR] xrdp_sec_process_mcs_data_monitors: error, virtual desktop width / height is too large"));
1976 return 1; /* error */
1977 }
1978
1979 /* keep a copy of non negative monitor info values for xrdp_wm usage */
1980 for (index = 0; index < monitorCount; index++)
1981 {
1982 client_info->minfo_wm[index].left = client_info->minfo[index].left - x1;
1983 client_info->minfo_wm[index].top = client_info->minfo[index].top - y1;
1984 client_info->minfo_wm[index].right = client_info->minfo[index].right - x1;
1985 client_info->minfo_wm[index].bottom = client_info->minfo[index].bottom - y1;
1986 client_info->minfo_wm[index].is_primary = client_info->minfo[index].is_primary;
19451987 }
19461988
19471989 return 0;
0 libtool.m4
1 lt*.m4
0 # ===========================================================================
1 # http://www.gnu.org/software/autoconf-archive/ax_append_flag.html
2 # ===========================================================================
3 #
4 # SYNOPSIS
5 #
6 # AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
7 #
8 # DESCRIPTION
9 #
10 # FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
11 # added in between.
12 #
13 # If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
14 # CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
15 # FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
16 # FLAG.
17 #
18 # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
19 #
20 # LICENSE
21 #
22 # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
23 # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
24 #
25 # This program is free software: you can redistribute it and/or modify it
26 # under the terms of the GNU General Public License as published by the
27 # Free Software Foundation, either version 3 of the License, or (at your
28 # option) any later version.
29 #
30 # This program is distributed in the hope that it will be useful, but
31 # WITHOUT ANY WARRANTY; without even the implied warranty of
32 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
33 # Public License for more details.
34 #
35 # You should have received a copy of the GNU General Public License along
36 # with this program. If not, see <http://www.gnu.org/licenses/>.
37 #
38 # As a special exception, the respective Autoconf Macro's copyright owner
39 # gives unlimited permission to copy, distribute and modify the configure
40 # scripts that are the output of Autoconf when processing the Macro. You
41 # need not follow the terms of the GNU General Public License when using
42 # or distributing such scripts, even though portions of the text of the
43 # Macro appear in them. The GNU General Public License (GPL) does govern
44 # all other use of the material that constitutes the Autoconf Macro.
45 #
46 # This special exception to the GPL applies to versions of the Autoconf
47 # Macro released by the Autoconf Archive. When you make and distribute a
48 # modified version of the Autoconf Macro, you may extend this special
49 # exception to the GPL to apply to your modified version as well.
50
51 #serial 6
52
53 AC_DEFUN([AX_APPEND_FLAG],
54 [dnl
55 AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
56 AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
57 AS_VAR_SET_IF(FLAGS,[
58 AS_CASE([" AS_VAR_GET(FLAGS) "],
59 [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
60 [
61 AS_VAR_APPEND(FLAGS,[" $1"])
62 AC_RUN_LOG([: FLAGS="$FLAGS"])
63 ])
64 ],
65 [
66 AS_VAR_SET(FLAGS,[$1])
67 AC_RUN_LOG([: FLAGS="$FLAGS"])
68 ])
69 AS_VAR_POPDEF([FLAGS])dnl
70 ])dnl AX_APPEND_FLAG
0 # ===========================================================================
1 # http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html
2 # ===========================================================================
3 #
4 # SYNOPSIS
5 #
6 # AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
7 # AX_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
8 # AX_FCFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
9 #
10 # DESCRIPTION
11 #
12 # Try to find a compiler option that enables most reasonable warnings.
13 #
14 # For the GNU compiler it will be -Wall (and -ansi -pedantic) The result
15 # is added to the shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default.
16 #
17 # Currently this macro knows about the GCC, Solaris, Digital Unix, AIX,
18 # HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and
19 # Intel compilers. For a given compiler, the Fortran flags are much more
20 # experimental than their C equivalents.
21 #
22 # - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS
23 # - $2 add-value-if-not-found : nothing
24 # - $3 action-if-found : add value to shellvariable
25 # - $4 action-if-not-found : nothing
26 #
27 # NOTE: These macros depend on AX_APPEND_FLAG.
28 #
29 # LICENSE
30 #
31 # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
32 # Copyright (c) 2010 Rhys Ulerich <rhys.ulerich@gmail.com>
33 #
34 # This program is free software; you can redistribute it and/or modify it
35 # under the terms of the GNU General Public License as published by the
36 # Free Software Foundation; either version 3 of the License, or (at your
37 # option) any later version.
38 #
39 # This program is distributed in the hope that it will be useful, but
40 # WITHOUT ANY WARRANTY; without even the implied warranty of
41 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
42 # Public License for more details.
43 #
44 # You should have received a copy of the GNU General Public License along
45 # with this program. If not, see <http://www.gnu.org/licenses/>.
46 #
47 # As a special exception, the respective Autoconf Macro's copyright owner
48 # gives unlimited permission to copy, distribute and modify the configure
49 # scripts that are the output of Autoconf when processing the Macro. You
50 # need not follow the terms of the GNU General Public License when using
51 # or distributing such scripts, even though portions of the text of the
52 # Macro appear in them. The GNU General Public License (GPL) does govern
53 # all other use of the material that constitutes the Autoconf Macro.
54 #
55 # This special exception to the GPL applies to versions of the Autoconf
56 # Macro released by the Autoconf Archive. When you make and distribute a
57 # modified version of the Autoconf Macro, you may extend this special
58 # exception to the GPL to apply to your modified version as well.
59
60 #serial 15
61
62 AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl
63 AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
64 AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl
65 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
66 VAR,[VAR="no, unknown"
67 ac_save_[]FLAGS="$[]FLAGS"
68 for ac_arg dnl
69 in "-warn all % -warn all" dnl Intel
70 "-pedantic % -Wall" dnl GCC
71 "-xstrconst % -v" dnl Solaris C
72 "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix
73 "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
74 "-ansi -ansiE % -fullwarn" dnl IRIX
75 "+ESlit % +w1" dnl HP-UX C
76 "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
77 "-h conform % -h msglevel 2" dnl Cray C (Unicos)
78 #
79 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
80 AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
81 [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
82 done
83 FLAGS="$ac_save_[]FLAGS"
84 ])
85 AS_VAR_POPDEF([FLAGS])dnl
86 AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
87 case ".$VAR" in
88 .ok|.ok,*) m4_ifvaln($3,$3) ;;
89 .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;;
90 *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;;
91 esac
92 AS_VAR_POPDEF([VAR])dnl
93 ])dnl AX_FLAGS_WARN_ALL
94 dnl implementation tactics:
95 dnl the for-argument contains a list of options. The first part of
96 dnl these does only exist to detect the compiler - usually it is
97 dnl a global option to enable -ansi or -extrawarnings. All other
98 dnl compilers will fail about it. That was needed since a lot of
99 dnl compilers will give false positives for some option-syntax
100 dnl like -Woption or -Xoption as they think of it is a pass-through
101 dnl to later compile stages or something. The "%" is used as a
102 dnl delimiter. A non-option comment can be given after "%%" marks
103 dnl which will be shown but not added to the respective C/CXXFLAGS.
104
105 AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl
106 AC_LANG_PUSH([C])
107 AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
108 AC_LANG_POP([C])
109 ])
110
111 AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl
112 AC_LANG_PUSH([C++])
113 AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
114 AC_LANG_POP([C++])
115 ])
116
117 AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl
118 AC_LANG_PUSH([Fortran])
119 AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
120 AC_LANG_POP([Fortran])
121 ])
0 # ===========================================================================
1 # http://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html
2 # ===========================================================================
3 #
4 # SYNOPSIS
5 #
6 # AX_GCC_FUNC_ATTRIBUTE(ATTRIBUTE)
7 #
8 # DESCRIPTION
9 #
10 # This macro checks if the compiler supports one of GCC's function
11 # attributes; many other compilers also provide function attributes with
12 # the same syntax. Compiler warnings are used to detect supported
13 # attributes as unsupported ones are ignored by default so quieting
14 # warnings when using this macro will yield false positives.
15 #
16 # The ATTRIBUTE parameter holds the name of the attribute to be checked.
17 #
18 # If ATTRIBUTE is supported define HAVE_FUNC_ATTRIBUTE_<ATTRIBUTE>.
19 #
20 # The macro caches its result in the ax_cv_have_func_attribute_<attribute>
21 # variable.
22 #
23 # The macro currently supports the following function attributes:
24 #
25 # alias
26 # aligned
27 # alloc_size
28 # always_inline
29 # artificial
30 # cold
31 # const
32 # constructor
33 # constructor_priority for constructor attribute with priority
34 # deprecated
35 # destructor
36 # dllexport
37 # dllimport
38 # error
39 # externally_visible
40 # flatten
41 # format
42 # format_arg
43 # gnu_inline
44 # hot
45 # ifunc
46 # leaf
47 # malloc
48 # noclone
49 # noinline
50 # nonnull
51 # noreturn
52 # nothrow
53 # optimize
54 # pure
55 # unused
56 # used
57 # visibility
58 # warning
59 # warn_unused_result
60 # weak
61 # weakref
62 #
63 # Unsuppored function attributes will be tested with a prototype returning
64 # an int and not accepting any arguments and the result of the check might
65 # be wrong or meaningless so use with care.
66 #
67 # LICENSE
68 #
69 # Copyright (c) 2013 Gabriele Svelto <gabriele.svelto@gmail.com>
70 #
71 # Copying and distribution of this file, with or without modification, are
72 # permitted in any medium without royalty provided the copyright notice
73 # and this notice are preserved. This file is offered as-is, without any
74 # warranty.
75
76 #serial 3
77
78 AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [
79 AS_VAR_PUSHDEF([ac_var], [ax_cv_have_func_attribute_$1])
80
81 AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [
82 AC_LINK_IFELSE([AC_LANG_PROGRAM([
83 m4_case([$1],
84 [alias], [
85 int foo( void ) { return 0; }
86 int bar( void ) __attribute__(($1("foo")));
87 ],
88 [aligned], [
89 int foo( void ) __attribute__(($1(32)));
90 ],
91 [alloc_size], [
92 void *foo(int a) __attribute__(($1(1)));
93 ],
94 [always_inline], [
95 inline __attribute__(($1)) int foo( void ) { return 0; }
96 ],
97 [artificial], [
98 inline __attribute__(($1)) int foo( void ) { return 0; }
99 ],
100 [cold], [
101 int foo( void ) __attribute__(($1));
102 ],
103 [const], [
104 int foo( void ) __attribute__(($1));
105 ],
106 [constructor_priority], [
107 int foo( void ) __attribute__((__constructor__(65535/2)));
108 ],
109 [constructor], [
110 int foo( void ) __attribute__(($1));
111 ],
112 [deprecated], [
113 int foo( void ) __attribute__(($1("")));
114 ],
115 [destructor], [
116 int foo( void ) __attribute__(($1));
117 ],
118 [dllexport], [
119 __attribute__(($1)) int foo( void ) { return 0; }
120 ],
121 [dllimport], [
122 int foo( void ) __attribute__(($1));
123 ],
124 [error], [
125 int foo( void ) __attribute__(($1("")));
126 ],
127 [externally_visible], [
128 int foo( void ) __attribute__(($1));
129 ],
130 [flatten], [
131 int foo( void ) __attribute__(($1));
132 ],
133 [format], [
134 int foo(const char *p, ...) __attribute__(($1(printf, 1, 2)));
135 ],
136 [format_arg], [
137 char *foo(const char *p) __attribute__(($1(1)));
138 ],
139 [gnu_inline], [
140 inline __attribute__(($1)) int foo( void ) { return 0; }
141 ],
142 [hot], [
143 int foo( void ) __attribute__(($1));
144 ],
145 [ifunc], [
146 int my_foo( void ) { return 0; }
147 static int (*resolve_foo(void))(void) { return my_foo; }
148 int foo( void ) __attribute__(($1("resolve_foo")));
149 ],
150 [leaf], [
151 __attribute__(($1)) int foo( void ) { return 0; }
152 ],
153 [malloc], [
154 void *foo( void ) __attribute__(($1));
155 ],
156 [noclone], [
157 int foo( void ) __attribute__(($1));
158 ],
159 [noinline], [
160 __attribute__(($1)) int foo( void ) { return 0; }
161 ],
162 [nonnull], [
163 int foo(char *p) __attribute__(($1(1)));
164 ],
165 [noreturn], [
166 void foo( void ) __attribute__(($1));
167 ],
168 [nothrow], [
169 int foo( void ) __attribute__(($1));
170 ],
171 [optimize], [
172 __attribute__(($1(3))) int foo( void ) { return 0; }
173 ],
174 [pure], [
175 int foo( void ) __attribute__(($1));
176 ],
177 [unused], [
178 int foo( void ) __attribute__(($1));
179 ],
180 [used], [
181 int foo( void ) __attribute__(($1));
182 ],
183 [visibility], [
184 int foo_def( void ) __attribute__(($1("default")));
185 int foo_hid( void ) __attribute__(($1("hidden")));
186 int foo_int( void ) __attribute__(($1("internal")));
187 int foo_pro( void ) __attribute__(($1("protected")));
188 ],
189 [warning], [
190 int foo( void ) __attribute__(($1("")));
191 ],
192 [warn_unused_result], [
193 int foo( void ) __attribute__(($1));
194 ],
195 [weak], [
196 int foo( void ) __attribute__(($1));
197 ],
198 [weakref], [
199 static int foo( void ) { return 0; }
200 static int bar( void ) __attribute__(($1("foo")));
201 ],
202 [
203 m4_warn([syntax], [Unsupported attribute $1, the test may fail])
204 int foo( void ) __attribute__(($1));
205 ]
206 )], [])
207 ],
208 dnl GCC doesn't exit with an error if an unknown attribute is
209 dnl provided but only outputs a warning, so accept the attribute
210 dnl only if no warning were issued.
211 [AS_IF([test -s conftest.err],
212 [AS_VAR_SET([ac_var], [no])],
213 [AS_VAR_SET([ac_var], [yes])])],
214 [AS_VAR_SET([ac_var], [no])])
215 ])
216
217 AS_IF([test yes = AS_VAR_GET([ac_var])],
218 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_FUNC_ATTRIBUTE_$1), 1,
219 [Define to 1 if the system has the `$1' function attribute])], [])
220
221 AS_VAR_POPDEF([ac_var])
222 ])
0 # ===========================================================================
1 # http://www.gnu.org/software/autoconf-archive/ax_require_defined.html
2 # ===========================================================================
3 #
4 # SYNOPSIS
5 #
6 # AX_REQUIRE_DEFINED(MACRO)
7 #
8 # DESCRIPTION
9 #
10 # AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
11 # been defined and thus are available for use. This avoids random issues
12 # where a macro isn't expanded. Instead the configure script emits a
13 # non-fatal:
14 #
15 # ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
16 #
17 # It's like AC_REQUIRE except it doesn't expand the required macro.
18 #
19 # Here's an example:
20 #
21 # AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
22 #
23 # LICENSE
24 #
25 # Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
26 #
27 # Copying and distribution of this file, with or without modification, are
28 # permitted in any medium without royalty provided the copyright notice
29 # and this notice are preserved. This file is offered as-is, without any
30 # warranty.
31
32 #serial 1
33
34 AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
35 m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
36 ])dnl AX_REQUIRE_DEFINED
0 EXTRA_DIST = mc.h
1
2 AM_CFLAGS = \
0 AM_CPPFLAGS = \
31 -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
42 -DXRDP_SBIN_PATH=\"${sbindir}\" \
53 -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
6 -DXRDP_PID_PATH=\"${localstatedir}/run\"
7
8 INCLUDES = \
4 -DXRDP_PID_PATH=\"${localstatedir}/run\" \
95 -I$(top_srcdir)/common
106
11 lib_LTLIBRARIES = \
7 module_LTLIBRARIES = \
128 libmc.la
139
14 libmc_la_SOURCES = mc.c
10 libmc_la_SOURCES = \
11 mc.c \
12 mc.h
1513
1614 libmc_la_LIBADD = \
1715 $(top_builddir)/common/libcommon.la
6161 int (*server_set_bgcolor)(struct mod* v, int bgcolor);
6262 int (*server_set_opcode)(struct mod* v, int opcode);
6363 int (*server_set_mixmode)(struct mod* v, int mixmode);
64 int (*server_set_brush)(struct mod* v, int x_orgin, int y_orgin,
64 int (*server_set_brush)(struct mod* v, int x_origin, int y_origin,
6565 int style, char* pattern);
6666 int (*server_set_pen)(struct mod* v, int style,
6767 int width);
6868 int (*server_draw_line)(struct mod* v, int x1, int y1, int x2, int y2);
69 int (*server_add_char)(struct mod* v, int font, int charactor,
69 int (*server_add_char)(struct mod* v, int font, int character,
7070 int offset, int baseline,
7171 int width, int height, char* data);
7272 int (*server_draw_text)(struct mod* v, int font,
0 EXTRA_DIST = xrdp-neutrinordp.h
10 EXTRA_DEFINES =
21
32 if XRDP_DEBUG
65 EXTRA_DEFINES += -DXRDP_NODEBUG
76 endif
87
9 AM_CFLAGS = \
8 AM_CPPFLAGS = \
109 -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
1110 -DXRDP_SBIN_PATH=\"${sbindir}\" \
1211 -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
1312 -DXRDP_PID_PATH=\"${localstatedir}/run\" \
14 $(EXTRA_DEFINES)
15
16 INCLUDES = \
13 $(EXTRA_DEFINES) \
1714 -I$(top_srcdir)/common \
1815 $(FREERDP_CFLAGS)
1916
20 lib_LTLIBRARIES = \
17 module_LTLIBRARIES = \
2118 libxrdpneutrinordp.la
2219
23 libxrdpneutrinordp_la_SOURCES = xrdp-neutrinordp.c xrdp-color.c
20 libxrdpneutrinordp_la_SOURCES = \
21 xrdp-color.c \
22 xrdp-neutrinordp.c \
23 xrdp-neutrinordp.h
2424
2525 libxrdpneutrinordp_la_LIBADD = \
2626 $(top_builddir)/common/libcommon.la \
212212 return bmpdata;
213213 }
214214
215 if ((in_bpp == 16) && (out_bpp == 32))
216 {
217 out = (char *)g_malloc(width * height * 4, 0);
218 src = bmpdata;
219 dst = out;
220
221 for (i = 0; i < height; i++)
222 {
223 for (j = 0; j < width; j++)
224 {
225 pixel = *((tui16 *)src);
226 SPLITCOLOR16(red, green, blue, pixel);
227 pixel = COLOR24RGB(red, green, blue);
228 *((tui32 *)dst) = pixel;
229 src += 2;
230 dst += 4;
231 }
232 }
233
234 return out;
235 }
236
215237 g_writeln("convert_bitmap: error unknown conversion from %d to %d",
216238 in_bpp, out_bpp);
217239 return 0;
291313 return pixel;
292314 }
293315
316 if ((in_bpp == 16) && (out_bpp == 32))
317 {
318 pixel = in_color;
319 SPLITCOLOR16(red, green, blue, pixel);
320 pixel = COLOR24BGR(red, green, blue);
321 return pixel;
322 }
323
294324 if ((in_bpp == 24) && (out_bpp == 24))
295325 {
296326 return in_color;
1919 #ifndef __XRDP_COLOR_H
2020 #define __XRDP_COLOR_H
2121
22 char* APP_CC
23 convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
24 int width, int height, int* palette);
22 char *APP_CC
23 convert_bitmap(int in_bpp, int out_bpp, char *bmpdata,
24 int width, int height, int *palette);
2525 int APP_CC
26 convert_color(int in_bpp, int out_bpp, int in_color, int* palette);
26 convert_color(int in_bpp, int out_bpp, int in_color, int *palette);
2727
2828 #endif
4747 {
4848 int i;
4949
50 for(i = 0; i < 255; i++)
50 for (i = 0; i < 255; i++)
5151 {
5252 if (mod->colormap[i] != 0)
5353 {
5454 return ;
5555 }
5656 }
57
5758 LLOGLN(0, ("The colormap is all NULL"));
5859 }
5960
113114 {
114115 case PREECONNECTERROR:
115116 g_snprintf(buf, 128, "The error code from connect is "
116 "PREECONNECTERROR");
117 "PREECONNECTERROR");
117118 break;
119
118120 case UNDEFINEDCONNECTERROR:
119121 g_snprintf(buf, 128, "The error code from connect is "
120 "UNDEFINEDCONNECTERROR");
122 "UNDEFINEDCONNECTERROR");
121123 break;
124
122125 case POSTCONNECTERROR:
123126 g_snprintf(buf, 128, "The error code from connect is "
124 "POSTCONNECTERROR");
127 "POSTCONNECTERROR");
125128 break;
129
126130 case DNSERROR:
127131 g_snprintf(buf, 128, "The DNS system generated an error");
128132 break;
133
129134 case DNSNAMENOTFOUND:
130135 g_snprintf(buf, 128, "The DNS system could not find the "
131 "specified name");
136 "specified name");
132137 break;
138
133139 case CONNECTERROR:
134140 g_snprintf(buf, 128, "A general connect error was returned");
135141 break;
142
136143 case MCSCONNECTINITIALERROR:
137144 g_snprintf(buf, 128, "The error code from connect is "
138 "MCSCONNECTINITIALERROR");
145 "MCSCONNECTINITIALERROR");
139146 break;
147
140148 case TLSCONNECTERROR:
141149 g_snprintf(buf, 128, "Error in TLS handshake");
142150 break;
151
143152 case AUTHENTICATIONERROR:
144153 g_snprintf(buf, 128, "Authentication error check your password "
145 "and username");
154 "and username");
146155 break;
156
157 case INSUFFICIENTPRIVILEGESERROR:
158 g_snprintf(buf, 128, "Insufficent privileges on target server");
159 break;
160
147161 default:
148162 g_snprintf(buf, 128, "Unhandled Errorcode from connect : %d",
149 connectErrorCode);
163 connectErrorCode);
150164 break;
151165 }
152166 }
153 log_message(LOG_LEVEL_INFO,buf);
167
168 log_message(LOG_LEVEL_INFO, buf);
154169 mod->server_msg(mod, buf, 0);
155170 }
156171
194209 switch (msg)
195210 {
196211 case 15: /* key down */
212
197213 /* Before we handle the first character we synchronize
198214 capslock and numlock. */
199215 /* We collect the state during the first synchronize
204220 mod->inst->input->SynchronizeEvent(mod->inst->input, mod->keyBoardLockInfo);
205221 mod->bool_keyBoardSynced = 1;
206222 }
223
207224 mod->inst->input->KeyboardEvent(mod->inst->input, param4, param3);
208225 break;
226
209227 case 16: /* key up */
210228 mod->inst->input->KeyboardEvent(mod->inst->input, param4, param3);
211229 break;
230
212231 case 17: /* Synchronize */
213 LLOGLN(11, ("Synchronized event handled : %d",param1));
232 LLOGLN(11, ("Synchronized event handled : %d", param1));
214233 /* In some situations the Synchronize event come to early.
215234 Therefore we store this information and use it when we
216235 receive the first keyboard event
217236 Without this fix numlock and capslock can come
218237 out of sync. */
219238 mod->inst->input->SynchronizeEvent(mod->inst->input, param1);
239
220240 if (!mod->bool_keyBoardSynced)
221241 {
222242 mod->keyBoardLockInfo = param1;
223243 }
244
224245 break;
246
225247 case 100: /* mouse move */
226248 LLOGLN(12, ("mouse move %d %d", param1, param2));
227249 x = param1;
229251 flags = PTR_FLAGS_MOVE;
230252 mod->inst->input->MouseEvent(mod->inst->input, flags, x, y);
231253 break;
254
232255 case 101: /* left button up */
233256 LLOGLN(12, ("left button up %d %d", param1, param2));
234257 x = param1;
236259 flags = PTR_FLAGS_BUTTON1;
237260 mod->inst->input->MouseEvent(mod->inst->input, flags, x, y);
238261 break;
262
239263 case 102: /* left button down */
240264 LLOGLN(12, ("left button down %d %d", param1, param2));
241265 x = param1;
243267 flags = PTR_FLAGS_BUTTON1 | PTR_FLAGS_DOWN;
244268 mod->inst->input->MouseEvent(mod->inst->input, flags, x, y);
245269 break;
270
246271 case 103: /* right button up */
247272 LLOGLN(12, ("right button up %d %d", param1, param2));
248273 x = param1;
250275 flags = PTR_FLAGS_BUTTON2;
251276 mod->inst->input->MouseEvent(mod->inst->input, flags, x, y);
252277 break;
278
253279 case 104: /* right button down */
254280 LLOGLN(12, ("right button down %d %d", param1, param2));
255281 x = param1;
257283 flags = PTR_FLAGS_BUTTON2 | PTR_FLAGS_DOWN;
258284 mod->inst->input->MouseEvent(mod->inst->input, flags, x, y);
259285 break;
286
260287 case 105: /* middle button up */
261288 LLOGLN(12, ("middle button up %d %d", param1, param2));
262289 x = param1;
264291 flags = PTR_FLAGS_BUTTON3;
265292 mod->inst->input->MouseEvent(mod->inst->input, flags, x, y);
266293 break;
294
267295 case 106: /* middle button down */
268296 LLOGLN(12, ("middle button down %d %d", param1, param2));
269297 x = param1;
271299 flags = PTR_FLAGS_BUTTON3 | PTR_FLAGS_DOWN;
272300 mod->inst->input->MouseEvent(mod->inst->input, flags, x, y);
273301 break;
302
274303 case 107: /* wheel up */
275304 flags = PTR_FLAGS_WHEEL | 0x0078;
276305 mod->inst->input->MouseEvent(mod->inst->input, flags, 0, 0);
277306 break;
307
278308 case 108:
279309 break;
310
280311 case 109: /* wheel down */
281312 flags = PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0088;
282313 mod->inst->input->MouseEvent(mod->inst->input, flags, 0, 0);
283314 break;
315
284316 case 110:
285317 break;
318
286319 case 200:
287320 LLOGLN(10, ("Invalidate request sent from client"));
288321 x = (param1 >> 16) & 0xffff;
291324 cy = (param2 >> 0) & 0xffff;
292325 mod->inst->SendInvalidate(mod->inst, -1, x, y, cx, cy);
293326 break;
327
294328 case 0x5555:
295329 chanid = LOWORD(param1);
296330 flags = HIWORD(param1);
299333 total_size = (int)param4;
300334
301335 LLOGLN(12, ("lxrdp_event: client to server ,chanid= %d flags= %d", chanid, flags));
336
302337 if ((chanid < 0) || (chanid >= mod->inst->settings->num_channels))
303338 {
304339 LLOGLN(0, ("lxrdp_event: error chanid %d", chanid));
312347 case 3:
313348 mod->inst->SendChannelData(mod->inst, lchid, (tui8 *)data, total_size);
314349 break;
350
315351 case 2:
316352 /* end */
317353 g_memcpy(mod->chan_buf + mod->chan_buf_valid, data, size);
323359 mod->chan_buf_bytes = 0;
324360 mod->chan_buf_valid = 0;
325361 break;
362
326363 case 1:
327364 /* start */
328365 g_free(mod->chan_buf);
332369 g_memcpy(mod->chan_buf + mod->chan_buf_valid, data, size);
333370 mod->chan_buf_valid += size;
334371 break;
372
335373 default:
336374 /* middle */
337375 g_memcpy(mod->chan_buf + mod->chan_buf_valid, data, size);
340378 }
341379
342380 break;
381
343382 default:
344383 LLOGLN(0, ("Unhandled message type in eventhandler %d", msg));
345384 break;
419458 {
420459 g_strncpy(mod->username, value, 255);
421460 }
461 else if (g_strcmp(name, "domain") == 0)
462 {
463 g_strncpy(mod->domain, value, 255);
464 }
422465 else if (g_strcmp(name, "password") == 0)
423466 {
424467 g_strncpy(mod->password, value, 255);
428471 g_memcpy(&(mod->client_info), value, sizeof(mod->client_info));
429472 /* This is a Struct and cannot be printed in next else*/
430473 LLOGLN(10, ("Client_info struct ignored"));
474 }
475 else if (g_strcmp(name, "program") == 0)
476 {
477 settings->shell = g_strdup(value);
478 }
479 else if (g_strcmp(name, "nla") == 0)
480 {
481 settings->nla_security = g_text2bool(value);
431482 }
432483 else
433484 {
571622
572623 if (bd->compressed)
573624 {
574 LLOGLN(20,("decompress size : %d",bd->bitmapLength));
575 if(!bitmap_decompress(bd->bitmapDataStream, (tui8 *)dst_data, bd->width,
576 bd->height, bd->bitmapLength, server_bpp, server_bpp)){
577 LLOGLN(0,("Failure to decompress the bitmap"));
625 LLOGLN(20, ("decompress size : %d", bd->bitmapLength));
626
627 if (!bitmap_decompress(bd->bitmapDataStream, (tui8 *)dst_data, bd->width,
628 bd->height, bd->bitmapLength, server_bpp, server_bpp))
629 {
630 LLOGLN(0, ("Failure to decompress the bitmap"));
578631 }
579632 }
580633 else
581634 {
582635 /* bitmap is upside down */
583 LLOGLN(10,("bitmap upside down"));
636 LLOGLN(10, ("bitmap upside down"));
584637 src = (char *)(bd->bitmapDataStream);
585638 dst = dst_data + bd->height * line_bytes;
586639
645698 patblt->backColor, mod->colormap);
646699
647700 LLOGLN(10, ("lfreerdp_pat_blt: nLeftRect %d nTopRect %d "
648 "nWidth %d nHeight %d fgcolor 0x%8.8x bgcolor 0x%8.8x",
649 patblt->nLeftRect, patblt->nTopRect,
650 patblt->nWidth, patblt->nHeight, fgcolor, bgcolor));
701 "nWidth %d nHeight %d fgcolor 0x%8.8x bgcolor 0x%8.8x",
702 patblt->nLeftRect, patblt->nTopRect,
703 patblt->nWidth, patblt->nHeight, fgcolor, bgcolor));
651704
652705 if (fgcolor == bgcolor)
653706 {
654707 LLOGLN(0, ("Warning same color on both bg and fg"));
655708 }
709
656710 mod->server_set_mixmode(mod, 1);
657711 mod->server_set_opcode(mod, patblt->bRop);
658712 mod->server_set_fgcolor(mod, fgcolor);
717771 fgcolor = convert_color(server_bpp, client_bpp,
718772 opaque_rect->color, mod->colormap);
719773 LLOGLN(10, ("lfreerdp_opaque_rect: nLeftRect %d nTopRect %d "
720 "nWidth %d nHeight %d fgcolor 0x%8.8x",
721 opaque_rect->nLeftRect, opaque_rect->nTopRect,
722 opaque_rect->nWidth, opaque_rect->nHeight, fgcolor));
774 "nWidth %d nHeight %d fgcolor 0x%8.8x",
775 opaque_rect->nLeftRect, opaque_rect->nTopRect,
776 opaque_rect->nWidth, opaque_rect->nHeight, fgcolor));
723777 mod->server_set_fgcolor(mod, fgcolor);
724778 mod->server_fill_rect(mod, opaque_rect->nLeftRect, opaque_rect->nTopRect,
725779 opaque_rect->nWidth, opaque_rect->nHeight);
792846 bgcolor = convert_color(server_bpp, client_bpp,
793847 glyph_index->backColor, mod->colormap);
794848 LLOGLN(10, ("lfreerdp_glyph_index: "
795 "bkLeft %d bkTop %d width %d height %d "
796 "opLeft %d opTop %d width %d height %d "
797 "cbData %d fgcolor 0x%8.8x bgcolor 0x%8.8x fOpRedundant %d",
798 glyph_index->bkLeft, glyph_index->bkTop,
799 glyph_index->bkRight - glyph_index->bkLeft,
800 glyph_index->bkBottom - glyph_index->bkTop,
801 glyph_index->opLeft, glyph_index->opTop,
802 glyph_index->opRight - glyph_index->opLeft,
803 glyph_index->opBottom - glyph_index->opTop,
804 glyph_index->cbData, fgcolor, bgcolor, glyph_index->fOpRedundant));
849 "bkLeft %d bkTop %d width %d height %d "
850 "opLeft %d opTop %d width %d height %d "
851 "cbData %d fgcolor 0x%8.8x bgcolor 0x%8.8x fOpRedundant %d",
852 glyph_index->bkLeft, glyph_index->bkTop,
853 glyph_index->bkRight - glyph_index->bkLeft,
854 glyph_index->bkBottom - glyph_index->bkTop,
855 glyph_index->opLeft, glyph_index->opTop,
856 glyph_index->opRight - glyph_index->opLeft,
857 glyph_index->opBottom - glyph_index->opTop,
858 glyph_index->cbData, fgcolor, bgcolor, glyph_index->fOpRedundant));
805859 mod->server_set_bgcolor(mod, fgcolor);
806860 mod->server_set_fgcolor(mod, bgcolor);
807861 opLeft = glyph_index->opLeft;
809863 opRight = glyph_index->opRight;
810864 opBottom = glyph_index->opBottom;
811865 #if 1
866
812867 /* workarounds for freerdp not using fOpRedundant in
813868 glyph.c::update_gdi_glyph_index */
814869 if (glyph_index->fOpRedundant)
816871 opLeft = glyph_index->bkLeft;
817872 opTop = glyph_index->bkTop;
818873 opRight = glyph_index->bkRight;
819 opBottom =glyph_index->bkBottom;
820 }
874 opBottom = glyph_index->bkBottom;
875 }
876
821877 #endif
822878 mod->server_draw_text(mod, glyph_index->cacheId, glyph_index->flAccel,
823879 glyph_index->fOpRedundant,
865921 /******************************************************************************/
866922 /* Turn the bitmap upside down*/
867923 static void DEFAULT_CC
868 lfreerdp_upsidedown(uint8* destination, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2_order, int server_Bpp)
924 lfreerdp_upsidedown(uint8 *destination, CACHE_BITMAP_V2_ORDER *cache_bitmap_v2_order, int server_Bpp)
869925 {
870926 tui8 *src;
871927 tui8 *dst;
10781134 lfreerdp_pointer_system(rdpContext *context,
10791135 POINTER_SYSTEM_UPDATE *pointer_system)
10801136 {
1081 LLOGLN(0, ("lfreerdp_pointer_system: - no code here type value = %d",pointer_system->type));
1137 LLOGLN(0, ("lfreerdp_pointer_system: - no code here type value = %d", pointer_system->type));
10821138 }
10831139
10841140 /******************************************************************************/
11111167 {
11121168 src8 = (tui8 *)bits;
11131169 src8 += y * delta + x * 4;
1114 pixel = ((int*)(src8))[0];
1170 pixel = ((int *)(src8))[0];
11151171 return pixel;
11161172 }
11171173 else
11581214 {
11591215 dst8 = (tui8 *)bits;
11601216 dst8 += y * delta + x * 4;
1161 ((int*)(dst8))[0] = pixel;
1217 ((int *)(dst8))[0] = pixel;
11621218 }
11631219 else
11641220 {
12091265 LLOGLN(20, ("lfreerdp_pointer_new:"));
12101266 LLOGLN(20, (" bpp %d", pointer_new->xorBpp));
12111267 LLOGLN(20, (" width %d height %d", pointer_new->colorPtrAttr.width,
1212 pointer_new->colorPtrAttr.height));
1268 pointer_new->colorPtrAttr.height));
12131269
12141270 LLOGLN(20, (" lengthXorMask %d lengthAndMask %d",
1215 pointer_new->colorPtrAttr.lengthXorMask,
1216 pointer_new->colorPtrAttr.lengthAndMask));
1271 pointer_new->colorPtrAttr.lengthXorMask,
1272 pointer_new->colorPtrAttr.lengthAndMask));
12171273
12181274 index = pointer_new->colorPtrAttr.cacheIndex;
1275
12191276 if (index >= 32)
12201277 {
12211278 LLOGLN(0, ("lfreerdp_pointer_new: pointer index too big"));
12221279 return ;
12231280 }
1281
12241282 if (pointer_new->xorBpp == 1 &&
1225 pointer_new->colorPtrAttr.width == 32 &&
1226 pointer_new->colorPtrAttr.height == 32)
1283 pointer_new->colorPtrAttr.width == 32 &&
1284 pointer_new->colorPtrAttr.height == 32)
12271285 {
12281286 LLOGLN(10, ("lfreerdp_pointer_new:"));
12291287 mod->pointer_cache[index].hotx = pointer_new->colorPtrAttr.xPos;
12401298 lfreerdp_convert_color_image(dst, 32, 32, 1, 32 / -8,
12411299 src, 32, 32, 1, 32 / 8);
12421300 }
1243 else if(pointer_new->xorBpp >= 8 &&
1244 pointer_new->colorPtrAttr.width == 32 &&
1245 pointer_new->colorPtrAttr.height == 32)
1301 else if (pointer_new->xorBpp >= 8 &&
1302 pointer_new->colorPtrAttr.width == 32 &&
1303 pointer_new->colorPtrAttr.height == 32)
12461304 {
12471305 bytes_per_pixel = (pointer_new->xorBpp + 7) / 8;
12481306 bits_per_pixel = pointer_new->xorBpp;
12491307 LLOGLN(10, ("lfreerdp_pointer_new: bpp %d Bpp %d", bits_per_pixel,
1250 bytes_per_pixel));
1308 bytes_per_pixel));
12511309 mod->pointer_cache[index].hotx = pointer_new->colorPtrAttr.xPos;
12521310 mod->pointer_cache[index].hoty = pointer_new->colorPtrAttr.yPos;
12531311 mod->pointer_cache[index].bpp = bits_per_pixel;
12621320 {
12631321 LLOGLN(0, ("lfreerdp_pointer_new: error bpp %d width %d height %d index: %d",
12641322 pointer_new->xorBpp, pointer_new->colorPtrAttr.width,
1265 pointer_new->colorPtrAttr.height,index));
1323 pointer_new->colorPtrAttr.height, index));
12661324 }
12671325
12681326 mod->server_set_pointer_ex(mod, mod->pointer_cache[index].hotx,
12981356
12991357 /******************************************************************************/
13001358 static void DEFAULT_CC
1301 lfreerdp_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
1359 lfreerdp_polygon_cb(rdpContext *context, POLYGON_CB_ORDER *polygon_cb)
13021360 {
13031361 LLOGLN(0, ("lfreerdp_polygon_sc called:- not supported!!!!!!!!!!!!!!!!!!!!"));
13041362 }
13051363
13061364 /******************************************************************************/
13071365 static void DEFAULT_CC
1308 lfreerdp_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc)
1366 lfreerdp_polygon_sc(rdpContext *context, POLYGON_SC_ORDER *polygon_sc)
13091367 {
13101368 struct mod *mod;
13111369 int i, npoints;
13151373
13161374 mod = ((struct mod_context *)context)->modi;
13171375 LLOGLN(10, ("lfreerdp_polygon_sc :%d(points) %d(color) %d(fillmode) "
1318 "%d(bRop) %d(cbData) %d(x) %d(y)",
1319 polygon_sc->nDeltaEntries, polygon_sc->brushColor,
1320 polygon_sc->fillMode, polygon_sc->bRop2,
1321 polygon_sc->cbData, polygon_sc->xStart,
1322 polygon_sc->yStart));
1376 "%d(bRop) %d(cbData) %d(x) %d(y)",
1377 polygon_sc->nDeltaEntries, polygon_sc->brushColor,
1378 polygon_sc->fillMode, polygon_sc->bRop2,
1379 polygon_sc->cbData, polygon_sc->xStart,
1380 polygon_sc->yStart));
1381
13231382 if (polygon_sc->nDeltaEntries == 3)
13241383 {
13251384 server_bpp = mod->inst->settings->color_depth;
13331392 points[i + 1].x = 0; // polygon_sc->points[i].x;
13341393 points[i + 1].y = 0; // polygon_sc->points[i].y;
13351394 }
1395
13361396 fgcolor = convert_color(server_bpp, client_bpp,
13371397 polygon_sc->brushColor, mod->colormap);
13381398
13421402 mod->server_set_pen(mod, 1, 1); // style, width
13431403 // TODO replace with correct brush; this is a workaround
13441404 // This workaround handles the text cursor in microsoft word.
1345 mod->server_draw_line(mod,polygon_sc->xStart,polygon_sc->yStart,polygon_sc->xStart,polygon_sc->yStart+points[2].y);
1346 // mod->server_fill_rect(mod, points[0].x, points[0].y,
1347 // points[0].x-points[3].x, points[0].y-points[2].y);
1348 // mod->server_set_brush(mod,); // howto use this on our indata??
1405 mod->server_draw_line(mod, polygon_sc->xStart, polygon_sc->yStart, polygon_sc->xStart, polygon_sc->yStart + points[2].y);
1406 // mod->server_fill_rect(mod, points[0].x, points[0].y,
1407 // points[0].x-points[3].x, points[0].y-points[2].y);
1408 // mod->server_set_brush(mod,); // howto use this on our indata??
13491409 mod->server_set_opcode(mod, 0xcc);
13501410 }
13511411 else
13561416
13571417 /******************************************************************************/
13581418 static void DEFAULT_CC
1359 lfreerdp_syncronize(rdpContext* context)
1419 lfreerdp_synchronize(rdpContext *context)
13601420 {
13611421 struct mod *mod;
13621422 mod = ((struct mod_context *)context)->modi;
14541514
14551515 instance->settings->username = g_strdup(mod->username);
14561516 instance->settings->password = g_strdup(mod->password);
1517 instance->settings->domain = g_strdup(mod->domain);
14571518
14581519 if (mod->client_info.rail_support_level > 0)
14591520 {
14711532 {
14721533 LLOGLN(10, ("Special PerformanceFlags changed"));
14731534 instance->settings->performance_flags = PERF_DISABLE_WALLPAPER |
1474 PERF_DISABLE_FULLWINDOWDRAG | PERF_DISABLE_MENUANIMATIONS |
1475 PERF_DISABLE_THEMING;
1476 // | PERF_DISABLE_CURSOR_SHADOW | PERF_DISABLE_CURSORSETTINGS;
1477 }
1535 PERF_DISABLE_FULLWINDOWDRAG | PERF_DISABLE_MENUANIMATIONS |
1536 PERF_DISABLE_THEMING;
1537 // | PERF_DISABLE_CURSOR_SHADOW | PERF_DISABLE_CURSORSETTINGS;
1538 }
1539
14781540 instance->settings->compression = 0;
14791541 instance->settings->ignore_certificate = 1;
14801542
14811543 // Multi Monitor Settings
14821544 instance->settings->num_monitors = mod->client_info.monitorCount;
1545
14831546 for (index = 0; index < mod->client_info.monitorCount; index++)
14841547 {
1485 instance->settings->monitors[index].x = mod->client_info.minfo[index].left;
1486 instance->settings->monitors[index].y = mod->client_info.minfo[index].top;
1487 instance->settings->monitors[index].width = mod->client_info.minfo[index].right;
1488 instance->settings->monitors[index].height = mod->client_info.minfo[index].bottom;
1489 instance->settings->monitors[index].is_primary = mod->client_info.minfo[index].is_primary;
1548 instance->settings->monitors[index].x = mod->client_info.minfo[index].left;
1549 instance->settings->monitors[index].y = mod->client_info.minfo[index].top;
1550 instance->settings->monitors[index].width = mod->client_info.minfo[index].right;
1551 instance->settings->monitors[index].height = mod->client_info.minfo[index].bottom;
1552 instance->settings->monitors[index].is_primary = mod->client_info.minfo[index].is_primary;
14901553 }
14911554
14921555 instance->update->BeginPaint = lfreerdp_begin_paint;
14931556 instance->update->EndPaint = lfreerdp_end_paint;
14941557 instance->update->SetBounds = lfreerdp_set_bounds;
14951558 instance->update->BitmapUpdate = lfreerdp_bitmap_update;
1496 instance->update->Synchronize = lfreerdp_syncronize ;
1559 instance->update->Synchronize = lfreerdp_synchronize;
14971560 instance->update->primary->DstBlt = lfreerdp_dst_blt;
14981561 instance->update->primary->PatBlt = lfreerdp_pat_blt;
14991562 instance->update->primary->ScrBlt = lfreerdp_scr_blt;
15351598 int index;
15361599 struct mod *mod;
15371600 struct rail_window_state_order wso;
1538 UNICONV* uniconv;
1539
1540 LLOGLN(0, ("llrail_WindowCreate:"));
1601 UNICONV *uniconv;
1602
1603 LLOGLN(10, ("lrail_WindowCreate:"));
15411604 uniconv = freerdp_uniconv_new();
15421605 mod = ((struct mod_context *)context)->modi;
15431606 memset(&wso, 0, sizeof(wso));
15501613 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_TITLE)
15511614 {
15521615 wso.title_info = freerdp_uniconv_in(uniconv,
1553 window_state->titleInfo.string, window_state->titleInfo.length);
1554 }
1555
1556 LLOGLN(0, ("lrail_WindowCreate: %s", wso.title_info));
1616 window_state->titleInfo.string, window_state->titleInfo.length);
1617 }
1618
1619 LLOGLN(10, ("lrail_WindowCreate: %s", wso.title_info));
15571620 wso.client_offset_x = window_state->clientOffsetX;
15581621 wso.client_offset_y = window_state->clientOffsetY;
15591622 wso.client_area_width = window_state->clientAreaWidth;
16131676 lrail_WindowUpdate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
16141677 WINDOW_STATE_ORDER *window_state)
16151678 {
1616 LLOGLN(0, ("lrail_WindowUpdate:"));
1679 LLOGLN(10, ("lrail_WindowUpdate:"));
16171680 lrail_WindowCreate(context, orderInfo, window_state);
16181681 }
16191682
16231686 {
16241687 struct mod *mod;
16251688
1626 LLOGLN(0, ("lrail_WindowDelete:"));
1689 LLOGLN(10, ("lrail_WindowDelete:"));
16271690 mod = ((struct mod_context *)context)->modi;
16281691 mod->server_window_delete(mod, orderInfo->windowId);
16291692 }
16361699 struct mod *mod;
16371700 struct rail_icon_info rii;
16381701
1639 LLOGLN(0, ("lrail_WindowIcon:"));
1702 LLOGLN(10, ("lrail_WindowIcon:"));
16401703 mod = ((struct mod_context *)context)->modi;
16411704 memset(&rii, 0, sizeof(rii));
16421705 rii.bpp = window_icon->iconInfo->bpp;
16611724 {
16621725 struct mod *mod;
16631726
1664 LLOGLN(0, ("lrail_WindowCachedIcon:"));
1727 LLOGLN(10, ("lrail_WindowCachedIcon:"));
16651728 mod = ((struct mod_context *)context)->modi;
16661729 mod->server_window_cached_icon(mod, orderInfo->windowId,
16671730 window_cached_icon->cachedIcon.cacheEntry,
16761739 {
16771740 struct mod *mod;
16781741 struct rail_notify_state_order rnso;
1679 UNICONV* uniconv;
1680
1681 LLOGLN(0, ("lrail_NotifyIconCreate:"));
1742 UNICONV *uniconv;
1743
1744 LLOGLN(10, ("lrail_NotifyIconCreate:"));
16821745 uniconv = freerdp_uniconv_new();
16831746 mod = ((struct mod_context *)context)->modi;
16841747
16871750
16881751 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_TIP)
16891752 {
1690 rnso.tool_tip = freerdp_uniconv_in(uniconv,
1691 notify_icon_state->toolTip.string, notify_icon_state->toolTip.length);
1692 }
1753 rnso.tool_tip = freerdp_uniconv_in(uniconv,
1754 notify_icon_state->toolTip.string, notify_icon_state->toolTip.length);
1755 }
1756
16931757 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP)
16941758 {
1695 rnso.infotip.timeout = notify_icon_state->infoTip.timeout;
1696 rnso.infotip.flags = notify_icon_state->infoTip.flags;
1697 rnso.infotip.text = freerdp_uniconv_in(uniconv,
1698 notify_icon_state->infoTip.text.string,
1699 notify_icon_state->infoTip.text.length);
1700 rnso.infotip.title = freerdp_uniconv_in(uniconv,
1701 notify_icon_state->infoTip.title.string,
1702 notify_icon_state->infoTip.title.length);
1759 rnso.infotip.timeout = notify_icon_state->infoTip.timeout;
1760 rnso.infotip.flags = notify_icon_state->infoTip.flags;
1761 rnso.infotip.text = freerdp_uniconv_in(uniconv,
1762 notify_icon_state->infoTip.text.string,
1763 notify_icon_state->infoTip.text.length);
1764 rnso.infotip.title = freerdp_uniconv_in(uniconv,
1765 notify_icon_state->infoTip.title.string,
1766 notify_icon_state->infoTip.title.length);
17031767 }
17041768
17051769 rnso.state = notify_icon_state->state;
17301794 lrail_NotifyIconUpdate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
17311795 NOTIFY_ICON_STATE_ORDER *notify_icon_state)
17321796 {
1733 LLOGLN(0, ("lrail_NotifyIconUpdate:"));
1797 LLOGLN(10, ("lrail_NotifyIconUpdate:"));
17341798 lrail_NotifyIconCreate(context, orderInfo, notify_icon_state);
17351799 }
17361800
17401804 {
17411805 struct mod *mod;
17421806
1743 LLOGLN(0, ("lrail_NotifyIconDelete:"));
1807 LLOGLN(10, ("lrail_NotifyIconDelete:"));
17441808 mod = ((struct mod_context *)context)->modi;
17451809 mod->server_notify_delete(mod, orderInfo->windowId,
17461810 orderInfo->notifyIconId);
17551819 struct mod *mod;
17561820 struct rail_monitored_desktop_order rmdo;
17571821
1758 LLOGLN(0, ("lrail_MonitoredDesktop:"));
1822 LLOGLN(10, ("lrail_MonitoredDesktop:"));
17591823 mod = ((struct mod_context *)context)->modi;
17601824 memset(&rmdo, 0, sizeof(rmdo));
17611825 rmdo.active_window_id = monitored_desktop->activeWindowId;
17851849 struct mod *mod;
17861850 struct rail_monitored_desktop_order rmdo;
17871851
1788 LLOGLN(0, ("lrail_NonMonitoredDesktop:"));
1852 LLOGLN(10, ("lrail_NonMonitoredDesktop:"));
17891853 mod = ((struct mod_context *)context)->modi;
17901854 memset(&rmdo, 0, sizeof(rmdo));
17911855 mod->server_monitored_desktop(mod, &rmdo, orderInfo->fieldFlags);
17971861 {
17981862 struct mod *mod;
17991863
1800 LLOGLN(0, ("lfreerdp_post_connect:"));
1864 LLOGLN(10, ("lfreerdp_post_connect:"));
18011865 mod = ((struct mod_context *)(instance->context))->modi;
18021866 g_memset(mod->password, 0, sizeof(mod->password));
18031867
3434
3535 struct bitmap_item
3636 {
37 int width;
38 int height;
39 char* data;
37 int width;
38 int height;
39 char *data;
4040 };
4141
4242 struct brush_item
4343 {
44 int bpp;
45 int width;
46 int height;
47 char* data;
48 char b8x8[8];
44 int bpp;
45 int width;
46 int height;
47 char *data;
48 char b8x8[8];
4949 };
5050
5151 struct pointer_item
5252 {
53 int hotx;
54 int hoty;
55 char data[32 * 32 * 4];
56 char mask[32 * 32 / 8];
57 int bpp;
53 int hotx;
54 int hoty;
55 char data[32 * 32 * 4];
56 char mask[32 * 32 / 8];
57 int bpp;
5858 };
5959
6060 #define CURRENT_MOD_VER 3
6161
6262 struct mod
6363 {
64 int size; /* size of this struct */
65 int version; /* internal version */
66 /* client functions */
67 int (*mod_start)(struct mod* v, int w, int h, int bpp);
68 int (*mod_connect)(struct mod* v);
69 int (*mod_event)(struct mod* v, int msg, long param1, long param2,
70 long param3, long param4);
71 int (*mod_signal)(struct mod* v);
72 int (*mod_end)(struct mod* v);
73 int (*mod_set_param)(struct mod* v, char* name, char* value);
74 int (*mod_session_change)(struct mod* v, int, int);
75 int (*mod_get_wait_objs)(struct mod* v, tbus* read_objs, int* rcount,
76 tbus* write_objs, int* wcount, int* timeout);
77 int (*mod_check_wait_objs)(struct mod* v);
78 tintptr mod_dumby[100 - 9]; /* align, 100 minus the number of mod
64 int size; /* size of this struct */
65 int version; /* internal version */
66 /* client functions */
67 int (*mod_start)(struct mod *v, int w, int h, int bpp);
68 int (*mod_connect)(struct mod *v);
69 int (*mod_event)(struct mod *v, int msg, long param1, long param2,
70 long param3, long param4);
71 int (*mod_signal)(struct mod *v);
72 int (*mod_end)(struct mod *v);
73 int (*mod_set_param)(struct mod *v, char *name, char *value);
74 int (*mod_session_change)(struct mod *v, int, int);
75 int (*mod_get_wait_objs)(struct mod *v, tbus *read_objs, int *rcount,
76 tbus *write_objs, int *wcount, int *timeout);
77 int (*mod_check_wait_objs)(struct mod *v);
78 tintptr mod_dumby[100 - 9]; /* align, 100 minus the number of mod
7979 functions above */
80 /* server functions */
81 int (*server_begin_update)(struct mod* v);
82 int (*server_end_update)(struct mod* v);
83 int (*server_fill_rect)(struct mod* v, int x, int y, int cx, int cy);
84 int (*server_screen_blt)(struct mod* v, int x, int y, int cx, int cy,
85 int srcx, int srcy);
86 int (*server_paint_rect)(struct mod* v, int x, int y, int cx, int cy,
87 char* data, int width, int height, int srcx, int srcy);
88 int (*server_set_pointer)(struct mod* v, int x, int y, char* data, char* mask);
89 int (*server_palette)(struct mod* v, int* palette);
90 int (*server_msg)(struct mod* v, char* msg, int code);
91 int (*server_is_term)(struct mod* v);
92 int (*server_set_clip)(struct mod* v, int x, int y, int cx, int cy);
93 int (*server_reset_clip)(struct mod* v);
94 int (*server_set_fgcolor)(struct mod* v, int fgcolor);
95 int (*server_set_bgcolor)(struct mod* v, int bgcolor);
96 int (*server_set_opcode)(struct mod* v, int opcode);
97 int (*server_set_mixmode)(struct mod* v, int mixmode);
98 int (*server_set_brush)(struct mod* v, int x_orgin, int y_orgin,
99 int style, char* pattern);
100 int (*server_set_pen)(struct mod* v, int style,
101 int width);
102 int (*server_draw_line)(struct mod* v, int x1, int y1, int x2, int y2);
103 int (*server_add_char)(struct mod* v, int font, int charactor,
104 int offset, int baseline,
105 int width, int height, char* data);
106 int (*server_draw_text)(struct mod* v, int font,
107 int flags, int mixmode, int clip_left, int clip_top,
108 int clip_right, int clip_bottom,
109 int box_left, int box_top,
110 int box_right, int box_bottom,
111 int x, int y, char* data, int data_len);
112 int (*server_reset)(struct mod* v, int width, int height, int bpp);
113 int (*server_query_channel)(struct mod* v, int index,
114 char* channel_name,
115 int* channel_flags);
116 int (*server_get_channel_id)(struct mod* v, char* name);
117 int (*server_send_to_channel)(struct mod* v, int channel_id,
118 char* data, int data_len,
119 int total_data_len, int flags);
120 int (*server_bell_trigger)(struct mod* v);
121 /* off screen bitmaps */
122 int (*server_create_os_surface)(struct mod* v, int rdpindex,
123 int width, int height);
124 int (*server_switch_os_surface)(struct mod* v, int rdpindex);
125 int (*server_delete_os_surface)(struct mod* v, int rdpindex);
126 int (*server_paint_rect_os)(struct mod* mod, int x, int y,
127 int cx, int cy,
128 int rdpindex, int srcx, int srcy);
129 int (*server_set_hints)(struct mod* mod, int hints, int mask);
130 /* rail */
131 int (*server_window_new_update)(struct mod* mod, int window_id,
132 struct rail_window_state_order* window_state,
133 int flags);
134 int (*server_window_delete)(struct mod* mod, int window_id);
135 int (*server_window_icon)(struct mod* mod,
136 int window_id, int cache_entry, int cache_id,
137 struct rail_icon_info* icon_info,
138 int flags);
139 int (*server_window_cached_icon)(struct mod* mod,
140 int window_id, int cache_entry,
141 int cache_id, int flags);
142 int (*server_notify_new_update)(struct mod* mod,
143 int window_id, int notify_id,
144 struct rail_notify_state_order* notify_state,
145 int flags);
146 int (*server_notify_delete)(struct mod* mod, int window_id,
147 int notify_id);
148 int (*server_monitored_desktop)(struct mod* mod,
149 struct rail_monitored_desktop_order* mdo,
150 int flags);
151 int (*server_set_pointer_ex)(struct mod* mod, int x, int y, char* data,
152 char* mask, int bpp);
80 /* server functions */
81 int (*server_begin_update)(struct mod *v);
82 int (*server_end_update)(struct mod *v);
83 int (*server_fill_rect)(struct mod *v, int x, int y, int cx, int cy);
84 int (*server_screen_blt)(struct mod *v, int x, int y, int cx, int cy,
85 int srcx, int srcy);
86 int (*server_paint_rect)(struct mod *v, int x, int y, int cx, int cy,
87 char *data, int width, int height, int srcx, int srcy);
88 int (*server_set_pointer)(struct mod *v, int x, int y, char *data, char *mask);
89 int (*server_palette)(struct mod *v, int *palette);
90 int (*server_msg)(struct mod *v, char *msg, int code);
91 int (*server_is_term)(struct mod *v);
92 int (*server_set_clip)(struct mod *v, int x, int y, int cx, int cy);
93 int (*server_reset_clip)(struct mod *v);
94 int (*server_set_fgcolor)(struct mod *v, int fgcolor);
95 int (*server_set_bgcolor)(struct mod *v, int bgcolor);
96 int (*server_set_opcode)(struct mod *v, int opcode);
97 int (*server_set_mixmode)(struct mod *v, int mixmode);
98 int (*server_set_brush)(struct mod *v, int x_origin, int y_origin,
99 int style, char *pattern);
100 int (*server_set_pen)(struct mod *v, int style,
101 int width);
102 int (*server_draw_line)(struct mod *v, int x1, int y1, int x2, int y2);
103 int (*server_add_char)(struct mod *v, int font, int character,
104 int offset, int baseline,
105 int width, int height, char *data);
106 int (*server_draw_text)(struct mod *v, int font,
107 int flags, int mixmode, int clip_left, int clip_top,
108 int clip_right, int clip_bottom,
109 int box_left, int box_top,
110 int box_right, int box_bottom,
111 int x, int y, char *data, int data_len);
112 int (*server_reset)(struct mod *v, int width, int height, int bpp);
113 int (*server_query_channel)(struct mod *v, int index,
114 char *channel_name,
115 int *channel_flags);
116 int (*server_get_channel_id)(struct mod *v, char *name);
117 int (*server_send_to_channel)(struct mod *v, int channel_id,
118 char *data, int data_len,
119 int total_data_len, int flags);
120 int (*server_bell_trigger)(struct mod *v);
121 /* off screen bitmaps */
122 int (*server_create_os_surface)(struct mod *v, int rdpindex,
123 int width, int height);
124 int (*server_switch_os_surface)(struct mod *v, int rdpindex);
125 int (*server_delete_os_surface)(struct mod *v, int rdpindex);
126 int (*server_paint_rect_os)(struct mod *mod, int x, int y,
127 int cx, int cy,
128 int rdpindex, int srcx, int srcy);
129 int (*server_set_hints)(struct mod *mod, int hints, int mask);
130 /* rail */
131 int (*server_window_new_update)(struct mod *mod, int window_id,
132 struct rail_window_state_order *window_state,
133 int flags);
134 int (*server_window_delete)(struct mod *mod, int window_id);
135 int (*server_window_icon)(struct mod *mod,
136 int window_id, int cache_entry, int cache_id,
137 struct rail_icon_info *icon_info,
138 int flags);
139 int (*server_window_cached_icon)(struct mod *mod,
140 int window_id, int cache_entry,
141 int cache_id, int flags);
142 int (*server_notify_new_update)(struct mod *mod,
143 int window_id, int notify_id,
144 struct rail_notify_state_order *notify_state,
145 int flags);
146 int (*server_notify_delete)(struct mod *mod, int window_id,
147 int notify_id);
148 int (*server_monitored_desktop)(struct mod *mod,
149 struct rail_monitored_desktop_order *mdo,
150 int flags);
151 int (*server_set_pointer_ex)(struct mod *mod, int x, int y, char *data,
152 char *mask, int bpp);
153153
154 tintptr server_dumby[100 - 37]; /* align, 100 minus the number of server
154 tintptr server_dumby[100 - 37]; /* align, 100 minus the number of server
155155 functions above */
156 /* common */
157 tintptr handle; /* pointer to self as long */
158 tintptr wm;
159 tintptr painter;
160 tintptr si;
161 /* mod data */
162 int sck;
163 int width;
164 int height;
165 int bpp;
166 int colormap[256];
167 char* chan_buf;
168 int chan_buf_valid;
169 int chan_buf_bytes;
170 int vmaj;
171 int vmin;
172 int vrev;
173 char username[256];
174 char password[256];
175 int bool_keyBoardSynced ; /* Numlock can be out of sync, we hold state here to resolve */
176 int keyBoardLockInfo ; /* Holds initial numlock capslock state */
156 /* common */
157 tintptr handle; /* pointer to self as long */
158 tintptr wm;
159 tintptr painter;
160 tintptr si;
177161
178 struct xrdp_client_info client_info;
162 /* mod data */
163 int sck;
164 int width;
165 int height;
166 int bpp;
167 int colormap[256];
168 char *chan_buf;
169 int chan_buf_valid;
170 int chan_buf_bytes;
171 int vmaj;
172 int vmin;
173 int vrev;
174 char username[256];
175 char password[256];
176 char domain[256];
177 int bool_keyBoardSynced ; /* Numlock can be out of sync, we hold state here to resolve */
178 int keyBoardLockInfo ; /* Holds initial numlock capslock state */
179179
180 struct rdp_freerdp* inst;
181 struct bitmap_item bitmap_cache[4][4096];
182 struct brush_item brush_cache[64];
183 struct pointer_item pointer_cache[32];
180 struct xrdp_client_info client_info;
181
182 struct rdp_freerdp *inst;
183 struct bitmap_item bitmap_cache[4][4096];
184 struct brush_item brush_cache[64];
185 struct pointer_item pointer_cache[32];
184186
185187 };
00
1 This is an atempt to explain my odd programming standard used for this project.
1 This is an attempt to explain my odd programming standard used for this project.
22 Not to defend any of these but its my default standard and make it easy
33 for me to read.
44 Some files break these rules, they will be updated eventually.
0 EXTRA_DIST = rdp.h
10 EXTRA_DEFINES =
21
32 if XRDP_DEBUG
65 EXTRA_DEFINES += -DXRDP_NODEBUG
76 endif
87
9 AM_CFLAGS = \
8 AM_CPPFLAGS = \
109 -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
1110 -DXRDP_SBIN_PATH=\"${sbindir}\" \
1211 -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
1312 -DXRDP_PID_PATH=\"${localstatedir}/run\" \
14 $(EXTRA_DEFINES)
15
16 INCLUDES = \
13 $(EXTRA_DEFINES) \
1714 -I$(top_srcdir)/common
1815
19 lib_LTLIBRARIES = \
16 module_LTLIBRARIES = \
2017 librdp.la
2118
2219 librdp_la_SOURCES = \
2320 rdp.c \
21 rdp.h \
2422 rdp_bitmap.c \
2523 rdp_iso.c \
2624 rdp_lic.c \
286286 int (*server_set_bgcolor)(struct mod* v, int bgcolor);
287287 int (*server_set_opcode)(struct mod* v, int opcode);
288288 int (*server_set_mixmode)(struct mod* v, int mixmode);
289 int (*server_set_brush)(struct mod* v, int x_orgin, int y_orgin,
289 int (*server_set_brush)(struct mod* v, int x_origin, int y_origin,
290290 int style, char* pattern);
291291 int (*server_set_pen)(struct mod* v, int style,
292292 int width);
293293 int (*server_draw_line)(struct mod* v, int x1, int y1, int x2, int y2);
294 int (*server_add_char)(struct mod* v, int font, int charactor,
294 int (*server_add_char)(struct mod* v, int font, int character,
295295 int offset, int baseline,
296296 int width, int height, char* data);
297297 int (*server_draw_text)(struct mod* v, int font,
7272 LICENCE_HWID_SIZE - 4);
7373 }
7474
75 #if 0
7576 /*****************************************************************************/
7677 /* Present an existing licence to the server */
7778 static void APP_CC
111112 rdp_sec_send(self->sec_layer, s, sec_flags);
112113 free_stream(s);
113114 }
115 #endif
114116
115117 /*****************************************************************************/
116118 /* Send a licence request packet */
160162 {
161163 char null_data[SEC_MODULUS_SIZE];
162164 char *server_random;
163 char signature[LICENCE_SIGNATURE_SIZE];
164 char hwid[LICENCE_HWID_SIZE];
165 char *licence_data;
166 int licence_size;
167 void *crypt_key;
168
169 licence_data = 0;
165
170166 /* Retrieve the server random from the incoming packet */
171167 in_uint8p(s, server_random, SEC_RANDOM_SIZE);
172168 /* We currently use null client keys. This is a bit naughty but, hey,
175171 rdp_lic_generate_keys(self, null_data, server_random, null_data);
176172
177173 #if 0
174 int licence_size;
175 char *licence_data;
176
178177 licence_size = 0; /* todo load_licence(&licence_data); */
179178
180179 if (licence_size > 0)
181180 {
181 void *crypt_key;
182 char hwid[LICENCE_HWID_SIZE];
183 char signature[LICENCE_SIGNATURE_SIZE];
184
182185 /* Generate a signature for the HWID buffer */
183186 rdp_lic_generate_hwid(self, hwid);
184187 rdp_sec_sign(signature, 16, self->licence_sign_key, 16,
1818 */
1919
2020 #include "rdp.h"
21 #include "common/log.h"
21 #include "log.h"
2222
2323 /*****************************************************************************/
2424 struct rdp_mcs *APP_CC
224224 int flags)
225225 {
226226 int cache_idx = 0;
227 int bufsize = 0;
228227 int cache_id = 0;
229228 int width = 0;
230229 int height = 0;
243242 in_uint8(s, height);
244243 in_uint8(s, bpp);
245244 Bpp = (bpp + 7) / 8;
246 in_uint16_le(s, bufsize);
245 in_uint8s(s, 2); /* bufsize */
247246 in_uint16_le(s, cache_idx);
248247 inverted = (char *)g_malloc(width * height * Bpp, 0);
249248
325324 int bpp = 0;
326325 int Bpp = 0;
327326 int bufsize = 0;
328 int pad1 = 0;
329 int pad2 = 0;
330 int row_size = 0;
331 int final_size = 0;
332327 struct rdp_bitmap *bitmap = (struct rdp_bitmap *)NULL;
333328 struct stream *rec_s = (struct stream *)NULL;
334329
335330 in_uint8(s, cache_id);
336 in_uint8(s, pad1);
331 in_uint8s(s, 1); /* pad */
337332 in_uint8(s, width);
338333 in_uint8(s, height);
339334 in_uint8(s, bpp);
347342 }
348343 else
349344 {
350 in_uint16_le(s, pad2);
345 in_uint8s(s, 2); /* pad */
351346 in_uint16_le(s, size);
352 in_uint16_le(s, row_size);
353 in_uint16_le(s, final_size);
347 in_uint8s(s, 2); /* row_size */
348 in_uint8s(s, 2); /* final_size */
354349 }
355350
356351 in_uint8p(s, data, size);
11141109 rdp_orders_process_desksave(struct rdp_orders *self, struct stream *s,
11151110 int present, int delta)
11161111 {
1117 int width = 0;
1118 int height = 0;
1112 //int width = 0;
1113 //int height = 0;
11191114
11201115 if (present & 0x01)
11211116 {
14341429 }
14351430
14361431 /*****************************************************************************/
1437 /* returns pointer, it might return bmpdata if the data dosen't need to
1432 /* returns pointer, it might return bmpdata if the data doesn't need to
14381433 be converted, else it mallocs it. The calling function must free
14391434 it if needed */
14401435 char *APP_CC
505505 rdp_rdp_process_pointer_pdu(struct rdp_rdp *self, struct stream *s)
506506 {
507507 int message_type;
508 int x;
509 int y;
510508 int rv;
511509
512510 rv = 0;
516514 switch (message_type)
517515 {
518516 case RDP_POINTER_MOVE:
519 in_uint16_le(s, x);
520 in_uint16_le(s, y);
517 in_uint8s(s, 2); /* x */
518 in_uint8s(s, 2); /* y */
521519 break;
522520 case RDP_POINTER_COLOR:
523521 rv = rdp_rdp_process_color_pointer_pdu(self, s);
933931 rdp_rdp_process_data_pdu(struct rdp_rdp *self, struct stream *s)
934932 {
935933 int data_pdu_type;
936 int ctype;
937 int len;
938934 int rv;
939935
940936 rv = 0;
941937 in_uint8s(s, 6); /* shareid, pad, streamid */
942 in_uint16_le(s, len);
938 in_uint8s(s, 2); /* len */
943939 in_uint8(s, data_pdu_type);
944 in_uint8(s, ctype);
940 in_uint8s(s, 1); /* ctype */
945941 in_uint8s(s, 2); /* clen */
946942
947943 switch (data_pdu_type)
982978 static void APP_CC
983979 rdp_rdp_process_bitmap_caps(struct rdp_rdp *self, struct stream *s)
984980 {
985 int width = 0;
986 int height = 0;
987981 int bpp = 0;
988982
989983 in_uint16_le(s, bpp);
990984 in_uint8s(s, 6);
991 in_uint16_le(s, width);
992 in_uint16_le(s, height);
985 in_uint8s(s, 2); /* width */
986 in_uint8s(s, 2); /* height */
993987 self->mod->rdp_bpp = bpp;
994988 /* todo, call reset if needed and use width and height */
995989 }
5454 {
5555 int rcvd;
5656
57 DEBUG((" in rdp_tcp_recv gota get %d bytes on sck %d",
57 DEBUG((" in rdp_tcp_recv will get %d bytes on sck %d",
5858 len, self->sck));
5959
6060 if (self->sck_closed)
7373 {
7474 if (g_tcp_last_error_would_block(self->sck))
7575 {
76 g_tcp_can_recv(self->sck, 10);
76 g_sck_can_recv(self->sck, 10);
7777 }
7878 else
7979 {
114114 }
115115
116116 len = s->end - s->data;
117 DEBUG((" in rdp_tcp_send gota send %d bytes on sck %d", len,
117 DEBUG((" in rdp_tcp_send will send %d bytes on sck %d", len,
118118 self->sck));
119119 total = 0;
120120
88 Mark from up 19.9 was the first to work with rdp server code.
99
1010 Tested with linux on i386, x64, sparc, and ppc.
11 I've got it compiling and working in windows with borland free tools.
12 Non of the sesman or Xserver stuff works in windows of course.
11 I've got it compiling and working in windows with Borland free tools.
12 None of the sesman or Xserver stuff works in windows of course.
1313
1414 xrdp directory is the main server code
1515 vnc directory is a simple vnc client module for xrdp
1818 rdp is an rdp client module for connecting to another rdp server
1919 xup is a module used to connect to an rdp specific X11 server
2020 Xserver is the files needed to build an rdp specific X11 server
21 COPYING is the licence file
22 design.txt is an attempt to expain the project design
23 prog_std.txt is an attemp to explain the programming standard used
21 COPYING is the license file
22 design.txt is an attempt to explain the project design
23 prog_std.txt is an attempt to explain the programming standard used
2424
25 since version 0.5.0 we switch to autotool to build xrdp
25 since version 0.5.0 we switch to autotools to build xrdp
2626
2727 to build and install
2828
0 EXTRA_DIST = sesman.ini startwm.sh sesman.h access.h auth.h config.h env.h lock.h scp.h scp_v0.h scp_v1.h scp_v1_mng.h session.h sig.h thread.h
1
2 AM_CFLAGS = \
0 AM_CPPFLAGS = \
31 -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
42 -DXRDP_SBIN_PATH=\"${sbindir}\" \
53 -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
6 -DXRDP_PID_PATH=\"${localstatedir}/run\"
7
8 INCLUDES = \
4 -DXRDP_PID_PATH=\"${localstatedir}/run\" \
95 -I$(top_srcdir)/common \
106 -I$(top_srcdir)/sesman/libscp
117
3632 xrdp-sesman
3733
3834 xrdp_sesman_SOURCES = \
35 access.c \
36 access.h \
37 auth.h \
38 config.c \
39 config.h \
40 env.c \
41 env.h \
3942 scp.c \
43 scp.h \
4044 scp_v0.c \
45 scp_v0.h \
4146 scp_v1.c \
47 scp_v1.h \
4248 scp_v1_mng.c \
49 scp_v1_mng.h \
4350 sesman.c \
51 sesman.h \
4452 session.c \
53 session.h \
4554 sig.c \
46 thread.c \
47 lock.c \
48 access.c \
49 config.c \
50 env.c \
55 sig.h \
5156 $(AUTH_C)
5257
5358 xrdp_sesman_LDADD = \
5863
5964 sesmansysconfdir=$(sysconfdir)/xrdp
6065
61 sesmansysconf_DATA = \
62 sesman.ini \
66 dist_sesmansysconf_DATA = \
67 sesman.ini
68
69 dist_sesmansysconf_SCRIPTS = \
6370 startwm.sh
6471
6572 SUBDIRS = \
6774 tools \
6875 sessvc \
6976 chansrv
70
71 # must be tab below
72 install-data-hook:
73 chmod 755 $(DESTDIR)$(sysconfdir)/xrdp/startwm.sh
00 /**
11 * xrdp: A Remote Desktop Protocol server.
22 *
3 * Copyright (C) Jay Sorg 2004-2013
3 * Copyright (C) Jay Sorg 2004-2015
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
9292
9393 if (0 == g_cfg->sec.ts_admins_enable)
9494 {
95 LOG_DBG("[MNG] Terminal Server Admin group is disabled,"
95 LOG_DBG("[MNG] Terminal Server Admin group is disabled, "
9696 "allowing authentication", 1);
9797 return 1;
9898 }
0 EXTRA_DIST = \
1 chansrv.h \
2 chansrv_fuse.h \
3 clipboard.h \
4 clipboard_common.h \
5 clipboard_file.h \
6 devredir.h \
7 drdynvc.h \
8 rail.h \
9 sound.h \
10 xcommon.h \
11 mlog.h \
12 chansrv_common.h \
13 irp.h \
14 smartcard.h \
15 smartcard_pcsc.h \
16 fifo.h
17
180 EXTRA_DEFINES =
191 EXTRA_INCLUDES =
202 EXTRA_LIBS =
3012 EXTRA_LIBS += -lopus
3113 endif
3214
33 AM_CFLAGS = \
15 AM_CPPFLAGS = \
3416 -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
3517 -DXRDP_SBIN_PATH=\"${sbindir}\" \
3618 -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
3719 -DXRDP_PID_PATH=\"${localstatedir}/run\" \
38 $(EXTRA_DEFINES)
39
40 INCLUDES = \
20 $(EXTRA_DEFINES) \
4121 -I$(top_srcdir)/common \
4222 $(EXTRA_INCLUDES)
23
24 AM_CFLAGS = $(X_CFLAGS)
4325
4426 sbin_PROGRAMS = \
4527 xrdp-chansrv
4628
4729 xrdp_chansrv_SOURCES = \
4830 chansrv.c \
31 chansrv.h \
32 chansrv_common.c \
33 chansrv_common.h \
34 chansrv_fuse.c \
35 chansrv_fuse.h \
36 clipboard.c \
37 clipboard.h \
38 clipboard_common.h \
39 clipboard_file.c \
40 clipboard_file.h \
41 devredir.c \
42 devredir.h \
43 drdynvc.c \
44 drdynvc.h \
45 fifo.c \
46 fifo.h \
47 irp.c \
48 irp.h \
49 mlog.h \
50 rail.c \
51 rail.h \
52 smartcard.c \
53 smartcard.h \
54 smartcard_pcsc.c \
55 smartcard_pcsc.h \
4956 sound.c \
50 clipboard.c \
51 clipboard_file.c \
52 devredir.c \
53 smartcard.c \
54 smartcard_pcsc.c \
55 rail.c \
57 sound.h \
5658 xcommon.c \
57 drdynvc.c \
58 chansrv_fuse.c \
59 irp.c \
60 fifo.c \
61 chansrv_common.c
59 xcommon.h
6260
6361 xrdp_chansrv_LDFLAGS = \
62 $(X_LIBS) \
6463 $(EXTRA_FLAGS)
6564
6665 xrdp_chansrv_LDADD = \
67 -L/usr/X11R6/lib \
6866 $(top_builddir)/common/libcommon.la \
69 -lX11 -lXfixes -lXrandr \
67 $(X_PRE_LIBS) -lXfixes -lXrandr -lX11 $(X_EXTRA_LIBS) \
7068 $(EXTRA_LIBS)
755755 my_trans_data_in(struct trans *trans)
756756 {
757757 struct stream *s = (struct stream *)NULL;
758 int id = 0;
759758 int size = 0;
760759 int error = 0;
761760
771770
772771 LOGM((LOG_LEVEL_DEBUG, "my_trans_data_in:"));
773772 s = trans_get_in_s(trans);
774 in_uint32_le(s, id);
773 in_uint8s(s, 4); /* id */
775774 in_uint32_le(s, size);
776775 error = trans_force_read(trans, size - 8);
777776
14861485
14871486 /* starting logging subsystem */
14881487 g_memset(&logconfig, 0, sizeof(struct log_config));
1489 logconfig.program_name = "XRDP-Chansrv";
1488 logconfig.program_name = "xrdp-chansrv";
14901489 g_snprintf(log_file, 255, "%s/xrdp-chansrv.log", log_path);
14911490 g_writeln("chansrv::main: using log file [%s]", log_file);
14921491
15241523
15251524 LOGM((LOG_LEVEL_ALWAYS, "main: app started pid %d(0x%8.8x)", pid, pid));
15261525 /* set up signal handler */
1527 g_signal_kill(term_signal_handler); /* SIGKILL */
15281526 g_signal_terminate(term_signal_handler); /* SIGTERM */
15291527 g_signal_user_interrupt(term_signal_handler); /* SIGINT */
15301528 g_signal_pipe(nil_signal_handler); /* SIGPIPE */
1818 /*
1919 * TODO
2020 * o when creating dir/file, ensure it does not already exist
21 * o do not allow dirs to be created in ino==1 except for .clipbard and share mounts
21 * o do not allow dirs to be created in ino==1 except for .clipboard and share mounts
2222 * o fix the HACK where I have to use my own buf instead of g_buffer
2323 * this is in func xfuse_check_wait_objs()
2424 * o if fuse mount point is already mounted, I get segfault
3838
3939 //#define USE_SYNC_FLAG
4040
41 static char g_fuse_mount_name[256] = "xrdp_client";
42
4341 /* FUSE mount point */
4442 char g_fuse_root_path[256] = "";
4543 char g_fuse_clipboard_path[256] = ""; /* for clipboard use */
6159 #include "chansrv_fuse.h"
6260
6361 /* dummy calls when XRDP_FUSE is not defined */
64 int xfuse_init() { return 0; }
65 int xfuse_deinit() { return 0; }
62 int xfuse_init(void) { return 0; }
63 int xfuse_deinit(void) { return 0; }
6664 int xfuse_check_wait_objs(void) { return 0; }
6765 int xfuse_get_wait_objs(tbus *objs, int *count, int *timeout) { return 0; }
6866 int xfuse_clear_clip_dir(void) { return 0; }
7371 void xfuse_devredir_cb_open_file(void *vp, tui32 IoStatus, tui32 DeviceId, tui32 FileId) {}
7472 void xfuse_devredir_cb_write_file(void *vp, char *buf, size_t length) {}
7573 void xfuse_devredir_cb_read_file(void *vp, char *buf, size_t length) {}
76 int xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) {}
74 int xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) { return 0; }
7775 void xfuse_devredir_cb_enum_dir_done(void *vp, tui32 IoStatus) {}
7876 void xfuse_devredir_cb_rmdir_or_file(void *vp, tui32 IoStatus) {}
7977 void xfuse_devredir_cb_rename_file(void *vp, tui32 IoStatus) {}
238236 struct fuse_file_info *fi;
239237 };
240238
239 static char g_fuse_mount_name[256] = "xrdp_client";
240
241241 FIFO g_fifo_opendir;
242242
243243 static struct list *g_req_list = 0;
252252 static tintptr g_bufsize = 0;
253253
254254 /* forward declarations for internal access */
255 static int xfuse_init_xrdp_fs();
256 static int xfuse_deinit_xrdp_fs();
255 static int xfuse_init_xrdp_fs(void);
256 static int xfuse_deinit_xrdp_fs(void);
257257 static int xfuse_init_lib(struct fuse_args *args);
258258 static int xfuse_is_inode_valid(int ino);
259259
263263 const char *name, mode_t mode, int type);
264264 #endif
265265
266 static void xfuse_dump_fs();
266 static void xfuse_dump_fs(void);
267267 static void xfuse_dump_xrdp_inode(struct xrdp_inode *xino);
268268 static tui32 xfuse_get_device_id_for_inode(tui32 ino, char *full_path);
269269 static void fuse_reverse_pathname(char *full_path, char *reverse_path);
280280 static int xfuse_delete_file_with_xinode(XRDP_INODE *xinode);
281281 static int xfuse_delete_dir_with_xinode(XRDP_INODE *xinode);
282282 static int xfuse_recursive_delete_dir_with_xinode(XRDP_INODE *xinode);
283 static void xfuse_update_xrdpfs_size();
283 static void xfuse_update_xrdpfs_size(void);
284284 static void xfuse_enum_dir(fuse_req_t req, fuse_ino_t ino, size_t size,
285285 off_t off, struct fuse_file_info *fi);
286286
305305 static void xfuse_cb_getattr(fuse_req_t req, fuse_ino_t ino,
306306 struct fuse_file_info *fi);
307307
308 /* this is not a callback, but its's used by xfuse_cb_readdir() */
308 /* this is not a callback, but it's used by xfuse_cb_readdir() */
309309 static void xfuse_dirbuf_add(fuse_req_t req, struct dirbuf *b,
310310 const char *name, fuse_ino_t ino);
311311
692692
693693 log_debug("entered");
694694
695 if (g_xrdp_fs.inode_table == NULL)
696 {
697 return 0;
698 }
699
695700 /* xinode for .clipboard */
696701 xip = g_xrdp_fs.inode_table[2];
697702
12581263 * Check if specified file exists
12591264 *
12601265 * @param parent parent inode of file
1261 * @param name flilename or dirname
1266 * @param name filename or dirname
12621267 *
12631268 * @return 1 if specified file exists, 0 otherwise
12641269 *****************************************************************************/
175175 #define LOG_ERROR 0
176176 #define LOG_INFO 1
177177 #define LOG_DEBUG 2
178
179 #undef LOG_LEVEL
178180 #define LOG_LEVEL LOG_ERROR
179181
180182 #define log_error(_params...) \
270272 CB_FILECLIP_NO_FILE_PATHS;
271273
272274 /* from client to server */
273 /* last recieved CLIPRDR_FORMAT_LIST(CLIPRDR_FORMAT_ANNOUNCE) */
275 /* last received CLIPRDR_FORMAT_LIST(CLIPRDR_FORMAT_ANNOUNCE) */
274276 static int g_formatIds[16];
275277 static int g_num_formatIds = 0;
276278
10831085 /* response to CB_FORMAT_LIST; used to indicate whether
10841086 processing of the Format List PDU was successful */
10851087 static int APP_CC
1086 clipboard_prcoess_format_ack(struct stream *s, int clip_msg_status,
1088 clipboard_process_format_ack(struct stream *s, int clip_msg_status,
10871089 int clip_msg_len)
10881090 {
1089 log_debug("clipboard_prcoess_format_ack: CLIPRDR_FORMAT_ACK");
1090 log_debug("clipboard_prcoess_format_ack:");
1091 log_debug("clipboard_process_format_ack: CLIPRDR_FORMAT_ACK");
1092 log_debug("clipboard_process_format_ack:");
10911093 return 0;
10921094 }
10931095
15461548 {
15471549 log_error("aborting clipboard_data_in - clipboard has not "
15481550 "been initialized");
1549 /* we return 0 here to indicate no protocol problem occured */
1551 /* we return 0 here to indicate no protocol problem occurred */
15501552 return 0;
15511553 }
15521554
16311633 /* response to CB_FORMAT_LIST; used to indicate whether */
16321634 /* processing of the Format List PDU was successful */
16331635 case CB_FORMAT_LIST_RESPONSE: /* 3 CLIPRDR_FORMAT_ACK */
1634 rv = clipboard_prcoess_format_ack(ls, clip_msg_status,
1636 rv = clipboard_process_format_ack(ls, clip_msg_status,
16351637 clip_msg_len);
16361638 break;
16371639 /* sent by recipient of CB_FORMAT_LIST; used to request data for one */
16941696 XFixesSelectionNotifyEvent *lxevent;
16951697
16961698 lxevent = (XFixesSelectionNotifyEvent *)xevent;
1697 log_debug("clipboard_event_selection_owner_notify: %p", lxevent->owner);
1699 log_debug("clipboard_event_selection_owner_notify: 0x%lx", lxevent->owner);
16981700 log_debug("clipboard_event_selection_owner_notify: "
1699 "window %d subtype %d owner %d g_wnd %d",
1701 "window %ld subtype %d owner %ld g_wnd %ld",
17001702 lxevent->window, lxevent->subtype, lxevent->owner, g_wnd);
17011703
17021704 if (lxevent->owner == g_wnd)
17031705 {
17041706 log_debug("clipboard_event_selection_owner_notify: matches g_wnd");
17051707 log_debug("clipboard_event_selection_owner_notify: skipping, "
1706 "onwer == g_wnd");
1708 "owner == g_wnd");
17071709 g_got_selection = 1;
17081710 return 0;
17091711 }
17321734 Atom ltype;
17331735
17341736 log_debug("clipboard_get_window_property:");
1735 log_debug(" prop %d name %s", prop, get_atom_text(prop));
1737 log_debug(" prop %ld name %s", prop, get_atom_text(prop));
17361738 lxdata = 0;
17371739 ltype = 0;
17381740 XGetWindowProperty(g_display, wnd, prop, 0, 0, 0,
18701872
18711873 if (rv == 0)
18721874 {
1873 log_debug("clipboard_event_selection_notify: wnd %p prop %s",
1875 log_debug("clipboard_event_selection_notify: wnd 0x%lx prop %s",
18741876 lxevent->requestor,
18751877 get_atom_text(lxevent->property));
18761878 rv = clipboard_get_window_property(lxevent->requestor, lxevent->property,
18861888 XDeleteProperty(g_display, lxevent->requestor, lxevent->property);
18871889 if (type == g_incr_atom)
18881890 {
1889 /* nothing more to do here, the data is comming in through
1891 /* nothing more to do here, the data is coming in through
18901892 PropertyNotify */
18911893 log_debug("clipboard_event_selection_notify: type is INCR "
18921894 "data_size %d property name %s type %s", data_size,
19191921 atom = atoms[index];
19201922 LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_notify: %d %s %d",
19211923 atom, get_atom_text(atom), XA_STRING));
1922 log_debug("clipboard_event_selection_notify: 0x%x %s",
1924 log_debug("clipboard_event_selection_notify: 0x%lx %s",
19231925 atom, get_atom_text(atom));
19241926 if (atom == g_utf8_atom)
19251927 {
19401942 }
19411943 else
19421944 {
1943 log_error("clipboard_event_selection_notify: unknown atom 0x%x", atom);
1945 log_error("clipboard_event_selection_notify: unknown atom 0x%lx", atom);
19441946 }
19451947 }
19461948 }
19471949 else
19481950 {
19491951 log_error("clipboard_event_selection_notify: error, "
1950 "target is 'TARGETS' and type[%d] or fmt[%d] not right, "
1951 "should be type[%d], fmt[%d]", type, fmt, XA_ATOM, 32);
1952 "target is 'TARGETS' and type[%ld] or fmt[%d] not right, "
1953 "should be type[%ld], fmt[%d]", type, fmt, XA_ATOM, 32);
19521954 }
19531955 }
19541956 else if (lxevent->target == g_utf8_atom)
21352137 char *xdata;
21362138
21372139 lxev = (XSelectionRequestEvent *)xevent;
2138 log_debug("clipboard_event_selection_request: %p", lxev->property);
2139 log_debug("clipboard_event_selection_request: g_wnd %d, "
2140 ".requestor %d .owner %d .selection %d '%s' .target %d .property %d",
2140 log_debug("clipboard_event_selection_request: 0x%lx", lxev->property);
2141 log_debug("clipboard_event_selection_request: g_wnd %ld, "
2142 ".requestor %ld .owner %ld .selection %ld '%s' .target %ld .property %ld",
21412143 g_wnd, lxev->requestor, lxev->owner, lxev->selection,
21422144 get_atom_text(lxev->selection),
21432145 lxev->target, lxev->property);
23232325 char *cptr;
23242326
23252327 log_debug("clipboard_event_property_notify:");
2326 log_debug("clipboard_event_property_notify: PropertyNotify .window %d "
2327 ".state %d .atom %d %s", xevent->xproperty.window,
2328 log_debug("clipboard_event_property_notify: PropertyNotify .window %ld "
2329 ".state %d .atom %ld %s", xevent->xproperty.window,
23282330 xevent->xproperty.state, xevent->xproperty.atom,
23292331 get_atom_text(xevent->xproperty.atom));
23302332
23782380 rv = XGetWindowProperty(g_display, g_wnd, g_clip_s2c.property, 0, 0, 0,
23792381 AnyPropertyType, &actual_type_return, &actual_format_return,
23802382 &nitems_returned, &bytes_left, &data);
2383
2384 if (rv != Success)
2385 {
2386 return 1;
2387 }
23812388
23822389 if (data != 0)
23832390 {
24092416 }
24102417 else
24112418 {
2412 log_error("clipboard_event_property_notify: error unknown type %d",
2419 log_error("clipboard_event_property_notify: error unknown type %ld",
24132420 g_clip_s2c.type);
24142421 clipboard_send_data_response_failed();
24152422 }
24212428 rv = XGetWindowProperty(g_display, g_wnd, g_clip_s2c.property, 0, bytes_left, 0,
24222429 AnyPropertyType, &actual_type_return, &actual_format_return,
24232430 &nitems_returned, &bytes_left, &data);
2431
2432 if (rv != Success)
2433 {
2434 return 1;
2435 }
24242436
24252437 format_in_bytes = FORMAT_TO_BYTES(actual_format_return);
24262438 new_data_len = nitems_returned * format_in_bytes;
2121 * CLIPRDR_FILEDESCRIPTOR
2222 * http://msdn.microsoft.com/en-us/library/ff362447%28prot.20%29.aspx */
2323
24 #include <sys/time.h>
2425 #include <X11/Xlib.h>
2526 #include <X11/Xatom.h>
2627 #include <X11/extensions/Xfixes.h>
100101 #define CB_EPOCH_DIFF 11644473600LL
101102
102103 /*****************************************************************************/
104 #if 0
103105 static tui64 APP_CC
104106 timeval2wintime(struct timeval *tv)
105107 {
111113 result += tv->tv_usec * 10;
112114 return result;
113115 }
116 #endif
114117
115118 /*****************************************************************************/
116119 /* this will replace %20 or any hex with the space or correct char
527530 int lindex;
528531 int dwFlags;
529532 int nPositionLow;
530 int nPositionHigh;
531533 int cbRequested;
532534 //int clipDataId;
533535
537539 in_uint32_le(s, lindex);
538540 in_uint32_le(s, dwFlags);
539541 in_uint32_le(s, nPositionLow);
540 in_uint32_le(s, nPositionHigh);
542 in_uint8s(s, 4); /* nPositionHigh */
541543 in_uint32_le(s, cbRequested);
542544 //in_uint32_le(s, clipDataId); /* options, used when locking */
543545 if (dwFlags & CB_FILECONTENTS_SIZE)
552554 }
553555
554556 /*****************************************************************************/
555 /* server requested info about the file and this is the responce
557 /* server requested info about the file and this is the response
556558 it's either the file size or file data */
557559 int APP_CC
558560 clipboard_process_file_response(struct stream *s, int clip_msg_status,
241241 case PAKID_CORE_CLIENT_NAME:
242242 /* client is telling us its computer name; do we even care? */
243243
244 /* let client know loggin was successful */
244 /* let client know login was successful */
245245 dev_redir_send_server_user_logged_on();
246246 usleep(1000 * 100);
247247
248 /* let client know our capabilites */
248 /* let client know our capabilities */
249249 dev_redir_send_server_core_cap_req();
250250
251251 /* send confirm clientID */
575575 ******************************************************************************/
576576
577577 /**
578 * @brief process client's repsonse to our core_capability_req() msg
578 * @brief process client's response to our core_capability_req() msg
579579 *
580580 * @param s stream containing client's response
581581 *****************************************************************************/
889889 XRDP_INODE *xinode;
890890
891891 tui32 Length;
892 tui32 NextEntryOffset;
893892 tui64 CreationTime;
894893 tui64 LastAccessTime;
895894 tui64 LastWriteTime;
896 tui64 ChangeTime;
897895 tui64 EndOfFile;
898896 tui32 FileAttributes;
899897 tui32 FileNameLength;
900898 tui32 status;
901
902 #ifdef USE_SHORT_NAMES_IN_DIR_LISTING
903 tui32 EaSize;
904 tui8 ShortNameLength;
905 tui8 Reserved;
906 #endif
907899
908900 char filename[256];
909901 int i = 0;
934926 {
935927 log_debug("processing FILE_DIRECTORY_INFORMATION structs");
936928
937 xstream_rd_u32_le(s_in, NextEntryOffset);
929 xstream_seek(s_in, 4); /* NextEntryOffset */
938930 xstream_seek(s_in, 4); /* FileIndex */
939931 xstream_rd_u64_le(s_in, CreationTime);
940932 xstream_rd_u64_le(s_in, LastAccessTime);
941933 xstream_rd_u64_le(s_in, LastWriteTime);
942 xstream_rd_u64_le(s_in, ChangeTime);
934 xstream_seek(s_in, 8); /* ChangeTime */
943935 xstream_rd_u64_le(s_in, EndOfFile);
944936 xstream_seek(s_in, 8); /* AllocationSize */
945937 xstream_rd_u32_le(s_in, FileAttributes);
946938 xstream_rd_u32_le(s_in, FileNameLength);
947939
948940 #ifdef USE_SHORT_NAMES_IN_DIR_LISTING
949 xstream_rd_u32_le(s_in, EaSize);
950 xstream_rd_u8(s_in, ShortNameLength);
951 xstream_rd_u8(s_in, Reserved);
941 xstream_seek(s_in, 4); /* EaSize */
942 xstream_seek(s_in, 1); /* ShortNameLength */
943 xstream_seek(s_in, 1); /* Reserved */
952944 xstream_seek(s_in, 23); /* ShortName in Unicode */
953945 #endif
954946 devredir_cvt_from_unicode_len(filename, s_in->p, FileNameLength);
958950 #else
959951 i += 64 + FileNameLength;
960952 #endif
961 //log_debug("NextEntryOffset: 0x%x", NextEntryOffset);
962953 //log_debug("CreationTime: 0x%llx", CreationTime);
963954 //log_debug("LastAccessTime: 0x%llx", LastAccessTime);
964955 //log_debug("LastWriteTime: 0x%llx", LastWriteTime);
965 //log_debug("ChangeTime: 0x%llx", ChangeTime);
966956 //log_debug("EndOfFile: %lld", EndOfFile);
967957 //log_debug("FileAttributes: 0x%x", FileAttributes);
968958 #ifdef USE_SHORT_NAMES_IN_DIR_LISTING
10391029
10401030 log_debug("looking for device_id=%d path=%s", device_id, path);
10411031
1042 /* when we get a respone to dev_redir_send_drive_create_request(), we */
1032 /* when we get a response to dev_redir_send_drive_create_request(), we */
10431033 /* call dev_redir_send_drive_dir_request(), which needs the following */
10441034 /* at the end of the path argument */
10451035 if (dev_redir_string_ends_with(irp->pathname, '\\'))
14831473 char *dest;
14841474 char *dest_saved;
14851475 char *src;
1486 int rv;
14871476 int i;
14881477 int bytes_to_alloc;
14891478 int max_bytes;
15081497 max_bytes = wcstombs(NULL, (wchar_t *) dest_saved, 0);
15091498 if (max_bytes > 0)
15101499 {
1511 rv = wcstombs(path, (wchar_t *) dest_saved, max_bytes);
1500 wcstombs(path, (wchar_t *) dest_saved, max_bytes);
15121501 path[max_bytes] = 0;
15131502 }
15141503
328328 (((_a) & W_FILE_ATTRIBUTE_DIRECTORY) ? S_IFDIR | 0100 : S_IFREG) |\
329329 (((_a) & W_FILE_ATTRIBUTE_READONLY) ? 0444 : 0644)
330330
331 /* winodws time starts on Jan 1, 1601 */
331 /* Windows time starts on Jan 1, 1601 */
332332 /* Linux time starts on Jan 1, 1970 */
333333 #define EPOCH_DIFF 11644473600LL
334334 #define WINDOWS_TO_LINUX_TIME(_t) ((_t) / 10000000) - EPOCH_DIFF;
341341
342342 uint32_t chan_id;
343343 int bytes_in_stream;
344 int data_len;
345344 int Len;
346345
347346 drdynvc_get_chan_id(s, cmd, &chan_id);
348347
349348 Len = (cmd >> 2) & 0x03;
350349
350 /* skip data_len */
351351 if (Len == 0)
352352 {
353 in_uint8(s, data_len);
353 in_uint8s(s, 1);
354354 }
355355 else if (Len == 1)
356356 {
357 in_uint16_le(s, data_len);
357 in_uint8s(s, 2);
358358 }
359359 else
360360 {
361 in_uint32_le(s, data_len);
361 in_uint8s(s, 4);
362362 }
363363
364364 bytes_in_stream = stream_length_after_p(s);
413413 * process incoming data on a dynamic virtual channel
414414 *
415415 * @pram s stream containing the incoming data
416 * @pram chand_id LK_TODO
416 * @pram chan_id LK_TODO
417417 * @pram chan_flags LK_TODO
418418 * @pram length LK_TODO
419419 * @pram total_length LK_TODO
9797
9898 /*****************************************************************************/
9999 static int __fastcall
100 load_funsc(void)
100 load_funcs(void)
101101 {
102102 HMODULE lib;
103103
107107 }
108108 g_funcs_loaded = 1;
109109 lib = LoadLibrary("winscard-org.dll");
110 LLOGLN(0, ("load_funsc: lib %p", lib));
110 LLOGLN(0, ("load_funcs: lib %p", lib));
111111 LLOAD(aSCardEstablishContext, tSCardEstablishContext, "SCardEstablishContext");
112112 LLOAD(aSCardReleaseContext, tSCardReleaseContext, "SCardReleaseContext");
113113 LLOAD(aSCardIsValidContext, tSCardIsValidContext, "SCardIsValidContext");
179179 {
180180 case DLL_PROCESS_ATTACH:
181181 LLOGLN(0, ("DllEntryPoint: DLL_PROCESS_ATTACH"));
182 load_funsc();
182 load_funcs();
183183 rv = TRUE;
184184 break;
185185 case DLL_THREAD_ATTACH:
0 #ifndef foomodulexrdpsinksymdeffoo
1 #define foomodulexrdpsinksymdeffoo
0 #ifndef MODULE_XRDP_SINK_SYMDEF_H
1 #define MODULE_XRDP_SINK_SYMDEF_H
22
33 #include <pulsecore/core.h>
44 #include <pulsecore/module.h>
7676 "sink_name=<name for the sink> "
7777 "sink_properties=<properties for the sink> "
7878 "format=<sample format> "
79 "rate=<sample rate>"
79 "rate=<sample rate> "
8080 "channels=<number of channels> "
8181 "channel_map=<channel map>");
8282
308308 s.sun_family = AF_UNIX;
309309 bytes = sizeof(s.sun_path) - 1;
310310 snprintf(s.sun_path, bytes, CHANSRV_PORT_STR, u->display_num);
311 pa_log_debug("trying to conenct to %s", s.sun_path);
311 pa_log_debug("trying to connect to %s", s.sun_path);
312312 if (connect(fd, (struct sockaddr *)&s,
313313 sizeof(struct sockaddr_un)) != 0) {
314314 u->failed_connect_time = pa_rtclock_now();
439439 pa_rtpoll_set_timer_disabled(u->rtpoll);
440440 }
441441
442 #if defined(PA_CHECK_VERSION) && PA_CHECK_VERSION(6, 0, 0)
443 if ((ret = pa_rtpoll_run(u->rtpoll)) < 0) {
444 #else
442445 if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0) {
446 #endif
443447 goto fail;
444448 }
445449
0 #ifndef foomodulenullsourcesymdeffoo
1 #define foomodulenullsourcesymdeffoo
0 #ifndef MODULE_XRDP_SOURCE_SYMDEF_H
1 #define MODULE_XRDP_SOURCE_SYMDEF_H
22
33 #include <pulsecore/core.h>
44 #include <pulsecore/module.h>
312312 } else {
313313 if (u->want_src_data)
314314 {
315 /* we dont want source data anymore */
315 /* we don't want source data anymore */
316316 char buf[12];
317317
318318 buf[0] = 0;
338338 }
339339
340340 /* Hmm, nothing to do. Let's sleep */
341 if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
341 #if defined(PA_CHECK_VERSION) && PA_CHECK_VERSION(6, 0, 0)
342 if ((ret = pa_rtpoll_run(u->rtpoll)) < 0) {
343 #else
344 if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0) {
345 #endif
342346 goto fail;
347 }
343348
344349 if (ret == 0)
345350 goto finish;
382382
383383 if (g_xrr_event_base > 0)
384384 {
385 LOG(0, ("rail_init: found RandR entension"));
385 LOG(0, ("rail_init: found RandR extension"));
386386 st = XRRQueryVersion(g_display, &ver_maj, &ver_min);
387387 if (st)
388388 {
507507 window_attributes.map_state == IsViewable &&
508508 list_index_of(g_window_list, children[i]) >= 0)
509509 {
510 LOG(10, (" dismiss pop up 0x%8.8x", children[i]));
510 LOG(10, (" dismiss pop up 0x%8.8lx", children[i]));
511511 rail_send_key_esc(children[i]);
512512 rv = 1;
513513 }
542542
543543 /*****************************************************************************/
544544 void DEFAULT_CC
545 my_timoeut(void* data)
546 {
547 LOG(10, ("my_timoeut: g_got_focus %d", g_got_focus));
545 my_timeout(void* data)
546 {
547 LOG(10, ("my_timeout: g_got_focus %d", g_got_focus));
548548 if (g_focus_counter == (int)(long)data)
549549 {
550 LOG(10, ("my_timoeut: g_focus_counter %d", g_focus_counter));
550 LOG(10, ("my_timeout: g_focus_counter %d", g_focus_counter));
551551 rail_win_popdown();
552552 }
553553 }
616616
617617 LOG(10, (" window attributes: override_redirect %d",
618618 window_attributes.override_redirect));
619 add_timeout(200, my_timoeut, (void*)(long)g_focus_counter);
619 add_timeout(200, my_timeout, (void*)(long)g_focus_counter);
620620 }
621621 return 0;
622622 }
755755 int old_state;
756756 unsigned long data[2] = { state, None };
757757
758 LOG(10, (" rail_win_set_state: %d", state));
758 LOG(10, (" rail_win_set_state: %ld", state));
759759 /* check whether WM_STATE exists */
760760 old_state = rail_win_get_state(win);
761761 if (old_state == -1)
12581258 }
12591259 if (data && len > 0)
12601260 {
1261 LOG(10, ("chansrv::rail_win_send_text: 0x%8.8x text %s length %d",
1261 LOG(10, ("chansrv::rail_win_send_text: 0x%8.8lx text %s length %d",
12621262 win, data, len));
12631263 make_stream(s);
12641264 init_stream(s, len + 1024);
12881288 {
12891289 struct stream *s;
12901290
1291 LOG(10, ("chansrv::rail_destroy_window 0x%8.8x", window_id));
1291 LOG(10, ("chansrv::rail_destroy_window 0x%8.8lx", window_id));
12921292 make_stream(s);
12931293 init_stream(s, 1024);
12941294
13081308 int flags;
13091309 struct stream* s;
13101310
1311 LOG(10, ("chansrv::rail_show_window 0x%8.8x 0x%x", window_id, show_state));
1311 LOG(10, ("chansrv::rail_show_window 0x%8.8lx 0x%x", window_id, show_state));
13121312 make_stream(s);
13131313 init_stream(s, 1024);
13141314
13501350 struct rail_window_data* rwd;
13511351 struct stream* s;
13521352
1353 LOG(10, ("chansrv::rail_create_window 0x%8.8x", window_id));
1353 LOG(10, ("chansrv::rail_create_window 0x%8.8lx", window_id));
13541354
13551355 rwd = rail_get_window_data_safe(window_id);
13561356 if (rwd == 0)
15061506 if (mask & CWStackMode)
15071507 {
15081508 LOG(10, ("chansrv::rail_configure_request_window: CWStackMode "
1509 "detail 0x%8.8x above 0x%8.8x", config->detail, config->above));
1509 "detail 0x%8.8x above 0x%8.8lx", config->detail, config->above));
15101510 if (config->detail == Above)
15111511 {
15121512 LOG(10, ("chansrv::rail_configure_request_window: bring to front "
17741774
17751775 /*****************************************************************************/
17761776 static int
1777 rail_desktop_resize(lxevent)
1777 rail_desktop_resize(XEvent *lxevent)
17781778 {
17791779 LOG(0, ("rail_desktop_resize:"));
17801780 return 0;
18071807 {
18081808 case PropertyNotify:
18091809 prop_name = XGetAtomName(g_display, lxevent->xproperty.atom);
1810 LOG(10, (" got PropertyNotify window_id 0x%8.8x %s state new %d",
1810 LOG(10, (" got PropertyNotify window_id 0x%8.8lx %s state new %d",
18111811 lxevent->xproperty.window, prop_name,
18121812 lxevent->xproperty.state == PropertyNewValue));
18131813
18301830 break;
18311831
18321832 case ConfigureRequest:
1833 LOG(10, (" got ConfigureRequest window_id 0x%8.8x", lxevent->xconfigurerequest.window));
1833 LOG(10, (" got ConfigureRequest window_id 0x%8.8lx", lxevent->xconfigurerequest.window));
18341834 g_memset(&xwc, 0, sizeof(xwc));
18351835 xwc.x = lxevent->xconfigurerequest.x;
18361836 xwc.y = lxevent->xconfigurerequest.y;
18481848 break;
18491849
18501850 case CreateNotify:
1851 LOG(10, (" got CreateNotify window 0x%8.8x parent 0x%8.8x",
1851 LOG(10, (" got CreateNotify window 0x%8.8lx parent 0x%8.8lx",
18521852 lxevent->xcreatewindow.window, lxevent->xcreatewindow.parent));
18531853 rail_select_input(lxevent->xcreatewindow.window);
18541854 break;
18551855
18561856 case DestroyNotify:
1857 LOG(10, (" got DestroyNotify window 0x%8.8x event 0x%8.8x",
1857 LOG(10, (" got DestroyNotify window 0x%8.8lx event 0x%8.8lx",
18581858 lxevent->xdestroywindow.window, lxevent->xdestroywindow.event));
18591859 if (lxevent->xdestroywindow.window != lxevent->xdestroywindow.event)
18601860 {
18701870 break;
18711871
18721872 case MapRequest:
1873 LOG(10, (" got MapRequest window 0x%8.8x", lxevent->xmaprequest.window));
1873 LOG(10, (" got MapRequest window 0x%8.8lx", lxevent->xmaprequest.window));
18741874 XMapWindow(g_display, lxevent->xmaprequest.window);
18751875 break;
18761876
18771877 case MapNotify:
1878 LOG(10, (" got MapNotify window 0x%8.8x event 0x%8.8x",
1878 LOG(10, (" got MapNotify window 0x%8.8lx event 0x%8.8lx",
18791879 lxevent->xmap.window, lxevent->xmap.event));
18801880 if (lxevent->xmap.window != lxevent->xmap.event)
18811881 {
19011901 break;
19021902
19031903 case UnmapNotify:
1904 LOG(10, (" got UnmapNotify 0x%8.8x", lxevent->xunmap.event));
1904 LOG(10, (" got UnmapNotify 0x%8.8lx", lxevent->xunmap.event));
19051905 if (lxevent->xunmap.window != lxevent->xunmap.event)
19061906 {
19071907 break;
19091909 if (is_window_valid_child_of_root(lxevent->xunmap.window))
19101910 {
19111911 index = list_index_of(g_window_list, lxevent->xunmap.window);
1912 LOG(10, (" window 0x%8.8x is unmapped", lxevent->xunmap.window));
1912 LOG(10, (" window 0x%8.8lx is unmapped", lxevent->xunmap.window));
19131913 if (index >= 0)
19141914 {
19151915 XGetWindowAttributes(g_display, lxevent->xunmap.window, &wnd_attributes);
19281928 break;
19291929
19301930 case ConfigureNotify:
1931 LOG(10, (" got ConfigureNotify 0x%8.8x event 0x%8.8x", lxevent->xconfigure.window,
1931 LOG(10, (" got ConfigureNotify 0x%8.8lx event 0x%8.8lx", lxevent->xconfigure.window,
19321932 lxevent->xconfigure.event));
19331933 rv = 0;
19341934 if (lxevent->xconfigure.event != lxevent->xconfigure.window ||
19741974 break;
19751975
19761976 case ReparentNotify:
1977 LOG(10, (" got ReparentNotify window 0x%8.8x parent 0x%8.8x "
1978 "event 0x%8.8x x %d y %d overrider redirect %d",
1977 LOG(10, (" got ReparentNotify window 0x%8.8lx parent 0x%8.8lx "
1978 "event 0x%8.8lx x %d y %d override redirect %d",
19791979 lxevent->xreparent.window, lxevent->xreparent.parent,
19801980 lxevent->xreparent.event, lxevent->xreparent.x,
19811981 lxevent->xreparent.y, lxevent->xreparent.override_redirect));
18531853 }
18541854
18551855 log_debug("send_bytes %d recv_bytes %d send dwProtocol %d cbPciLength %d "
1856 "extra_bytes %d recv dwProtocol %d cbPciLength %d", send_bytes,
1857 recv_bytes, send_ior->dwProtocol, send_ior->cbPciLength,
1856 "extra_bytes %d recv dwProtocol %d cbPciLength %d extra_bytes %d",
1857 send_bytes, recv_bytes, send_ior->dwProtocol, send_ior->cbPciLength,
18581858 send_ior->extra_bytes, recv_ior->dwProtocol, recv_ior->cbPciLength,
18591859 recv_ior->extra_bytes);
18601860
18721872 * u32 4 bytes dwProtocol
18731873 * u32 4 bytes cbPciLength
18741874 * u32 4 bytes map2
1875 * u32 4 byts cbSendLength
1875 * u32 4 bytes cbSendLength
18761876 * u32 4 bytes map3
18771877 * u32 4 bytes map4
18781878 * u32 4 bytes map5
258258 }
259259 list_delete(context->cards);
260260 }
261 LLOGLN(10, (" left over context 0x%8.8x", context->context));
261 LLOGLN(10, (" left over context %p", context->context));
262262 scard_send_cancel(0, context->context, context->context_bytes);
263263 scard_send_release_context(0, context->context,
264264 context->context_bytes);
102102 g_pcm_44100_data /* data */
103103 };
104104
105 #if defined(XRDP_OPUS)
105106 static char g_opus_44100_data[] = { 0 };
106107 static struct xr_wave_format_ex g_opus_44100 =
107108 {
114115 0, /* data size */
115116 g_opus_44100_data /* data */
116117 };
118 #endif
117119
118120
119121 #if defined(XRDP_OPUS)
10001002
10011003 /******************************************************************************
10021004 ** **
1003 ** Microphone releated code **
1005 ** Microphone related code **
10041006 ** **
10051007 ******************************************************************************/
10061008
6262 /* The X server had an internal error. This is the last function called.
6363 Do any cleanup that needs to be done on exit, like removing temporary files.
6464 Don't worry about memory leaks */
65 #if 0
6566 static int DEFAULT_CC
6667 xcommon_fatal_handler(Display *dis)
6768 {
6869 return 0;
6970 }
71 #endif
7072
7173 /*****************************************************************************/
72 /* returns time in miliseconds
73 this is like g_time2 in os_calls, but not miliseconds since machine was
74 /* returns time in milliseconds
75 this is like g_time2 in os_calls, but not milliseconds since machine was
7476 up, something else
7577 this is a time value similar to what the xserver uses */
7678 int APP_CC
115115 int ts_users;
116116 /**
117117 * @var ts_admins
118 * @brief Terminal Server Adminnistrators group
118 * @brief Terminal Server Administrators group
119119 */
120120 int ts_admins_enable;
121121 int ts_admins;
219219 */
220220 struct list* rdp_params;
221221 /**
222 * @var xorg_params
223 * @brief Xorg additional parameter list
224 */
225 struct list* xorg_params;
226 /**
222227 * @var log
223228 * @brief Log configuration struct
224229 */
225
226 struct list* xorg_params;
227 /**
228 * @var log
229 * @brief Log configuration struct
230 */
231
232230 //struct log_config log;
233231 /**
234232 * @var sec
3333
3434 /******************************************************************************/
3535 int DEFAULT_CC
36 env_check_password_file(char *filename, char *password)
36 env_check_password_file(char *filename, char *passwd)
3737 {
3838 char encryptedPasswd[16];
3939 char key[24];
40 char passwd_hash[20];
41 char passwd_hash_text[40];
4042 int fd;
41 void* des;
43 int passwd_bytes;
44 void *des;
45 void *sha1;
4246
47 /* create password hash from password */
48 passwd_bytes = g_strlen(passwd);
49 sha1 = ssl_sha1_info_create();
50 ssl_sha1_transform(sha1, "xrdp_vnc", 8);
51 ssl_sha1_transform(sha1, passwd, passwd_bytes);
52 ssl_sha1_transform(sha1, passwd, passwd_bytes);
53 ssl_sha1_complete(sha1, passwd_hash);
54 ssl_sha1_info_delete(sha1);
55 g_snprintf(passwd_hash_text, 39, "%2.2x%2.2x%2.2x%2.2x",
56 (tui8)passwd_hash[0], (tui8)passwd_hash[1],
57 (tui8)passwd_hash[2], (tui8)passwd_hash[3]);
58 passwd_hash_text[39] = 0;
59 passwd = passwd_hash_text;
60
61 /* create file from password */
4362 g_memset(encryptedPasswd, 0, sizeof(encryptedPasswd));
44 g_strncpy(encryptedPasswd, password, 8);
63 g_strncpy(encryptedPasswd, passwd, 8);
4564 g_memset(key, 0, sizeof(key));
4665 g_mirror_memcpy(key, g_fixedkey, 8);
4766 des = ssl_des3_encrypt_info_create(key, 0);
4867 ssl_des3_encrypt(des, 8, encryptedPasswd, encryptedPasswd);
4968 ssl_des3_info_delete(des);
50 fd = g_file_open(filename);
69 fd = g_file_open_ex(filename, 0, 1, 1, 1);
5170 if (fd == -1)
5271 {
5372 log_message(LOG_LEVEL_WARNING,
54 "can't read vnc password file - %s",
73 "can't write vnc password hash file - %s",
5574 filename);
5675 return 1;
5776 }
110129 g_set_current_dir(pw_dir);
111130 g_sprintf(text, ":%d.0", display);
112131 g_setenv("DISPLAY", text, 1);
113 g_setenv("LANG", "en_US.UTF-8", 1);
114132 g_setenv("XRDP_SESSION", "1", 1);
115133 if ((env_names != 0) && (env_values != 0) &&
116134 (env_names->count == env_values->count))
3232 *
3333 * @brief Creates vnc password file
3434 * @param filename VNC password file name
35 * @param password The password to be encrypte
35 * @param password The password to be encrypted
3636 * @return 0 on success, 1 on error
3737 *
3838 */
0 EXTRA_DIST = libscp_connection.h libscp_commands.h libscp.h libscp_session.h libscp_types_mng.h libscp_v1c_mng.h libscp_vX.h libscp_commands_mng.h libscp_init.h libscp_tcp.h libscp_v0.h libscp_v1s.h libscp_lock.h \
1 libscp_types.h libscp_v1c.h libscp_v1s_mng.h
2
3 AM_CFLAGS = \
0 AM_CPPFLAGS = \
41 -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
52 -DXRDP_SBIN_PATH=\"${sbindir}\" \
63 -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
7 -DXRDP_PID_PATH=\"${localstatedir}/run\"
8
9 INCLUDES = \
4 -DXRDP_PID_PATH=\"${localstatedir}/run\" \
105 -I$(top_srcdir)/common
116
12 lib_LTLIBRARIES = \
7 module_LTLIBRARIES = \
138 libscp.la
149
1510 libscp_la_SOURCES = \
11 libscp.h \
12 libscp_commands.h \
13 libscp_commands_mng.h \
1614 libscp_connection.c \
15 libscp_connection.h \
1716 libscp_init.c \
17 libscp_init.h \
1818 libscp_lock.c \
19 libscp_lock.h \
1920 libscp_session.c \
21 libscp_session.h \
2022 libscp_tcp.c \
23 libscp_tcp.h \
24 libscp_types.h \
25 libscp_types_mng.h \
2126 libscp_v0.c \
27 libscp_v0.h \
2228 libscp_v1c.c \
29 libscp_v1c.h \
30 libscp_v1c_mng.c \
31 libscp_v1c_mng.h \
2332 libscp_v1s.c \
24 libscp_v1c_mng.c \
33 libscp_v1s.h \
2534 libscp_v1s_mng.c \
26 libscp_vX.c
35 libscp_v1s_mng.h \
36 libscp_vX.c \
37 libscp_vX.h
2738
2839 libscp_la_LIBADD = \
2940 $(top_builddir)/common/libcommon.la \
3535 * @brief version neutral server accept function
3636 * @param c connection descriptor
3737 * @param s session descriptor pointer address.
38 * it will return a newely allocated descriptor.
38 * it will return a newly allocated descriptor.
3939 * It this memory needs to be g_free()d
4040 *
4141 */
1919 */
2020
2121 #include "libscp_lock.h"
22 #include "thread_calls.h"
2223
23 #include <semaphore.h>
2424 #include <pthread.h>
2525
2626 pthread_mutex_t lock_fork; /* this lock protects the counters */
2727 pthread_mutexattr_t lock_fork_attr; /* mutex attributes */
28 sem_t lock_fork_req; /* semaphore on which the process that are going to fork suspend on */
29 sem_t lock_fork_wait; /* semaphore on which the suspended process wait on */
28 tbus lock_fork_req; /* semaphore on which the process that are going to fork suspend on */
29 tbus lock_fork_wait; /* semaphore on which the suspended process wait on */
3030 int lock_fork_forkers_count; /* threads that want to fork */
31 int lock_fork_blockers_count; /* threads thar are blocking fork */
31 int lock_fork_blockers_count; /* threads that are blocking fork */
3232 int lock_fork_waiting_count; /* threads suspended until the fork finishes */
3333
3434 void DEFAULT_CC
3737 /* initializing fork lock */
3838 pthread_mutexattr_init(&lock_fork_attr);
3939 pthread_mutex_init(&lock_fork, &lock_fork_attr);
40 sem_init(&lock_fork_req, 0, 0);
41 sem_init(&lock_fork_wait, 0, 0);
40 lock_fork_req = tc_sem_create(0);
41 lock_fork_wait = tc_sem_create(0);
4242
4343 /* here we don't use locking because lock_init() should be called BEFORE */
4444 /* any thread is created */
5656
5757 if (lock_fork_blockers_count == 0)
5858 {
59 /* if noone is blocking fork(), then we're allowed to fork */
60 sem_post(&lock_fork_req);
59 /* if no one is blocking fork(), then we're allowed to fork */
60 tc_sem_inc(lock_fork_req);
6161 }
6262
6363 lock_fork_forkers_count++;
6464 pthread_mutex_unlock(&lock_fork);
6565
6666 /* we wait to be allowed to fork() */
67 sem_wait(&lock_fork_req);
67 tc_sem_dec(lock_fork_req);
6868 }
6969
7070 /******************************************************************************/
7777 /* if there's someone else that want to fork, we let him fork() */
7878 if (lock_fork_forkers_count > 0)
7979 {
80 sem_post(&lock_fork_req);
80 tc_sem_inc(lock_fork_req);
8181 }
8282
8383 for (; lock_fork_waiting_count > 0; lock_fork_waiting_count--)
8484 {
8585 /* waking up the other processes */
86 sem_post(&lock_fork_wait);
86 tc_sem_inc(lock_fork_wait);
8787 }
8888
8989 pthread_mutex_unlock(&lock_fork);
9393 void DEFAULT_CC
9494 scp_lock_fork_critical_section_end(int blocking)
9595 {
96 //LOG_DBG("lock_fork_critical_secection_end()",0);
96 //LOG_DBG("lock_fork_critical_section_end()",0);
9797 /* lock mutex */
9898 pthread_mutex_lock(&lock_fork);
9999
106106 /* then we let him go */
107107 if ((lock_fork_blockers_count == 0) && (lock_fork_forkers_count > 0))
108108 {
109 sem_post(&lock_fork_req);
109 tc_sem_inc(lock_fork_req);
110110 }
111111
112112 pthread_mutex_unlock(&lock_fork);
116116 int DEFAULT_CC
117117 scp_lock_fork_critical_section_start(void)
118118 {
119 //LOG_DBG("lock_fork_critical_secection_start()",0);
119 //LOG_DBG("lock_fork_critical_section_start()",0);
120120 do
121121 {
122122 pthread_mutex_lock(&lock_fork);
128128 pthread_mutex_unlock(&lock_fork);
129129
130130 /* we wait until the fork finishes */
131 sem_wait(&lock_fork_wait);
131 tc_sem_dec(lock_fork_wait);
132132
133133 }
134134 else
5151 *
5252 * @brief starts a section that is critical for forking
5353 *
54 * starts a section that is critical for forking, that is noone can fork()
55 * while i'm in a critical section. But if someone wanted to fork we have
54 * starts a section that is critical for forking, that is no one can fork()
55 * while I'm in a critical section. But if someone wanted to fork we have
5656 * to wait until he finishes with lock_fork_release()
5757 *
5858 * @return
136136 case 15:
137137 case 16:
138138 case 24:
139 case 32:
139140 s->bpp = bpp;
141 break;
140142 default:
141143 return 1;
142144 }
143
144145 return 0;
145146 }
146147
1818 /**
1919 *
2020 * @file tcp.c
21 * @brief Tcp stream funcions
21 * @brief Tcp stream functions
2222 * @author Jay Sorg, Simone Fedele
2323 *
2424 */
251251 scp_session_set_height(session, sz);
252252 /* bpp */
253253 in_uint16_be(c->in_s, sz);
254 scp_session_set_bpp(session, (tui8)sz);
254 if (0 != scp_session_set_bpp(session, (tui8)sz))
255 {
256 scp_session_destroy(session);
257 log_message(LOG_LEVEL_WARNING,
258 "[v0:%d] connection aborted: unsupported bpp: %d",
259 __LINE__, (tui8)sz);
260 return SCP_SERVER_STATE_INTERNAL_ERR;
261 }
255262
256263 if (s_check_rem(c->in_s, 2))
257264 {
130130 in_uint16_be(c->in_s, cmd);
131131 scp_session_set_height(session, cmd);
132132 in_uint8(c->in_s, sz);
133 scp_session_set_bpp(session, sz);
133 if (0 != scp_session_set_bpp(session, sz))
134 {
135 scp_session_destroy(session);
136 log_message(LOG_LEVEL_WARNING,
137 "[v1s:%d] connection aborted: unsupported bpp: %d",
138 __LINE__, sz);
139 return SCP_SERVER_STATE_INTERNAL_ERR;
140 }
134141 in_uint8(c->in_s, sz);
135142 scp_session_set_rsr(session, sz);
136143 in_uint8a(c->in_s, buf, 17);
434441 }
435442
436443 /* then we wait for client ack */
437 #warning maybe this message could say if the session should be resized on
438 #warning server side or client side
444
445 /*
446 * Maybe this message could say if the session should be resized on
447 * server side or client side.
448 */
439449 init_stream(c->in_s, c->in_s->size);
440450
441451 if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
636646 /* if we got here, the requested sid wasn't one from the list we sent */
637647 /* we should kill the connection */
638648 log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error (no such session in list)", __LINE__);
639 return SCP_CLIENT_STATE_INTERNAL_ERR;
649 return SCP_SERVER_STATE_INTERNAL_ERR;
640650 }
641651 else if (cmd == 44)
642652 {
3737 * @param skipVchk if set to !0 skips the version control (to be used after
3838 * scp_vXs_accept() )
3939 *
40 * this function places in *s the address of a newely allocated SCP_SESSION structure
40 * this function places in *s the address of a newly allocated SCP_SESSION structure
4141 * that should be free()d
4242 */
4343 enum SCP_SERVER_STATES_E
4747 *
4848 * @brief denies connection to sesman
4949 * @param c connection descriptor
50 * @param reason pointer to a string containinge the reason for denying connection
50 * @param reason pointer to a string containing the reason for denying connection
5151 *
5252 */
5353 /* 002 */
3535 * @param c connection descriptor
3636 * @param s pointer to session descriptor pointer
3737 *
38 * this function places in *s the address of a newely allocated SCP_SESSION structure
38 * this function places in *s the address of a newly allocated SCP_SESSION structure
3939 * that should be free()d
4040 */
4141 enum SCP_SERVER_STATES_E
5555 *
5656 * @brief denies connection to sesman
5757 * @param c connection descriptor
58 * @param reason pointer to a string containinge the reason for denying connection
58 * @param reason pointer to a string containing the reason for denying connection
5959 *
6060 */
6161 /* 003 */
3737 * @brief version neutral server accept function
3838 * @param c connection descriptor
3939 * @param s session descriptor pointer address.
40 * it will return a newely allocated descriptor.
40 * it will return a newly allocated descriptor.
4141 * It this memory needs to be g_free()d
4242 *
4343 */
+0
-121
sesman/lock.c less more
0 /**
1 * xrdp: A Remote Desktop Protocol server.
2 *
3 * Copyright (C) Jay Sorg 2004-2013
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * session manager
18 * linux only
19 */
20
21 #include "sesman.h"
22
23 extern struct config_sesman *g_cfg; /* in sesman.c */
24
25 static tbus g_sync_mutex = 0;
26 static tbus g_lock_chain = 0;
27 static tbus g_sync_sem = 0;
28 static tbus g_lock_socket = 0;
29
30 /******************************************************************************/
31 void APP_CC
32 lock_init(void)
33 {
34 g_sync_mutex = tc_mutex_create();
35 g_lock_chain = tc_mutex_create();
36 g_sync_sem = tc_sem_create(0);
37 g_lock_socket = tc_sem_create(1);
38 }
39
40 /******************************************************************************/
41 void APP_CC
42 lock_deinit(void)
43 {
44 tc_mutex_delete(g_sync_mutex);
45 tc_mutex_delete(g_lock_chain);
46 tc_sem_delete(g_sync_sem);
47 tc_sem_delete(g_lock_socket);
48 }
49
50 /******************************************************************************/
51 void APP_CC
52 lock_chain_acquire(void)
53 {
54 /* lock the chain */
55 LOG_DBG("lock_chain_acquire()");
56 tc_mutex_lock(g_lock_chain);
57 }
58
59 /******************************************************************************/
60 void APP_CC
61 lock_chain_release(void)
62 {
63 /* unlock the chain */
64 LOG_DBG("lock_chain_release()");
65 tc_mutex_unlock(g_lock_chain);
66 }
67
68 /******************************************************************************/
69 void APP_CC
70 lock_socket_acquire(void)
71 {
72 /* lock socket variable */
73 LOG_DBG("lock_socket_acquire()");
74 tc_sem_dec(g_lock_socket);
75 }
76
77 /******************************************************************************/
78 void APP_CC
79 lock_socket_release(void)
80 {
81 /* unlock socket variable */
82 LOG_DBG("lock_socket_release()");
83 tc_sem_inc(g_lock_socket);
84 }
85
86 /******************************************************************************/
87 void APP_CC
88 lock_sync_acquire(void)
89 {
90 /* lock sync variable */
91 LOG_DBG("lock_sync_acquire()");
92 tc_mutex_lock(g_sync_mutex);
93 }
94
95 /******************************************************************************/
96 void APP_CC
97 lock_sync_release(void)
98 {
99 /* unlock socket variable */
100 LOG_DBG("lock_sync_release()");
101 tc_mutex_unlock(g_sync_mutex);
102 }
103
104 /******************************************************************************/
105 void APP_CC
106 lock_sync_sem_acquire(void)
107 {
108 /* dec sem */
109 LOG_DBG("lock_sync_sem_acquire()");
110 tc_sem_dec(g_sync_sem);
111 }
112
113 /******************************************************************************/
114 void APP_CC
115 lock_sync_sem_release(void)
116 {
117 /* inc sem */
118 LOG_DBG("lock_sync_sem_release()");
119 tc_sem_inc(g_sync_sem);
120 }
+0
-104
sesman/lock.h less more
0 /**
1 * xrdp: A Remote Desktop Protocol server.
2 *
3 * Copyright (C) Jay Sorg 2004-2013
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 #ifndef LOCK_H
19 #define LOCK_H
20
21 #include "sesman.h"
22
23 /**
24 *
25 * @brief initializes all the locks
26 *
27 */
28 void APP_CC
29 lock_init(void);
30
31 /**
32 *
33 * @brief cleanup all the locks
34 *
35 */
36 void APP_CC
37 lock_deinit(void);
38
39 /**
40 *
41 * @brief acquires the lock for the session chain
42 *
43 */
44 void APP_CC
45 lock_chain_acquire(void);
46
47 /**
48 *
49 * @brief releases the session chain lock
50 *
51 */
52 void APP_CC
53 lock_chain_release(void);
54
55 /**
56 *
57 * @brief request the socket lock
58 *
59 */
60 void APP_CC
61 lock_socket_acquire(void);
62
63 /**
64 *
65 * @brief releases the socket lock
66 *
67 */
68 void APP_CC
69 lock_socket_release(void);
70
71 /**
72 *
73 * @brief request the main sync lock
74 *
75 */
76 void APP_CC
77 lock_sync_acquire(void);
78
79 /**
80 *
81 * @brief releases the main sync lock
82 *
83 */
84 void APP_CC
85 lock_sync_release(void);
86
87 /**
88 *
89 * @brief request the sync sem lock
90 *
91 */
92 void APP_CC
93 lock_sync_sem_acquire(void);
94
95 /**
96 *
97 * @brief releases the sync sem lock
98 *
99 */
100 void APP_CC
101 lock_sync_sem_release(void);
102
103 #endif
00 /**
11 * xrdp: A Remote Desktop Protocol server.
22 *
3 * Copyright (C) Jay Sorg 2004-2013
3 * Copyright (C) Jay Sorg 2004-2015
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
2828
2929 #include "sesman.h"
3030
31 extern int g_thread_sck; /* in thread.c */
3231 extern struct config_sesman *g_cfg; /* in sesman.c */
3332
3433 /******************************************************************************/
3837 struct SCP_CONNECTION scon;
3938 struct SCP_SESSION *sdata;
4039
41 /* making a local copy of the socket (it's on the stack) */
42 /* probably this is just paranoia */
43 scon.in_sck = g_thread_sck;
40 scon.in_sck = (int)(tintptr)sck;
4441 LOG_DBG("started scp thread on socket %d", scon.in_sck);
45
46 /* unlocking g_thread_sck */
47 lock_socket_release();
4842
4943 make_stream(scon.in_s);
5044 make_stream(scon.out_s);
00 /**
11 * xrdp: A Remote Desktop Protocol server.
22 *
3 * Copyright (C) Jay Sorg 2004-2013
3 * Copyright (C) Jay Sorg 2004-2015
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
3434 int display = 0;
3535 tbus data;
3636 struct session_item *s_item;
37 int errorcode = 0 ;
37 int errorcode = 0;
3838
39 data = auth_userpass(s->username, s->password,&errorcode);
39 data = auth_userpass(s->username, s->password, &errorcode);
4040
4141 if (s->type == SCP_GW_AUTHENTICATION)
4242 {
5454 }
5555 else
5656 {
57 scp_v0s_replyauthentication(c, 32+3); /* all first 32 are reserved for PAM errors */
57 scp_v0s_replyauthentication(c, 32 + 3); /* all first 32 are reserved for PAM errors */
5858 log_message(LOG_LEVEL_INFO, "Username okey but group problem for "
5959 "user: %s", s->username);
6060 /* g_writeln("user password ok, but group problem"); */
127127 display = session_start(s->width, s->height, s->bpp, s->username,
128128 s->password, data, SESMAN_SESSION_TYPE_XRDP,
129129 s->domain, s->program, s->directory,
130 s->client_ip);
131 }
130 s->client_ip);
131 }
132132 else if (SCP_SESSION_TYPE_XORG == s->type)
133133 {
134 /* type is SCP_SESSION_TYPE_XORG */
134 /* type is SCP_SESSION_TYPE_XORG */
135135 log_message(LOG_LEVEL_INFO, "starting Xorg session...");
136136 display = session_start(s->width, s->height, s->bpp, s->username,
137137 s->password, data, SESMAN_SESSION_TYPE_XORG,
00 /**
11 * xrdp: A Remote Desktop Protocol server.
22 *
3 * Copyright (C) Jay Sorg 2004-2013
3 * Copyright (C) Jay Sorg 2004-2015
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
109109 if (scount == 0)
110110 {
111111 /* no disconnected sessions - start a new one */
112 log_message(LOG_LEVEL_DEBUG, "No disconnected sessions for this user"
112 log_message(LOG_LEVEL_DEBUG, "No disconnected sessions for this user "
113113 "- we create a new one");
114114
115115 if (0 != s->client_ip)
00 /**
11 * xrdp: A Remote Desktop Protocol server.
22 *
3 * Copyright (C) Jay Sorg 2004-2013
3 * Copyright (C) Jay Sorg 2004-2015
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
3030 unsigned char g_fixedkey[8] = { 23, 82, 107, 6, 35, 78, 88, 7 };
3131 struct config_sesman *g_cfg; /* defined in config.h */
3232
33 tbus g_term_event = 0;
34 tbus g_sync_event = 0;
35
36 extern int g_thread_sck; /* in thread.c */
33 tintptr g_term_event = 0;
3734
3835 /******************************************************************************/
3936 /**
7976 robjs_count = 0;
8077 robjs[robjs_count++] = sck_obj;
8178 robjs[robjs_count++] = g_term_event;
82 robjs[robjs_count++] = g_sync_event;
8379
8480 /* wait */
8581 if (g_obj_wait(robjs, robjs_count, 0, 0, -1) != 0)
9187 if (g_is_wait_obj_set(g_term_event)) /* term */
9288 {
9389 break;
94 }
95
96 if (g_is_wait_obj_set(g_sync_event)) /* sync */
97 {
98 g_reset_wait_obj(g_sync_event);
99 session_sync_start();
10090 }
10191
10292 if (g_is_wait_obj_set(sck_obj)) /* incoming connection */
117107 {
118108 /* we've got a connection, so we pass it to scp code */
119109 LOG_DBG("new connection");
120 thread_scp_start(in_sck);
121 /* todo, do we have to wait here ? */
110 scp_process_start((void*)(tintptr)in_sck);
111 g_sck_close(in_sck);
122112 }
123113 }
124114 }
137127 "port '%s': %d (%s)", g_cfg->listen_port,
138128 g_get_errno(), g_get_strerror());
139129 }
140
141 if (g_sck != -1)
142 g_tcp_close(g_sck);
130 g_tcp_close(g_sck);
143131 }
144132
145133 /******************************************************************************/
147135 main(int argc, char **argv)
148136 {
149137 int fd;
150 enum logReturns error;
138 enum logReturns log_error;
139 int error;
151140 int daemon = 1;
152141 int pid;
153142 char pid_s[32];
170159 (0 == g_strcasecmp(argv[1], "-ns"))))
171160 {
172161 /* starts sesman not daemonized */
173 g_printf("starting sesman in foregroud...\n");
162 g_printf("starting sesman in foreground...\n");
174163 daemon = 0;
175164 }
176165 else if ((2 == argc) && ((0 == g_strcasecmp(argv[1], "--help")) ||
251240 {
252241 g_printf("sesman is already running.\n");
253242 g_printf("if it's not running, try removing ");
254 g_printf(pid_file);
243 g_printf("%s", pid_file);
255244 g_printf("\n");
256245 g_deinit();
257246 g_exit(1);
278267 g_snprintf(cfg_file, 255, "%s/sesman.ini", XRDP_CFG_PATH);
279268
280269 /* starting logging subsystem */
281 error = log_start(cfg_file, "XRDP-sesman");
282
283 if (error != LOG_STARTUP_OK)
284 {
285 switch (error)
270 log_error = log_start(cfg_file, "xrdp-sesman");
271
272 if (log_error != LOG_STARTUP_OK)
273 {
274 switch (log_error)
286275 {
287276 case LOG_ERROR_MALLOC:
288277 g_writeln("error on malloc. cannot start logging. quitting.");
291280 g_writeln("error opening log file [%s]. quitting.",
292281 getLogFile(text, 255));
293282 break;
283 default:
284 g_writeln("error");
285 break;
294286 }
295287
296288 g_deinit();
327319 {
328320 }
329321 }
330
331 /* initializing locks */
332 lock_init();
333322
334323 /* signal handling */
335324 g_pid = g_getpid();
341330 #if 1
342331 g_signal_hang_up(sig_sesman_reload_cfg); /* SIGHUP */
343332 g_signal_user_interrupt(sig_sesman_shutdown); /* SIGINT */
344 g_signal_kill(sig_sesman_shutdown); /* SIGKILL */
345333 g_signal_terminate(sig_sesman_shutdown); /* SIGTERM */
346334 g_signal_child_stop(sig_sesman_session_end); /* SIGCHLD */
347335 #endif
386374
387375 g_snprintf(text, 255, "xrdp_sesman_%8.8x_main_term", g_pid);
388376 g_term_event = g_create_wait_obj(text);
389 g_snprintf(text, 255, "xrdp_sesman_%8.8x_main_sync", g_pid);
390 g_sync_event = g_create_wait_obj(text);
391377
392378 sesman_main_loop();
393379
398384 }
399385
400386 g_delete_wait_obj(g_term_event);
401 g_delete_wait_obj(g_sync_event);
402387
403388 if (!daemon)
404389 {
4141 #include "session.h"
4242 #include "access.h"
4343 #include "scp.h"
44 #include "thread.h"
45 #include "lock.h"
46 #include "thread_calls.h"
4744
4845 #include "libscp.h"
4946
6262 SyslogLevel=DEBUG
6363
6464 [X11rdp]
65 param0=X11rdp
6566 param1=-bs
6667 param2=-ac
6768 param3=-nolisten
6970 param5=-uds
7071
7172 [Xvnc]
73 param0=Xvnc
7274 param1=-bs
7375 param2=-ac
7476 param3=-nolisten
7880 param7=96
7981
8082 [Xorg]
83 param0=Xorg
8184 param1=-config
8285 param2=xrdp/xorg.conf
8386 param3=-logfile
00 /**
11 * xrdp: A Remote Desktop Protocol server.
22 *
3 * Copyright (C) Jay Sorg 2004-2013
3 * Copyright (C) Jay Sorg 2004-2015
44 *
55 * BSD process grouping by:
66 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland.
3131 #include "sesman.h"
3232 #include "libscp_types.h"
3333
34 #include <errno.h>
35 //#include <time.h>
36
37 extern tbus g_sync_event;
3834 extern unsigned char g_fixedkey[8];
3935 extern struct config_sesman *g_cfg; /* in sesman.c */
4036 extern int g_sck; /* in sesman.c */
41 extern int g_thread_sck; /* in thread.c */
4237 struct session_chain *g_sessions;
4338 int g_session_count;
4439
45 static int g_sync_width;
46 static int g_sync_height;
47 static int g_sync_bpp;
48 static char *g_sync_username;
49 static char *g_sync_password;
50 static char *g_sync_domain;
51 static char *g_sync_program;
52 static char *g_sync_directory;
53 static char *g_sync_client_ip;
54 static tbus g_sync_data;
55 static tui8 g_sync_type;
56 static int g_sync_result;
57 static int g_sync_cmd;
40 extern tbus g_term_event; /* in sesman.c */
5841
5942 /**
6043 * Creates a string consisting of all parameters that is hosted in the param list
6750 dumpItemsToString(struct list *self, char *outstr, int len)
6851 {
6952 int index;
70 tbus item;
7153 int totalLen = 0;
7254
7355 g_memset(outstr, 0, len);
9880 {
9981 struct session_chain *tmp;
10082 enum SESMAN_CFG_SESS_POLICY policy = g_cfg->sess.policy;
101
102 /*THREAD-FIX require chain lock */
103 lock_chain_acquire();
10483
10584 tmp = g_sessions;
10685
11897 type = SESMAN_SESSION_TYPE_XORG;
11998 break;
12099 default:
121 lock_chain_release();
122100 return 0;
123101 }
124102
140118 tmp->item->client_ip);
141119 #endif
142120
143 if ((type == SESMAN_SESSION_TYPE_XRDP) || (type == SESMAN_SESSION_TYPE_XORG))
144 {
145 /* only name and bpp need to match for X11rdp, it can resize */
146 if (g_strncmp(name, tmp->item->name, 255) == 0 &&
147 (!(policy & SESMAN_CFG_SESS_POLICY_D) ||
148 (tmp->item->width == width && tmp->item->height == height)) &&
149 (!(policy & SESMAN_CFG_SESS_POLICY_I) ||
150 (g_strncmp_d(client_ip, tmp->item->client_ip, ':', 255) == 0)) &&
151 (!(policy & SESMAN_CFG_SESS_POLICY_C) ||
152 (g_strncmp(client_ip, tmp->item->client_ip, 255) == 0)) &&
153 tmp->item->bpp == bpp &&
154 tmp->item->type == type)
155 {
156 /*THREAD-FIX release chain lock */
157 lock_chain_release();
158 return tmp->item;
159 }
160 }
161
162121 if (g_strncmp(name, tmp->item->name, 255) == 0 &&
163 (tmp->item->width == width && tmp->item->height == height) &&
122 (!(policy & SESMAN_CFG_SESS_POLICY_D) ||
123 (tmp->item->width == width && tmp->item->height == height)) &&
164124 (!(policy & SESMAN_CFG_SESS_POLICY_I) ||
165125 (g_strncmp_d(client_ip, tmp->item->client_ip, ':', 255) == 0)) &&
166126 (!(policy & SESMAN_CFG_SESS_POLICY_C) ||
168128 tmp->item->bpp == bpp &&
169129 tmp->item->type == type)
170130 {
171 /*THREAD-FIX release chain lock */
172 lock_chain_release();
173131 return tmp->item;
174132 }
175133
176134 tmp = tmp->next;
177135 }
178136
179 /*THREAD-FIX release chain lock */
180 lock_chain_release();
181137 return 0;
182138 }
183139
281237 {
282238 char text[256];
283239 int x_running;
284 int sck;
285240
286241 g_sprintf(text, "/tmp/.X11-unix/X%d", display);
287242 x_running = g_file_exist(text);
323278 /* building parameters */
324279 g_snprintf(exe_path, 261, "%s/xrdp-sessvc", XRDP_SBIN_PATH);
325280
326 list_add_item(sessvc_params, (long)g_strdup(exe_path));
327 list_add_item(sessvc_params, (long)g_strdup(xpid_str));
328 list_add_item(sessvc_params, (long)g_strdup(wmpid_str));
281 list_add_item(sessvc_params, (tintptr)g_strdup(exe_path));
282 list_add_item(sessvc_params, (tintptr)g_strdup(xpid_str));
283 list_add_item(sessvc_params, (tintptr)g_strdup(wmpid_str));
329284 list_add_item(sessvc_params, 0); /* mandatory */
330285
331286 env_set_user(username, 0, display,
343298 /* no problem calling strerror for thread safety: other threads
344299 are blocked */
345300 log_message(LOG_LEVEL_DEBUG, "errno: %d, description: %s",
346 errno, g_get_strerror());
301 g_get_errno(), g_get_strerror());
347302 log_message(LOG_LEVEL_DEBUG, "execve parameter list:");
348303
349304 for (i = 0; i < (sessvc_params->count); i++)
392347 /******************************************************************************/
393348 /* called with the main thread */
394349 static int APP_CC
395 session_get_aval_display_from_chain(void)
350 session_get_avail_display_from_chain(void)
396351 {
397352 int display;
398353
399354 display = g_cfg->sess.x11_display_offset;
400 lock_chain_acquire();
401355
402356 while ((display - g_cfg->sess.x11_display_offset) <= g_cfg->sess.max_sessions)
403357 {
405359 {
406360 if (!x_server_running_check_ports(display))
407361 {
408 lock_chain_release();
409362 return display;
410363 }
411364 }
413366 display++;
414367 }
415368
416 lock_chain_release();
417369 log_message(LOG_LEVEL_ERROR, "X server -- no display in range is available");
418370 return 0;
419371 }
459411 int pampid = 0;
460412 int xpid = 0;
461413 int i = 0;
414 char *xserver; /* absolute/relative path to Xorg/X11rdp/Xvnc */
462415 char geometry[32];
463416 char depth[32];
464 char screen[32];
417 char screen[32]; /* display number */
465418 char text[256];
466419 char passwd_file[256];
467420 char *pfile;
508461 return 0;
509462 }
510463
511 display = session_get_aval_display_from_chain();
464 display = session_get_avail_display_from_chain();
512465
513466 if (display == 0)
514467 {
517470 return 0;
518471 }
519472
520 pid = g_fork();
473 pid = g_fork(); /* parent is fork from tcp accept,
474 child forks X and wm, then becomes scp */
521475
522476 if (pid == -1)
523477 {
524478 }
525 else if (pid == 0) /* child sesman */
526 {
479 else if (pid == 0)
480 {
481 g_tcp_close(g_term_event);
527482 g_tcp_close(g_sck);
528 g_tcp_close(g_thread_sck);
529483 g_sprintf(geometry, "%dx%d", width, height);
530484 g_sprintf(depth, "%d", bpp);
531485 g_sprintf(screen, ":%d", display);
550504 * Create a new session and process group since the 4.4BSD
551505 * setlogin() affects the entire process group
552506 */
553 if (setsid() < 0)
554 {
555 log_message(LOG_LEVEL_ERROR,
556 "setsid failed - pid %d", g_getpid());
557 }
558
559 if (setlogin(username) < 0)
560 {
561 log_message(LOG_LEVEL_ERROR,
562 "setlogin failed for user %s - pid %d", username, g_getpid());
507 if (g_setsid() < 0)
508 {
509 log_message(LOG_LEVEL_ERROR,
510 "setsid failed - pid %d", g_getpid());
511 }
512
513 if (g_setlogin(username) < 0)
514 {
515 log_message(LOG_LEVEL_ERROR,
516 "setlogin failed for user %s - pid %d", username,
517 g_getpid());
563518 }
564519 }
565520
566521 g_waitpid(bsdsespid);
567522 #endif
568 wmpid = g_fork();
523 wmpid = g_fork(); /* parent becomes X,
524 child forks wm, and waits, todo */
569525 if (wmpid == -1)
570526 {
571527 }
572 else if (wmpid == 0) /* child (child sesman) xserver */
528 else if (wmpid == 0)
573529 {
574530 wait_for_xserver(display);
575531 auth_start_session(data, display);
576 pampid = g_fork();
532 pampid = g_fork(); /* parent waits, todo
533 child becomes wm */
577534 if (pampid == -1)
578535 {
579536 }
580 else if (pampid == 0) /* child: X11/client */
537 else if (pampid == 0)
581538 {
582539 env_set_user(username, 0, display,
583540 g_cfg->session_variables1,
613570 "wm for user %s - pid %d", username, g_getpid());
614571 /* logging parameters */
615572 log_message(LOG_LEVEL_DEBUG, "errno: %d, "
616 "description: %s", errno, g_get_strerror());
573 "description: %s", g_get_errno(), g_get_strerror());
617574 log_message(LOG_LEVEL_DEBUG, "execlp3 parameter "
618575 "list:");
619576 log_message(LOG_LEVEL_DEBUG, " argv[0] = %s",
631588 "wm for user %s - pid %d", username, g_getpid());
632589 /* logging parameters */
633590 log_message(LOG_LEVEL_DEBUG, "errno: %d, description: "
634 "%s", errno, g_get_strerror());
591 "%s", g_get_errno(), g_get_strerror());
635592 log_message(LOG_LEVEL_DEBUG, "execlp3 parameter list:");
636593 log_message(LOG_LEVEL_DEBUG, " argv[0] = %s",
637594 text);
646603 "for user %s - pid %d", username, g_getpid());
647604 /* logging parameters */
648605 log_message(LOG_LEVEL_DEBUG, "errno: %d, description: "
649 "%s", errno, g_get_strerror());
606 "%s", g_get_errno(), g_get_strerror());
650607 }
651608 else
652609 {
665622 g_exit(0);
666623 }
667624 }
668 else /* parent (child sesman) */
669 {
670 xpid = g_fork();
671
625 else
626 {
627 xpid = g_fork(); /* parent becomes scp,
628 child becomes X */
672629 if (xpid == -1)
673630 {
674631 }
695652 xserver_params = list_create();
696653 xserver_params->auto_free = 1;
697654
655 /* get path of Xorg from config */
656 xserver = g_strdup((const char *)list_get_item(g_cfg->xorg_params, 0));
657 list_remove_item(g_cfg->xorg_params, 0);
658
698659 /* these are the must have parameters */
699 list_add_item(xserver_params, (long) g_strdup("Xorg"));
700 list_add_item(xserver_params, (long) g_strdup(screen));
660 list_add_item(xserver_params, (tintptr) g_strdup(xserver));
661 list_add_item(xserver_params, (tintptr) g_strdup(screen));
701662
702663 /* additional parameters from sesman.ini file */
703664 list_append_list_strdup(g_cfg->xorg_params, xserver_params, 0);
717678 g_setenv("XRDP_START_HEIGHT", geometry, 1);
718679
719680 /* fire up Xorg */
720 g_execvp("Xorg", pp1);
681 g_execvp(xserver, pp1);
721682 }
722683 else if (type == SESMAN_SESSION_TYPE_XVNC)
723684 {
725686 xserver_params = list_create();
726687 xserver_params->auto_free = 1;
727688
689 /* get path of Xvnc from config */
690 xserver = g_strdup((const char *)list_get_item(g_cfg->vnc_params, 0));
691 list_remove_item(g_cfg->vnc_params, 0);
692
728693 /* these are the must have parameters */
729 list_add_item(xserver_params, (long)g_strdup("Xvnc"));
730 list_add_item(xserver_params, (long)g_strdup(screen));
731 list_add_item(xserver_params, (long)g_strdup("-geometry"));
732 list_add_item(xserver_params, (long)g_strdup(geometry));
733 list_add_item(xserver_params, (long)g_strdup("-depth"));
734 list_add_item(xserver_params, (long)g_strdup(depth));
735 list_add_item(xserver_params, (long)g_strdup("-rfbauth"));
736 list_add_item(xserver_params, (long)g_strdup(passwd_file));
694 list_add_item(xserver_params, (tintptr)g_strdup(xserver));
695 list_add_item(xserver_params, (tintptr)g_strdup(screen));
696 list_add_item(xserver_params, (tintptr)g_strdup("-geometry"));
697 list_add_item(xserver_params, (tintptr)g_strdup(geometry));
698 list_add_item(xserver_params, (tintptr)g_strdup("-depth"));
699 list_add_item(xserver_params, (tintptr)g_strdup(depth));
700 list_add_item(xserver_params, (tintptr)g_strdup("-rfbauth"));
701 list_add_item(xserver_params, (tintptr)g_strdup(passwd_file));
737702
738703 /* additional parameters from sesman.ini file */
739704 //config_read_xserver_params(SESMAN_SESSION_TYPE_XVNC,
744709 list_add_item(xserver_params, 0);
745710 pp1 = (char **)xserver_params->items;
746711 log_message(LOG_LEVEL_INFO, "%s", dumpItemsToString(xserver_params, execvpparams, 2048));
747 g_execvp("Xvnc", pp1);
712 g_execvp(xserver, pp1);
748713 }
749714 else if (type == SESMAN_SESSION_TYPE_XRDP)
750715 {
751716 xserver_params = list_create();
752717 xserver_params->auto_free = 1;
753718
719 /* get path of X11rdp from config */
720 xserver = g_strdup((const char *)list_get_item(g_cfg->rdp_params, 0));
721 list_remove_item(g_cfg->rdp_params, 0);
722
754723 /* these are the must have parameters */
755 list_add_item(xserver_params, (long)g_strdup("X11rdp"));
756 list_add_item(xserver_params, (long)g_strdup(screen));
757 list_add_item(xserver_params, (long)g_strdup("-geometry"));
758 list_add_item(xserver_params, (long)g_strdup(geometry));
759 list_add_item(xserver_params, (long)g_strdup("-depth"));
760 list_add_item(xserver_params, (long)g_strdup(depth));
724 list_add_item(xserver_params, (tintptr)g_strdup(xserver));
725 list_add_item(xserver_params, (tintptr)g_strdup(screen));
726 list_add_item(xserver_params, (tintptr)g_strdup("-geometry"));
727 list_add_item(xserver_params, (tintptr)g_strdup(geometry));
728 list_add_item(xserver_params, (tintptr)g_strdup("-depth"));
729 list_add_item(xserver_params, (tintptr)g_strdup(depth));
761730
762731 /* additional parameters from sesman.ini file */
763732 //config_read_xserver_params(SESMAN_SESSION_TYPE_XRDP,
768737 list_add_item(xserver_params, 0);
769738 pp1 = (char **)xserver_params->items;
770739 log_message(LOG_LEVEL_INFO, "%s", dumpItemsToString(xserver_params, execvpparams, 2048));
771 g_execvp("X11rdp", pp1);
740 g_execvp(xserver, pp1);
772741 }
773742 else
774743 {
783752
784753 /* logging parameters */
785754 log_message(LOG_LEVEL_DEBUG, "errno: %d, description: "
786 "%s", errno, g_get_strerror());
755 "%s", g_get_errno(), g_get_strerror());
787756 log_message(LOG_LEVEL_DEBUG, "execve parameter list size: "
788757 "%d", (xserver_params)->count);
789758
796765 list_delete(xserver_params);
797766 g_exit(1);
798767 }
799 else /* parent (child sesman)*/
768 else
800769 {
801770 wait_for_xserver(display);
802771 g_snprintf(text, 255, "%d", display);
808777 }
809778 }
810779 }
811 else /* parent sesman process */
780 else
812781 {
813782 temp->item->pid = pid;
814783 temp->item->display = display;
822791 ltime = g_time1();
823792 localtime_r(&ltime, &stime);
824793 temp->item->connect_time.year = (tui16)(stime.tm_year + 1900);
825 temp->item->connect_time.month = (tui8)stime.tm_mon;
794 temp->item->connect_time.month = (tui8)(stime.tm_mon + 1);
826795 temp->item->connect_time.day = (tui8)stime.tm_mday;
827796 temp->item->connect_time.hour = (tui8)stime.tm_hour;
828797 temp->item->connect_time.minute = (tui8)stime.tm_min;
832801 temp->item->type = type;
833802 temp->item->status = SESMAN_SESSION_STATUS_ACTIVE;
834803
835 /*THREAD-FIX require chain lock */
836 lock_chain_acquire();
837
838804 temp->next = g_sessions;
839805 g_sessions = temp;
840806 g_session_count++;
841
842 /*THREAD-FIX release chain lock */
843 lock_chain_release();
844807
845808 return display;
846809 }
888851 long data, tui8 type, char *domain, char *program,
889852 char *directory, char *client_ip)
890853 {
891 int display;
892
893 /* lock mutex */
894 lock_sync_acquire();
895 /* set shared vars */
896 g_sync_cmd = 0;
897 g_sync_width = width;
898 g_sync_height = height;
899 g_sync_bpp = bpp;
900 g_sync_username = username;
901 g_sync_password = password;
902 g_sync_domain = domain;
903 g_sync_program = program;
904 g_sync_directory = directory;
905 g_sync_client_ip = client_ip;
906 g_sync_data = data;
907 g_sync_type = type;
908 /* set event for main thread to see */
909 g_set_wait_obj(g_sync_event);
910 /* wait for main thread to get done */
911 lock_sync_sem_acquire();
912 /* read result(display) from shared var */
913 display = g_sync_result;
914 /* unlock mutex */
915 lock_sync_release();
916 return display;
854 return session_start_fork(width, height, bpp, username,
855 password, data, type, domain,
856 program, directory, client_ip);
917857 }
918858
919859 /******************************************************************************/
922862 int DEFAULT_CC
923863 session_reconnect(int display, char *username)
924864 {
925 /* lock mutex */
926 lock_sync_acquire();
927 /* set shared vars */
928 g_sync_cmd = 1;
929 g_sync_width = display;
930 g_sync_username = username;
931 /* set event for main thread to see */
932 g_set_wait_obj(g_sync_event);
933 /* wait for main thread to get done */
934 lock_sync_sem_acquire();
935 /* unlock mutex */
936 lock_sync_release();
937 return 0;
938 }
939
940 /******************************************************************************/
941 /* called with the main thread */
942 int APP_CC
943 session_sync_start(void)
944 {
945 if (g_sync_cmd == 0)
946 {
947 g_sync_result = session_start_fork(g_sync_width, g_sync_height, g_sync_bpp,
948 g_sync_username, g_sync_password,
949 g_sync_data, g_sync_type, g_sync_domain,
950 g_sync_program, g_sync_directory,
951 g_sync_client_ip);
952 }
953 else
954 {
955 /* g_sync_width is really display */
956 g_sync_result = session_reconnect_fork(g_sync_width, g_sync_username);
957 }
958
959 lock_sync_sem_release();
960 return 0;
865 return session_reconnect_fork(display, username);
961866 }
962867
963868 /******************************************************************************/
966871 {
967872 struct session_chain *tmp;
968873 struct session_chain *prev;
969
970 /*THREAD-FIX require chain lock */
971 lock_chain_acquire();
972874
973875 tmp = g_sessions;
974876 prev = 0;
991893 prev->next = tmp->next;
992894 }
993895
994 /*THREAD-FIX release chain lock */
995 lock_chain_release();
996896 return SESMAN_SESSION_KILL_NULLITEM;
997897 }
998898
1015915
1016916 g_free(tmp);
1017917 g_session_count--;
1018 /*THREAD-FIX release chain lock */
1019 lock_chain_release();
1020918 return SESMAN_SESSION_KILL_OK;
1021919 }
1022920
1025923 tmp = tmp->next;
1026924 }
1027925
1028 /*THREAD-FIX release chain lock */
1029 lock_chain_release();
1030926 return SESMAN_SESSION_KILL_NOTFOUND;
1031927 }
1032928
1036932 {
1037933 struct session_chain *tmp;
1038934
1039 /*THREAD-FIX require chain lock */
1040 lock_chain_acquire();
1041
1042935 tmp = g_sessions;
1043936
1044937 while (tmp != 0)
1056949 /* go on */
1057950 tmp = tmp->next;
1058951 }
1059
1060 /*THREAD-FIX release chain lock */
1061 lock_chain_release();
1062952 }
1063953
1064954 /******************************************************************************/
1076966 return 0;
1077967 }
1078968
1079 /*THREAD-FIX require chain lock */
1080 lock_chain_acquire();
1081
1082969 tmp = g_sessions;
1083970
1084971 while (tmp != 0)
1087974 {
1088975 log_message(LOG_LEVEL_ERROR, "session descriptor for "
1089976 "pid %d is null!", pid);
1090 /*THREAD-FIX release chain lock */
1091 lock_chain_release();
1092977 g_free(dummy);
1093978 return 0;
1094979 }
1095980
1096981 if (tmp->item->pid == pid)
1097982 {
1098 /*THREAD-FIX release chain lock */
1099983 g_memcpy(dummy, tmp->item, sizeof(struct session_item));
1100 lock_chain_release();
1101 /*return tmp->item;*/
1102984 return dummy;
1103985 }
1104986
1106988 tmp = tmp->next;
1107989 }
1108990
1109 /*THREAD-FIX release chain lock */
1110 lock_chain_release();
1111991 g_free(dummy);
1112992 return 0;
1113993 }
11231003
11241004 count = 0;
11251005
1126 /*THREAD-FIX require chain lock */
1127 lock_chain_acquire();
1128
11291006 tmp = g_sessions;
11301007
11311008 while (tmp != 0)
11511028 if (count == 0)
11521029 {
11531030 (*cnt) = 0;
1154 /*THREAD-FIX release chain lock */
1155 lock_chain_release();
11561031 return 0;
11571032 }
11581033
11621037 if (sess == 0)
11631038 {
11641039 (*cnt) = 0;
1165 /*THREAD-FIX release chain lock */
1166 lock_chain_release();
11671040 return 0;
11681041 }
11691042
11721045
11731046 while (tmp != 0)
11741047 {
1175 #warning FIXME: we should get only disconnected sessions!
1048 /* #warning FIXME: we should get only disconnected sessions! */
11761049 if ((NULL == user) || (!g_strncasecmp(user, tmp->item->name, 256)))
11771050 {
11781051 if ((tmp->item->status) & flags)
11821055 (sess[index]).height = tmp->item->height;
11831056 (sess[index]).width = tmp->item->width;
11841057 (sess[index]).bpp = tmp->item->bpp;
1185 #warning FIXME: setting idle times and such
1058 /* #warning FIXME: setting idle times and such */
11861059 /*(sess[index]).connect_time.year = tmp->item->connect_time.year;
11871060 (sess[index]).connect_time.month = tmp->item->connect_time.month;
11881061 (sess[index]).connect_time.day = tmp->item->connect_time.day;
12151088 tmp = tmp->next;
12161089 }
12171090
1218 /*THREAD-FIX release chain lock */
1219 lock_chain_release();
12201091 (*cnt) = count;
12211092 return sess;
12221093 }
111111
112112 /**
113113 *
114 * @brief starts a session
115 * @return error
116 *
117 */
118 int APP_CC
119 session_sync_start(void);
120
121 /**
122 *
123114 * @brief kills a session
124115 * @param pid the pid of the session to be killed
125116 * @return
00
1 AM_CFLAGS = \
1 AM_CPPFLAGS = \
22 -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
33 -DXRDP_SBIN_PATH=\"${sbindir}\" \
44 -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
5 -DXRDP_PID_PATH=\"${localstatedir}/run\"
6
7 INCLUDES = \
5 -DXRDP_PID_PATH=\"${localstatedir}/run\" \
86 -I$(top_srcdir)/common
97
108 sbin_PROGRAMS = \
9292 return 1;
9393 }
9494
95 g_signal_kill(term_signal_handler); /* SIGKILL */
9695 g_signal_terminate(term_signal_handler); /* SIGTERM */
9796 g_signal_user_interrupt(term_signal_handler); /* SIGINT */
9897 g_signal_pipe(nil_signal_handler); /* SIGPIPE */
10099 wm_pid = g_atoi(argv[2]);
101100 g_writeln("xrdp-sessvc: waiting for X (pid %d) and WM (pid %d)",
102101 x_pid, wm_pid);
103 /* run xrdp-chansrv as a seperate process */
102 /* run xrdp-chansrv as a separate process */
104103 chansrv_pid = g_fork();
105104
106105 if (chansrv_pid == -1)
9292 /* stop logging subsystem */
9393 log_end();
9494
95 /* replace old config with new readed one */
95 /* replace old config with newly read one */
9696 g_cfg = cfg;
9797
9898 g_snprintf(cfg_file, 255, "%s/sesman.ini", XRDP_CFG_PATH);
9999
100100 /* start again logging subsystem */
101 error = log_start(cfg_file, "XRDP-sesman");
101 error = log_start(cfg_file, "xrdp-sesman");
102102
103103 if (error != LOG_STARTUP_OK)
104104 {
157157 sigaddset(&waitmask, SIGHUP);
158158 sigaddset(&waitmask, SIGCHLD);
159159 sigaddset(&waitmask, SIGTERM);
160 sigaddset(&waitmask, SIGKILL);
161160 sigaddset(&waitmask, SIGINT);
162161
163162 // sigaddset(&waitmask, SIGFPE);
187186 LOG_DBG("sesman received SIGINT", 0);
188187 sig_sesman_shutdown(recv_signal);
189188 break;
190 case SIGKILL:
191 /* we die */
192 LOG_DBG("sesman received SIGKILL", 0);
193 sig_sesman_shutdown(recv_signal);
194 break;
195189 case SIGTERM:
196190 /* we die */
197191 LOG_DBG("sesman received SIGTERM", 0);
2828 xterm
2929 }
3030
31 #Execution sequence for interactive login shell
32 #Following pseudo code explains the sequence of execution of these files.
33 #execute /etc/profile
34 #IF ~/.bash_profile exists THEN
35 # execute ~/.bash_profile
36 #ELSE
37 # IF ~/.bash_login exist THEN
38 # execute ~/.bash_login
39 # ELSE
40 # IF ~/.profile exist THEN
41 # execute ~/.profile
42 # END IF
43 # END IF
44 #END IF
31 # Execution sequence for interactive login shell - pseudocode
32 #
33 # IF /etc/profile is readable THEN
34 # execute ~/.bash_profile
35 # END IF
36 # IF ~/.bash_profile is readable THEN
37 # execute ~/.bash_profile
38 # ELSE
39 # IF ~/.bash_login is readable THEN
40 # execute ~/.bash_login
41 # ELSE
42 # IF ~/.profile is readable THEN
43 # execute ~/.profile
44 # END IF
45 # END IF
46 # END IF
4547 pre_start()
4648 {
47 if [ -f /etc/profile ]
48 then
49 if [ -r /etc/profile ]; then
4950 . /etc/profile
5051 fi
51 if [ -f ~/.bash_profile ]
52 then
52 if [ -r ~/.bash_profile ]; then
5353 . ~/.bash_profile
5454 else
55 if [ -f ~/.bash_login ]
56 then
55 if [ -r ~/.bash_login ]; then
5756 . ~/.bash_login
5857 else
59 if [ -f ~/.profile ]
60 then
58 if [ -r ~/.profile ]; then
6159 . ~/.profile
6260 fi
6361 fi
6563 return 0
6664 }
6765
68 #When you logout of the interactive shell, following is the
69 #sequence of execution:
70 #IF ~/.bash_logout exists THEN
71 # execute ~/.bash_logout
72 #END IF
66 # When loging out from the interactive shell, the execution sequence is:
67 #
68 # IF ~/.bash_logout exists THEN
69 # execute ~/.bash_logout
70 # END IF
7371 post_start()
7472 {
75 if [ -f ~/.bash_logout ]
76 then
73 if [ -r ~/.bash_logout ]; then
7774 . ~/.bash_logout
7875 fi
7976 return 0
+0
-173
sesman/thread.c less more
0 /**
1 * xrdp: A Remote Desktop Protocol server.
2 *
3 * Copyright (C) Jay Sorg 2004-2013
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 /**
19 *
20 * @file thread.c
21 * @brief thread stuff...
22 * @author Simone Fedele
23 *
24 */
25
26 #include "sesman.h"
27
28 #include <errno.h>
29 #include <signal.h>
30 #include <pthread.h>
31
32 extern struct config_sesman *g_cfg; /* in sesman.c */
33
34 static pthread_t g_thread_sighandler;
35 //static pthread_t g_thread_updater;
36
37 /* a variable to pass the socket of s connection to a thread */
38 int g_thread_sck;
39
40 /******************************************************************************/
41 int DEFAULT_CC
42 thread_sighandler_start(void)
43 {
44 int ret;
45 sigset_t sigmask;
46 sigset_t oldmask;
47 sigset_t waitmask;
48
49 /* mask signals to be able to wait for them... */
50 sigfillset(&sigmask);
51 pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask);
52
53 /* unblock some signals... */
54 sigemptyset(&waitmask);
55
56 /* it is a good idea not to block SIGILL SIGSEGV */
57 /* SIGFPE -- see sigaction(2) NOTES */
58 sigaddset(&waitmask, SIGILL);
59 sigaddset(&waitmask, SIGSEGV);
60 sigaddset(&waitmask, SIGFPE);
61 pthread_sigmask(SIG_UNBLOCK, &waitmask, NULL);
62
63 log_message(LOG_LEVEL_INFO, "starting signal handling thread...");
64
65 ret = pthread_create(&g_thread_sighandler, NULL, sig_handler_thread, "");
66 pthread_detach(g_thread_sighandler);
67
68 if (ret == 0)
69 {
70 log_message(LOG_LEVEL_INFO, "signal handler thread started successfully");
71 return 0;
72 }
73
74 /* if something happened while starting a new thread... */
75 switch (ret)
76 {
77 case EINVAL:
78 log_message(LOG_LEVEL_ERROR, "invalid attributes for signal handling thread (creation returned EINVAL)");
79 break;
80 case EAGAIN:
81 log_message(LOG_LEVEL_ERROR, "not enough resources to start signal handling thread (creation returned EAGAIN)");
82 break;
83 case EPERM:
84 log_message(LOG_LEVEL_ERROR, "invalid permissions for signal handling thread (creation returned EPERM)");
85 break;
86 default:
87 log_message(LOG_LEVEL_ERROR, "unknown error starting signal handling thread");
88 }
89
90 return 1;
91 }
92
93 #ifdef JUST_TO_AVOID_COMPILER_ERRORS
94 /******************************************************************************/
95 int DEFAULT_CC
96 thread_session_update_start(void)
97 {
98 int ret;
99 //starts the session update thread
100 //that checks for idle time, destroys sessions, ecc...
101
102 #warning this thread should always request lock_fork before read or write
103 #warning (so we can Fork() In Peace)
104 ret = pthread_create(&g_thread_updater, NULL, , "");
105 pthread_detach(g_thread_updater);
106
107 if (ret == 0)
108 {
109 log_message(&(g_cfg->log), LOG_LEVEL_INFO, "session update thread started successfully");
110 return 0;
111 }
112
113 /* if something happened while starting a new thread... */
114 switch (ret)
115 {
116 case EINVAL:
117 log_message(LOG_LEVEL_ERROR, "invalid attributes for session update thread (creation returned EINVAL)");
118 break;
119 case EAGAIN:
120 log_message(LOG_LEVEL_ERROR, "not enough resources to start session update thread (creation returned EAGAIN)");
121 break;
122 case EPERM:
123 log_message(LOG_LEVEL_ERROR, "invalid permissions for session update thread (creation returned EPERM)");
124 break;
125 default:
126 log_message(LOG_LEVEL_ERROR, "unknown error starting session update thread");
127 }
128
129 return 1;
130 }
131 #endif
132
133 /******************************************************************************/
134 int DEFAULT_CC
135 thread_scp_start(int skt)
136 {
137 int ret;
138 pthread_t th;
139
140 /* blocking the use of thread_skt */
141 lock_socket_acquire();
142 g_thread_sck = skt;
143
144 /* start a thread that processes a connection */
145 ret = pthread_create(&th, NULL, scp_process_start, "");
146 //ret = pthread_create(&th, NULL, scp_process_start, (void*) (&g_thread_sck));
147 pthread_detach(th);
148
149 if (ret == 0)
150 {
151 log_message(LOG_LEVEL_INFO, "scp thread on sck %d started successfully", skt);
152 return 0;
153 }
154
155 /* if something happened while starting a new thread... */
156 switch (ret)
157 {
158 case EINVAL:
159 log_message(LOG_LEVEL_ERROR, "invalid attributes for scp thread on sck %d (creation returned EINVAL)", skt);
160 break;
161 case EAGAIN:
162 log_message(LOG_LEVEL_ERROR, "not enough resources to start scp thread on sck %d (creation returned EAGAIN)", skt);
163 break;
164 case EPERM:
165 log_message(LOG_LEVEL_ERROR, "invalid permissions for scp thread on sck %d (creation returned EPERM)", skt);
166 break;
167 default:
168 log_message(LOG_LEVEL_ERROR, "unknown error starting scp thread on sck %d");
169 }
170
171 return 1;
172 }
+0
-56
sesman/thread.h less more
0 /**
1 * xrdp: A Remote Desktop Protocol server.
2 *
3 * Copyright (C) Jay Sorg 2004-2013
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 /**
19 *
20 * @file thread.h
21 * @brief thread stuff...
22 * @author Simone Fedele
23 *
24 */
25
26 #ifndef THREAD_H
27 #define THREAD_H
28
29 /**
30 *
31 * @brief Starts the signal handling thread
32 * @retval 0 on success
33 * @retval 1 on error
34 *
35 */
36 int DEFAULT_CC
37 thread_sighandler_start(void);
38
39 /**
40 *
41 * @brief Starts the session update thread
42 *
43 */
44 int DEFAULT_CC
45 thread_session_update_start(void);
46
47 /**
48 *
49 * @brief Starts a thread to handle an incoming connection
50 *
51 */
52 int DEFAULT_CC
53 thread_scp_start(int skt);
54
55 #endif
0 EXTRA_DIST = tcp.h
1
2 AM_CFLAGS = \
0 AM_CPPFLAGS = \
31 -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
42 -DXRDP_SBIN_PATH=\"${sbindir}\" \
53 -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
6 -DXRDP_PID_PATH=\"${localstatedir}/run\"
7
8 INCLUDES = \
4 -DXRDP_PID_PATH=\"${localstatedir}/run\" \
95 -I$(top_srcdir)/common \
106 -I$(top_srcdir)/sesman/libscp \
117 -I$(top_srcdir)/sesman
8
9 AM_CFLAGS = $(X_CFLAGS)
1210
1311 bin_PROGRAMS = \
1412 xrdp-sesrun \
2018 xrdp-xcon
2119
2220 xrdp_sesrun_SOURCES = \
21 config.c \
2322 sesrun.c \
2423 tcp.c \
25 config.c
24 tcp.h
2625
2726 xrdp_sestest_SOURCES = \
2827 sestest.c
4746 $(top_builddir)/common/libcommon.la \
4847 $(top_builddir)/sesman/libscp/libscp.la
4948
49 xrdp_xcon_LDFLAGS = \
50 $(X_LIBS)
51
5052 xrdp_xcon_LDADD = \
51 -L/usr/X11R6/lib \
52 -lX11
53 $(X_PRE_LIBS) -lX11 $(X_EXTRA_LIBS)
0 #include "../config.c"
100100
101101 if (0 == g_strncmp(user, "", 1))
102102 {
103 g_strncpy(user, "root", 256);
103 cmndHelp();
104 return 0;
105 }
106
107 if (0 == g_strncmp(cmnd, "", 1))
108 {
109 cmndHelp();
110 return 0;
104111 }
105112
106113 if (0 == g_strncmp(pass, "", 1))
167174
168175 void cmndHelp()
169176 {
170 fprintf(stderr, "sesadmin - a console sesman adminitration tool\n");
171 fprintf(stderr, "sysntax: sesadmin [] COMMAND [OPTIONS]\n\n");
177 fprintf(stderr, "sesadmin - a console sesman administration tool\n");
178 fprintf(stderr, "syntax: sesadmin [] COMMAND [OPTIONS]\n\n");
172179 fprintf(stderr, "-u=<username>: username to connect to sesman [MANDATORY]\n");
173 fprintf(stderr, "-p=<password>: password to connect to sesman [MANDATORY]\n");
180 fprintf(stderr, "-p=<password>: password to connect to sesman (asked if not given)\n");
174181 fprintf(stderr, "-s=<hostname>: sesman host (default is localhost)\n");
175182 fprintf(stderr, "-i=<port> : sesman port (default 3350)\n");
176183 fprintf(stderr, "-c=<command> : command to execute on the server [MANDATORY]\n");
114114 {
115115 in_uint16_be(in_s, data);
116116 in_uint16_be(in_s, display);
117 g_printf("ok %d display %d\n", data, display);
117 g_printf("ok %d display %d\n", (int)data, display);
118118 }
119119 }
120120 }
200200 }
201201
202202 g_printf("session type:\n");
203 g_printf("0: Xvnc\n", SCP_SESSION_TYPE_XVNC);
204 g_printf("1: x11rdp\n", SCP_SESSION_TYPE_XRDP);
203 g_printf("%d: Xvnc\n", SCP_SESSION_TYPE_XVNC);
204 g_printf("%d: x11rdp\n", SCP_SESSION_TYPE_XRDP);
205205 integer = menuSelect(1);
206206
207207 if (integer == 1)
1818 /**
1919 *
2020 * @file tcp.c
21 * @brief Tcp stream funcions
21 * @brief Tcp stream functions
2222 * @author Jay Sorg, Simone Fedele
2323 *
2424 */
1818 #include <stdio.h>
1919 #include <stdlib.h>
2020 #include <string.h>
21 #include <unistd.h>
22 #include <sys/types.h>
2123 #include <X11/Xlib.h>
2224
2325 Display *g_display = 0;
0 A QT based utility program for thinclients using xrdp and NeutrinoRDP
0 A QT based utility program for thin clients using xrdp and NeutrinoRDP
11
22 This program sends commands to NeutrinoRDP to do something
33 useful on the client end (such as unmounting a USB drive,
0 !Makefile
222222 }
223223
224224 /**
225 * Start listening on specifed local socket; when we get a connection,
225 * Start listening on specified local socket; when we get a connection,
226226 * connect to specified remote server and transfer data between local
227227 * and remote server
228228 *****************************************************************************/
610610
611611 static void on_destroy(GtkWidget *widget, gpointer data)
612612 {
613 /* this will destory all windows and return control to gtk_main() */
613 /* this will destroy all windows and return control to gtk_main() */
614614 gtk_main_quit();
615615 }
616616
672672
673673 static void on_quit_clicked(GtkWidget *widget, gpointer data)
674674 {
675 /* this will destory all windows and return control to gtk_main() */
675 /* this will destroy all windows and return control to gtk_main() */
676676 gtk_main_quit();
677677 }
6868 }
6969
7070 /**
71 * Place specifed socket in non blocking mode
71 * Place specified socket in non blocking mode
7272 *****************************************************************************/
7373
7474 void tcp_set_non_blocking(int skt)
2525 #include <errno.h>
2626 #include <locale.h>
2727 #include <netdb.h>
28 #include <sys/types.h>
28 #include <sys/types.h>
2929 #include <sys/socket.h>
3030 #include <netinet/in.h>
3131 #include <arpa/inet.h>
108108 g_printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.');
109109 }
110110
111 g_writeln("");
111 g_writeln("%s", "");
112112 offset += thisline;
113113 line += thisline;
114114 }
394394 g_signal_user_interrupt(void (*func)(int))
395395 {
396396 signal(SIGINT, func);
397 }
398
399 /*****************************************************************************/
400 static void APP_CC
401 g_signal_kill(void (*func)(int))
402 {
403 signal(SIGKILL, func);
404397 }
405398
406399 /*****************************************************************************/
453446 g_writeln("bind failed");
454447 }
455448
456 /* listen for an incomming connection */
449 /* listen for an incoming connection */
457450 if (error == 0)
458451 {
459452 error = g_tcp_listen(lis_sck);
464457 }
465458 }
466459
467 /* accept an incomming connection */
460 /* accept an incoming connection */
468461 if (error == 0)
469462 {
470463 while ((!g_terminated) && (error == 0))
522515
523516 if (i > 99)
524517 {
525 g_writeln("timout connecting");
518 g_writeln("timeout connecting");
526519 error = 1;
527520 }
528521
684677
685678 g_init("tcp_proxy");
686679 g_signal_user_interrupt(proxy_shutdown); /* SIGINT */
687 g_signal_kill(proxy_shutdown); /* SIGKILL */
688680 g_signal_usr1(clear_counters); /* SIGUSR1 */
689681 g_signal_terminate(proxy_shutdown); /* SIGTERM */
690682
0 EXTRA_DIST = vnc.h
1
2 AM_CFLAGS = \
0 AM_CPPFLAGS = \
31 -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
42 -DXRDP_SBIN_PATH=\"${sbindir}\" \
53 -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
6 -DXRDP_PID_PATH=\"${localstatedir}/run\"
7
8 INCLUDES = \
4 -DXRDP_PID_PATH=\"${localstatedir}/run\" \
95 -I$(top_srcdir)/common
106
11 lib_LTLIBRARIES = \
7 module_LTLIBRARIES = \
128 libvnc.la
139
14 libvnc_la_SOURCES = vnc.c
10 libvnc_la_SOURCES = \
11 vnc.c \
12 vnc.h
1513
1614 libvnc_la_LIBADD = \
1715 $(top_builddir)/common/libcommon.la
5252 rfbEncryptBytes(char *bytes, char *passwd)
5353 {
5454 char key[24];
55 char passwd_hash[20];
56 char passwd_hash_text[40];
5557 void *des;
58 void *sha1;
5659 int len;
60 int passwd_bytes;
61
62 /* create password hash from password */
63 passwd_bytes = g_strlen(passwd);
64 sha1 = ssl_sha1_info_create();
65 ssl_sha1_transform(sha1, "xrdp_vnc", 8);
66 ssl_sha1_transform(sha1, passwd, passwd_bytes);
67 ssl_sha1_transform(sha1, passwd, passwd_bytes);
68 ssl_sha1_complete(sha1, passwd_hash);
69 ssl_sha1_info_delete(sha1);
70 g_snprintf(passwd_hash_text, 39, "%2.2x%2.2x%2.2x%2.2x",
71 (tui8)passwd_hash[0], (tui8)passwd_hash[1],
72 (tui8)passwd_hash[2], (tui8)passwd_hash[3]);
73 passwd_hash_text[39] = 0;
74 passwd = passwd_hash_text;
5775
5876 /* key is simply password padded with nulls */
5977 g_memset(key, 0, sizeof(key));
346364 }
347365 else if (msg == 200) /* invalidate */
348366 {
349 /* FrambufferUpdateRequest */
367 /* FramebufferUpdateRequest */
350368 init_stream(s, 8192);
351369 out_uint8(s, 3);
352370 out_uint8(s, 0);
672690 }
673691 }
674692
675 /* keep these in 32x32, vnc cursor can be alot bigger */
693 /* keep these in 32x32, vnc cursor can be a lot bigger */
676694 if (x > 31)
677695 {
678696 x = 31;
708726
709727 if (error == 0)
710728 {
711 /* FrambufferUpdateRequest */
729 /* FramebufferUpdateRequest */
712730 init_stream(s, 8192);
713731 out_uint8(s, 3);
714732 out_uint8(s, 1);
974992 v->server_msg(v, "VNC started connecting", 0);
975993 check_sec_result = 1;
976994
977 /* only support 8 and 16 bpp connections from rdp client */
978 if ((v->server_bpp != 8) && (v->server_bpp != 15) &&
979 (v->server_bpp != 16) && (v->server_bpp != 24))
980 {
981 v->server_msg(v, "VNC error - only supporting 8, 15, 16 and 24 bpp rdp "
982 "connections", 0);
995 /* check if bpp is supported for rdp connection */
996 switch (v->server_bpp)
997 {
998 case 8:
999 case 15:
1000 case 16:
1001 case 24:
1002 case 32:
1003 break;
1004 default:
1005 v->server_msg(v, "VNC error - only supporting 8, 15, 16, 24 and 32 "
1006 "bpp rdp connections", 0);
9831007 return 1;
9841008 }
9851009
10221046 if (error == 0)
10231047 {
10241048 v->server_msg(v, "VNC tcp connected", 0);
1025 /* protocal version */
1049 /* protocol version */
10261050 init_stream(s, 8192);
10271051 error = trans_force_read_s(v->trans, s, 12);
10281052 if (error == 0)
10801104
10811105 if (error != 0)
10821106 {
1083 log_message(LOG_LEVEL_DEBUG, "VNC Error after security negotiation");
1107 log_message(LOG_LEVEL_DEBUG, "VNC error %d after security negotiation",
1108 error);
10841109 }
10851110
10861111 if (error == 0 && check_sec_result)
12901315
12911316 if (error == 0)
12921317 {
1293 /* FrambufferUpdateRequest */
1318 /* FramebufferUpdateRequest */
12941319 init_stream(s, 8192);
12951320 out_uint8(s, 3);
12961321 out_uint8(s, 0);
6161 int (*server_set_bgcolor)(struct vnc* v, int bgcolor);
6262 int (*server_set_opcode)(struct vnc* v, int opcode);
6363 int (*server_set_mixmode)(struct vnc* v, int mixmode);
64 int (*server_set_brush)(struct vnc* v, int x_orgin, int y_orgin,
64 int (*server_set_brush)(struct vnc* v, int x_origin, int y_origin,
6565 int style, char* pattern);
6666 int (*server_set_pen)(struct vnc* v, int style,
6767 int width);
6868 int (*server_draw_line)(struct vnc* v, int x1, int y1, int x2, int y2);
69 int (*server_add_char)(struct vnc* v, int font, int charactor,
69 int (*server_add_char)(struct vnc* v, int font, int character,
7070 int offset, int baseline,
7171 int width, int height, char* data);
7272 int (*server_draw_text)(struct vnc* v, int font,
2222 /*
2323 * TODO:
2424 * o need to maintain aspect ratio while resizing
25 * o clicking in the middle of the slider bar shuld move the slider to the middle
25 * o clicking in the middle of the slider bar should move the slider to the middle
2626 * o need to be able to rewind the move when it is done playing
2727 * o need to be able to load another move and play it w/o restarting player
2828 * o pause button needs to work
6161 ~MainWindow();
6262
6363 signals:
64 void onGeometryChanged(int x, int y, int widht, int height);
64 void onGeometryChanged(int x, int y, int width, int height);
6565
6666 public slots:
6767 void onSliderValueChanged(int value);
0 !Makefile
557557 int
558558 rdpup_set_cursor_ex(short x, short y, char *cur_data, char *cur_mask, int bpp);
559559 int
560 rdpup_create_os_surface(int rdpindexd, int width, int height);
561 int
562 rdpup_create_os_surface_bpp(int rdpindexd, int width, int height, int bpp);
560 rdpup_create_os_surface(int rdpindex, int width, int height);
561 int
562 rdpup_create_os_surface_bpp(int rdpindex, int width, int height, int bpp);
563563 int
564564 rdpup_switch_os_surface(int rdpindex);
565565 int
581581 int
582582 rdpup_check_dirty_screen(rdpPixmapRec* pDirtyPriv);
583583 int
584 rdpup_add_char(int font, int charactor, short x, short y, int cx, int cy,
584 rdpup_add_char(int font, int character, short x, short y, int cx, int cy,
585585 char* bmpdata, int bmpdata_bytes);
586586 int
587 rdpup_add_char_alpha(int font, int charactor, short x, short y, int cx, int cy,
587 rdpup_add_char_alpha(int font, int character, short x, short y, int cx, int cy,
588588 char* bmpdata, int bmpdata_bytes);
589589 int
590590 rdpup_draw_text(int font, int flags, int mixmode,
223223
224224 /******************************************************************************/
225225 static int
226 compsoite_print(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
226 composite_print(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
227227 INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst,
228228 INT16 yDst, CARD16 width, CARD16 height)
229229 {
232232 rdpPixmapRec* pSrcPriv;
233233 rdpPixmapRec* pDstPriv;
234234
235 LLOGLN(0, ("compsoite_print: op %d xSrc %d ySrc %d xDst %d yDst %d "
235 LLOGLN(0, ("composite_print: op %d xSrc %d ySrc %d xDst %d yDst %d "
236236 "width %d height %d",
237237 op, xSrc, ySrc, xDst, yDst, width, height));
238238
492492 {
493493 LLOGLN(10, ("check_drawables: can not remote [%s]", g_com_fail_strings[fail_reason]));
494494 #if 0
495 compsoite_print(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
495 composite_print(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
496496 xDst, yDst, width, height);
497497 #endif
498498 }
500500 {
501501 LLOGLN(10, ("check_drawables: can remote [%s]", g_com_fail_strings[fail_reason]));
502502 #if 0
503 compsoite_print(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
503 composite_print(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
504504 xDst, yDst, width, height);
505505 #endif
506506 }
706706 {
707707 if (pMask != 0)
708708 {
709 /* TODO: here we can try to send it as a gylph */
709 /* TODO: here we can try to send it as a glyph */
710710 }
711711 }
712712 }
744744 post_process = 1;
745745 if (g_do_dirty_os)
746746 {
747 LLOGLN(10, ("rdpComposite: gettig dirty"));
747 LLOGLN(10, ("rdpComposite: getting dirty"));
748748 pDstPriv->is_dirty = 1;
749749 dirty_type = g_doing_font ? RDI_IMGLL : RDI_IMGLY;
750750 pDirtyPriv = pDstPriv;
187187 pGC->alu == GXnoop ||
188188 pGC->alu == GXand ||
189189 pGC->alu == GXcopy /*||
190 pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */
190 pGC->alu == GXxor*/)) /* todo, why doesn't xor work? */
191191 {
192192 draw_item_add_fill_region(pDirtyPriv, fill_reg, pGC->fgPixel,
193193 pGC->alu);
209209 pGC->alu == GXnoop ||
210210 pGC->alu == GXand ||
211211 pGC->alu == GXcopy /*||
212 pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */
212 pGC->alu == GXxor*/)) /* todo, why doesn't xor work? */
213213 {
214214 rdpup_set_fgcolor(pGC->fgPixel);
215215 rdpup_set_opcode(pGC->alu);
252252 pGC->alu == GXnoop ||
253253 pGC->alu == GXand ||
254254 pGC->alu == GXcopy /*||
255 pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */
255 pGC->alu == GXxor*/)) /* todo, why doesn't xor work? */
256256 {
257257 LLOGLN(10, ("rdpPolyFillRect: 3"));
258258 draw_item_add_fill_region(pDirtyPriv, &clip_reg,
279279 pGC->alu == GXnoop ||
280280 pGC->alu == GXand ||
281281 pGC->alu == GXcopy /*||
282 pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */
282 pGC->alu == GXxor*/)) /* todo, why doesn't xor work? */
283283 {
284284 rdpup_set_fgcolor(pGC->fgPixel);
285285 rdpup_set_opcode(pGC->alu);
607607 /******************************************************************************/
608608 /* returns boolean */
609609 static int
610 region_interect_at_all(RegionPtr reg_small, RegionPtr reg_big)
610 region_intersect_at_all(RegionPtr reg_small, RegionPtr reg_big)
611611 {
612612 int rv;
613613 RegionRec reg;
718718 {
719719 if ((di->type == RDI_TEXT) && (di_prev->type == RDI_IMGLY))
720720 {
721 if (region_interect_at_all(di->reg, di_prev->reg))
721 if (region_intersect_at_all(di->reg, di_prev->reg))
722722 {
723723 di_prev->type = RDI_IMGLL;
724724 }
502502 PictFormatPtr format;
503503 } GlyphListRec, *GlyphListPtr;
504504 */
505 /* see ghyphstr.h but the follow is not in there
505 /* see glyphstr.h but the following is not in there
506506 typedef struct _XGlyphInfo {
507507 unsigned short width;
508508 unsigned short height;
556556 post_process = 1;
557557 if (g_do_dirty_os)
558558 {
559 LLOGLN(10, ("rdpGlyphu: gettig dirty"));
559 LLOGLN(10, ("rdpGlyphu: getting dirty"));
560560 pDstPriv->is_dirty = 1;
561561 dirty_type = RDI_IMGLL;
562562 pDirtyPriv = pDstPriv;
2525 flags right so control down is used to determine between pause and
2626 num lock */
2727 /* this should be fixed in rdesktop */
28 /* g_pause_spe flag for specal control sent by ms client before scan code
28 /* g_pause_spe flag for special control sent by ms client before scan code
2929 69 is sent to tell that its pause, not num lock. both pause and num
3030 lock use scan code 69 */
3131
6767 static OsTimerPtr g_timer = 0;
6868 static int g_x = 0;
6969 static int g_y = 0;
70 static int g_timer_schedualed = 0;
70 static int g_timer_scheduled = 0;
7171 static int g_delay_motion = 1; /* turn on or off */
7272 static int g_use_evdev = 0;
7373
181181 if (ctrls->enabled_ctrls & XkbRepeatKeysMask)
182182 {
183183 LLOGLN(10, ("rdpChangeKeyboardControl: autoRepeat on"));
184 /* schedual to turn off the autorepeat after 100 ms so any app
184 /* schedule to turn off the autorepeat after 100 ms so any app
185185 * polling it will be happy it's on */
186186 g_kbtimer = TimerSet(g_kbtimer, 0, 100,
187187 rdpInDeferredUpdateCallback, 0);
237237 0x0000042C Azeri Latin
238238 0x0000042F FYRO Macedonian
239239 0x00000437 Georgian
240 0x00000438 Faeroese
240 0x00000438 Faroese
241241 0x00000439 Devanagari - INSCRIPT
242242 0x0000043A Maltese 47-key
243243 0x0000043B Norwegian with Sami
858858 rdpDeferredInputCallback(OsTimerPtr timer, CARD32 now, pointer arg)
859859 {
860860 LLOGLN(10, ("rdpDeferredInputCallback:"));
861 g_timer_schedualed = 0;
861 g_timer_scheduled = 0;
862862 if ((g_old_x != g_x) || (g_old_y != g_y))
863863 {
864864 rdpEnqueueMotion(g_x, g_y);
883883 return;
884884 }
885885 send_now = (buttonMask ^ g_old_button_mask) || (g_delay_motion == 0);
886 LLOGLN(10, ("PtrAddEvent: send_now %d g_timer_schedualed %d",
887 send_now, g_timer_schedualed));
886 LLOGLN(10, ("PtrAddEvent: send_now %d g_timer_scheduled %d",
887 send_now, g_timer_scheduled));
888888 if (send_now)
889889 {
890 if (g_timer_schedualed)
891 {
892 g_timer_schedualed = 0;
890 if (g_timer_scheduled)
891 {
892 g_timer_scheduled = 0;
893893 TimerCancel(g_timer);
894894 }
895895 if ((g_old_x != x) || (g_old_y != y))
922922 {
923923 g_x = x;
924924 g_y = y;
925 if (!g_timer_schedualed)
926 {
927 g_timer_schedualed = 1;
925 if (!g_timer_scheduled)
926 {
927 g_timer_scheduled = 1;
928928 g_timer = TimerSet(g_timer, 0, 60, rdpDeferredInputCallback, 0);
929929 }
930930 }
5555 #define XSCAN_KP_3 89
5656 #define XSCAN_KP_0 90
5757 #define XSCAN_KP_Decimal 91
58 /* "/ ?" on br keybaord */
58 /* "/ ?" on br keyboard */
5959 #define XSCAN_97 97 /* ------------------------------? */
6060 #define XSCAN_Enter 108 /* 104 */ /* on keypad */
6161 #define XSCAN_Control_R 109 /* 105 */
8080 #define XSCAN_Menu 117 /* 135 */
8181 #define XSCAN_LMeta 156
8282 #define XSCAN_RMeta 156
83 #define XSCAN_211 211 /* "/ ?" on br keybaord, "\ _" on jp keyboard */
83 #define XSCAN_211 211 /* "/ ?" on br keyboard, "\ _" on jp keyboard */
8484
8585 /******************************************************************************/
8686 void
278278 break;
279279
280280 case RDPSCAN_115:
281 rdpEnqueueKey(type, XSCAN_211); /* "/ ?" on br keybaord, "\ _" on jp keyboard */
281 rdpEnqueueKey(type, XSCAN_211); /* "/ ?" on br keyboard, "\ _" on jp keyboard */
282282 break;
283283
284284 case RDPSCAN_126:
5555 #define XSCAN_KP_3 89
5656 #define XSCAN_KP_0 90
5757 #define XSCAN_KP_Decimal 91
58 /* "/ ?" on br keybaord */
58 /* "/ ?" on br keyboard */
5959 #define XSCAN_97 97
6060 #define XSCAN_Enter 104 /* on keypad */
6161 #define XSCAN_Control_R 105
277277 break;
278278
279279 case RDPSCAN_115:
280 rdpEnqueueKey(type, XSCAN_97); /* "/ ?" on br keybaord */
280 rdpEnqueueKey(type, XSCAN_97); /* "/ ?" on br keyboard */
281281 break;
282282
283283 case RDPSCAN_126:
4040 #endif
4141
4242 #if XRDP_DISABLE_LINUX_ABSTRACT
43 /* because including <X11/Xtrans/Xtransint.h> in problematic
43 /* because including <X11/Xtrans/Xtransint.h> is problematic
4444 * we dup a small struct
4545 * we need to set flags to zero to turn off abstract sockets */
4646 struct _MyXtransport
138138 rdpPointerNewEventScreen
139139 };
140140
141 int glGetBufferSubData(void);
142
141143 /******************************************************************************/
142144 /* returns error, zero is good */
143145 static int
187189 g_redBits = 8;
188190 g_greenBits = 8;
189191 g_blueBits = 8;
192 }
193 else if (g_bpp == 33)
194 {
195 /* will never happen */
196 glGetBufferSubData();
190197 }
191198 else
192199 {
413420 g_rdpScreen.CloseScreen = pScreen->CloseScreen;
414421 /* GC procedures */
415422 g_rdpScreen.CreateGC = pScreen->CreateGC;
416 /* Pixmap procudures */
423 /* Pixmap procedures */
417424 g_rdpScreen.CreatePixmap = pScreen->CreatePixmap;
418425 g_rdpScreen.DestroyPixmap = pScreen->DestroyPixmap;
419426
589596 /******************************************************************************/
590597 /* this is the first function called, it can be called many times
591598 returns the number or parameters processed
592 if it dosen't apply to the rdp part, return 0 */
599 if it doesn't apply to the rdp part, return 0 */
593600 int
594601 ddxProcessArgument(int argc, char **argv, int i)
595602 {
653660 OsVendorInit(void)
654661 {
655662 #if XRDP_DISABLE_LINUX_ABSTRACT
656 /* turn off the Linux abstract unix doamin sockets TRANS_ABSTRACT */
663 /* turn off the Linux abstract unix domain sockets TRANS_ABSTRACT */
657664 /* TRANS_NOLISTEN = 1 << 3 */
658665 _XSERVTransSocketLocalFuncs.flags = 0;
659666 #endif
253253
254254 //#ifdef _XSERVER64
255255 #if 1
256 /* I thought xalloc whould work here but I guess not, why, todo */
256 /* I thought xalloc would work here but I guess not, why, todo */
257257 rv = (char *)malloc(size);
258258 #else
259259 rv = (char *)Xalloc(size);
278278 {
279279 //#ifdef _XSERVER64
280280 #if 1
281 /* I thought xfree whould work here but I guess not, why, todo */
281 /* I thought xfree would work here but I guess not, why, todo */
282282 free(ptr);
283283 #else
284284 Xfree(ptr);
3737
3838 static XID g_wid = 0;
3939
40 static int g_panning = 0;
41
42 #define LOG_LEVEL 1
43 #define LLOG(_level, _args) \
44 do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
45 #define LLOGLN(_level, _args) \
46 do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
47
4048 /******************************************************************************/
4149 Bool
4250 rdpRRRegisterSize(ScreenPtr pScreen, int width, int height)
6775 Bool
6876 rdpRRGetInfo(ScreenPtr pScreen, Rotation *pRotations)
6977 {
70 int width;
71 int height;
72
7378 ErrorF("rdpRRGetInfo:\n");
7479 *pRotations = RR_Rotate_0;
75
76 width = g_rdpScreen.width;
77 height = g_rdpScreen.height;
78 rdpRRRegisterSize(pScreen, width, height);
7980 return TRUE;
8081 }
8182
213214 rdpRRCrtcGetGamma(ScreenPtr pScreen, RRCrtcPtr crtc)
214215 {
215216 ErrorF("rdpRRCrtcGetGamma:\n");
217 crtc->gammaSize = 1;
218 if (crtc->gammaRed == NULL)
219 {
220 crtc->gammaRed = g_malloc(32, 1);
221 }
222 if (crtc->gammaBlue == NULL)
223 {
224 crtc->gammaBlue = g_malloc(32, 1);
225 }
226 if (crtc->gammaGreen == NULL)
227 {
228 crtc->gammaGreen = g_malloc(32, 1);
229 }
216230 return TRUE;
217231 }
218232
255269 BoxPtr trackingArea, INT16 *border)
256270 {
257271 ErrorF("rdpRRGetPanning:\n");
272
273 if (!g_panning)
274 {
275 return FALSE;
276 }
258277
259278 if (totalArea != 0)
260279 {
291310 ErrorF("rdpRRSetPanning:\n");
292311 return TRUE;
293312 }
313
314 /******************************************************************************/
315 static RROutputPtr
316 rdpRRAddOutput(const char *aname, int x, int y, int width, int height)
317 {
318 RRModePtr mode;
319 RRCrtcPtr crtc;
320 RROutputPtr output;
321 xRRModeInfo modeInfo;
322 char name[64];
323
324 sprintf (name, "%dx%d", width, height);
325 memset (&modeInfo, 0, sizeof(modeInfo));
326 modeInfo.width = width;
327 modeInfo.height = height;
328 modeInfo.nameLength = strlen(name);
329 mode = RRModeGet(&modeInfo, name);
330 if (mode == 0)
331 {
332 LLOGLN(0, ("rdpRRAddOutput: RRModeGet failed"));
333 return 0;
334 }
335
336 crtc = RRCrtcCreate(g_pScreen, NULL);
337 if (crtc == 0)
338 {
339 LLOGLN(0, ("rdpRRAddOutput: RRCrtcCreate failed"));
340 RRModeDestroy(mode);
341 return 0;
342 }
343 output = RROutputCreate(g_pScreen, aname, strlen(aname), NULL);
344 if (output == 0)
345 {
346 LLOGLN(0, ("rdpRRAddOutput: RROutputCreate failed"));
347 RRCrtcDestroy(crtc);
348 RRModeDestroy(mode);
349 return 0;
350 }
351 if (!RROutputSetClones(output, NULL, 0))
352 {
353 LLOGLN(0, ("rdpRRAddOutput: RROutputSetClones failed"));
354 }
355 if (!RROutputSetModes(output, &mode, 1, 0))
356 {
357 LLOGLN(0, ("rdpRRAddOutput: RROutputSetModes failed"));
358 }
359 if (!RROutputSetCrtcs(output, &crtc, 1))
360 {
361 LLOGLN(0, ("rdpRRAddOutput: RROutputSetCrtcs failed"));
362 }
363 if (!RROutputSetConnection(output, RR_Connected))
364 {
365 LLOGLN(0, ("rdpRRAddOutput: RROutputSetConnection failed"));
366 }
367 RRCrtcNotify(crtc, mode, x, y, RR_Rotate_0, NULL, 1, &output);
368
369 return output;
370 }
371
372 /******************************************************************************/
373 static void
374 RRSetPrimaryOutput(rrScrPrivPtr pScrPriv, RROutputPtr output)
375 {
376 if (pScrPriv->primaryOutput == output)
377 {
378 return;
379 }
380 /* clear the old primary */
381 if (pScrPriv->primaryOutput)
382 {
383 RROutputChanged(pScrPriv->primaryOutput, 0);
384 pScrPriv->primaryOutput = NULL;
385 }
386 /* set the new primary */
387 if (output)
388 {
389 pScrPriv->primaryOutput = output;
390 RROutputChanged(output, 0);
391 }
392 pScrPriv->layoutChanged = TRUE;
393 }
394
395 /******************************************************************************/
396 int
397 rdpRRSetRdpOutputs(void)
398 {
399 rrScrPrivPtr pRRScrPriv;
400 int index;
401 int width;
402 int height;
403 char text[256];
404 RROutputPtr output;
405
406 pRRScrPriv = rrGetScrPriv(g_pScreen);
407
408 LLOGLN(0, ("rdpRRSetRdpOutputs: numCrtcs %d", pRRScrPriv->numCrtcs));
409 while (pRRScrPriv->numCrtcs > 0)
410 {
411 RRCrtcDestroy(pRRScrPriv->crtcs[0]);
412 }
413 LLOGLN(0, ("rdpRRSetRdpOutputs: numOutputs %d", pRRScrPriv->numOutputs));
414 while (pRRScrPriv->numOutputs > 0)
415 {
416 RROutputDestroy(pRRScrPriv->outputs[0]);
417 }
418
419 if (g_rdpScreen.client_info.monitorCount == 0)
420 {
421 rdpRRAddOutput("rdp0", 0, 0, g_rdpScreen.width, g_rdpScreen.height);
422 }
423 else
424 {
425 for (index = 0; index < g_rdpScreen.client_info.monitorCount; index++)
426 {
427 snprintf(text, 255, "rdp%d", index);
428 width = g_rdpScreen.client_info.minfo[index].right - g_rdpScreen.client_info.minfo[index].left + 1;
429 height = g_rdpScreen.client_info.minfo[index].bottom - g_rdpScreen.client_info.minfo[index].top + 1;
430 output = rdpRRAddOutput(text,
431 g_rdpScreen.client_info.minfo[index].left,
432 g_rdpScreen.client_info.minfo[index].top,
433 width, height);
434 if ((output != 0) && (g_rdpScreen.client_info.minfo[index].is_primary))
435 {
436 RRSetPrimaryOutput(pRRScrPriv, output);
437 }
438 }
439 }
440
441 for (index = 0; index < pRRScrPriv->numOutputs; index++)
442 {
443 RROutputSetCrtcs(pRRScrPriv->outputs[index], pRRScrPriv->crtcs,
444 pRRScrPriv->numCrtcs);
445 }
446
447 return 0;
448 }
449
5656 rdpRRSetPanning(ScreenPtr pScrn, RRCrtcPtr crtc, BoxPtr totalArea,
5757 BoxPtr trackingArea, INT16* border);
5858
59 int
60 rdpRRSetRdpOutputs(void);
61
5962 #endif
2121 #include "rdp.h"
2222 #include "xrdp_rail.h"
2323 #include "rdpglyph.h"
24 #include "rdprandr.h"
2425
2526 #include <signal.h>
2627 #include <sys/ipc.h>
711712 static int
712713 process_screen_size_msg(int width, int height, int bpp)
713714 {
714 RRScreenSizePtr pSize;
715715 int mmwidth;
716716 int mmheight;
717717 int bytes;
782782
783783 mmwidth = PixelToMM(width);
784784 mmheight = PixelToMM(height);
785
786 pSize = RRRegisterSize(g_pScreen, width, height, mmwidth, mmheight);
787 RRSetCurrentConfig(g_pScreen, RR_Rotate_0, 0, pSize);
788785
789786 if ((g_rdpScreen.width != width) || (g_rdpScreen.height != height))
790787 {
929926 int y;
930927 int cx;
931928 int cy;
929 int index;
932930 RegionRec reg;
933931 BoxRec box;
934932
11181116 {
11191117 LLOGLN(0, (" client can not do new(color) cursor"));
11201118 }
1119
11211120 if (g_rdpScreen.client_info.monitorCount > 0)
11221121 {
11231122 LLOGLN(0, (" client can do multimon"));
11241123 LLOGLN(0, (" client monitor data, monitorCount= %d", g_rdpScreen.client_info.monitorCount));
1124 box.x1 = g_rdpScreen.client_info.minfo[0].left;
1125 box.y1 = g_rdpScreen.client_info.minfo[0].top;
1126 box.x2 = g_rdpScreen.client_info.minfo[0].right;
1127 box.y2 = g_rdpScreen.client_info.minfo[0].bottom;
11251128 g_do_multimon = 1;
1129 /* adjust monitor info so it's not negative */
1130 for (index = 1; index < g_rdpScreen.client_info.monitorCount; index++)
1131 {
1132 box.x1 = min(box.x1, g_rdpScreen.client_info.minfo[index].left);
1133 box.y1 = min(box.y1, g_rdpScreen.client_info.minfo[index].top);
1134 box.x2 = max(box.x2, g_rdpScreen.client_info.minfo[index].right);
1135 box.y2 = max(box.y2, g_rdpScreen.client_info.minfo[index].bottom);
1136 }
1137 for (index = 0; index < g_rdpScreen.client_info.monitorCount; index++)
1138 {
1139 g_rdpScreen.client_info.minfo[index].left -= box.x1;
1140 g_rdpScreen.client_info.minfo[index].top -= box.y1;
1141 g_rdpScreen.client_info.minfo[index].right -= box.x1;
1142 g_rdpScreen.client_info.minfo[index].bottom -= box.y1;
1143 LLOGLN(0, (" left %d top %d right %d bottom %d",
1144 g_rdpScreen.client_info.minfo[index].left,
1145 g_rdpScreen.client_info.minfo[index].top,
1146 g_rdpScreen.client_info.minfo[index].right,
1147 g_rdpScreen.client_info.minfo[index].bottom));
1148 }
1149 rdpRRSetRdpOutputs();
1150 RRTellChanged(g_pScreen);
11261151 }
11271152 else
11281153 {
11291154 LLOGLN(0, (" client can not do multimon"));
11301155 g_do_multimon = 0;
1156 rdpRRSetRdpOutputs();
1157 RRTellChanged(g_pScreen);
11311158 }
11321159
11331160 rdpLoadLayout(&(g_rdpScreen.client_info));
13181345 g_disconnect_timeout_s = 60;
13191346 }
13201347
1321 rdpLog("kill disconencted [%d] timeout [%d] sec\n", g_do_kill_disconnected,
1348 rdpLog("kill disconnected [%d] timeout [%d] sec\n", g_do_kill_disconnected,
13221349 g_disconnect_timeout_s);
13231350
13241351 return 1;
21212148 safety = 0;
21222149 while (RegionContainsRect(g_shm_reg, &box))
21232150 {
2124 /* instread of rdpup_end_update, call rdpup_send_pending */
2151 /* instead of rdpup_end_update, call rdpup_send_pending */
21252152 rdpup_send_pending();
21262153 rdpup_begin_update();
21272154 safety++;
28222849
28232850 /******************************************************************************/
28242851 int
2825 rdpup_add_char(int font, int charactor, short x, short y, int cx, int cy,
2852 rdpup_add_char(int font, int character, short x, short y, int cx, int cy,
28262853 char* bmpdata, int bmpdata_bytes)
28272854 {
28282855 if (g_connected)
28332860 out_uint16_le(g_out_s, 18 + bmpdata_bytes); /* size */
28342861 g_count++;
28352862 out_uint16_le(g_out_s, font);
2836 out_uint16_le(g_out_s, charactor);
2863 out_uint16_le(g_out_s, character);
28372864 out_uint16_le(g_out_s, x);
28382865 out_uint16_le(g_out_s, y);
28392866 out_uint16_le(g_out_s, cx);
28462873
28472874 /******************************************************************************/
28482875 int
2849 rdpup_add_char_alpha(int font, int charactor, short x, short y, int cx, int cy,
2876 rdpup_add_char_alpha(int font, int character, short x, short y, int cx, int cy,
28502877 char* bmpdata, int bmpdata_bytes)
28512878 {
28522879 if (g_connected)
28572884 out_uint16_le(g_out_s, 18 + bmpdata_bytes); /* size */
28582885 g_count++;
28592886 out_uint16_le(g_out_s, font);
2860 out_uint16_le(g_out_s, charactor);
2887 out_uint16_le(g_out_s, character);
28612888 out_uint16_le(g_out_s, x);
28622889 out_uint16_le(g_out_s, y);
28632890 out_uint16_le(g_out_s, cx);
164164 rdpXvSetPortAttribute(ClientPtr client, XvPortPtr pPort, Atom attribute,
165165 INT32 value)
166166 {
167 LLOGLN(0, ("rdpXvxSetPortAttribute:"));
167 LLOGLN(0, ("rdpXvSetPortAttribute:"));
168168 return Success;
169169 }
170170
1111 libpng-1.2.46.tar.gz : libpng-1.2.46 :
1212 pixman-0.30.0.tar.bz2 : pixman-0.30.0 : --disable-gtk
1313 freetype-2.4.6.tar.bz2 : freetype-2.4.6 :
14 fontconfig-2.8.0.tar.gz : fontconfig-2.8.0 :
14 fontconfig-2.8.0.tar.gz : fontconfig-2.8.0 : --disable-docs
1515 cairo-1.8.8.tar.gz : cairo-1.8.8 :
1616 expat-2.0.1.tar.gz : expat-2.0.1 :
1717 xextproto-7.1.2.tar.bz2 : xextproto-7.1.2 :
6969
7070 if ((fd = open(filename, O_RDONLY)) < 0)
7171 {
72 printf("error opeing %s\n", filename);
72 printf("error opening %s\n", filename);
7373 return -1;
7474 }
7575
204204 }
205205 else
206206 {
207 printf("XListFonts() reted NULL\n");
207 printf("XListFonts() returned NULL\n");
208208 }
209209
210210 #endif
00 # Process this file with autoconf to produce a configure script
11
22 AC_PREREQ(2.59)
3 AC_INIT([xrdpmod], [0.1.0], [xrdp-devel@lists.sourceforge.net])
3 AC_INIT([xrdpmod], [0.1.0], [xrdp-devel@googlegroups.com])
44 AC_CONFIG_HEADERS(config_ac.h:config_ac-h.in)
55 AM_INIT_AUTOMAKE([1.6 foreign])
66 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
88 amd64/i420_to_rgb32_amd64_sse2.asm \
99 amd64/yuy2_to_rgb32_amd64_sse2.asm \
1010 amd64/uyvy_to_rgb32_amd64_sse2.asm \
11 amd64/a8r8g8b8_to_a8b8g8r8_box_amd64_sse2.asm
11 amd64/a8r8g8b8_to_a8b8g8r8_box_amd64_sse2.asm \
12 amd64/a8r8g8b8_to_nv12_box_amd64_sse2.asm
1213 EXTRA_FLAGS += -DSIMD_USE_ACCEL=1
1314 endif
1415
1819 x86/i420_to_rgb32_x86_sse2.asm \
1920 x86/yuy2_to_rgb32_x86_sse2.asm \
2021 x86/uyvy_to_rgb32_x86_sse2.asm \
21 x86/a8r8g8b8_to_a8b8g8r8_box_x86_sse2.asm
22 x86/a8r8g8b8_to_a8b8g8r8_box_x86_sse2.asm \
23 x86/a8r8g8b8_to_nv12_box_x86_sse2.asm
2224 EXTRA_FLAGS += -DSIMD_USE_ACCEL=1
2325 endif
2426
0 ;
1 ;Copyright 2015 Jay Sorg
2 ;
3 ;Permission to use, copy, modify, distribute, and sell this software and its
4 ;documentation for any purpose is hereby granted without fee, provided that
5 ;the above copyright notice appear in all copies and that both that
6 ;copyright notice and this permission notice appear in supporting
7 ;documentation.
8 ;
9 ;The above copyright notice and this permission notice shall be included in
10 ;all copies or substantial portions of the Software.
11 ;
12 ;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 ;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 ;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 ;OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
16 ;AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17 ;CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 ;
19 ;ARGB to NV12
20 ;amd64 SSE2
21 ;
22 ; notes
23 ; address s8 should be aligned on 16 bytes, will be slower if not
24 ; width should be multile of 8 and > 0
25 ; height should be even and > 0
26
27 SECTION .data
28
29 align 16
30
31 cd255 times 4 dd 255
32
33 cw255 times 8 dw 255
34 cw16 times 8 dw 16
35 cw128 times 8 dw 128
36 cw66 times 8 dw 66
37 cw129 times 8 dw 129
38 cw25 times 8 dw 25
39 cw38 times 8 dw 38
40 cw74 times 8 dw 74
41 cw112 times 8 dw 112
42 cw94 times 8 dw 94
43 cw18 times 8 dw 18
44 cw2 times 8 dw 2
45
46 SECTION .text
47
48 %macro PROC 1
49 align 16
50 global %1
51 %1:
52 %endmacro
53
54 %define LS8 [rsp + 0] ; s8
55 %define LSRC_STRIDE [rsp + 8] ; src_stride
56 %define LD8_Y [rsp + 16] ; d8_y
57 %define LDST_Y_STRIDE [rsp + 24] ; dst_stride_y
58 %define LD8_UV [rsp + 32] ; d8_uv
59 %define LDST_UV_STRIDE [rsp + 40] ; dst_stride_uv
60 %define LU1 [rsp + 48] ; first line U, 8 bytes
61 %define LV1 [rsp + 56] ; first line V, 8 bytes
62 %define LU2 [rsp + 64] ; second line U, 8 bytes
63 %define LV2 [rsp + 72] ; second line V, 8 bytes
64
65 %define LWIDTH [rsp + 104] ; width
66 %define LHEIGHT [rsp + 112] ; height
67
68 ;The first six integer or pointer arguments are passed in registers
69 ; RDI, RSI, RDX, RCX, R8, and R9
70
71 ;int
72 ;a8r8g8b8_to_nv12_box_amd64_sse2(char *s8, int src_stride,
73 ; char *d8_y, int dst_stride_y,
74 ; char *d8_uv, int dst_stride_uv,
75 ; int width, int height);
76 PROC a8r8g8b8_to_nv12_box_amd64_sse2
77 push rbx
78 push rbp
79 sub rsp, 80 ; local vars, 80 bytes
80
81 mov LS8, rdi ; s8
82 mov LSRC_STRIDE, rsi ; src_stride
83 mov LD8_Y, rdx ; d8_y
84 mov LDST_Y_STRIDE, rcx ; dst_stride_y
85 mov LD8_UV, r8 ; d8_uv
86 mov LDST_UV_STRIDE, r9 ; dst_stride_uv
87
88 pxor xmm7, xmm7
89
90 mov ebx, LHEIGHT ; ebx = height
91 shr ebx, 1 ; doing 2 lines at a time
92
93 row_loop1:
94 mov rsi, LS8 ; s8
95 mov rdi, LD8_Y ; d8_y
96 mov rdx, LD8_UV ; d8_uv
97
98 mov ecx, LWIDTH ; ecx = width
99 shr ecx, 3 ; doing 8 pixels at a time
100
101 loop1:
102 ; first line
103 movdqu xmm0, [rsi] ; 4 pixels, 16 bytes
104 movdqa xmm1, xmm0 ; blue
105 pand xmm1, [rel cd255] ; blue
106 movdqa xmm2, xmm0 ; green
107 psrld xmm2, 8 ; green
108 pand xmm2, [rel cd255] ; green
109 movdqa xmm3, xmm0 ; red
110 psrld xmm3, 16 ; red
111 pand xmm3, [rel cd255] ; red
112
113 movdqu xmm0, [rsi + 16] ; 4 pixels, 16 bytes
114 movdqa xmm4, xmm0 ; blue
115 pand xmm4, [rel cd255] ; blue
116 movdqa xmm5, xmm0 ; green
117 psrld xmm5, 8 ; green
118 pand xmm5, [rel cd255] ; green
119 movdqa xmm6, xmm0 ; red
120 psrld xmm6, 16 ; red
121 pand xmm6, [rel cd255] ; red
122
123 packssdw xmm1, xmm4 ; xmm1 = 8 blues
124 packssdw xmm2, xmm5 ; xmm2 = 8 greens
125 packssdw xmm3, xmm6 ; xmm3 = 8 reds
126
127 ; _Y = (( 66 * _R + 129 * _G + 25 * _B + 128) >> 8) + 16;
128 movdqa xmm4, xmm1 ; blue
129 movdqa xmm5, xmm2 ; green
130 movdqa xmm6, xmm3 ; red
131 pmullw xmm4, [rel cw25]
132 pmullw xmm5, [rel cw129]
133 pmullw xmm6, [rel cw66]
134 paddw xmm4, xmm5
135 paddw xmm4, xmm6
136 paddw xmm4, [rel cw128]
137 psrlw xmm4, 8
138 paddw xmm4, [rel cw16]
139 packuswb xmm4, xmm7
140 movq [rdi], xmm4 ; out 8 bytes yyyyyyyy
141
142 ; _U = ((-38 * _R - 74 * _G + 112 * _B + 128) >> 8) + 128;
143 movdqa xmm4, xmm1 ; blue
144 movdqa xmm5, xmm2 ; green
145 movdqa xmm6, xmm3 ; red
146 pmullw xmm4, [rel cw112]
147 pmullw xmm5, [rel cw74]
148 pmullw xmm6, [rel cw38]
149 psubw xmm4, xmm5
150 psubw xmm4, xmm6
151 paddw xmm4, [rel cw128]
152 psraw xmm4, 8
153 paddw xmm4, [rel cw128]
154 packuswb xmm4, xmm7
155 movq LU1, xmm4 ; save for later
156
157 ; _V = ((112 * _R - 94 * _G - 18 * _B + 128) >> 8) + 128;
158 movdqa xmm6, xmm1 ; blue
159 movdqa xmm5, xmm2 ; green
160 movdqa xmm4, xmm3 ; red
161 pmullw xmm4, [rel cw112]
162 pmullw xmm5, [rel cw94]
163 pmullw xmm6, [rel cw18]
164 psubw xmm4, xmm5
165 psubw xmm4, xmm6
166 paddw xmm4, [rel cw128]
167 psraw xmm4, 8
168 paddw xmm4, [rel cw128]
169 packuswb xmm4, xmm7
170 movq LV1, xmm4 ; save for later
171
172 ; go down to second line
173 add rsi, LSRC_STRIDE
174 add rdi, LDST_Y_STRIDE
175
176 ; second line
177 movdqu xmm0, [rsi] ; 4 pixels, 16 bytes
178 movdqa xmm1, xmm0 ; blue
179 pand xmm1, [rel cd255] ; blue
180 movdqa xmm2, xmm0 ; green
181 psrld xmm2, 8 ; green
182 pand xmm2, [rel cd255] ; green
183 movdqa xmm3, xmm0 ; red
184 psrld xmm3, 16 ; red
185 pand xmm3, [rel cd255] ; red
186
187 movdqu xmm0, [rsi + 16] ; 4 pixels, 16 bytes
188 movdqa xmm4, xmm0 ; blue
189 pand xmm4, [rel cd255] ; blue
190 movdqa xmm5, xmm0 ; green
191 psrld xmm5, 8 ; green
192 pand xmm5, [rel cd255] ; green
193 movdqa xmm6, xmm0 ; red
194 psrld xmm6, 16 ; red
195 pand xmm6, [rel cd255] ; red
196
197 packssdw xmm1, xmm4 ; xmm1 = 8 blues
198 packssdw xmm2, xmm5 ; xmm2 = 8 greens
199 packssdw xmm3, xmm6 ; xmm3 = 8 reds
200
201 ; _Y = (( 66 * _R + 129 * _G + 25 * _B + 128) >> 8) + 16;
202 movdqa xmm4, xmm1 ; blue
203 movdqa xmm5, xmm2 ; green
204 movdqa xmm6, xmm3 ; red
205 pmullw xmm4, [rel cw25]
206 pmullw xmm5, [rel cw129]
207 pmullw xmm6, [rel cw66]
208 paddw xmm4, xmm5
209 paddw xmm4, xmm6
210 paddw xmm4, [rel cw128]
211 psrlw xmm4, 8
212 paddw xmm4, [rel cw16]
213 packuswb xmm4, xmm7
214 movq [rdi], xmm4 ; out 8 bytes yyyyyyyy
215
216 ; _U = ((-38 * _R - 74 * _G + 112 * _B + 128) >> 8) + 128;
217 movdqa xmm4, xmm1 ; blue
218 movdqa xmm5, xmm2 ; green
219 movdqa xmm6, xmm3 ; red
220 pmullw xmm4, [rel cw112]
221 pmullw xmm5, [rel cw74]
222 pmullw xmm6, [rel cw38]
223 psubw xmm4, xmm5
224 psubw xmm4, xmm6
225 paddw xmm4, [rel cw128]
226 psraw xmm4, 8
227 paddw xmm4, [rel cw128]
228 packuswb xmm4, xmm7
229 movq LU2, xmm4 ; save for later
230
231 ; _V = ((112 * _R - 94 * _G - 18 * _B + 128) >> 8) + 128;
232 movdqa xmm6, xmm1 ; blue
233 movdqa xmm5, xmm2 ; green
234 movdqa xmm4, xmm3 ; red
235 pmullw xmm4, [rel cw112]
236 pmullw xmm5, [rel cw94]
237 pmullw xmm6, [rel cw18]
238 psubw xmm4, xmm5
239 psubw xmm4, xmm6
240 paddw xmm4, [rel cw128]
241 psraw xmm4, 8
242 paddw xmm4, [rel cw128]
243 packuswb xmm4, xmm7
244 movq LV2, xmm4 ; save for later
245
246 ; uv add and divide(average)
247 movq mm1, LU1 ; u from first line
248 movq mm3, mm1
249 pand mm1, [rel cw255]
250 psrlw mm3, 8
251 pand mm3, [rel cw255]
252 paddw mm1, mm3 ; add
253 movq mm2, LU2 ; u from second line
254 movq mm3, mm2
255 pand mm2, [rel cw255]
256 paddw mm1, mm2 ; add
257 psrlw mm3, 8
258 pand mm3, [rel cw255]
259 paddw mm1, mm3 ; add
260 paddw mm1, [rel cw2] ; add 2
261 psrlw mm1, 2 ; div 4
262
263 movq mm2, LV1 ; v from first line
264 movq mm4, mm2
265 pand mm2, [rel cw255]
266 psrlw mm4, 8
267 pand mm4, [rel cw255]
268 paddw mm2, mm4 ; add
269 movq mm3, LV2 ; v from second line
270 movq mm4, mm3
271 pand mm3, [rel cw255]
272 paddw mm2, mm3 ; add
273 psrlw mm4, 8
274 pand mm4, [rel cw255]
275 paddw mm2, mm4 ; add
276 paddw mm2, [rel cw2] ; add 2
277 psrlw mm2, 2 ; div 4
278
279 packuswb mm1, mm1
280 packuswb mm2, mm2
281
282 punpcklbw mm1, mm2 ; uv
283 movq [rdx], mm1 ; out 8 bytes uvuvuvuv
284
285 ; go up to first line
286 sub rsi, LSRC_STRIDE
287 sub rdi, LDST_Y_STRIDE
288
289 ; move right
290 lea rsi, [rsi + 32]
291 lea rdi, [rdi + 8]
292 lea rdx, [rdx + 8]
293
294 dec ecx
295 jnz loop1
296
297 ; update s8
298 mov rax, LS8 ; s8
299 add rax, LSRC_STRIDE ; s8 += src_stride
300 add rax, LSRC_STRIDE ; s8 += src_stride
301 mov LS8, rax
302
303 ; update d8_y
304 mov rax, LD8_Y ; d8_y
305 add rax, LDST_Y_STRIDE ; d8_y += dst_stride_y
306 add rax, LDST_Y_STRIDE ; d8_y += dst_stride_y
307 mov LD8_Y, rax
308
309 ; update d8_uv
310 mov rax, LD8_UV ; d8_uv
311 add rax, LDST_UV_STRIDE ; d8_uv += dst_stride_uv
312 mov LD8_UV, rax
313
314 dec ebx
315 jnz row_loop1
316
317 mov rax, 0 ; return value
318 add rsp, 80 ; local vars, 80 bytes
319 pop rbp
320 pop rbx
321 ret
322 align 16
323
00 /*
1 Copyright 2014 Jay Sorg
1 Copyright 2014-2015 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
3737 a8r8g8b8_to_a8b8g8r8_box_amd64_sse2(char *s8, int src_stride,
3838 char *d8, int dst_stride,
3939 int width, int height);
40 int
41 a8r8g8b8_to_nv12_box_amd64_sse2(char *s8, int src_stride,
42 char *d8_y, int dst_stride_y,
43 char *d8_uv, int dst_stride_uv,
44 int width, int height);
4045
4146 #endif
4247
00 /*
1 Copyright 2005-2014 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
141141 int old_button_mask;
142142 int button_mask;
143143 DeviceIntPtr device;
144 int old_cursor_x;
145 int old_cursor_y;
144146 };
145147 typedef struct _rdpPointer rdpPointer;
146148
213215 typedef int (*copy_box_proc)(char *s8, int src_stride,
214216 char *d8, int dst_stride,
215217 int width, int height);
218 /* copy_box_proc but 2 dest */
219 typedef int (*copy_box_dst2_proc)(char *s8, int src_stride,
220 char *d8_y, int dst_stride_y,
221 char *d8_uv, int dst_stride_uv,
222 int width, int height);
216223
217224 /* move this to common header */
218225 struct _rdpRec
296303 OsTimerPtr xv_timer;
297304
298305 copy_box_proc a8r8g8b8_to_a8b8g8r8_box;
306 copy_box_dst2_proc a8r8g8b8_to_nv12_box;
299307
300308 /* multimon */
301309 int extra_outputs;
00 /*
11 Copyright 2014 Laxmikant Rashinkar
2 Copyright 2014-2015 Jay Sorg
2 Copyright 2014-2016 Jay Sorg
33
44 Permission to use, copy, modify, distribute, and sell this software and its
55 documentation for any purpose is hereby granted without fee, provided that
534534 U_sum += RDPCLAMP(U, 0, 255);
535535 V_sum += RDPCLAMP(V, 0, 255);
536536
537 d8uv[0] = U_sum / 4;
537 d8uv[0] = (U_sum + 2) / 4;
538538 d8uv++;
539 d8uv[0] = V_sum / 4;
539 d8uv[0] = (V_sum + 2) / 4;
540540 d8uv++;
541541 }
542542 }
572572 d8_uv += (box->x1 - dstx) * 1;
573573 width = box->x2 - box->x1;
574574 height = box->y2 - box->y1;
575 a8r8g8b8_to_nv12_box(s8, src_stride, d8_y, dst_stride_y,
576 d8_uv, dst_stride_uv, width, height);
575 clientCon->dev->a8r8g8b8_to_nv12_box(s8, src_stride,
576 d8_y, dst_stride_y,
577 d8_uv, dst_stride_uv,
578 width, height);
577579 }
578580 return 0;
579581 }
00 /*
11 Copyright 2014 Laxmikant Rashinkar
2 Copyright 2014-2015 Jay Sorg
2 Copyright 2014-2016 Jay Sorg
33
44 Permission to use, copy, modify, distribute, and sell this software and its
55 documentation for any purpose is hereby granted without fee, provided that
4141 a8r8g8b8_to_a8b8g8r8_box(char *s8, int src_stride,
4242 char *d8, int dst_stride,
4343 int width, int height);
44 extern _X_EXPORT int
45 a8r8g8b8_to_nv12_box(char *s8, int src_stride,
46 char *d8_y, int dst_stride_y,
47 char *d8_uv, int dst_stride_uv,
48 int width, int height);
4449
4550 #endif
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
133133 AddEnabledDevice(clientCon->sck);
134134 }
135135
136 #if 0
136 #if 1
137137 if (dev->clientConTail != NULL)
138138 {
139 LLOGLN(0, ("rdpClientConGotConnection: disconnecting only clientCon"));
139140 rdpClientConDisconnect(dev, dev->clientConTail);
140141 dev->clientConHead = NULL;
141142 dev->clientConTail = NULL;
864865 RRTellChanged(dev->pScreen);
865866 }
866867
867 //rdpLoadLayout(g_rdpScreen.client_info.keylayout);
868 /* rdpLoadLayout */
869 rdpInputKeyboardEvent(dev, 18, (long)(&(clientCon->client_info)),
870 0, 0, 0);
868871
869872 return 0;
870873 }
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2012-2015 Jay Sorg
1 Copyright 2012-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2012-2015 Jay Sorg
1 Copyright 2012-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2013-2015 Jay Sorg
1 Copyright 2013-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2013-2015 Jay Sorg
1 Copyright 2013-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2013-2015 Jay Sorg
1 Copyright 2013-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2013-2015 Jay Sorg
1 Copyright 2013-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2013-2015 Jay Sorg
1 Copyright 2013-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2013-2015 Jay Sorg
1 Copyright 2013-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2011-2014 Jay Sorg
1 Copyright 2011-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
268268
269269 if (!g_panning)
270270 {
271 return FALSE;
271 return FALSE;
272272 }
273273
274274 dev = rdpGetDevFromScreen(pScreen);
00 /*
1 Copyright 2011-2015 Jay Sorg
1 Copyright 2011-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2013-2015 Jay Sorg
1 Copyright 2013-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2013-2015 Jay Sorg
1 Copyright 2013-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2005-2015 Jay Sorg
1 Copyright 2005-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2014-2015 Jay Sorg
1 Copyright 2014-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
7171 dev->yuy2_to_rgb32 = YUY2_to_RGB32;
7272 dev->uyvy_to_rgb32 = UYVY_to_RGB32;
7373 dev->a8r8g8b8_to_a8b8g8r8_box = a8r8g8b8_to_a8b8g8r8_box;
74 dev->a8r8g8b8_to_nv12_box = a8r8g8b8_to_nv12_box;
7475 #if SIMD_USE_ACCEL
7576 if (g_simd_use_accel)
7677 {
8687 dev->yuy2_to_rgb32 = yuy2_to_rgb32_amd64_sse2;
8788 dev->uyvy_to_rgb32 = uyvy_to_rgb32_amd64_sse2;
8889 dev->a8r8g8b8_to_a8b8g8r8_box = a8r8g8b8_to_a8b8g8r8_box_amd64_sse2;
90 dev->a8r8g8b8_to_nv12_box = a8r8g8b8_to_nv12_box_amd64_sse2;
8991 LLOGLN(0, ("rdpSimdInit: sse2 amd64 yuv functions assigned"));
9092 }
9193 #elif defined(__x86__) || defined(_M_IX86) || defined(__i386__)
100102 dev->yuy2_to_rgb32 = yuy2_to_rgb32_x86_sse2;
101103 dev->uyvy_to_rgb32 = uyvy_to_rgb32_x86_sse2;
102104 dev->a8r8g8b8_to_a8b8g8r8_box = a8r8g8b8_to_a8b8g8r8_box_x86_sse2;
105 dev->a8r8g8b8_to_nv12_box = a8r8g8b8_to_nv12_box_x86_sse2;
103106 LLOGLN(0, ("rdpSimdInit: sse2 x86 yuv functions assigned"));
104107 }
105108 #endif
00 /*
1 Copyright 2014-2015 Jay Sorg
1 Copyright 2014-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2014-2015 Jay Sorg
1 Copyright 2014-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2014-2014 Jay Sorg
1 Copyright 2014-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2014-2015 Jay Sorg
1 Copyright 2014-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
00 /*
1 Copyright 2014-2015 Jay Sorg
1 Copyright 2014-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
0 ;
1 ;Copyright 2015 Jay Sorg
2 ;
3 ;Permission to use, copy, modify, distribute, and sell this software and its
4 ;documentation for any purpose is hereby granted without fee, provided that
5 ;the above copyright notice appear in all copies and that both that
6 ;copyright notice and this permission notice appear in supporting
7 ;documentation.
8 ;
9 ;The above copyright notice and this permission notice shall be included in
10 ;all copies or substantial portions of the Software.
11 ;
12 ;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 ;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 ;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 ;OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
16 ;AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17 ;CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 ;
19 ;ARGB to NV12
20 ;x86 SSE2
21 ;
22 ; notes
23 ; address s8 should be aligned on 16 bytes, will be slower if not
24 ; width should be multile of 8 and > 0
25 ; height should be even and > 0
26
27 SECTION .data
28
29 align 16
30
31 cd255 times 4 dd 255
32
33 cw255 times 8 dw 255
34 cw16 times 8 dw 16
35 cw128 times 8 dw 128
36 cw66 times 8 dw 66
37 cw129 times 8 dw 129
38 cw25 times 8 dw 25
39 cw38 times 8 dw 38
40 cw74 times 8 dw 74
41 cw112 times 8 dw 112
42 cw94 times 8 dw 94
43 cw18 times 8 dw 18
44 cw2 times 8 dw 2
45
46 SECTION .text
47
48 %macro PROC 1
49 align 16
50 global %1
51 %1:
52 %endmacro
53
54 %define LU1 [esp + 0] ; first line U, 8 bytes
55 %define LV1 [esp + 8] ; first line V, 8 bytes
56 %define LU2 [esp + 16] ; second line U, 8 bytes
57 %define LV2 [esp + 24] ; second line V, 8 bytes
58
59 %define LS8 [esp + 52] ; s8
60 %define LSRC_STRIDE [esp + 56] ; src_stride
61 %define LD8_Y [esp + 60] ; d8_y
62 %define LDST_Y_STRIDE [esp + 64] ; dst_stride_y
63 %define LD8_UV [esp + 68] ; d8_uv
64 %define LDST_UV_STRIDE [esp + 72] ; dst_stride_uv
65 %define LWIDTH [esp + 76] ; width
66 %define LHEIGHT [esp + 80] ; height
67
68 ;int
69 ;a8r8g8b8_to_nv12_box_x86_sse2(char *s8, int src_stride,
70 ; char *d8_y, int dst_stride_y,
71 ; char *d8_uv, int dst_stride_uv,
72 ; int width, int height);
73 PROC a8r8g8b8_to_nv12_box_x86_sse2
74 push ebx
75 push esi
76 push edi
77 push ebp
78 sub esp, 32 ; local vars, 32 bytes
79
80 pxor xmm7, xmm7
81
82 mov ebx, LHEIGHT ; ebx = height
83 shr ebx, 1 ; doing 2 lines at a time
84
85 row_loop1:
86 mov esi, LS8 ; s8
87 mov edi, LD8_Y ; d8_y
88 mov edx, LD8_UV ; d8_uv
89
90 mov ecx, LWIDTH ; ecx = width
91 shr ecx, 3 ; doing 8 pixels at a time
92
93 loop1:
94 ; first line
95 movdqu xmm0, [esi] ; 4 pixels, 16 bytes
96 movdqa xmm1, xmm0 ; blue
97 pand xmm1, [cd255] ; blue
98 movdqa xmm2, xmm0 ; green
99 psrld xmm2, 8 ; green
100 pand xmm2, [cd255] ; green
101 movdqa xmm3, xmm0 ; red
102 psrld xmm3, 16 ; red
103 pand xmm3, [cd255] ; red
104
105 movdqu xmm0, [esi + 16] ; 4 pixels, 16 bytes
106 movdqa xmm4, xmm0 ; blue
107 pand xmm4, [cd255] ; blue
108 movdqa xmm5, xmm0 ; green
109 psrld xmm5, 8 ; green
110 pand xmm5, [cd255] ; green
111 movdqa xmm6, xmm0 ; red
112 psrld xmm6, 16 ; red
113 pand xmm6, [cd255] ; red
114
115 packssdw xmm1, xmm4 ; xmm1 = 8 blues
116 packssdw xmm2, xmm5 ; xmm2 = 8 greens
117 packssdw xmm3, xmm6 ; xmm3 = 8 reds
118
119 ; _Y = (( 66 * _R + 129 * _G + 25 * _B + 128) >> 8) + 16;
120 movdqa xmm4, xmm1 ; blue
121 movdqa xmm5, xmm2 ; green
122 movdqa xmm6, xmm3 ; red
123 pmullw xmm4, [cw25]
124 pmullw xmm5, [cw129]
125 pmullw xmm6, [cw66]
126 paddw xmm4, xmm5
127 paddw xmm4, xmm6
128 paddw xmm4, [cw128]
129 psrlw xmm4, 8
130 paddw xmm4, [cw16]
131 packuswb xmm4, xmm7
132 movq [edi], xmm4 ; out 8 bytes yyyyyyyy
133
134 ; _U = ((-38 * _R - 74 * _G + 112 * _B + 128) >> 8) + 128;
135 movdqa xmm4, xmm1 ; blue
136 movdqa xmm5, xmm2 ; green
137 movdqa xmm6, xmm3 ; red
138 pmullw xmm4, [cw112]
139 pmullw xmm5, [cw74]
140 pmullw xmm6, [cw38]
141 psubw xmm4, xmm5
142 psubw xmm4, xmm6
143 paddw xmm4, [cw128]
144 psraw xmm4, 8
145 paddw xmm4, [cw128]
146 packuswb xmm4, xmm7
147 movq LU1, xmm4 ; save for later
148
149 ; _V = ((112 * _R - 94 * _G - 18 * _B + 128) >> 8) + 128;
150 movdqa xmm6, xmm1 ; blue
151 movdqa xmm5, xmm2 ; green
152 movdqa xmm4, xmm3 ; red
153 pmullw xmm4, [cw112]
154 pmullw xmm5, [cw94]
155 pmullw xmm6, [cw18]
156 psubw xmm4, xmm5
157 psubw xmm4, xmm6
158 paddw xmm4, [cw128]
159 psraw xmm4, 8
160 paddw xmm4, [cw128]
161 packuswb xmm4, xmm7
162 movq LV1, xmm4 ; save for later
163
164 ; go down to second line
165 add esi, LSRC_STRIDE
166 add edi, LDST_Y_STRIDE
167
168 ; second line
169 movdqu xmm0, [esi] ; 4 pixels, 16 bytes
170 movdqa xmm1, xmm0 ; blue
171 pand xmm1, [cd255] ; blue
172 movdqa xmm2, xmm0 ; green
173 psrld xmm2, 8 ; green
174 pand xmm2, [cd255] ; green
175 movdqa xmm3, xmm0 ; red
176 psrld xmm3, 16 ; red
177 pand xmm3, [cd255] ; red
178
179 movdqu xmm0, [esi + 16] ; 4 pixels, 16 bytes
180 movdqa xmm4, xmm0 ; blue
181 pand xmm4, [cd255] ; blue
182 movdqa xmm5, xmm0 ; green
183 psrld xmm5, 8 ; green
184 pand xmm5, [cd255] ; green
185 movdqa xmm6, xmm0 ; red
186 psrld xmm6, 16 ; red
187 pand xmm6, [cd255] ; red
188
189 packssdw xmm1, xmm4 ; xmm1 = 8 blues
190 packssdw xmm2, xmm5 ; xmm2 = 8 greens
191 packssdw xmm3, xmm6 ; xmm3 = 8 reds
192
193 ; _Y = (( 66 * _R + 129 * _G + 25 * _B + 128) >> 8) + 16;
194 movdqa xmm4, xmm1 ; blue
195 movdqa xmm5, xmm2 ; green
196 movdqa xmm6, xmm3 ; red
197 pmullw xmm4, [cw25]
198 pmullw xmm5, [cw129]
199 pmullw xmm6, [cw66]
200 paddw xmm4, xmm5
201 paddw xmm4, xmm6
202 paddw xmm4, [cw128]
203 psrlw xmm4, 8
204 paddw xmm4, [cw16]
205 packuswb xmm4, xmm7
206 movq [edi], xmm4 ; out 8 bytes yyyyyyyy
207
208 ; _U = ((-38 * _R - 74 * _G + 112 * _B + 128) >> 8) + 128;
209 movdqa xmm4, xmm1 ; blue
210 movdqa xmm5, xmm2 ; green
211 movdqa xmm6, xmm3 ; red
212 pmullw xmm4, [cw112]
213 pmullw xmm5, [cw74]
214 pmullw xmm6, [cw38]
215 psubw xmm4, xmm5
216 psubw xmm4, xmm6
217 paddw xmm4, [cw128]
218 psraw xmm4, 8
219 paddw xmm4, [cw128]
220 packuswb xmm4, xmm7
221 movq LU2, xmm4 ; save for later
222
223 ; _V = ((112 * _R - 94 * _G - 18 * _B + 128) >> 8) + 128;
224 movdqa xmm6, xmm1 ; blue
225 movdqa xmm5, xmm2 ; green
226 movdqa xmm4, xmm3 ; red
227 pmullw xmm4, [cw112]
228 pmullw xmm5, [cw94]
229 pmullw xmm6, [cw18]
230 psubw xmm4, xmm5
231 psubw xmm4, xmm6
232 paddw xmm4, [cw128]
233 psraw xmm4, 8
234 paddw xmm4, [cw128]
235 packuswb xmm4, xmm7
236 movq LV2, xmm4 ; save for later
237
238 ; uv add and divide(average)
239 movq mm1, LU1 ; u from first line
240 movq mm3, mm1
241 pand mm1, [cw255]
242 psrlw mm3, 8
243 pand mm3, [cw255]
244 paddw mm1, mm3 ; add
245 movq mm2, LU2 ; u from second line
246 movq mm3, mm2
247 pand mm2, [cw255]
248 paddw mm1, mm2 ; add
249 psrlw mm3, 8
250 pand mm3, [cw255]
251 paddw mm1, mm3 ; add
252 paddw mm1, [cw2] ; add 2
253 psrlw mm1, 2 ; div 4
254
255 movq mm2, LV1 ; v from first line
256 movq mm4, mm2
257 pand mm2, [cw255]
258 psrlw mm4, 8
259 pand mm4, [cw255]
260 paddw mm2, mm4 ; add
261 movq mm3, LV2 ; v from second line
262 movq mm4, mm3
263 pand mm3, [cw255]
264 paddw mm2, mm3 ; add
265 psrlw mm4, 8
266 pand mm4, [cw255]
267 paddw mm2, mm4 ; add
268 paddw mm2, [cw2] ; add 2
269 psrlw mm2, 2 ; div 4
270
271 packuswb mm1, mm1
272 packuswb mm2, mm2
273
274 punpcklbw mm1, mm2 ; uv
275 movq [edx], mm1 ; out 8 bytes uvuvuvuv
276
277 ; go up to first line
278 sub esi, LSRC_STRIDE
279 sub edi, LDST_Y_STRIDE
280
281 ; move right
282 lea esi, [esi + 32]
283 lea edi, [edi + 8]
284 lea edx, [edx + 8]
285
286 dec ecx
287 jnz loop1
288
289 ; update s8
290 mov eax, LS8 ; s8
291 add eax, LSRC_STRIDE ; s8 += src_stride
292 add eax, LSRC_STRIDE ; s8 += src_stride
293 mov LS8, eax
294
295 ; update d8_y
296 mov eax, LD8_Y ; d8_y
297 add eax, LDST_Y_STRIDE ; d8_y += dst_stride_y
298 add eax, LDST_Y_STRIDE ; d8_y += dst_stride_y
299 mov LD8_Y, eax
300
301 ; update d8_uv
302 mov eax, LD8_UV ; d8_uv
303 add eax, LDST_UV_STRIDE ; d8_uv += dst_stride_uv
304 mov LD8_UV, eax
305
306 dec ebx
307 jnz row_loop1
308
309 mov eax, 0 ; return value
310 add esp, 32 ; local vars, 32 bytes
311 pop ebp
312 pop edi
313 pop esi
314 pop ebx
315 ret
316 align 16
317
00 /*
1 Copyright 2014 Jay Sorg
1 Copyright 2014-2015 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
1616 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1717 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1818
19 x86 asm files
19 x86 asm functions
2020
2121 */
2222
3737 a8r8g8b8_to_a8b8g8r8_box_x86_sse2(char *s8, int src_stride,
3838 char *d8, int dst_stride,
3939 int width, int height);
40 int
41 a8r8g8b8_to_nv12_box_x86_sse2(char *s8, int src_stride,
42 char *d8_y, int dst_stride_y,
43 char *d8_uv, int dst_stride_uv,
44 int width, int height);
4045
4146 #endif
4247
0 ------------------------------------------------------
1 11/04/2015
2 ------------------------------------------------------
3
4 After normal make and make install, you can test Xorg startup with
5 Xorg -config xrdp/xorg.conf -logfile /tmp/Xjay.log -noreset -ac :10
6
07 ------------------------------------------------------
18 11/05/2014
29 ------------------------------------------------------
0
1 #OBJS = yuv2rgb_speed.o a8r8g8b8_to_nv12_box_x86_sse2.o
2 OBJS = yuv2rgb_speed.o a8r8g8b8_to_nv12_box_amd64_sse2.o
3
4 CFLAGS = -Wall -O2
5
6 LDFLAGS =
7
8 all: yuv2rgb_speed
9
10 yuv2rgb_speed: $(OBJS)
11 $(CC) -o yuv2rgb_speed $(OBJS) $(LDFLAGS)
12
13 clean:
14 rm -f $(OBJS) yuv2rgb_speed
15
16 a8r8g8b8_to_nv12_box_x86_sse2.o: ../../module/x86/a8r8g8b8_to_nv12_box_x86_sse2.asm
17 yasm -f elf32 ../../module/x86/a8r8g8b8_to_nv12_box_x86_sse2.asm
18
19 a8r8g8b8_to_nv12_box_amd64_sse2.o: ../../module/amd64/a8r8g8b8_to_nv12_box_amd64_sse2.asm
20 yasm -f elf64 ../../module/amd64/a8r8g8b8_to_nv12_box_amd64_sse2.asm
0 /*
1 Copyright 2014-2015 Jay Sorg
2
3 Permission to use, copy, modify, distribute, and sell this software and its
4 documentation for any purpose is hereby granted without fee, provided that
5 the above copyright notice appear in all copies and that both that
6 copyright notice and this permission notice appear in supporting
7 documentation.
8
9 The above copyright notice and this permission notice shall be included in
10 all copies or substantial portions of the Software.
11
12 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
16 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
19 yuv to rgb speed testing
20
21 */
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <fcntl.h>
27 #include <unistd.h>
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #include <sys/time.h>
31
32 /******************************************************************************/
33 //Y = ( ( 66 * R + 129 * G + 25 * B + 128) >> 8) + 16
34 //U = ( ( -38 * R - 74 * G + 112 * B + 128) >> 8) + 128
35 //V = ( ( 112 * R - 94 * G - 18 * B + 128) >> 8) + 128
36
37 //C = Y - 16
38 //D = U - 128
39 //E = V - 128
40 //R = clip(( 298 * C + 409 * E + 128) >> 8)
41 //G = clip(( 298 * C - 100 * D - 208 * E + 128) >> 8)
42 //B = clip(( 298 * C + 516 * D + 128) >> 8)
43
44 /******************************************************************************/
45 #define RDPCLAMP(_val, _lo, _hi) \
46 (_val) < (_lo) ? (_lo) : (_val) > (_hi) ? (_hi) : (_val)
47
48 // floating point
49 #define YUV2RGB1(_Y, _U, _V, _R, _G, _B) \
50 _Y = (0.257 * _R) + (0.504 * _G) + (0.098 * _B) + 16; \
51 _U = -(0.148 * _R) - (0.291 * _G) + (0.439 * _B) + 128; \
52 _V = (0.439 * _R) - (0.368 * _G) - (0.071 * _B) + 128;
53
54 #define YUV2RGB3(_Y, _U, _V, _R, _G, _B) \
55 _Y = (( 1053 * _R + 2064 * _G + 401 * _B) >> 12) + 16; \
56 _U = (( -606 * _R - 1192 * _G + 1798 * _B) >> 12) + 128; \
57 _V = (( 1798 * _R - 1507 * _G - 291 * _B) >> 12) + 128;
58
59 #define YUV2RGB2(_Y, _U, _V, _R, _G, _B) \
60 _Y = (( 16843 * _R + 33030 * _G + 6423 * _B) >> 16) + 16; \
61 _U = (( -9699 * _R - 19071 * _G + 28770 * _B) >> 16) + 128; \
62 _V = (( 28770 * _R - 24117 * _G - 4653 * _B) >> 16) + 128;
63
64 // original
65 #define YUV2RGB(_Y, _U, _V, _R, _G, _B) \
66 _Y = (( 66 * _R + 129 * _G + 25 * _B + 128) >> 8) + 16; \
67 _U = ((-38 * _R - 74 * _G + 112 * _B + 128) >> 8) + 128; \
68 _V = ((112 * _R - 94 * _G - 18 * _B + 128) >> 8) + 128;
69
70 #define YUV2RGB4(_Y, _U, _V, _R, _G, _B) \
71 _Y = ( ((1053 * ((_R) << 4)) >> 16) + ((2064 * ((_G) << 4)) >> 16) + (( 401 * ((_B) << 4)) >> 16)) + 16; \
72 _U = ( ((1798 * ((_B) << 4)) >> 16) - (( 606 * ((_R) << 4)) >> 16) - ((1192 * ((_G) << 4)) >> 16)) + 128; \
73 _V = ( ((1798 * ((_R) << 4)) >> 16) - ((1507 * ((_G) << 4)) >> 16) - (( 291 * ((_B) << 4)) >> 16)) + 128;
74
75 /******************************************************************************/
76 static int
77 a8r8g8b8_to_nv12_box(char *s8, int src_stride,
78 char *d8_y, int dst_stride_y,
79 char *d8_uv, int dst_stride_uv,
80 int width, int height)
81 {
82 int index;
83 int jndex;
84 int R;
85 int G;
86 int B;
87 int Y;
88 int U;
89 int V;
90 int U_sum;
91 int V_sum;
92 int pixel;
93 int lwidth;
94 int lheight;
95 int *s32a;
96 int *s32b;
97 char *d8ya;
98 char *d8yb;
99 char *d8uv;
100
101 /* must be even */
102 lwidth = width & ~1;
103 lheight = height & ~1;
104 for (jndex = 0; jndex < lheight; jndex += 2)
105 {
106 s32a = (int *) (s8 + src_stride * jndex);
107 s32b = (int *) (s8 + src_stride * (jndex + 1));
108 d8ya = d8_y + dst_stride_y * jndex;
109 d8yb = d8_y + dst_stride_y * (jndex + 1);
110 d8uv = d8_uv + dst_stride_uv * (jndex / 2);
111 for (index = 0; index < lwidth; index += 2)
112 {
113 U_sum = 0;
114 V_sum = 0;
115
116 pixel = s32a[0];
117 s32a++;
118 R = (pixel >> 16) & 0xff;
119 G = (pixel >> 8) & 0xff;
120 B = (pixel >> 0) & 0xff;
121 YUV2RGB(Y, U, V, R, G, B);
122 d8ya[0] = RDPCLAMP(Y, 0, 255);
123 d8ya++;
124 U_sum += RDPCLAMP(U, 0, 255);
125 V_sum += RDPCLAMP(V, 0, 255);
126
127 pixel = s32a[0];
128 s32a++;
129 R = (pixel >> 16) & 0xff;
130 G = (pixel >> 8) & 0xff;
131 B = (pixel >> 0) & 0xff;
132 YUV2RGB(Y, U, V, R, G, B);
133 d8ya[0] = RDPCLAMP(Y, 0, 255);
134 d8ya++;
135 U_sum += RDPCLAMP(U, 0, 255);
136 V_sum += RDPCLAMP(V, 0, 255);
137
138 pixel = s32b[0];
139 s32b++;
140 R = (pixel >> 16) & 0xff;
141 G = (pixel >> 8) & 0xff;
142 B = (pixel >> 0) & 0xff;
143 YUV2RGB(Y, U, V, R, G, B);
144 d8yb[0] = RDPCLAMP(Y, 0, 255);
145 d8yb++;
146 U_sum += RDPCLAMP(U, 0, 255);
147 V_sum += RDPCLAMP(V, 0, 255);
148
149 pixel = s32b[0];
150 s32b++;
151 R = (pixel >> 16) & 0xff;
152 G = (pixel >> 8) & 0xff;
153 B = (pixel >> 0) & 0xff;
154 YUV2RGB(Y, U, V, R, G, B);
155 d8yb[0] = RDPCLAMP(Y, 0, 255);
156 d8yb++;
157 U_sum += RDPCLAMP(U, 0, 255);
158 V_sum += RDPCLAMP(V, 0, 255);
159
160 d8uv[0] = (U_sum + 2) / 4;
161 d8uv++;
162 d8uv[0] = (V_sum + 2) / 4;
163 d8uv++;
164 }
165 }
166
167 return 0;
168 }
169
170 int output_params(void)
171 {
172 return 0;
173 }
174
175 void hexdump(const void* p, int len)
176 {
177 const unsigned char* line;
178 int i;
179 int thisline;
180 int offset;
181
182 line = (const unsigned char *)p;
183 offset = 0;
184
185 while (offset < len)
186 {
187 printf("%04x ", offset);
188 thisline = len - offset;
189
190 if (thisline > 16)
191 {
192 thisline = 16;
193 }
194
195 for (i = 0; i < thisline; i++)
196 {
197 printf("%02x ", line[i]);
198 }
199
200 for (; i < 16; i++)
201 {
202 printf(" ");
203 }
204
205 for (i = 0; i < thisline; i++)
206 {
207 printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.');
208 }
209
210 printf("\n");
211 offset += thisline;
212 line += thisline;
213 }
214 }
215
216 int lmemcmp(const void* data1, const void* data2, int bytes, int* offset)
217 {
218 int index;
219 int diff;
220 const unsigned char* ldata1;
221 const unsigned char* ldata2;
222
223 ldata1 = (const unsigned char*)data1;
224 ldata2 = (const unsigned char*)data2;
225
226 for (index = 0; index < bytes; index++)
227 {
228 diff = ldata1[index] - ldata2[index];
229 if (abs(diff) > 0)
230 {
231 *offset = index;
232 return 1;
233 }
234 }
235 return 0;
236 }
237
238 int get_mstime(void)
239 {
240 struct timeval tp;
241
242 gettimeofday(&tp, 0);
243 return (tp.tv_sec * 1000) + (tp.tv_usec / 1000);
244 }
245
246 int
247 a8r8g8b8_to_nv12_box_x86_sse2(char *s8, int src_stride,
248 char *d8_y, int dst_stride_y,
249 char *d8_uv, int dst_stride_uv,
250 int width, int height);
251 int
252 a8r8g8b8_to_nv12_box_amd64_sse2(char *s8, int src_stride,
253 char *d8_y, int dst_stride_y,
254 char *d8_uv, int dst_stride_uv,
255 int width, int height);
256
257 #define AL(_ptr) ((char*)((((size_t)_ptr) + 15) & ~15))
258
259 int main(int argc, char** argv)
260 {
261 int index;
262 int offset;
263 int fd;
264 int data_bytes;
265 int stime;
266 int etime;
267 char* rgb_data;
268 char* yuv_data1;
269 char* yuv_data2;
270 char* al_rgb_data;
271 char* al_yuv_data1;
272 char* al_yuv_data2;
273
274 if (argc == 1)
275 {
276 return output_params();
277 }
278 fd = open("/dev/urandom", O_RDONLY);
279 data_bytes = 1920 * 1080 * 4;
280 rgb_data = (char*)malloc(data_bytes + 16);
281 al_rgb_data = AL(rgb_data);
282 if (read(fd, al_rgb_data, data_bytes) != data_bytes)
283 {
284 printf("error\n");
285 }
286 close(fd);
287 data_bytes = 1920 * 1080 * 2;
288 yuv_data1 = (char*)malloc(data_bytes + 16);
289 yuv_data2 = (char*)malloc(data_bytes + 16);
290 al_yuv_data1 = AL(yuv_data1);
291 al_yuv_data2 = AL(yuv_data2);
292 stime = get_mstime();
293 for (index = 0; index < 100; index++)
294 {
295 a8r8g8b8_to_nv12_box(al_rgb_data, 1920 * 4,
296 al_yuv_data1, 1920,
297 al_yuv_data1 + 1920 * 1080,
298 1920, 1920, 1080);
299 }
300 etime = get_mstime();
301 printf("a8r8g8b8_to_nv12_box took %d\n", etime - stime);
302 stime = get_mstime();
303 for (index = 0; index < 100; index++)
304 {
305 //a8r8g8b8_to_nv12_box_x86_sse2
306 //a8r8g8b8_to_nv12_box_amd64_sse2
307 a8r8g8b8_to_nv12_box_amd64_sse2(al_rgb_data, 1920 * 4,
308 al_yuv_data2, 1920,
309 al_yuv_data2 + 1920 * 1080, 1920,
310 1920, 1080);
311 }
312 etime = get_mstime();
313 printf("a8r8g8b8_to_nv12_box_x86_sse2 took %d\n", etime - stime);
314 if (lmemcmp(al_yuv_data1, al_yuv_data2, 1920 * 1080 * 3 / 2, &offset) != 0)
315 {
316 printf("no match at offset %d\n", offset);
317 printf("first\n");
318 hexdump(al_yuv_data1 + offset, 16);
319 printf("second\n");
320 hexdump(al_yuv_data2 + offset, 16);
321 }
322 else
323 {
324 printf("match\n");
325 }
326 free(rgb_data);
327 free(yuv_data1);
328 free(yuv_data2);
329 return 0;
330 }
00 /*
1 Copyright 2013-2014 Jay Sorg
1 Copyright 2013-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
137137 rgb zeros1;
138138 Gamma zeros2;
139139 int got_res_match;
140 #if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1, 16, 0, 0, 0)
140141 char **modename;
142 #else
143 const char **modename;
144 #endif
141145 DisplayModePtr mode;
142146 rdpPtr dev;
143147
00 /*
1 Copyright 2013-2014 Jay Sorg
1 Copyright 2013-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
196196 NoSymbol, NoSymbol
197197 };
198198
199 static int
200 rdpLoadLayout(rdpKeyboard *keyboard, struct xrdp_client_info *client_info);
201
199202 /******************************************************************************/
200203 static void
201204 rdpEnqueueKey(DeviceIntPtr device, int type, int scancode)
433436 rdpEnqueueKey(keyboard->device, type, 117);
434437 break;
435438
439 case 89: /* left meta */
440 rdpEnqueueKey(keyboard->device, type, 156);
441 break;
442
443 case 90: /* right meta */
444 rdpEnqueueKey(keyboard->device, type, 156);
445 break;
446
447 case 115: /* "/ ?" on br keybaord */
448 sendDownUpKeyEvent(keyboard->device, type, 211);
449 break;
450
451 case 126: /* . on br keypad */
452 sendDownUpKeyEvent(keyboard->device, type, 134);
453 break;
454
436455 default:
437456 x_scancode = rdp_scancode + MIN_KEY_CODE;
438457
496515 case 17: /* from RDP_INPUT_SYNCHRONIZE */
497516 KbdSync(keyboard, param1);
498517 break;
518 case 18:
519 rdpLoadLayout(keyboard, (struct xrdp_client_info *) param1);
520 break;
521
499522 }
500523 return 0;
501524 }
675698 return Success;
676699 }
677700
678 #if XORG_VERSION_CURRENT < (((1) * 10000000) + ((9) * 100000) + ((0) * 1000) + 1)
701 #if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1, 9, 0, 1, 0)
679702
680703 /* debian 6
681704 ubuntu 10.04 */
754777 rdpkeybUnplug(pointer p)
755778 {
756779 LLOGLN(0, ("rdpkeybUnplug:"));
780 }
781
782 /******************************************************************************/
783 static int
784 reload_xkb(DeviceIntPtr keyboard, XkbRMLVOSet *set)
785 {
786 XkbSrvInfoPtr xkbi;
787 XkbDescPtr xkb;
788 KeySymsPtr keySyms;
789 KeyCode first_key;
790 CARD8 num_keys;
791 DeviceIntPtr pDev;
792
793 /* free some stuff so we can call InitKeyboardDeviceStruct again */
794 xkbi = keyboard->key->xkbInfo;
795 xkb = xkbi->desc;
796 XkbFreeKeyboard(xkb, 0, TRUE);
797 free(xkbi);
798 keyboard->key->xkbInfo = NULL;
799 free(keyboard->kbdfeed);
800 keyboard->kbdfeed = NULL;
801 free(keyboard->key);
802 keyboard->key = NULL;
803
804 /* init keyboard and reload the map */
805 if (!InitKeyboardDeviceStruct(keyboard, set, rdpkeybBell,
806 rdpkeybChangeKeyboardControl))
807 {
808 LLOGLN(0, ("rdpLoadLayout: InitKeyboardDeviceStruct failed"));
809 return 1;
810 }
811
812 /* notify the X11 clients eg. X_ChangeKeyboardMapping */
813 keySyms = XkbGetCoreMap(keyboard);
814 if (keySyms)
815 {
816 first_key = keySyms->minKeyCode;
817 num_keys = (keySyms->maxKeyCode - keySyms->minKeyCode) + 1;
818 XkbApplyMappingChange(keyboard, keySyms, first_key, num_keys,
819 NULL, serverClient);
820 for (pDev = inputInfo.devices; pDev; pDev = pDev->next)
821 {
822 if ((pDev->coreEvents || pDev == keyboard) && pDev->key)
823 {
824 XkbApplyMappingChange(pDev, keySyms, first_key, num_keys,
825 NULL, serverClient);
826 }
827 }
828 }
829 else
830 {
831 return 1;
832 }
833 return 0;
834 }
835
836 /******************************************************************************/
837 static int
838 rdpLoadLayout(rdpKeyboard *keyboard, struct xrdp_client_info *client_info)
839 {
840 XkbRMLVOSet set;
841
842 int keylayout = client_info->keylayout;
843
844 LLOGLN(0, ("rdpLoadLayout: keylayout 0x%8.8x variant %s display %s",
845 keylayout, client_info->variant, display));
846 memset(&set, 0, sizeof(set));
847 set.rules = "base";
848
849 set.model = "pc104";
850 set.layout = "us";
851 set.variant = "";
852 set.options = "";
853
854 if (strlen(client_info->model) > 0)
855 {
856 set.model = client_info->model;
857 }
858 if (strlen(client_info->variant) > 0)
859 {
860 set.variant = client_info->variant;
861 }
862 if (strlen(client_info->layout) > 0)
863 {
864 set.layout = client_info->layout;
865 }
866 if (strlen(client_info->options) > 0)
867 {
868 set.options = client_info->options;
869 }
870
871 reload_xkb(keyboard->device, &set);
872 reload_xkb(inputInfo.keyboard, &set);
873
874 return 0;
757875 }
758876
759877 /******************************************************************************/
00 /*
1 Copyright 2013-2014 Jay Sorg
1 Copyright 2013-2016 Jay Sorg
22
33 Permission to use, copy, modify, distribute, and sell this software and its
44 documentation for any purpose is hereby granted without fee, provided that
110110 int type;
111111 int buttons;
112112
113 rdpEnqueueMotion(pointer->device, pointer->cursor_x, pointer->cursor_y);
114
115113 LLOGLN(10, ("PtrAddEvent: x %d y %d", pointer->cursor_x, pointer->cursor_y));
114
115 if ((pointer->old_cursor_x != pointer->cursor_x) ||
116 (pointer->old_cursor_y != pointer->cursor_y))
117 {
118 rdpEnqueueMotion(pointer->device, pointer->cursor_x, pointer->cursor_y);
119 pointer->old_cursor_x = pointer->cursor_x;
120 pointer->old_cursor_y = pointer->cursor_y;
121 }
116122
117123 for (i = 0; i < 5; i++)
118124 {
260266 return Success;
261267 }
262268
263 #if XORG_VERSION_CURRENT < (((1) * 10000000) + ((9) * 100000) + ((0) * 1000) + 1)
269 #if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1, 9, 0, 1, 0)
264270
265271 /* debian 6
266272 ubuntu 10.04 */
0 EXTRA_DIST = xrdp.ini ad24b.bmp ad256.bmp xrdp24b.bmp xrdp256.bmp xrdp_logo.bmp sans-10.fv1 cursor0.cur cursor1.cur xrdp.h xrdp_types.h \
1 xrdp_encoder.h xrdp_keyboard.ini
2
30 EXTRA_INCLUDES =
41 EXTRA_LIBS =
52 EXTRA_FLAGS =
107 EXTRA_DEFINES = -DXRDP_NODEBUG
118 endif
129
13 if GOT_PREFIX
14 EXTRA_INCLUDES += -I$(prefix)/include
15 EXTRA_FLAGS += -L$(prefix)/lib -Wl,-rpath -Wl,$(prefix)/lib
16 endif
17
1810 if XRDP_RFXCODEC
1911 EXTRA_DEFINES += -DXRDP_RFXCODEC
2012 EXTRA_INCLUDES += -I$(top_srcdir)/librfxcodec/include
2113 EXTRA_LIBS += $(top_srcdir)/librfxcodec/src/librfxencode.a
2214 endif
2315
24 AM_CFLAGS = \
16 AM_CPPFLAGS = \
2517 -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
2618 -DXRDP_SBIN_PATH=\"${sbindir}\" \
2719 -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
2820 -DXRDP_PID_PATH=\"${localstatedir}/run\" \
29 -DXRDP_LIB_PATH=\"${libdir}\" \
30 $(EXTRA_DEFINES)
31
32 INCLUDES = \
21 -DXRDP_MODULE_PATH=\"${moduledir}\" \
22 $(EXTRA_DEFINES) \
3323 -I$(top_builddir) \
3424 -I$(top_srcdir)/common \
3525 -I$(top_srcdir)/libxrdp \
4131 xrdp_SOURCES = \
4232 funcs.c \
4333 lang.c \
34 xrdp.c \
35 xrdp.h \
4436 xrdp_bitmap.c \
45 xrdp.c \
4637 xrdp_cache.c \
38 xrdp_encoder.c \
39 xrdp_encoder.h \
4740 xrdp_font.c \
4841 xrdp_listen.c \
4942 xrdp_login_wnd.c \
5144 xrdp_painter.c \
5245 xrdp_process.c \
5346 xrdp_region.c \
54 xrdp_wm.c \
55 xrdp_encoder.c
47 xrdp_types.h \
48 xrdp_wm.c
5649
5750 xrdp_LDADD = \
5851 $(top_builddir)/common/libcommon.la \
6457
6558 xrdpsysconfdir=$(sysconfdir)/xrdp
6659
67 xrdpsysconf_DATA = \
60 dist_xrdpsysconf_DATA = \
6861 xrdp.ini \
6962 xrdp_keyboard.ini
7063
7164 xrdppkgdatadir=$(datadir)/xrdp
7265
73 xrdppkgdata_DATA = \
66 dist_xrdppkgdata_DATA = \
7467 ad24b.bmp \
7568 ad256.bmp \
7669 xrdp24b.bmp \
Binary diff not shown
262262 if (g_memcmp(lkeymap, keymap, sizeof(struct xrdp_keymap)) != 0)
263263 {
264264 log_message(LOG_LEVEL_WARNING,
265 "local keymap file for 0x%4.4x found and dosen't match "
265 "local keymap file for 0x%4.4x found and doesn't match "
266266 "built in keymap, using local keymap file", keylayout);
267267 }
268268
22
33 en-us
44
5 4000s in the down flags columm is from repeating keys(holding a key down)
5 4000s in the down flags column is from repeating keys(holding a key down)
66 When holding a key down, the down flags repeat but the up flags only
77 come once at the end.
88 Rdesktop does not do this as of yet. It always sends down and up
Binary diff not shown
3333 static long g_sync1_mutex = 0;
3434 static tbus g_term_event = 0;
3535 static tbus g_sync_event = 0;
36 /* syncronize stuff */
36 /* synchronize stuff */
3737 static int g_sync_command = 0;
3838 static long g_sync_result = 0;
3939 static long g_sync_param1 = 0;
106106
107107 threadid = tc_get_threadid();
108108 g_writeln("shutting down");
109 g_writeln("signal %d threadid %p", sig, threadid);
109 g_writeln("signal %d threadid %lld", sig, (long long)threadid);
110110
111111 if (!g_is_wait_obj_set(g_term_event))
112112 {
292292 }
293293
294294 /*****************************************************************************/
295 /* Basic sanity checks before any forking */
296 int
297 xrdp_sanity_check(void)
298 {
299 int intval = 1;
300 int host_be;
301 char key_file[256];
302
303 /* check compiled endian with actual endian */
304 host_be = !((int)(*(unsigned char *)(&intval)));
305
306 #if defined(B_ENDIAN)
307 if (!host_be)
308 {
309 g_writeln("Not a big endian machine, edit arch.h");
310 return 1;
311 }
312 #endif
313 #if defined(L_ENDIAN)
314 if (host_be)
315 {
316 g_writeln("Not a little endian machine, edit arch.h");
317 return 1;
318 }
319 #endif
320
321 /* check long, int and void* sizes */
322 if (sizeof(int) != 4)
323 {
324 g_writeln("unusable int size, must be 4");
325 return 1;
326 }
327
328 if (sizeof(long) != sizeof(void *))
329 {
330 g_writeln("long size must match void* size");
331 return 1;
332 }
333
334 if (sizeof(long) != 4 && sizeof(long) != 8)
335 {
336 g_writeln("unusable long size, must be 4 or 8");
337 return 1;
338 }
339
340 if (sizeof(tui64) != 8)
341 {
342 g_writeln("unusable tui64 size, must be 8");
343 return 1;
344 }
345
346 g_snprintf(key_file, 255, "%s/rsakeys.ini", XRDP_CFG_PATH);
347 if (!g_file_exist(key_file))
348 {
349 g_writeln("File %s is missing, create it using xrdp-keygen", key_file);
350 return 1;
351 }
352
353 return 0;
354 }
355
356 /*****************************************************************************/
295357 int DEFAULT_CC
296358 main(int argc, char **argv)
297359 {
298360 int test;
299 int host_be;
300361 char cfg_file[256];
301362 enum logReturns error;
302363 struct xrdp_startup_params *startup_params;
314375 DEBUG(("Argument %i - %s", test, argv[test]));
315376 }
316377
317 /* check compiled endian with actual endian */
318 test = 1;
319 host_be = !((int)(*(unsigned char *)(&test)));
320 #if defined(B_ENDIAN)
321 if (!host_be)
322 #endif
323 #if defined(L_ENDIAN)
324 if (host_be)
325 #endif
326 {
327 g_writeln("endian wrong, edit arch.h");
328 return 0;
329 }
330
331 /* check long, int and void* sizes */
332 if (sizeof(int) != 4)
333 {
334 g_writeln("unusable int size, must be 4");
335 return 0;
336 }
337
338 if (sizeof(long) != sizeof(void *))
339 {
340 g_writeln("long size must match void* size");
341 return 0;
342 }
343
344 if (sizeof(long) != 4 && sizeof(long) != 8)
345 {
346 g_writeln("unusable long size, must be 4 or 8");
347 return 0;
348 }
349
350 if (sizeof(tui64) != 8)
351 {
352 g_writeln("unusable tui64 size, must be 8");
353 return 0;
354 }
355
356378 g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
357379
358380 startup_params = (struct xrdp_startup_params *)
362384 {
363385 g_writeln("Unknown Parameter");
364386 g_writeln("xrdp -h for help");
365 g_writeln("");
387 g_writeln("%s", "");
366388 g_deinit();
367389 g_exit(0);
368390 }
372394
373395 if (startup_params->help)
374396 {
375 g_writeln("");
397 g_writeln("%s", "");
376398 g_writeln("xrdp: A Remote Desktop Protocol server.");
377399 g_writeln("Copyright (C) Jay Sorg 2004-2014");
378400 g_writeln("See http://www.xrdp.org for more information.");
379 g_writeln("");
401 g_writeln("%s", "");
380402 g_writeln("Usage: xrdp [options]");
381403 g_writeln(" --help: show help");
382404 g_writeln(" --nodaemon: don't fork into background");
383405 g_writeln(" --kill: shut down xrdp");
384406 g_writeln(" --port: tcp listen port");
385407 g_writeln(" --fork: fork on new connection");
386 g_writeln("");
408 g_writeln("%s", "");
387409 g_deinit();
388410 g_exit(0);
389411 }
390412
391413 if (startup_params->version)
392414 {
393 g_writeln("");
415 g_writeln("%s", "");
394416 g_writeln("xrdp: A Remote Desktop Protocol server.");
395417 g_writeln("Copyright (C) Jay Sorg 2004-2014");
396418 g_writeln("See http://www.xrdp.org for more information.");
397419 g_writeln("Version %s", PACKAGE_VERSION);
398 g_writeln("");
420 g_writeln("%s", "");
399421 g_deinit();
400422 g_exit(0);
401423 }
402424
425 if (xrdp_sanity_check() != 0)
426 {
427 g_writeln("Fatal error occurred, exiting");
428 g_deinit();
429 g_exit(1);
430 }
431
432 if (startup_params->kill)
433 {
434 g_writeln("stopping xrdp");
435 /* read the xrdp.pid file */
436 fd = -1;
437
438 if (g_file_exist(pid_file)) /* xrdp.pid */
439 {
440 fd = g_file_open(pid_file); /* xrdp.pid */
441 }
442
443 if (fd == -1)
444 {
445 g_writeln("problem opening to xrdp.pid [%s]", pid_file);
446 g_writeln("maybe its not running");
447 }
448 else
449 {
450 g_memset(text, 0, 32);
451 g_file_read(fd, text, 31);
452 pid = g_atoi(text);
453 g_writeln("stopping process id %d", pid);
454
455 if (pid > 0)
456 {
457 g_sigterm(pid);
458 }
459
460 g_file_close(fd);
461 }
462
463 g_deinit();
464 g_exit(0);
465 }
466
403467 /* starting logging subsystem */
404 error = log_start(cfg_file, "XRDP");
468 error = log_start(cfg_file, "xrdp");
405469
406470 if (error != LOG_STARTUP_OK)
407471 {
427491
428492 if (g_file_exist(pid_file)) /* xrdp.pid */
429493 {
430 g_writeln("It looks like xrdp is allready running,");
431 g_writeln("if not delete the xrdp.pid file and try again");
432 g_deinit();
433 g_exit(0);
434 }
435
436 if (startup_params->kill)
437 {
438 g_writeln("stopping xrdp");
439 /* read the xrdp.pid file */
440 fd = -1;
441
442 if (g_file_exist(pid_file)) /* xrdp.pid */
443 {
444 fd = g_file_open(pid_file); /* xrdp.pid */
445 }
446
447 if (fd == -1)
448 {
449 g_writeln("problem opening to xrdp.pid [%s]", pid_file);
450 g_writeln("maybe its not running");
451 }
452 else
453 {
454 g_memset(text, 0, 32);
455 g_file_read(fd, text, 31);
456 pid = g_atoi(text);
457 g_writeln("stopping process id %d", pid);
458
459 if (pid > 0)
460 {
461 g_sigterm(pid);
462 }
463
464 g_file_close(fd);
465 }
466
494 g_writeln("It looks like xrdp is already running.");
495 g_writeln("If not, delete %s and try again.", pid_file);
467496 g_deinit();
468497 g_exit(0);
469498 }
562591 g_threadid = tc_get_threadid();
563592 g_listen = xrdp_listen_create();
564593 g_signal_user_interrupt(xrdp_shutdown); /* SIGINT */
565 g_signal_kill(xrdp_shutdown); /* SIGKILL */
566594 g_signal_pipe(pipe_sig); /* SIGPIPE */
567595 g_signal_terminate(xrdp_shutdown); /* SIGTERM */
568596 g_signal_child_stop(xrdp_child); /* SIGCHLD */
135135 int
136136 callback(long id, int msg, long param1, long param2, long param3, long param4);
137137 int APP_CC
138 xrdp_wm_delete_all_childs(struct xrdp_wm* self);
138 xrdp_wm_delete_all_children(struct xrdp_wm* self);
139139 int APP_CC
140140 xrdp_wm_show_log(struct xrdp_wm *self);
141141 int APP_CC
380380 xrdp_mm_check_chan(struct xrdp_mm *self);
381381 int APP_CC
382382 xrdp_mm_check_wait_objs(struct xrdp_mm* self);
383 int APP_CC
384 xrdp_mm_frame_ack(struct xrdp_mm *self, int frame_id);
383385 int DEFAULT_CC
384386 server_begin_update(struct xrdp_mod* mod);
385387 int DEFAULT_CC
436438 int DEFAULT_CC
437439 server_set_mixmode(struct xrdp_mod* mod, int mixmode);
438440 int DEFAULT_CC
439 server_set_brush(struct xrdp_mod* mod, int x_orgin, int y_orgin,
441 server_set_brush(struct xrdp_mod* mod, int x_origin, int y_origin,
440442 int style, char* pattern);
441443 int DEFAULT_CC
442444 server_set_pen(struct xrdp_mod* mod, int style, int width);
443445 int DEFAULT_CC
444446 server_draw_line(struct xrdp_mod* mod, int x1, int y1, int x2, int y2);
445447 int DEFAULT_CC
446 server_add_char(struct xrdp_mod* mod, int font, int charactor,
448 server_add_char(struct xrdp_mod* mod, int font, int character,
447449 int offset, int baseline,
448450 int width, int height, char* data);
449451 int DEFAULT_CC
508510 struct rail_monitored_desktop_order* mdo,
509511 int flags);
510512 int DEFAULT_CC
511 server_add_char_alpha(struct xrdp_mod* mod, int font, int charactor,
513 server_add_char_alpha(struct xrdp_mod* mod, int font, int character,
512514 int offset, int baseline,
513515 int width, int height, char* data);
Binary diff not shown
164164 if (((bpp >= 24) && (data_as_int & 3)) ||
165165 (((bpp == 15) || (bpp == 16)) && (data_as_int & 1)))
166166 {
167 /* got to copy data here, it's not alligned
167 /* got to copy data here, it's not aligned
168168 other calls in this file assume alignment */
169169 Bpp = 4;
170170 switch (bpp)
12531253 painter->brush.pattern[5] = 0x55;
12541254 painter->brush.pattern[6] = 0xaa;
12551255 painter->brush.pattern[7] = 0x55;
1256 painter->brush.x_orgin = x;
1257 painter->brush.x_orgin = x;
1256 painter->brush.x_origin = x;
1257 painter->brush.x_origin = x;
12581258 painter->brush.style = 3;
12591259 painter->fg_color = self->wm->black;
12601260 painter->bg_color = self->parent->bg_color;
7878 {
7979 for (jndex = 0; jndex < 64 * 1024; jndex++)
8080 {
81 /* it's ok to deinit a zero'ed out struct list16 */
81 /* it's ok to deinit a zeroed out struct list16 */
8282 list16_deinit(&(self->crc16[index][jndex]));
8383 list16_init(&(self->crc16[index][jndex]));
8484 }
683683 }
684684
685685 /*****************************************************************************/
686 /* this does not take owership of pointer_item, it makes a copy */
686 /* this does not take ownership of pointer_item, it makes a copy */
687687 int APP_CC
688688 xrdp_cache_add_pointer_static(struct xrdp_cache *self,
689689 struct xrdp_pointer_item *pointer_item,
715715 }
716716
717717 /*****************************************************************************/
718 /* this does not take owership of brush_item_data, it makes a copy */
718 /* this does not take ownership of brush_item_data, it makes a copy */
719719 int APP_CC
720720 xrdp_cache_add_brush(struct xrdp_cache *self,
721721 char *brush_item_data)
110110 return 0;
111111 }
112112
113 LLOGLN(0, ("init_xrdp_encoder: initing encoder codec_id %d", self->codec_id));
113 LLOGLN(0, ("init_xrdp_encoder: initializing encoder codec_id %d", self->codec_id));
114114
115115 /* setup required FIFOs */
116116 self->fifo_to_proc = fifo_create();
3939
4040 # default
4141 [default]
42 # keyboard_type and keyboard_subtype is not readed for default section. It
43 # is only as a place holder to keep consistency. Default model/variant are
42 # keyboard_type and keyboard_subtype is not read for default section. It
43 # is only a placeholder to keep consistency. Default model/variant are
4444 # platform dependent, and could be overridden if needed.
4545 keyboard_type=0
4646 keyboard_subtype=0
9595
9696 /*****************************************************************************/
9797 int APP_CC
98 xrdp_wm_delete_all_childs(struct xrdp_wm *self)
98 xrdp_wm_delete_all_children(struct xrdp_wm *self)
9999 {
100100 int index;
101101 struct xrdp_bitmap *b;
227227 wm->mm->login_names->auto_free = 1;
228228 wm->mm->login_values = list_create();
229229 wm->mm->login_values->auto_free = 1;
230 /* gota copy these cause dialog gets freed */
230 /* will copy these cause dialog gets freed */
231231 list_append_list_strdup(mod_data->names, wm->mm->login_names, 0);
232232 list_append_list_strdup(mod_data->values, wm->mm->login_values, 0);
233233 xrdp_wm_set_login_mode(wm, 2);
256256 *
257257 * Users can create shortcuts where this information is configured. These
258258 * shortcuts simplifies login.
259 * @param orginalDomainInfo indata to this function
259 * @param originalDomainInfo indata to this function
260260 * @param comboMax the max number of combo choices
261261 * @param decode if true then we perform decoding of combo choice
262262 * @param resultBuffer must be pre allocated before calling this function.
265265 * 0 if the user does not prefer any choice.
266266 */
267267 static int APP_CC
268 xrdp_wm_parse_domain_information(char *orginalDomainInfo, int comboMax,
268 xrdp_wm_parse_domain_information(char *originalDomainInfo, int comboMax,
269269 int decode, char *resultBuffer)
270270 {
271271 int ret;
279279 ret = 0; /* default return value */
280280 /* resultBuffer assumed to be 256 chars */
281281 g_memset(resultBuffer, 0, 256);
282 if (orginalDomainInfo[0] == '_')
282 if (originalDomainInfo[0] == '_')
283283 {
284284 /* we try to locate a number indicating what combobox index the user
285285 * prefer the information is loaded from domain field, from the client
288288 * Underscore is a valid name in the domain.
289289 * Invalid chars are ignored in microsoft client therefore we use '_'
290290 * again. this sec '__' contains the split for index.*/
291 pos = g_pos(&orginalDomainInfo[1], "__");
291 pos = g_pos(&originalDomainInfo[1], "__");
292292 if (pos > 0)
293293 {
294294 /* an index is found we try to use it
297297 {
298298 g_memset(index, 0, 2);
299299 /* we just accept values 0-9 (one figure) */
300 g_strncpy(index, &orginalDomainInfo[pos + 3], 1);
300 g_strncpy(index, &originalDomainInfo[pos + 3], 1);
301301 comboxindex = g_htoi(index);
302302 g_snprintf(debugstr, 255, "Value of index (as char): %s "
303303 "(converted) : %d (max) : %d", index, comboxindex,
313313 }
314314 }
315315 /* pos limit the String to only contain the IP */
316 g_strncpy(resultBuffer, &orginalDomainInfo[1], pos);
316 g_strncpy(resultBuffer, &originalDomainInfo[1], pos);
317317 }
318318 else
319319 {
320320 /* log_message(LOG_LEVEL_DEBUG, "domain does not contain _"); */
321 g_strncpy(resultBuffer, &orginalDomainInfo[1], 255);
321 g_strncpy(resultBuffer, &originalDomainInfo[1], 255);
322322 }
323323 }
324324 return ret;
343343
344344 username_set = 0;
345345
346 /* free labels and edits, cause we gota create them */
346 /* free labels and edits, cause we will create them */
347347 /* creation or combo changed */
348348 for (index = 100; index < 200; index++)
349349 {
617617 int log_width;
618618 int log_height;
619619 int regular;
620 int primary_x_offset;
621 int primary_y_offset;
622 int index;
623 int x;
624 int y;
625 int cx;
626 int cy;
620627
621628 globals = &self->xrdp_config->cfg_globals;
629
630 primary_x_offset = self->screen->width / 2;
631 primary_y_offset = self->screen->height / 2;
622632
623633 log_width = globals->ls_width;
624634 log_height = globals->ls_height;
636646 }
637647
638648 regular = 0;
649 }
650
651 /* multimon scenario, draw login window on primary monitor */
652 if (self->client_info->monitorCount > 1)
653 {
654 for (index = 0; index < self->client_info->monitorCount; index++)
655 {
656 if (self->client_info->minfo_wm[index].is_primary)
657 {
658 x = self->client_info->minfo_wm[index].left;
659 y = self->client_info->minfo_wm[index].top;
660 cx = self->client_info->minfo_wm[index].right;
661 cy = self->client_info->minfo_wm[index].bottom;
662
663 primary_x_offset = x + ((cx - x) / 2);
664 primary_y_offset = y + ((cy - y) / 2);
665 break;
666 }
667 }
639668 }
640669
641670 /* draw login window */
646675 self->login_window->owner = self->screen;
647676 self->login_window->bg_color = globals->ls_bg_color;
648677
649 self->login_window->left = self->screen->width / 2 -
650 self->login_window->width / 2;
651
652 self->login_window->top = self->screen->height / 2 -
653 self->login_window->height / 2;
678 self->login_window->left = primary_x_offset - self->login_window->width / 2;
679 self->login_window->top = primary_y_offset - self->login_window->height / 2;
680
654681
655682 self->login_window->notify = xrdp_wm_login_notify;
656683
790817
791818 globals = &config->cfg_globals;
792819
793 /* set default values incase we can't get them from xrdp.ini file */
820 /* set default values in case we can't get them from xrdp.ini file */
794821 globals->ini_version = 1;
795822 globals->ls_top_window_bg_color = HCOLOR(bpp, xrdp_wm_htoi("009cb5"));
796823 globals->ls_bg_color = HCOLOR(bpp, xrdp_wm_htoi("dedede"));
797824 globals->ls_width = 350;
798825 globals->ls_height = 350;
799 globals->ls_bg_color = 0xdedede;
800826 globals->ls_logo_x_pos = 63;
801827 globals->ls_logo_y_pos = 50;
802828 globals->ls_label_x_pos = 30;
356356
357357 if (self->mod_handle == 0)
358358 {
359 g_snprintf(text, 255, "%s/%s", XRDP_LIB_PATH, lib);
359 g_snprintf(text, 255, "%s/%s", XRDP_MODULE_PATH, lib);
360360 /* Let the main thread load the lib,*/
361361 self->mod_handle = g_xrdp_sync(xrdp_mm_sync_load, (tintptr)text, 0);
362362
577577 else
578578 {
579579 xrdp_wm_show_log(self->wm);
580 if (self->wm->hide_log_window)
581 {
582 rv = 1;
583 }
580584 }
581585 }
582586
812816 return rv;
813817 }
814818
819 #if 0
815820 /*****************************************************************************/
816821 /* returns error
817822 process rail configure window order */
878883 g_free(rwso.visibility_rects);
879884 return rv;
880885 }
886 #endif
881887
882888 /*****************************************************************************/
883889 /* returns error
10511057 {
10521058 struct xrdp_mm *self;
10531059 struct stream *s;
1054 int id;
10551060 int size;
10561061 int error;
10571062
10681073 return 1;
10691074 }
10701075
1071 in_uint32_le(s, id);
1076 in_uint8s(s, 4); /* id */
10721077 in_uint32_le(s, size);
10731078 error = trans_force_read(trans, size - 8);
10741079
11461151
11471152 if (!(self->chan_trans_up))
11481153 {
1149 log_message(LOG_LEVEL_ERROR,"xrdp_mm_connect_chansrv: error in"
1154 log_message(LOG_LEVEL_ERROR,"xrdp_mm_connect_chansrv: error in "
11501155 "trans_connect chan");
11511156 }
11521157
11591164 }
11601165 else
11611166 {
1162 log_message(LOG_LEVEL_DEBUG,"xrdp_mm_connect_chansrv: chansrv"
1167 log_message(LOG_LEVEL_DEBUG,"xrdp_mm_connect_chansrv: chansrv "
11631168 "connect successful");
11641169 }
11651170 }
12301235 log_message(LOG_LEVEL_INFO,"xrdp_mm_process_login_response: "
12311236 "login failed");
12321237 xrdp_wm_show_log(self->wm);
1238 if (self->wm->hide_log_window)
1239 {
1240 rv = 1;
1241 }
12331242 }
12341243
12351244 cleanup_sesman_connection(self);
14491458 if (reply > 0)
14501459 {
14511460 /* We wait in 5 sec for a reply from sesman*/
1452 if (g_tcp_can_recv(socket, 5000))
1461 if (g_sck_can_recv(socket, 5000))
14531462 {
14541463 reply = g_tcp_recv(socket, in_s->end, 500, 0);
14551464
19741983 if (xrdp_mm_setup_mod2(self) == 0)
19751984 {
19761985 xrdp_wm_set_login_mode(self->wm, 10);
1977 rv = 0; /*sucess*/
1986 rv = 0; /*success*/
19781987 }
19791988 else
19801989 {
20052014 xrdp_mm_connect_chansrv(self, "", chansrvport);
20062015 }
20072016
2008 log_message(LOG_LEVEL_DEBUG,"returnvalue from xrdp_mm_connect %d", rv);
2017 log_message(LOG_LEVEL_DEBUG,"return value from xrdp_mm_connect %d", rv);
20092018
20102019 return rv;
20112020 }
21542163 if (trans_check_wait_objs(self->sesman_trans) != 0)
21552164 {
21562165 self->delete_sesman_trans = 1;
2166 if (self->wm->hide_log_window)
2167 {
2168 /* if hide_log_window, this is fatal */
2169 rv = 1;
2170 }
21572171 }
21582172 }
21592173
26442658
26452659 if (code == 1)
26462660 {
2647 g_writeln(msg);
2661 g_writeln("%s",msg);
26482662 return 0;
26492663 }
26502664
27622776
27632777 /*****************************************************************************/
27642778 int DEFAULT_CC
2765 server_set_brush(struct xrdp_mod *mod, int x_orgin, int y_orgin,
2779 server_set_brush(struct xrdp_mod *mod, int x_origin, int y_origin,
27662780 int style, char *pattern)
27672781 {
27682782 struct xrdp_painter *p;
27742788 return 0;
27752789 }
27762790
2777 p->brush.x_orgin = x_orgin;
2778 p->brush.y_orgin = y_orgin;
2791 p->brush.x_origin = x_origin;
2792 p->brush.y_origin = y_origin;
27792793 p->brush.style = style;
27802794 g_memcpy(p->brush.pattern, pattern, 8);
27812795 return 0;
28192833
28202834 /*****************************************************************************/
28212835 int DEFAULT_CC
2822 server_add_char(struct xrdp_mod *mod, int font, int charactor,
2836 server_add_char(struct xrdp_mod *mod, int font, int character,
28232837 int offset, int baseline,
28242838 int width, int height, char *data)
28252839 {
28332847 fi.data = data;
28342848 fi.bpp = 1;
28352849 return libxrdp_orders_send_font(((struct xrdp_wm *)mod->wm)->session,
2836 &fi, font, charactor);
2850 &fi, font, character);
28372851 }
28382852
28392853 /*****************************************************************************/
29152929 int fd;
29162930 int ret = 0;
29172931 char cfg_file[256];
2918 int pos;
29192932
29202933 g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
29212934 fd = g_file_open(cfg_file);
29242937 {
29252938 names->auto_free = 1;
29262939 values->auto_free = 1;
2927 pos = 0;
29282940
29292941 /* all values in this section can be valid channel names */
29302942 if (file_read_section(fd, "channels", names, values) == 0)
34563468
34573469 /*****************************************************************************/
34583470 int DEFAULT_CC
3459 server_add_char_alpha(struct xrdp_mod* mod, int font, int charactor,
3471 server_add_char_alpha(struct xrdp_mod* mod, int font, int character,
34603472 int offset, int baseline,
34613473 int width, int height, char* data)
34623474 {
34703482 fi.data = data;
34713483 fi.bpp = 8;
34723484 return libxrdp_orders_send_font(((struct xrdp_wm*)mod->wm)->session,
3473 &fi, font, charactor);
3474 }
3485 &fi, font, character);
3486 }
2828 self = (struct xrdp_painter *)g_malloc(sizeof(struct xrdp_painter), 1);
2929 self->wm = wm;
3030 self->session = session;
31 self->rop = 0xcc; /* copy gota use 0xcc*/
31 self->rop = 0xcc; /* copy will use 0xcc*/
3232 self->clip_children = 1;
3333 return self;
3434 }
914914 int k;
915915 int dx;
916916 int dy;
917 int palette_id;
918917 int cache_srcidx;
919918 int cache_mskidx;
920919
938937 dstx += dx;
939938 dsty += dy;
940939
941 palette_id = 0;
942940 cache_srcidx = src->item_index;
943941 cache_mskidx = -1;
944942 if (mskflags & 1)
201201 /* this function is just above */
202202 self->session->is_term = xrdp_is_term;
203203
204 if (libxrdp_process_incomming(self->session) == 0)
204 if (libxrdp_process_incoming(self->session) == 0)
205205 {
206206 init_stream(self->server_trans->in_s, 32 * 1024);
207207
252252 }
253253 else
254254 {
255 g_writeln("xrdp_process_main_loop: libxrdp_process_incomming failed");
255 g_writeln("xrdp_process_main_loop: libxrdp_process_incoming failed");
256256 /* this will try to send a disconnect,
257257 maybe should check that connection got far enough */
258258 libxrdp_disconnect(self->session);
6969 int (*server_set_bgcolor)(struct xrdp_mod* v, int bgcolor);
7070 int (*server_set_opcode)(struct xrdp_mod* v, int opcode);
7171 int (*server_set_mixmode)(struct xrdp_mod* v, int mixmode);
72 int (*server_set_brush)(struct xrdp_mod* v, int x_orgin, int y_orgin,
72 int (*server_set_brush)(struct xrdp_mod* v, int x_origin, int y_origin,
7373 int style, char* pattern);
7474 int (*server_set_pen)(struct xrdp_mod* v, int style,
7575 int width);
7676 int (*server_draw_line)(struct xrdp_mod* v, int x1, int y1, int x2, int y2);
77 int (*server_add_char)(struct xrdp_mod* v, int font, int charactor,
77 int (*server_add_char)(struct xrdp_mod* v, int font, int character,
7878 int offset, int baseline,
7979 int width, int height, char* data);
8080 int (*server_draw_text)(struct xrdp_mod* v, int font,
124124 int flags);
125125 int (*server_set_pointer_ex)(struct xrdp_mod* v, int x, int y, char* data,
126126 char* mask, int bpp);
127 int (*server_add_char_alpha)(struct xrdp_mod* mod, int font, int charactor,
127 int (*server_add_char_alpha)(struct xrdp_mod* mod, int font, int character,
128128 int offset, int baseline,
129129 int width, int height, char* data);
130130
222222 /* moved to xrdp_constants.h
223223 #define XRDP_BITMAP_CACHE_ENTRIES 2048 */
224224
225 /* differnce caches */
225 /* difference caches */
226226 struct xrdp_cache
227227 {
228228 struct xrdp_wm* wm; /* owner */
559559 xrdp_wm_load_static_pointers(self);
560560 self->screen->bg_color = self->xrdp_config->cfg_globals.ls_top_window_bg_color;
561561
562 if (self->session->client_info->rdp_autologin)
562 if (self->session->client_info->rdp_autologin || self->hide_log_window)
563563 {
564564 /*
565565 * NOTE: this should eventually be accessed from self->xrdp_config
575575 values->auto_free = 1;
576576
577577 /* look for module name to be loaded */
578 if (autorun_name[0] != 0) {
578 if (autorun_name[0] != 0)
579 {
579580 /* if autorun is configured in xrdp.ini, we enforce that module to be loaded */
580581 g_strncpy(section_name, autorun_name, 255);
581582 }
592593 {
593594 /* if no domain is passed, and no autorun in xrdp.ini,
594595 use the first item in the xrdp.ini
595 file thats not named
596 file that's not named
596597 'globals' or 'Logging' or 'channels' */
597 /* TODO: change this and have a 'autologin'
598 /* TODO: change this and have an 'autologin'
598599 line in globals section */
599600 file_read_sections(fd, names);
600601 for (index = 0; index < names->count; index++)
808809 self->painter->brush.pattern[5] = 0x55;
809810 self->painter->brush.pattern[6] = 0xaa;
810811 self->painter->brush.pattern[7] = 0x55;
811 self->painter->brush.x_orgin = 0;
812 self->painter->brush.x_orgin = 0;
812 self->painter->brush.x_origin = 0;
813 self->painter->brush.x_origin = 0;
813814 self->painter->brush.style = 3;
814815 self->painter->bg_color = self->black;
815816 self->painter->fg_color = self->white;
868869 }
869870
870871 /*****************************************************************************/
871 /* return true is rect is totaly exposed going in reverse z order */
872 /* return true if rect is totally exposed going in reverse z order */
872873 /* from wnd up */
873874 static int APP_CC
874875 xrdp_wm_is_rect_vis(struct xrdp_wm *self, struct xrdp_bitmap *wnd,
16861687 }
16871688
16881689 /******************************************************************************/
1689 /* this is the callbacks comming from libxrdp.so */
1690 /* this is the callbacks coming from libxrdp.so */
16901691 int DEFAULT_CC
16911692 callback(long id, int msg, long param1, long param2, long param3, long param4)
16921693 {
17581759
17591760 if (self->login_mode == 0)
17601761 {
1761 /* this is the inital state of the login window */
1762 /* this is the initial state of the login window */
17621763 xrdp_wm_set_login_mode(self, 1); /* put the wm in login mode */
17631764 list_clear(self->log);
1764 xrdp_wm_delete_all_childs(self);
1765 xrdp_wm_delete_all_children(self);
17651766 self->dragging = 0;
17661767 xrdp_wm_init(self);
17671768 }
17701771 if (xrdp_mm_connect(self->mm) == 0)
17711772 {
17721773 xrdp_wm_set_login_mode(self, 3); /* put the wm in connected mode */
1773 xrdp_wm_delete_all_childs(self);
1774 xrdp_wm_delete_all_children(self);
17741775 self->dragging = 0;
17751776 }
17761777 else
17801781 }
17811782 else if (self->login_mode == 10)
17821783 {
1783 xrdp_wm_delete_all_childs(self);
1784 xrdp_wm_delete_all_children(self);
17841785 self->dragging = 0;
17851786 xrdp_wm_set_login_mode(self, 11);
17861787 }
18651866 do
18661867 {
18671868 new_part_message = g_strndup(current_pointer, LOG_WINDOW_CHAR_PER_LINE) ;
1868 g_writeln(new_part_message);
1869 g_writeln("%s",new_part_message);
18691870 list_add_item(log, (long)new_part_message);
18701871 processedlen = processedlen + g_strlen(new_part_message);
18711872 current_pointer = current_pointer + g_strlen(new_part_message) ;
18821883 int h;
18831884 int xoffset;
18841885 int yoffset;
1886 int index;
1887 int primary_x_offset;
1888 int primary_y_offset;
1889
18851890
18861891 if (self->hide_log_window)
18871892 {
19081913 {
19091914 h = self->screen->height - 4;
19101915 yoffset = 2;
1916 }
1917
1918 primary_x_offset = 0;
1919 primary_y_offset = 0;
1920
1921 /* multimon scenario, draw log window on primary monitor */
1922 if (self->client_info->monitorCount > 1)
1923 {
1924 for (index = 0; index < self->client_info->monitorCount; index++)
1925 {
1926 if (self->client_info->minfo_wm[index].is_primary)
1927 {
1928 primary_x_offset = self->client_info->minfo_wm[index].left;
1929 primary_y_offset = self->client_info->minfo_wm[index].top;
1930 break;
1931 }
1932 }
19111933 }
19121934
19131935 /* log window */
19171939 self->log_wnd->parent = self->screen;
19181940 self->log_wnd->owner = self->screen;
19191941 self->log_wnd->bg_color = self->grey;
1920 self->log_wnd->left = xoffset;
1921 self->log_wnd->top = yoffset;
1942 self->log_wnd->left = primary_x_offset + xoffset;
1943 self->log_wnd->top = primary_y_offset + yoffset;
19221944 set_string(&(self->log_wnd->caption1), "Connection Log");
19231945 /* ok button */
19241946 but = xrdp_bitmap_create(DEFAULT_BUTTON_W, DEFAULT_BUTTON_H, self->screen->bpp, WND_TYPE_BUTTON, self);
3333 static long g_sync1_mutex = 0;
3434 static tbus g_term_event = 0;
3535 static tbus g_sync_event = 0;
36 /* syncronize stuff */
36 /* synchronize stuff */
3737 static int g_sync_command = 0;
3838 static long g_sync_result = 0;
3939 static long g_sync_param1 = 0;
343343 g_strncasecmp(argv[1], "--help", 255) == 0 ||
344344 g_strncasecmp(argv[1], "-h", 255) == 0)
345345 {
346 g_writeln("");
346 g_writeln("%s", "");
347347 g_writeln("xrdp: A Remote Desktop Protocol server.");
348348 g_writeln("Copyright (C) Jay Sorg 2004-2011");
349349 g_writeln("See http://xrdp.sourceforge.net for more information.");
350 g_writeln("");
350 g_writeln("%s", "");
351351 g_writeln("Usage: xrdp [options]");
352352 g_writeln(" -h: show help");
353353 g_writeln(" -install: install service");
354354 g_writeln(" -remove: remove service");
355 g_writeln("");
355 g_writeln("%s", "");
356356 g_exit(0);
357357 }
358358 else if (g_strncasecmp(argv[1], "-install", 255) == 0 ||
368368 g_exit(0);
369369 }
370370
371 /* check if service is allready installed */
371 /* check if service is already installed */
372372 sc_ser = OpenService(sc_man, "xrdp", SERVICE_ALL_ACCESS);
373373
374374 if (sc_ser == 0)
382382 }
383383 else
384384 {
385 g_writeln("error service is allready installed");
385 g_writeln("error service is already installed");
386386 CloseServiceHandle(sc_ser);
387387 CloseServiceHandle(sc_man);
388388 g_exit(0);
404404 g_exit(0);
405405 }
406406
407 /* check if service is allready installed */
407 /* check if service is already installed */
408408 sc_ser = OpenService(sc_man, "xrdp", SERVICE_ALL_ACCESS);
409409
410410 if (sc_ser == 0)
422422 {
423423 g_writeln("Unknown Parameter");
424424 g_writeln("xrdp -h for help");
425 g_writeln("");
425 g_writeln("%s", "");
426426 g_exit(0);
427427 }
428428 }
430430 {
431431 g_writeln("Unknown Parameter");
432432 g_writeln("xrdp -h for help");
433 g_writeln("");
433 g_writeln("%s", "");
434434 g_exit(0);
435435 }
436436
498498 g_strncasecmp(argv[1], "--help", 255) == 0 ||
499499 g_strncasecmp(argv[1], "-h", 255) == 0)
500500 {
501 g_writeln("");
501 g_writeln("%s", "");
502502 g_writeln("xrdp: A Remote Desktop Protocol server.");
503503 g_writeln("Copyright (C) Jay Sorg 2004-2011");
504504 g_writeln("See http://xrdp.sourceforge.net for more information.");
505 g_writeln("");
505 g_writeln("%s", "");
506506 g_writeln("Usage: xrdp [options]");
507507 g_writeln(" -h: show help");
508508 g_writeln(" -nodaemon: don't fork into background");
509509 g_writeln(" -kill: shut down xrdp");
510 g_writeln("");
510 g_writeln("%s", "");
511511 g_exit(0);
512512 }
513513 else if ((g_strncasecmp(argv[1], "-v", 255) == 0) ||
514514 (g_strncasecmp(argv[1], "--version", 255) == 0))
515515 {
516 g_writeln("");
516 g_writeln("%s", "");
517517 g_writeln("xrdp: A Remote Desktop Protocol server.");
518518 g_writeln("Copyright (C) Jay Sorg 2004-2011");
519519 g_writeln("See http://xrdp.sourceforge.net for more information.");
520520 g_writeln("Version %s", PACKAGE_VERSION);
521 g_writeln("");
521 g_writeln("%s", "");
522522 g_exit(0);
523523 }
524524 else
525525 {
526526 g_writeln("Unknown Parameter");
527527 g_writeln("xrdp -h for help");
528 g_writeln("");
528 g_writeln("%s", "");
529529 g_exit(0);
530530 }
531531 }
533533 {
534534 g_writeln("Unknown Parameter");
535535 g_writeln("xrdp -h for help");
536 g_writeln("");
536 g_writeln("%s", "");
537537 g_exit(0);
538538 }
539539
540540 if (g_file_exist(pid_file)) /* xrdp.pid */
541541 {
542 g_writeln("It looks like xrdp is allready running,");
543 g_writeln("if not delete the xrdp.pid file and try again");
542 g_writeln("It looks like xrdp is already running.");
543 g_writeln("If not, delete %s and try again.", pid_file);
544544 g_exit(0);
545545 }
546546
617617 g_threadid = tc_get_threadid();
618618 g_listen = xrdp_listen_create();
619619 g_signal_user_interrupt(xrdp_shutdown); /* SIGINT */
620 g_signal_kill(xrdp_shutdown); /* SIGKILL */
621620 g_signal_pipe(pipe_sig); /* SIGPIPE */
622621 g_signal_terminate(xrdp_shutdown); /* SIGTERM */
623622 g_sync_mutex = tc_mutex_create();
0 EXTRA_DIST = xrdpapi.h
1
20 EXTRA_DEFINES =
31 EXTRA_INCLUDES =
42 EXTRA_LIBS =
53 EXTRA_FLAGS =
64
7 AM_CFLAGS = \
8 $(EXTRA_DEFINES)
9
10 INCLUDES = \
5 AM_CPPFLAGS = \
6 $(EXTRA_DEFINES) \
117 $(EXTRA_INCLUDES)
128
13 lib_LTLIBRARIES = \
9 module_LTLIBRARIES = \
1410 libxrdpapi.la
1511
1612 libxrdpapi_la_SOURCES = \
17 xrdpapi.c
13 xrdpapi.c \
14 xrdpapi.h
1815
1916 libxrdpapi_la_LDFLAGS = \
2017 $(EXTRA_FLAGS)
117117
118118 if (wts->display_num <= 0)
119119 {
120 LLOGLN(0, ("WTSVirtualChannelOpenEx: fatal errror; display is 0"));
120 LLOGLN(0, ("WTSVirtualChannelOpenEx: fatal error; display is 0"));
121121 free(wts);
122122 return NULL;
123123 }
125125 /* we use unix domain socket to communicate with chansrv */
126126 if ((wts->fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
127127 {
128 g_free(wts);
128 free(wts);
129129 return NULL;
130130 }
131131
161161 return wts;
162162 }
163163
164 /*
165 * Prevent receiving SIGPIPE on disconnect using either MSG_NOSIGNAL (Linux)
166 * or SO_NOSIGPIPE (Mac OS X)
167 */
168 #if !defined(MSG_NOSIGNAL)
169 #define MSG_NOSIGNAL 0
170 #endif
171
164172 /*****************************************************************************/
165173 static int
166174 mysend(int sck, const void* adata, int bytes)
168176 int sent;
169177 int error;
170178 const char* data;
179
180 #if defined(SO_NOSIGPIPE)
181 const int on = 1;
182 setsockopt(sck, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on));
183 #endif
171184
172185 data = (const char*)adata;
173186 sent = 0;
233246 return -1;
234247 }
235248
236 LLOGLN(10, ("WTSVirtualChannelWrite: mysend() reted %d", rv));
249 LLOGLN(10, ("WTSVirtualChannelWrite: mysend() returned %d", rv));
237250
238251 if (rv >= 0)
239252 {
466479 {
467480 int index;
468481 int mode;
469 int host_index;
470482 int disp_index;
471 int scre_index;
472 char host[256];
473483 char disp[256];
474 char scre[256];
475484
476485 index = 0;
477 host_index = 0;
478486 disp_index = 0;
479 scre_index = 0;
480487 mode = 0;
481488
482489 while (display_text[index] != 0)
488495 else if (display_text[index] == '.')
489496 {
490497 mode = 2;
491 }
492 else if (mode == 0)
493 {
494 host[host_index] = display_text[index];
495 host_index++;
496498 }
497499 else if (mode == 1)
498500 {
499501 disp[disp_index] = display_text[index];
500502 disp_index++;
501503 }
502 else if (mode == 2)
503 {
504 scre[scre_index] = display_text[index];
505 scre_index++;
506 }
507504
508505 index++;
509506 }
510507
511 host[host_index] = 0;
512508 disp[disp_index] = 0;
513 scre[scre_index] = 0;
514509 return atoi(disp);
515510 }
0 EXTRA_DIST = xrdpvr.h
1
20 EXTRA_DEFINES =
31 EXTRA_INCLUDES =
42 EXTRA_LIBS =
53 EXTRA_FLAGS =
64
7 AM_CFLAGS = \
8 $(EXTRA_DEFINES)
9
10 INCLUDES = \
5 AM_CPPFLAGS = \
6 $(EXTRA_DEFINES) \
117 $(EXTRA_INCLUDES)
128
13 lib_LTLIBRARIES = \
9 module_LTLIBRARIES = \
1410 libxrdpvr.la
1511
1612 libxrdpvr_la_SOURCES = \
17 xrdpvr.c
13 xrdpvr.c \
14 xrdpvr.h
1815
1916 libxrdpvr_la_LDFLAGS = \
2017 $(EXTRA_FLAGS)
193193 //if (avformat_find_stream_info(g_psi.p_format_ctx, NULL) < 0)
194194 if (av_find_stream_info(g_psi.p_format_ctx) < 0)
195195 {
196 printf("ERRRO reading stream info\n");
196 printf("ERROR reading stream info\n");
197197 return -1;
198198 }
199199
0 EXTRA_DIST = xup.h
1
2 AM_CFLAGS = \
0 AM_CPPFLAGS = \
31 -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
42 -DXRDP_SBIN_PATH=\"${sbindir}\" \
53 -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
6 -DXRDP_PID_PATH=\"${localstatedir}/run\"
7
8 INCLUDES = \
4 -DXRDP_PID_PATH=\"${localstatedir}/run\" \
95 -I$(top_srcdir)/common
106
11 lib_LTLIBRARIES = \
7 module_LTLIBRARIES = \
128 libxup.la
139
14 libxup_la_SOURCES = xup.c
10 libxup_la_SOURCES = \
11 xup.c \
12 xup.h
1513
1614 libxup_la_LIBADD = \
1715 $(top_builddir)/common/libcommon.la
8585 struct stream *s;
8686 int len;
8787
88 LLOGLN(10, ("lib_data_in:"));
8889 if (trans == 0)
8990 {
9091 return 1;
209210 error = -1;
210211 if (trans_connect(mod->trans, mod->ip, con_port, 3000) == 0)
211212 {
213 LLOGLN(0, ("lib_mod_connect: connected to Xserver "
214 "(Xorg or X11rdp) sck %ld", mod->trans->sck));
212215 error = 0;
213216 }
214217
793796 {
794797 int rv;
795798 int font;
796 int charactor;
799 int character;
797800 int x;
798801 int y;
799802 int cx;
802805 char *bmpdata;
803806
804807 in_uint16_le(s, font);
805 in_uint16_le(s, charactor);
808 in_uint16_le(s, character);
806809 in_sint16_le(s, x);
807810 in_sint16_le(s, y);
808811 in_uint16_le(s, cx);
809812 in_uint16_le(s, cy);
810813 in_uint16_le(s, len_bmpdata);
811814 in_uint8p(s, bmpdata, len_bmpdata);
812 rv = mod->server_add_char(mod, font, charactor, x, y, cx, cy, bmpdata);
815 rv = mod->server_add_char(mod, font, character, x, y, cx, cy, bmpdata);
813816 return rv;
814817 }
815818
821824 {
822825 int rv;
823826 int font;
824 int charactor;
827 int character;
825828 int x;
826829 int y;
827830 int cx;
830833 char *bmpdata;
831834
832835 in_uint16_le(s, font);
833 in_uint16_le(s, charactor);
836 in_uint16_le(s, character);
834837 in_sint16_le(s, x);
835838 in_sint16_le(s, y);
836839 in_uint16_le(s, cx);
837840 in_uint16_le(s, cy);
838841 in_uint16_le(s, len_bmpdata);
839842 in_uint8p(s, bmpdata, len_bmpdata);
840 rv = mod->server_add_char_alpha(mod, font, charactor, x, y, cx, cy,
843 rv = mod->server_add_char_alpha(mod, font, character, x, y, cx, cy,
841844 bmpdata);
842845 return rv;
843846 }
11471150 int shmem_offset;
11481151 int width;
11491152 int height;
1150 int x;
1151 int y;
1152 int cx;
1153 int cy;
11541153 int index;
11551154 int rv;
11561155 tsi16 *ldrects;
12361235 g_free(lcrects);
12371236 g_free(ldrects);
12381237
1239 return 0;
1238 return rv;
12401239 }
12411240
12421241 /******************************************************************************/
12461245 {
12471246 int rv;
12481247
1248 LLOGLN(10, ("lib_mod_process_orders: type %d", type));
12491249 rv = 0;
12501250 switch (type)
12511251 {
13831383 int type;
13841384 char *phold;
13851385
1386 LLOGLN(10, ("lib_mod_process_message:"));
13861387 rv = 0;
13871388 if (rv == 0)
13881389 {
13891390 in_uint16_le(s, type);
13901391 in_uint16_le(s, num_orders);
13911392 in_uint32_le(s, len);
1393 LLOGLN(10, ("lib_mod_process_message: type %d", type));
13921394
13931395 if (type == 1) /* original order list */
13941396 {
6565 int (*server_set_bgcolor)(struct mod* v, int bgcolor);
6666 int (*server_set_opcode)(struct mod* v, int opcode);
6767 int (*server_set_mixmode)(struct mod* v, int mixmode);
68 int (*server_set_brush)(struct mod* v, int x_orgin, int y_orgin,
68 int (*server_set_brush)(struct mod* v, int x_origin, int y_origin,
6969 int style, char* pattern);
7070 int (*server_set_pen)(struct mod* v, int style,
7171 int width);
7272 int (*server_draw_line)(struct mod* v, int x1, int y1, int x2, int y2);
73 int (*server_add_char)(struct mod* v, int font, int charactor,
73 int (*server_add_char)(struct mod* v, int font, int character,
7474 int offset, int baseline,
7575 int width, int height, char* data);
7676 int (*server_draw_text)(struct mod* v, int font,
120120 int flags);
121121 int (*server_set_cursor_ex)(struct mod* v, int x, int y, char* data,
122122 char* mask, int bpp);
123 int (*server_add_char_alpha)(struct mod* v, int font, int charactor,
123 int (*server_add_char_alpha)(struct mod* v, int font, int character,
124124 int offset, int baseline,
125125 int width, int height, char* data);
126126 int (*server_create_os_surface_bpp)(struct mod* v, int rdpindex,