1 /**
2  * FreeRDP: A Remote Desktop Protocol client.
3  * RemoteFX Codec Library - Encode
4  *
5  * Copyright 2011 Vic Lee
6  * Copyright 2014-2015 Jay Sorg <jay.sorg@gmail.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #if defined(HAVE_CONFIG_H)
22 #include <config_ac.h>
23 #endif
24 
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 
29 #include "rfxcommon.h"
30 #include "rfxencode.h"
31 #include "rfxencode_differential.h"
32 #include "rfxencode_rlgr1.h"
33 #include "rfxencode_rlgr3.h"
34 #include "rfxencode_alpha.h"
35 #include "rfxencode_diff_rlgr1.h"
36 #include "rfxencode_diff_rlgr3.h"
37 
38 #include "amd64/funcs_amd64.h"
39 
40 #define LLOG_LEVEL 1
41 #define LLOGLN(_level, _args) \
42     do { if (_level < LLOG_LEVEL) { printf _args ; printf("\n"); } } while (0)
43 
44 /******************************************************************************/
45 int
rfx_encode_component_rlgr1_amd64_sse2(struct rfxencode * enc,const char * qtable,const uint8 * data,uint8 * buffer,int buffer_size,int * size)46 rfx_encode_component_rlgr1_amd64_sse2(struct rfxencode *enc, const char *qtable,
47                                       const uint8 *data,
48                                       uint8 *buffer, int buffer_size, int *size)
49 {
50     LLOGLN(10, ("rfx_encode_component_rlgr1_amd64_sse2:"));
51     if (rfxcodec_encode_dwt_shift_amd64_sse2(qtable, data, enc->dwt_buffer1,
52                                              enc->dwt_buffer) != 0)
53     {
54         return 1;
55     }
56     *size = rfx_encode_diff_rlgr1(enc->dwt_buffer1, buffer, buffer_size);
57     return 0;
58 }
59 
60 /******************************************************************************/
61 int
rfx_encode_component_rlgr3_amd64_sse2(struct rfxencode * enc,const char * qtable,const uint8 * data,uint8 * buffer,int buffer_size,int * size)62 rfx_encode_component_rlgr3_amd64_sse2(struct rfxencode *enc, const char *qtable,
63                                       const uint8 *data,
64                                       uint8 *buffer, int buffer_size, int *size)
65 {
66     LLOGLN(10, ("rfx_encode_component_rlgr3_amd64_sse2:"));
67     if (rfxcodec_encode_dwt_shift_amd64_sse2(qtable, data, enc->dwt_buffer1,
68                                              enc->dwt_buffer) != 0)
69     {
70         return 1;
71     }
72     *size = rfx_encode_diff_rlgr3(enc->dwt_buffer1, buffer, buffer_size);
73     return 0;
74 }
75 
76 /******************************************************************************/
77 int
rfx_encode_component_rlgr1_amd64_sse41(struct rfxencode * enc,const char * qtable,const uint8 * data,uint8 * buffer,int buffer_size,int * size)78 rfx_encode_component_rlgr1_amd64_sse41(struct rfxencode *enc, const char *qtable,
79                                        const uint8 *data,
80                                        uint8 *buffer, int buffer_size, int *size)
81 {
82     LLOGLN(10, ("rfx_encode_component_rlgr1_amd64_sse41:"));
83     if (rfxcodec_encode_dwt_shift_amd64_sse41(qtable, data, enc->dwt_buffer1,
84                                               enc->dwt_buffer) != 0)
85     {
86         return 1;
87     }
88     *size = rfx_encode_diff_rlgr1(enc->dwt_buffer1, buffer, buffer_size);
89     return 0;
90 }
91 
92 /******************************************************************************/
93 int
rfx_encode_component_rlgr3_amd64_sse41(struct rfxencode * enc,const char * qtable,const uint8 * data,uint8 * buffer,int buffer_size,int * size)94 rfx_encode_component_rlgr3_amd64_sse41(struct rfxencode *enc, const char *qtable,
95                                        const uint8 *data,
96                                        uint8 *buffer, int buffer_size, int *size)
97 {
98     LLOGLN(10, ("rfx_encode_component_rlgr3_amd64_sse41:"));
99     if (rfxcodec_encode_dwt_shift_amd64_sse41(qtable, data, enc->dwt_buffer1,
100                                               enc->dwt_buffer) != 0)
101     {
102         return 1;
103     }
104     *size = rfx_encode_diff_rlgr3(enc->dwt_buffer1, buffer, buffer_size);
105     return 0;
106 }
107