1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Jia Haipeng, jiahaipeng95@gmail.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other oclMaterials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#if defined (DOUBLE_SUPPORT)
#pragma OPENCL EXTENSION cl_khr_fp64:enable
#endif
///////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////optimized code using vector roi//////////////////////////
////////////vector fuction name format: merge_vector_C(channels number)D_(data type depth)//////
////////////////////////////////////////////////////////////////////////////////////////////////
__kernel void merge_vector_C2_D0(__global uchar *mat_dst, int dst_step, int dst_offset,
__global uchar *mat_src0, int src0_step, int src0_offset,
__global uchar *mat_src1, int src1_step, int src1_offset,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
x = x << 1;
#define dst_align ((dst_offset & 3) >> 1)
int src0_index = mad24(y, src0_step, src0_offset + x - dst_align);
int src1_index = mad24(y, src1_step, src1_offset + x - dst_align);
int dst_start = mad24(y, dst_step, dst_offset);
int dst_end = mad24(y, dst_step, dst_offset + dst_step1);
int dst_index = mad24(y, dst_step, dst_offset + (x << 1) & (int)0xfffffffc);
__global uchar4 * dst = (__global uchar4 *)(mat_dst + dst_index);
__global uchar * src0 = mat_src0 + src0_index;
__global uchar * src1 = src0 + 1;
__global uchar * src2 = mat_src1 + src1_index;
__global uchar * src3 = src2 + 1;
uchar4 dst_data = *dst;
uchar data_0 = *(src0);
uchar data_1 = *(src1);
uchar data_2 = *(src2);
uchar data_3 = *(src3);
uchar4 tmp_data = (uchar4)(data_0, data_2, data_1, data_3);
tmp_data.xy = dst_index + 0 >= dst_start ? tmp_data.xy : dst_data.xy;
tmp_data.zw = dst_index + 2 < dst_end ? tmp_data.zw : dst_data.zw;
*dst = tmp_data;
}
}
__kernel void merge_vector_C2_D1(__global char *mat_dst, int dst_step, int dst_offset,
__global char *mat_src0, int src0_step, int src0_offset,
__global char *mat_src1, int src1_step, int src1_offset,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
x = x << 1;
#define dst_align ((dst_offset & 3) >> 1)
int src0_index = mad24(y, src0_step, src0_offset + x - dst_align);
int src1_index = mad24(y, src1_step, src1_offset + x - dst_align);
int dst_start = mad24(y, dst_step, dst_offset);
int dst_end = mad24(y, dst_step, dst_offset + dst_step1);
int dst_index = mad24(y, dst_step, dst_offset + (x << 1) & (int)0xfffffffc);
__global char4 * dst = (__global char4 *)(mat_dst + dst_index);
__global char * src0 = mat_src0 + src0_index;
__global char * src1 = src0 + 1;
__global char * src2 = mat_src1 + src1_index;
__global char * src3 = src2 + 1;
char4 dst_data = *dst;
char data_0 = *(src0);
char data_1 = *(src1);
char data_2 = *(src2);
char data_3 = *(src3);
char4 tmp_data = (char4)(data_0, data_2, data_1, data_3);
tmp_data.xy = dst_index + 0 >= dst_start ? tmp_data.xy : dst_data.xy;
tmp_data.zw = dst_index + 2 < dst_end ? tmp_data.zw : dst_data.zw;
*dst = tmp_data;
}
}
__kernel void merge_vector_C2_D2(__global ushort *mat_dst, int dst_step, int dst_offset,
__global ushort *mat_src0, int src0_step, int src0_offset,
__global ushort *mat_src1, int src1_step, int src1_offset,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
int src0_index = mad24(y, src0_step, src0_offset);
int src1_index = mad24(y, src1_step, src1_offset);
int dst_index = mad24(y, dst_step , dst_offset);
__global ushort* src0 = (__global ushort * )((__global uchar *)mat_src0 + src0_index + (x << 1));
__global ushort* src1 = (__global ushort * )((__global uchar *)mat_src1 + src1_index + (x << 1));
__global ushort2* dist = (__global ushort2 *)((__global uchar *)mat_dst + dst_index + (x << 2));
ushort src0_data = *src0;
ushort src1_data = *src1;
*dist = (ushort2)(src0_data, src1_data);
}
}
__kernel void merge_vector_C2_D3(__global short *mat_dst, int dst_step, int dst_offset,
__global short *mat_src0, int src0_step, int src0_offset,
__global short *mat_src1, int src1_step, int src1_offset,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
int src0_index = mad24(y, src0_step, src0_offset);
int src1_index = mad24(y, src1_step, src1_offset);
int dst_index = mad24(y, dst_step , dst_offset);
__global short* src0 = (__global short * )((__global uchar *)mat_src0 + src0_index + (x << 1));
__global short* src1 = (__global short * )((__global uchar *)mat_src1 + src1_index + (x << 1));
__global short2* dist = (__global short2 *)((__global uchar *)mat_dst + dst_index + (x << 2));
short src0_data = *src0;
short src1_data = *src1;
*dist = (short2)(src0_data, src1_data);
}
}
__kernel void merge_vector_C2_D4(__global int *mat_dst, int dst_step, int dst_offset,
__global int *mat_src0, int src0_step, int src0_offset,
__global int *mat_src1, int src1_step, int src1_offset,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
int src0_index = mad24(y, src0_step, src0_offset);
int src1_index = mad24(y, src1_step, src1_offset);
int dst_index = mad24(y, dst_step , dst_offset);
int src0 = *((__global int *)((__global uchar *)mat_src0 + src0_index + (x << 2)));
int src1 = *((__global int *)((__global uchar *)mat_src1 + src1_index + (x << 2)));
*((__global int2 *)((__global uchar *)mat_dst + dst_index + (x << 4))) = (int2)(src0, src1);
}
}
__kernel void merge_vector_C2_D5(__global float *mat_dst, int dst_step, int dst_offset,
__global float *mat_src0, int src0_step, int src0_offset,
__global float *mat_src1, int src1_step, int src1_offset,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
int src0_index = mad24(y, src0_step, src0_offset);
int src1_index = mad24(y, src1_step, src1_offset);
int dst_index = mad24(y, dst_step , dst_offset);
float src0 = *((__global float *)((__global uchar *)mat_src0 + src0_index + (x << 2)));
float src1 = *((__global float *)((__global uchar *)mat_src1 + src1_index + (x << 2)));
*((__global float2 *)((__global uchar *)mat_dst + dst_index + (x << 4))) = (float2)(src0, src1);
}
}
#if defined (DOUBLE_SUPPORT)
__kernel void merge_vector_C2_D6(__global double *mat_dst, int dst_step, int dst_offset,
__global double *mat_src0, int src0_step, int src0_offset,
__global double *mat_src1, int src1_step, int src1_offset,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
int src0_index = mad24(y, src0_step, src0_offset);
int src1_index = mad24(y, src1_step, src1_offset);
int dst_index = mad24(y, dst_step , dst_offset);
double src0 = *((__global double *)((__global uchar *)mat_src0 + src0_index + (x << 3)));
double src1 = *((__global double *)((__global uchar *)mat_src1 + src1_index + (x << 3)));
*((__global double2 *)((__global uchar *)mat_dst + dst_index + (x << 4))) = (double2)(src0, src1);
}
}
#endif
__kernel void merge_vector_C3_D0(__global uchar *mat_dst, int dst_step, int dst_offset,
__global uchar *mat_src0, int src0_step, int src0_offset,
__global uchar *mat_src1, int src1_step, int src1_offset,
__global uchar *mat_src2, int src2_step, int src2_offset, int offset_cols,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
x = x << 2;
int src0_index = mad24(y, src0_step, x + src0_offset - offset_cols);
int src1_index = mad24(y, src1_step, x + src1_offset - offset_cols);
int src2_index = mad24(y, src2_step, x + src2_offset - offset_cols);
int dst_start = mad24(y, dst_step, dst_offset);
int dst_end = mad24(y, dst_step, dst_offset + dst_step1);
int dst_index = mad24(y, dst_step, dst_offset + 3 * x - offset_cols * 3);
uchar data0_0 = *(mat_src0 + src0_index + 0);
uchar data0_1 = *(mat_src0 + src0_index + 1);
uchar data0_2 = *(mat_src0 + src0_index + 2);
uchar data0_3 = *(mat_src0 + src0_index + 3);
uchar data1_0 = *(mat_src1 + src1_index + 0);
uchar data1_1 = *(mat_src1 + src1_index + 1);
uchar data1_2 = *(mat_src1 + src1_index + 2);
uchar data1_3 = *(mat_src1 + src1_index + 3);
uchar data2_0 = *(mat_src2 + src2_index + 0);
uchar data2_1 = *(mat_src2 + src2_index + 1);
uchar data2_2 = *(mat_src2 + src2_index + 2);
uchar data2_3 = *(mat_src2 + src2_index + 3);
uchar4 tmp_data0 = (uchar4)(data0_0, data1_0, data2_0, data0_1);
uchar4 tmp_data1 = (uchar4)(data1_1, data2_1, data0_2, data1_2);
uchar4 tmp_data2 = (uchar4)(data2_2, data0_3, data1_3, data2_3);
uchar4 dst_data0 = *((__global uchar4*)(mat_dst + dst_index + 0));
uchar4 dst_data1 = *((__global uchar4*)(mat_dst + dst_index + 4));
uchar4 dst_data2 = *((__global uchar4*)(mat_dst + dst_index + 8));
tmp_data0.x = ((dst_index + 0 >= dst_start) && (dst_index + 0 < dst_end)) ? tmp_data0.x : dst_data0.x;
tmp_data0.y = ((dst_index + 1 >= dst_start) && (dst_index + 1 < dst_end)) ? tmp_data0.y : dst_data0.y;
tmp_data0.z = ((dst_index + 2 >= dst_start) && (dst_index + 2 < dst_end)) ? tmp_data0.z : dst_data0.z;
tmp_data0.w = ((dst_index + 3 >= dst_start) && (dst_index + 3 < dst_end)) ? tmp_data0.w : dst_data0.w;
tmp_data1.x = ((dst_index + 4 >= dst_start) && (dst_index + 4 < dst_end)) ? tmp_data1.x : dst_data1.x;
tmp_data1.y = ((dst_index + 5 >= dst_start) && (dst_index + 5 < dst_end)) ? tmp_data1.y : dst_data1.y;
tmp_data1.z = ((dst_index + 6 >= dst_start) && (dst_index + 6 < dst_end)) ? tmp_data1.z : dst_data1.z;
tmp_data1.w = ((dst_index + 7 >= dst_start) && (dst_index + 7 < dst_end)) ? tmp_data1.w : dst_data1.w;
tmp_data2.x = ((dst_index + 8 >= dst_start) && (dst_index + 8 < dst_end)) ? tmp_data2.x : dst_data2.x;
tmp_data2.y = ((dst_index + 9 >= dst_start) && (dst_index + 9 < dst_end)) ? tmp_data2.y : dst_data2.y;
tmp_data2.z = ((dst_index + 10 >= dst_start) && (dst_index + 10 < dst_end)) ? tmp_data2.z : dst_data2.z;
tmp_data2.w = ((dst_index + 11 >= dst_start) && (dst_index + 11 < dst_end)) ? tmp_data2.w : dst_data2.w;
*((__global uchar4*)(mat_dst + dst_index + 0)) = tmp_data0;
*((__global uchar4*)(mat_dst + dst_index + 4)) = tmp_data1;
*((__global uchar4*)(mat_dst + dst_index + 8)) = tmp_data2;
}
}
__kernel void merge_vector_C3_D1(__global char *mat_dst, int dst_step, int dst_offset,
__global char *mat_src0, int src0_step, int src0_offset,
__global char *mat_src1, int src1_step, int src1_offset,
__global char *mat_src2, int src2_step, int src2_offset, int offset_cols,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
x = x << 2;
int src0_index = mad24(y, src0_step, x + src0_offset - offset_cols);
int src1_index = mad24(y, src1_step, x + src1_offset - offset_cols);
int src2_index = mad24(y, src2_step, x + src2_offset - offset_cols);
int dst_start = mad24(y, dst_step, dst_offset);
int dst_end = mad24(y, dst_step, dst_offset + dst_step1);
int dst_index = mad24(y, dst_step, dst_offset + 3 * x - offset_cols * 3);
char data0_0 = *(mat_src0 + src0_index + 0);
char data0_1 = *(mat_src0 + src0_index + 1);
char data0_2 = *(mat_src0 + src0_index + 2);
char data0_3 = *(mat_src0 + src0_index + 3);
char data1_0 = *(mat_src1 + src1_index + 0);
char data1_1 = *(mat_src1 + src1_index + 1);
char data1_2 = *(mat_src1 + src1_index + 2);
char data1_3 = *(mat_src1 + src1_index + 3);
char data2_0 = *(mat_src2 + src2_index + 0);
char data2_1 = *(mat_src2 + src2_index + 1);
char data2_2 = *(mat_src2 + src2_index + 2);
char data2_3 = *(mat_src2 + src2_index + 3);
char4 tmp_data0 = (char4)(data0_0, data1_0, data2_0, data0_1);
char4 tmp_data1 = (char4)(data1_1, data2_1, data0_2, data1_2);
char4 tmp_data2 = (char4)(data2_2, data0_3, data1_3, data2_3);
char4 dst_data0 = *((__global char4*)(mat_dst + dst_index + 0));
char4 dst_data1 = *((__global char4*)(mat_dst + dst_index + 4));
char4 dst_data2 = *((__global char4*)(mat_dst + dst_index + 8));
tmp_data0.x = ((dst_index + 0 >= dst_start) && (dst_index + 0 < dst_end)) ? tmp_data0.x : dst_data0.x;
tmp_data0.y = ((dst_index + 1 >= dst_start) && (dst_index + 1 < dst_end)) ? tmp_data0.y : dst_data0.y;
tmp_data0.z = ((dst_index + 2 >= dst_start) && (dst_index + 2 < dst_end)) ? tmp_data0.z : dst_data0.z;
tmp_data0.w = ((dst_index + 3 >= dst_start) && (dst_index + 3 < dst_end)) ? tmp_data0.w : dst_data0.w;
tmp_data1.x = ((dst_index + 4 >= dst_start) && (dst_index + 4 < dst_end)) ? tmp_data1.x : dst_data1.x;
tmp_data1.y = ((dst_index + 5 >= dst_start) && (dst_index + 5 < dst_end)) ? tmp_data1.y : dst_data1.y;
tmp_data1.z = ((dst_index + 6 >= dst_start) && (dst_index + 6 < dst_end)) ? tmp_data1.z : dst_data1.z;
tmp_data1.w = ((dst_index + 7 >= dst_start) && (dst_index + 7 < dst_end)) ? tmp_data1.w : dst_data1.w;
tmp_data2.x = ((dst_index + 8 >= dst_start) && (dst_index + 8 < dst_end)) ? tmp_data2.x : dst_data2.x;
tmp_data2.y = ((dst_index + 9 >= dst_start) && (dst_index + 9 < dst_end)) ? tmp_data2.y : dst_data2.y;
tmp_data2.z = ((dst_index + 10 >= dst_start) && (dst_index + 10 < dst_end)) ? tmp_data2.z : dst_data2.z;
tmp_data2.w = ((dst_index + 11 >= dst_start) && (dst_index + 11 < dst_end)) ? tmp_data2.w : dst_data2.w;
*((__global char4*)(mat_dst + dst_index + 0)) = tmp_data0;
*((__global char4*)(mat_dst + dst_index + 4)) = tmp_data1;
*((__global char4*)(mat_dst + dst_index + 8)) = tmp_data2;
}
}
__kernel void merge_vector_C3_D2(__global ushort *mat_dst, int dst_step, int dst_offset,
__global ushort *mat_src0, int src0_step, int src0_offset,
__global ushort *mat_src1, int src1_step, int src1_offset,
__global ushort *mat_src2, int src2_step, int src2_offset, int offset_cols,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
x = x << 1;
int src0_index = mad24(y, src0_step, (x << 1) + src0_offset - offset_cols);
int src1_index = mad24(y, src1_step, (x << 1) + src1_offset - offset_cols);
int src2_index = mad24(y, src2_step, (x << 1) + src2_offset - offset_cols);
int dst_start = mad24(y, dst_step, dst_offset);
int dst_end = mad24(y, dst_step, dst_offset + dst_step1);
int dst_index = mad24(y, dst_step, dst_offset + 6 * x - offset_cols * 6);
ushort data0_0 = *((__global ushort *)((__global char *)mat_src0 + src0_index + 0));
ushort data0_1 = *((__global ushort *)((__global char *)mat_src0 + src0_index + 2));
ushort data1_0 = *((__global ushort *)((__global char *)mat_src1 + src1_index + 0));
ushort data1_1 = *((__global ushort *)((__global char *)mat_src1 + src1_index + 2));
ushort data2_0 = *((__global ushort *)((__global char *)mat_src2 + src2_index + 0));
ushort data2_1 = *((__global ushort *)((__global char *)mat_src2 + src2_index + 2));
ushort2 tmp_data0 = (ushort2)(data0_0, data1_0);
ushort2 tmp_data1 = (ushort2)(data2_0, data0_1);
ushort2 tmp_data2 = (ushort2)(data1_1, data2_1);
ushort2 dst_data0 = *((__global ushort2*)((__global char *)mat_dst + dst_index + 0));
ushort2 dst_data1 = *((__global ushort2*)((__global char *)mat_dst + dst_index + 4));
ushort2 dst_data2 = *((__global ushort2*)((__global char *)mat_dst + dst_index + 8));
tmp_data0.x = ((dst_index + 0 >= dst_start) && (dst_index + 0 < dst_end)) ? tmp_data0.x : dst_data0.x;
tmp_data0.y = ((dst_index + 2 >= dst_start) && (dst_index + 2 < dst_end)) ? tmp_data0.y : dst_data0.y;
tmp_data1.x = ((dst_index + 4 >= dst_start) && (dst_index + 4 < dst_end)) ? tmp_data1.x : dst_data1.x;
tmp_data1.y = ((dst_index + 6 >= dst_start) && (dst_index + 6 < dst_end)) ? tmp_data1.y : dst_data1.y;
tmp_data2.x = ((dst_index + 8 >= dst_start) && (dst_index + 8 < dst_end)) ? tmp_data2.x : dst_data2.x;
tmp_data2.y = ((dst_index + 10 >= dst_start) && (dst_index + 10 < dst_end)) ? tmp_data2.y : dst_data2.y;
*((__global ushort2*)((__global char *)mat_dst + dst_index + 0)) = tmp_data0;
*((__global ushort2*)((__global char *)mat_dst + dst_index + 4)) = tmp_data1;
*((__global ushort2*)((__global char *)mat_dst + dst_index + 8)) = tmp_data2;
}
}
__kernel void merge_vector_C3_D3(__global short *mat_dst, int dst_step, int dst_offset,
__global short *mat_src0, int src0_step, int src0_offset,
__global short *mat_src1, int src1_step, int src1_offset,
__global short *mat_src2, int src2_step, int src2_offset, int offset_cols,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
x = x << 1;
int src0_index = mad24(y, src0_step, (x << 1) + src0_offset - offset_cols);
int src1_index = mad24(y, src1_step, (x << 1) + src1_offset - offset_cols);
int src2_index = mad24(y, src2_step, (x << 1) + src2_offset - offset_cols);
int dst_start = mad24(y, dst_step, dst_offset);
int dst_end = mad24(y, dst_step, dst_offset + dst_step1);
int dst_index = mad24(y, dst_step, dst_offset + 6 * x - offset_cols * 6);
short data0_0 = *((__global short *)((__global char *)mat_src0 + src0_index + 0));
short data0_1 = *((__global short *)((__global char *)mat_src0 + src0_index + 2));
short data1_0 = *((__global short *)((__global char *)mat_src1 + src1_index + 0));
short data1_1 = *((__global short *)((__global char *)mat_src1 + src1_index + 2));
short data2_0 = *((__global short *)((__global char *)mat_src2 + src2_index + 0));
short data2_1 = *((__global short *)((__global char *)mat_src2 + src2_index + 2));
short2 tmp_data0 = (short2)(data0_0, data1_0);
short2 tmp_data1 = (short2)(data2_0, data0_1);
short2 tmp_data2 = (short2)(data1_1, data2_1);
short2 dst_data0 = *((__global short2*)((__global char *)mat_dst + dst_index + 0));
short2 dst_data1 = *((__global short2*)((__global char *)mat_dst + dst_index + 4));
short2 dst_data2 = *((__global short2*)((__global char *)mat_dst + dst_index + 8));
tmp_data0.x = ((dst_index + 0 >= dst_start) && (dst_index + 0 < dst_end)) ? tmp_data0.x : dst_data0.x;
tmp_data0.y = ((dst_index + 2 >= dst_start) && (dst_index + 2 < dst_end)) ? tmp_data0.y : dst_data0.y;
tmp_data1.x = ((dst_index + 4 >= dst_start) && (dst_index + 4 < dst_end)) ? tmp_data1.x : dst_data1.x;
tmp_data1.y = ((dst_index + 6 >= dst_start) && (dst_index + 6 < dst_end)) ? tmp_data1.y : dst_data1.y;
tmp_data2.x = ((dst_index + 8 >= dst_start) && (dst_index + 8 < dst_end)) ? tmp_data2.x : dst_data2.x;
tmp_data2.y = ((dst_index + 10 >= dst_start) && (dst_index + 10 < dst_end)) ? tmp_data2.y : dst_data2.y;
*((__global short2*)((__global char *)mat_dst + dst_index + 0)) = tmp_data0;
*((__global short2*)((__global char *)mat_dst + dst_index + 4)) = tmp_data1;
*((__global short2*)((__global char *)mat_dst + dst_index + 8)) = tmp_data2;
}
}
__kernel void merge_vector_C3_D4(__global int *mat_dst, int dst_step, int dst_offset,
__global int *mat_src0, int src0_step, int src0_offset,
__global int *mat_src1, int src1_step, int src1_offset,
__global int *mat_src2, int src2_step, int src2_offset, int offset_cols,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
int src0_index = mad24(y, src0_step, src0_offset);
int src1_index = mad24(y, src1_step, src1_offset);
int src2_index = mad24(y, src2_step, src2_offset);
int dst_index = mad24(y, dst_step , dst_offset);
__global int* src0 = (__global int * )((__global uchar *)mat_src0 + src0_index + (x << 2));
__global int* src1 = (__global int * )((__global uchar *)mat_src1 + src1_index + (x << 2));
__global int* src2 = (__global int * )((__global uchar *)mat_src2 + src2_index + (x << 2));
__global int* dist0 = (__global int *)((__global uchar *)mat_dst + dst_index + 3 * (x << 2));
__global int* dist1 = dist0 + 1;
__global int* dist2 = dist0 + 2;
int src0_data = *src0;
int src1_data = *src1;
int src2_data = *src2;
*dist0 = src0_data;
*dist1 = src1_data;
*dist2 = src2_data;
}
}
__kernel void merge_vector_C3_D5(__global float *mat_dst, int dst_step, int dst_offset,
__global float *mat_src0, int src0_step, int src0_offset,
__global float *mat_src1, int src1_step, int src1_offset,
__global float *mat_src2, int src2_step, int src2_offset, int offset_cols,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
int src0_index = mad24(y, src0_step, src0_offset);
int src1_index = mad24(y, src1_step, src1_offset);
int src2_index = mad24(y, src2_step, src2_offset);
int dst_index = mad24(y, dst_step , dst_offset);
__global float* src0 = (__global float * )((__global uchar *)mat_src0 + src0_index + (x << 2));
__global float* src1 = (__global float * )((__global uchar *)mat_src1 + src1_index + (x << 2));
__global float* src2 = (__global float * )((__global uchar *)mat_src2 + src2_index + (x << 2));
__global float* dist0 = (__global float *)((__global uchar *)mat_dst + dst_index + 3 * (x << 2));
__global float* dist1 = dist0 + 1;
__global float* dist2 = dist0 + 2;
float src0_data = *src0;
float src1_data = *src1;
float src2_data = *src2;
*dist0 = src0_data;
*dist1 = src1_data;
*dist2 = src2_data;
}
}
#if defined (DOUBLE_SUPPORT)
__kernel void merge_vector_C3_D6(__global double *mat_dst, int dst_step, int dst_offset,
__global double *mat_src0, int src0_step, int src0_offset,
__global double *mat_src1, int src1_step, int src1_offset,
__global double *mat_src2, int src2_step, int src2_offset, int offset_cols,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
int src0_index = mad24(y, src0_step, src0_offset);
int src1_index = mad24(y, src1_step, src1_offset);
int src2_index = mad24(y, src2_step, src2_offset);
int dst_index = mad24(y, dst_step , dst_offset);
__global double* src0 = (__global double * )((__global uchar *)mat_src0 + src0_index + (x << 3));
__global double* src1 = (__global double * )((__global uchar *)mat_src1 + src1_index + (x << 3));
__global double* src2 = (__global double * )((__global uchar *)mat_src2 + src2_index + (x << 3));
__global double* dist0 = (__global double *)((__global uchar *)mat_dst + dst_index + 3 * (x << 3));
__global double* dist1 = dist0 + 1;
__global double* dist2 = dist0 + 2;
double src0_data = *src0;
double src1_data = *src1;
double src2_data = *src2;
*dist0 = src0_data;
*dist1 = src1_data;
*dist2 = src2_data;
}
}
#endif
__kernel void merge_vector_C4_D0(__global uchar *mat_dst, int dst_step, int dst_offset,
__global uchar *mat_src0, int src0_step, int src0_offset,
__global uchar *mat_src1, int src1_step, int src1_offset,
__global uchar *mat_src2, int src2_step, int src2_offset,
__global uchar *mat_src3, int src3_step, int src3_offset,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
int src0_index = mad24(y, src0_step, src0_offset);
int src1_index = mad24(y, src1_step, src1_offset);
int src2_index = mad24(y, src2_step, src2_offset);
int src3_index = mad24(y, src3_step, src3_offset);
int dst_index = mad24(y, dst_step , dst_offset);
uchar src0 = *(mat_src0 + src0_index + x );
uchar src1 = *(mat_src1 + src1_index + x);
uchar src2 = *(mat_src2 + src2_index + x);
uchar src3 = *(mat_src3 + src3_index + x);
*((__global uchar4 *)(mat_dst + dst_index + (x << 2))) = (uchar4)(src0, src1, src2, src3);
}
}
__kernel void merge_vector_C4_D1(__global char *mat_dst, int dst_step, int dst_offset,
__global char *mat_src0, int src0_step, int src0_offset,
__global char *mat_src1, int src1_step, int src1_offset,
__global char *mat_src2, int src2_step, int src2_offset,
__global char *mat_src3, int src3_step, int src3_offset,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
int src0_index = mad24(y, src0_step, src0_offset);
int src1_index = mad24(y, src1_step, src1_offset);
int src2_index = mad24(y, src2_step, src2_offset);
int src3_index = mad24(y, src3_step, src3_offset);
int dst_index = mad24(y, dst_step , dst_offset);
char src0 = *(mat_src0 + src0_index + x );
char src1 = *(mat_src1 + src1_index + x);
char src2 = *(mat_src2 + src2_index + x);
char src3 = *(mat_src3 + src3_index + x);
*((__global char4 *)(mat_dst + dst_index + (x << 2))) = (char4)(src0, src1, src2, src3);
}
}
__kernel void merge_vector_C4_D2(__global ushort *mat_dst, int dst_step, int dst_offset,
__global ushort *mat_src0, int src0_step, int src0_offset,
__global ushort *mat_src1, int src1_step, int src1_offset,
__global ushort *mat_src2, int src2_step, int src2_offset,
__global ushort *mat_src3, int src3_step, int src3_offset,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
int src0_index = mad24(y, src0_step, src0_offset);
int src1_index = mad24(y, src1_step, src1_offset);
int src2_index = mad24(y, src2_step, src2_offset);
int src3_index = mad24(y, src3_step, src3_offset);
int dst_index = mad24(y, dst_step , dst_offset);
ushort src0 = *((__global ushort *)((__global uchar *)mat_src0 + src0_index + (x << 1)));
ushort src1 = *((__global ushort *)((__global uchar *)mat_src1 + src1_index + (x << 1)));
ushort src2 = *((__global ushort *)((__global uchar *)mat_src2 + src2_index + (x << 1)));
ushort src3 = *((__global ushort *)((__global uchar *)mat_src3 + src3_index + (x << 1)));
*((__global ushort4 *)((__global uchar *)mat_dst + dst_index + (x << 3))) = (ushort4)(src0, src1, src2, src3);
}
}
__kernel void merge_vector_C4_D3(__global short *mat_dst, int dst_step, int dst_offset,
__global short *mat_src0, int src0_step, int src0_offset,
__global short *mat_src1, int src1_step, int src1_offset,
__global short *mat_src2, int src2_step, int src2_offset,
__global short *mat_src3, int src3_step, int src3_offset,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
int src0_index = mad24(y, src0_step, src0_offset);
int src1_index = mad24(y, src1_step, src1_offset);
int src2_index = mad24(y, src2_step, src2_offset);
int src3_index = mad24(y, src3_step, src3_offset);
int dst_index = mad24(y, dst_step , dst_offset);
short src0 = *((__global short *)((__global uchar *)mat_src0 + src0_index + (x << 1)));
short src1 = *((__global short *)((__global uchar *)mat_src1 + src1_index + (x << 1)));
short src2 = *((__global short *)((__global uchar *)mat_src2 + src2_index + (x << 1)));
short src3 = *((__global short *)((__global uchar *)mat_src3 + src3_index + (x << 1)));
*((__global short4 *)((__global uchar *)mat_dst + dst_index + (x << 3))) = (short4)(src0, src1, src2, src3);
}
}
__kernel void merge_vector_C4_D4(__global int *mat_dst, int dst_step, int dst_offset,
__global int *mat_src0, int src0_step, int src0_offset,
__global int *mat_src1, int src1_step, int src1_offset,
__global int *mat_src2, int src2_step, int src2_offset,
__global int *mat_src3, int src3_step, int src3_offset,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
int src0_index = mad24(y, src0_step, src0_offset);
int src1_index = mad24(y, src1_step, src1_offset);
int src2_index = mad24(y, src2_step, src2_offset);
int src3_index = mad24(y, src3_step, src3_offset);
int dst_index = mad24(y, dst_step , dst_offset);
int src0 = *((__global int *)((__global uchar *)mat_src0 + src0_index + (x << 2)));
int src1 = *((__global int *)((__global uchar *)mat_src1 + src1_index + (x << 2)));
int src2 = *((__global int *)((__global uchar *)mat_src2 + src2_index + (x << 2)));
int src3 = *((__global int *)((__global uchar *)mat_src3 + src3_index + (x << 2)));
*((__global int4 *)((__global uchar *)mat_dst + dst_index + (x << 4))) = (int4)(src0, src1, src2, src3);
}
}
__kernel void merge_vector_C4_D5(__global float *mat_dst, int dst_step, int dst_offset,
__global float *mat_src0, int src0_step, int src0_offset,
__global float *mat_src1, int src1_step, int src1_offset,
__global float *mat_src2, int src2_step, int src2_offset,
__global float *mat_src3, int src3_step, int src3_offset,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
int src0_index = mad24(y, src0_step, src0_offset);
int src1_index = mad24(y, src1_step, src1_offset);
int src2_index = mad24(y, src2_step, src2_offset);
int src3_index = mad24(y, src3_step, src3_offset);
int dst_index = mad24(y, dst_step , dst_offset);
float src0 = *((__global float *)((__global uchar *)mat_src0 + src0_index + (x << 2)));
float src1 = *((__global float *)((__global uchar *)mat_src1 + src1_index + (x << 2)));
float src2 = *((__global float *)((__global uchar *)mat_src2 + src2_index + (x << 2)));
float src3 = *((__global float *)((__global uchar *)mat_src3 + src3_index + (x << 2)));
*((__global float4 *)((__global uchar *)mat_dst + dst_index + (x << 4))) = (float4)(src0, src1, src2, src3);
}
}
#if defined (DOUBLE_SUPPORT)
__kernel void merge_vector_C4_D6(__global double *mat_dst, int dst_step, int dst_offset,
__global double *mat_src0, int src0_step, int src0_offset,
__global double *mat_src1, int src1_step, int src1_offset,
__global double *mat_src2, int src2_step, int src2_offset,
__global double *mat_src3, int src3_step, int src3_offset,
int rows, int cols, int dst_step1)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
int src0_index = mad24(y, src0_step, src0_offset);
int src1_index = mad24(y, src1_step, src1_offset);
int src2_index = mad24(y, src2_step, src2_offset);
int src3_index = mad24(y, src3_step, src3_offset);
int dst_index = mad24(y, dst_step , dst_offset);
double src0 = *((__global double *)((__global uchar *)mat_src0 + src0_index + (x << 3)));
double src1 = *((__global double *)((__global uchar *)mat_src1 + src1_index + (x << 3)));
double src2 = *((__global double *)((__global uchar *)mat_src2 + src2_index + (x << 3)));
double src3 = *((__global double *)((__global uchar *)mat_src3 + src3_index + (x << 3)));
*((__global double4 *)((__global uchar *)mat_dst + dst_index + (x << 5))) = (double4)(src0, src1, src2, src3);
}
}
#endif
///////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////optimized code using vector no roi//////////////////////////
////////////vector fuction name format: merge_vector_C(channels number)D_(data type depth)//////
////////////////////////////////////////////////////////////////////////////////////////////////
__kernel void merge_vector_C2_D0_1(int rows, int cols,
__global uchar *mat_dst, int dst_step,
__global uchar *mat_src0, int src0_step,
__global uchar *mat_src1, int src1_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global uchar4 *src0_y = (__global uchar4 * )(mat_src0 + y * src0_step);
__global uchar4 *src1_y = (__global uchar4 * )(mat_src1 + y * src1_step);
__global uchar8 *dst_y = (__global uchar8 *)(mat_dst + y * dst_step);
uchar4 value1 = src0_y[x];
uchar4 value2 = src1_y[x];
uchar8 value;
value.even = value1;
value.odd = value2;
dst_y[x] = value;
}
}
__kernel void merge_vector_C2_D1_1(int rows, int cols,
__global char *mat_dst, int dst_step,
__global char *mat_src0, int src0_step,
__global char *mat_src1, int src1_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global char4 *src0_y = (__global char4 * )(mat_src0 + y * src0_step);
__global char4 *src1_y = (__global char4 * )(mat_src1 + y * src1_step);
__global char8 *dst_y = (__global char8 *)(mat_dst + y * dst_step);
char4 value1 = src0_y[x];
char4 value2 = src1_y[x];
char8 value;
value.even = value1;
value.odd = value2;
dst_y[x] = value;
}
}
__kernel void merge_vector_C2_D2_1(int rows, int cols,
__global ushort *mat_dst, int dst_step,
__global ushort *mat_src0, int src0_step,
__global ushort *mat_src1, int src1_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global ushort2 *src0_y = (__global ushort2 *)((__global uchar *)mat_src0 + y * src0_step);
__global ushort2 *src1_y = (__global ushort2 *)((__global uchar *)mat_src1 + y * src1_step);
__global ushort4 *dst_y = (__global ushort4 *)((__global uchar *)mat_dst + y * dst_step);
ushort2 value1 = src0_y[x];
ushort2 value2 = src1_y[x];
ushort4 value;
value.even = value1;
value.odd = value2;
dst_y[x] = value;
}
}
__kernel void merge_vector_C2_D3_1(int rows, int cols,
__global short *mat_dst, int dst_step,
__global short *mat_src0, int src0_step,
__global short *mat_src1, int src1_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global short2 *src0_y = (__global short2 *)((__global uchar *)mat_src0 + y * src0_step);
__global short2 *src1_y = (__global short2 *)((__global uchar *)mat_src1 + y * src1_step);
__global short4 *dst_y = (__global short4 *)((__global uchar *)mat_dst + y * dst_step);
short2 value1 = src0_y[x];
short2 value2 = src1_y[x];
short4 value;
value.even = value1;
value.odd = value2;
dst_y[x] = value;
}
}
__kernel void merge_vector_C2_D4_1(int rows, int cols,
__global int *mat_dst, int dst_step,
__global int *mat_src0, int src0_step,
__global int *mat_src1, int src1_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global int *src0_y = (__global int *)((__global uchar *)mat_src0 + y * src0_step);
__global int *src1_y = (__global int *)((__global uchar *)mat_src1 + y * src1_step);
__global int2 *dst_y = (__global int2 *)((__global uchar *)mat_dst + y * dst_step);
int value1 = src0_y[x];
int value2 = src1_y[x];
int2 value;
value.even = value1;
value.odd = value2;
dst_y[x] = value;
}
}
__kernel void merge_vector_C2_D5_1(int rows, int cols,
__global float *mat_dst, int dst_step,
__global float *mat_src0, int src0_step,
__global float *mat_src1, int src1_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global float *src0_y = (__global float *)((__global uchar *)mat_src0 + y * src0_step);
__global float *src1_y = (__global float *)((__global uchar *)mat_src1 + y * src1_step);
__global float2 *dst_y = (__global float2 *)((__global uchar *)mat_dst + y * dst_step);
float value1 = src0_y[x];
float value2 = src1_y[x];
dst_y[x] = (float2)(value1, value2);
}
}
#if defined (DOUBLE_SUPPORT)
__kernel void merge_vector_C2_D6_1(int rows, int cols,
__global double *mat_dst, int dst_step,
__global double *mat_src0, int src0_step,
__global double *mat_src1, int src1_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global double *src0_y = (__global double *)((__global uchar *)mat_src0 + y * src0_step);
__global double *src1_y = (__global double *)((__global uchar *)mat_src1 + y * src1_step);
__global double2 *dst_y = (__global double2 *)((__global uchar *)mat_dst + y * dst_step);
double value1 = src0_y[x];
double value2 = src1_y[x];
dst_y[x] = (double2)(value1, value2);
}
}
#endif
__kernel void merge_vector_C3_D0_1(int rows, int cols,
__global uchar *mat_dst, int dst_step,
__global uchar *mat_src0, int src0_step,
__global uchar *mat_src1, int src1_step,
__global uchar *mat_src2, int src2_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global uchar4 *src0_y = (__global uchar4 * )(mat_src0 + y * src0_step);
__global uchar4 *src1_y = (__global uchar4 * )(mat_src1 + y * src1_step);
__global uchar4 *src2_y = (__global uchar4 * )(mat_src2 + y * src0_step);
__global uchar4 *dst_y = (__global uchar4 *)(mat_dst + y * dst_step);
uchar4 value0 = src0_y[x];
uchar4 value1 = src1_y[x];
uchar4 value2 = src2_y[x];
dst_y[3 * x + 0] = (uchar4)(value0.s0, value1.s0, value2.s0,
value0.s1);
dst_y[3 * x + 1] = (uchar4)(value1.s1, value2.s1,
value0.s2, value1.s2);
dst_y[3 * x + 2] = (uchar4)(value2.s2,
value0.s3, value1.s3, value2.s3);
}
}
__kernel void merge_vector_C3_D1_1(int rows, int cols,
__global char *mat_dst, int dst_step,
__global char *mat_src0, int src0_step,
__global char *mat_src1, int src1_step,
__global char *mat_src2, int src2_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global char4 *src0_y = (__global char4 * )(mat_src0 + y * src0_step);
__global char4 *src1_y = (__global char4 * )(mat_src1 + y * src1_step);
__global char4 *src2_y = (__global char4 * )(mat_src2 + y * src0_step);
__global char4 *dst_y = (__global char4 *)(mat_dst + y * dst_step);
char4 value0 = src0_y[x];
char4 value1 = src1_y[x];
char4 value2 = src2_y[x];
dst_y[3 * x + 0] = (char4)(value0.s0, value1.s0, value2.s0,
value0.s1);
dst_y[3 * x + 1] = (char4)(value1.s1, value2.s1,
value0.s2, value1.s2);
dst_y[3 * x + 2] = (char4)(value2.s2,
value0.s3, value1.s3, value2.s3);
/* for test do not delete
dst_y[3 * x + 0] = (char8)(value0.s0, value1.s0, value2.s0,
value0.s1, value1.s1, value2.s1,
value0.s2, value1.s2);
dst_y[3 * x + 1] = (char8)(value2.s2,
value0.s3, value1.s3, value2.s3,
value0.s4, value1.s4, value2.s4,
value0.s5);
dst_y[3 * x + 2] = (char8)(value1.s5, value2.s5,
value0.s6, value1.s6, value2.s6,
value0.s7, value1.s7, value2.s7);
*/
}
}
__kernel void merge_vector_C3_D2_1(int rows, int cols,
__global ushort *mat_dst, int dst_step,
__global ushort *mat_src0, int src0_step,
__global ushort *mat_src1, int src1_step,
__global ushort *mat_src2, int src2_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global ushort2 *src0_y = (__global ushort2 * )((__global char *)mat_src0 + y * src0_step);
__global ushort2 *src1_y = (__global ushort2 * )((__global char *)mat_src1 + y * src1_step);
__global ushort2 *src2_y = (__global ushort2 * )((__global char *)mat_src2 + y * src0_step);
__global ushort2 *dst_y = (__global ushort2 *)((__global char *)mat_dst + y * dst_step);
ushort2 value0 = src0_y[x];
ushort2 value1 = src1_y[x];
ushort2 value2 = src2_y[x];
dst_y[3 * x + 0] = (ushort2)(value0.x, value1.x);
dst_y[3 * x + 1] = (ushort2)(value2.x, value0.y);
dst_y[3 * x + 2] = (ushort2)(value1.y, value2.y);
}
}
__kernel void merge_vector_C3_D3_1(int rows, int cols,
__global short *mat_dst, int dst_step,
__global short *mat_src0, int src0_step,
__global short *mat_src1, int src1_step,
__global short *mat_src2, int src2_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global short2 *src0_y = (__global short2 * )((__global char *)mat_src0 + y * src0_step);
__global short2 *src1_y = (__global short2 * )((__global char *)mat_src1 + y * src1_step);
__global short2 *src2_y = (__global short2 * )((__global char *)mat_src2 + y * src0_step);
__global short2 *dst_y = (__global short2 *)((__global char *)mat_dst + y * dst_step);
short2 value0 = src0_y[x];
short2 value1 = src1_y[x];
short2 value2 = src2_y[x];
dst_y[3 * x + 0] = (short2)(value0.x, value1.x);
dst_y[3 * x + 1] = (short2)(value2.x, value0.y);
dst_y[3 * x + 2] = (short2)(value1.y, value2.y);
/*
dst_y[3 * x + 0] = (short4)(value0.s0, value1.s0, value2.s0,
value0.s1);
dst_y[3 * x + 1] = (short4)(value1.s1, value2.s1,
value0.s2, value1.s2);
dst_y[3 * x + 2] = (short4)(value2.s2,
value0.s3, value1.s3, value2.s3);
*/
}
}
__kernel void merge_vector_C3_D4_1(int rows, int cols,
__global int *mat_dst, int dst_step,
__global int *mat_src0, int src0_step,
__global int *mat_src1, int src1_step,
__global int *mat_src2, int src2_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global int *src0_y = (__global int * )((__global char *)mat_src0 + y * src0_step);
__global int *src1_y = (__global int * )((__global char *)mat_src1 + y * src1_step);
__global int *src2_y = (__global int * )((__global char *)mat_src2 + y * src0_step);
__global int *dst_y = (__global int *)((__global char *)mat_dst + y * dst_step);
int value0 = src0_y[x];
int value1 = src1_y[x];
int value2 = src2_y[x];
dst_y[3 * x + 0] = value0;
dst_y[3 * x + 1] = value1;
dst_y[3 * x + 2] = value2;
/*for test do not delete
dst_y[3 * x + 0] = (int2)(value0.x, value1.x);
dst_y[3 * x + 1] = (int2)(value2.x, value0.y);
dst_y[3 * x + 2] = (int2)(value1.y, value2.y);
*/
}
}
__kernel void merge_vector_C3_D5_1(int rows, int cols,
__global float *mat_dst, int dst_step,
__global float *mat_src0, int src0_step,
__global float *mat_src1, int src1_step,
__global float *mat_src2, int src2_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global float *src0_y = (__global float * )((__global char *)mat_src0 + y * src0_step);
__global float *src1_y = (__global float * )((__global char *)mat_src1 + y * src1_step);
__global float *src2_y = (__global float * )((__global char *)mat_src2 + y * src0_step);
__global float *dst_y = (__global float *)((__global char *)mat_dst + y * dst_step);
float value0 = src0_y[x];
float value1 = src1_y[x];
float value2 = src2_y[x];
dst_y[3 * x + 0] = value0;
dst_y[3 * x + 1] = value1;
dst_y[3 * x + 2] = value2;
}
}
#if defined (DOUBLE_SUPPORT)
__kernel void merge_vector_C3_D6_1(int rows, int cols,
__global double *mat_dst, int dst_step,
__global double *mat_src0, int src0_step,
__global double *mat_src1, int src1_step,
__global double *mat_src2, int src2_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global double *src0_y = (__global double * )((__global char *)mat_src0 + y * src0_step);
__global double *src1_y = (__global double * )((__global char *)mat_src1 + y * src1_step);
__global double *src2_y = (__global double * )((__global char *)mat_src2 + y * src0_step);
__global double *dst_y = (__global double *)((__global char *)mat_dst + y * dst_step);
double value0 = src0_y[x];
double value1 = src1_y[x];
double value2 = src2_y[x];
dst_y[3 * x + 0] = value0;
dst_y[3 * x + 1] = value1;
dst_y[3 * x + 2] = value2;
}
}
#endif
__kernel void merge_vector_C4_D0_1(int rows, int cols,
__global uchar *mat_dst, int dst_step,
__global uchar *mat_src0, int src0_step,
__global uchar *mat_src1, int src1_step,
__global uchar *mat_src2, int src2_step,
__global uchar *mat_src3, int src3_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global uchar4 *src0_y = (__global uchar4 * )(mat_src0 + y * src0_step);
__global uchar4 *src1_y = (__global uchar4 * )(mat_src1 + y * src1_step);
__global uchar4 *src2_y = (__global uchar4 * )(mat_src2 + y * src0_step);
__global uchar4 *src3_y = (__global uchar4 * )(mat_src3 + y * src1_step);
__global uchar16 *dst_y = (__global uchar16 *)(mat_dst + y * dst_step);
uchar4 value0 = src0_y[x];
uchar4 value1 = src1_y[x];
uchar4 value2 = src2_y[x];
uchar4 value3 = src3_y[x];
dst_y[x] = (uchar16)(value0.x, value1.x, value2.x, value3.x,
value0.y, value1.y, value2.y, value3.y,
value0.z, value1.z, value2.z, value3.z,
value0.w, value1.w, value2.w, value3.w);
}
}
__kernel void merge_vector_C4_D1_1(int rows, int cols,
__global char *mat_dst, int dst_step,
__global char *mat_src0, int src0_step,
__global char *mat_src1, int src1_step,
__global char *mat_src2, int src2_step,
__global char *mat_src3, int src3_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global char4 *src0_y = (__global char4 * )(mat_src0 + y * src0_step);
__global char4 *src1_y = (__global char4 * )(mat_src1 + y * src1_step);
__global char4 *src2_y = (__global char4 * )(mat_src2 + y * src0_step);
__global char4 *src3_y = (__global char4 * )(mat_src3 + y * src1_step);
__global char16 *dst_y = (__global char16 *)(mat_dst + y * dst_step);
char4 value0 = src0_y[x];
char4 value1 = src1_y[x];
char4 value2 = src2_y[x];
char4 value3 = src3_y[x];
dst_y[x] = (char16)(value0.x, value1.x, value2.x, value3.x,
value0.y, value1.y, value2.y, value3.y,
value0.z, value1.z, value2.z, value3.z,
value0.w, value1.w, value2.w, value3.w);
}
}
__kernel void merge_vector_C4_D2_1(int rows, int cols,
__global ushort *mat_dst, int dst_step,
__global ushort *mat_src0, int src0_step,
__global ushort *mat_src1, int src1_step,
__global ushort *mat_src2, int src2_step,
__global ushort *mat_src3, int src3_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global ushort2 *src0_y = (__global ushort2 * )((__global uchar*)mat_src0 + y * src0_step);
__global ushort2 *src1_y = (__global ushort2 * )((__global uchar*)mat_src1 + y * src1_step);
__global ushort2 *src2_y = (__global ushort2 * )((__global uchar*)mat_src2 + y * src0_step);
__global ushort2 *src3_y = (__global ushort2 * )((__global uchar*)mat_src3 + y * src1_step);
__global ushort8 *dst_y = (__global ushort8 *)((__global uchar*)mat_dst + y * dst_step);
ushort2 value0 = src0_y[x];
ushort2 value1 = src1_y[x];
ushort2 value2 = src2_y[x];
ushort2 value3 = src3_y[x];
dst_y[x] = (ushort8)(value0.x, value1.x, value2.x, value3.x,
value0.y, value1.y, value2.y, value3.y);
}
}
__kernel void merge_vector_C4_D3_1(int rows, int cols,
__global short *mat_dst, int dst_step,
__global short *mat_src0, int src0_step,
__global short *mat_src1, int src1_step,
__global short *mat_src2, int src2_step,
__global short *mat_src3, int src3_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global short2 *src0_y = (__global short2 * )((__global uchar*)mat_src0 + y * src0_step);
__global short2 *src1_y = (__global short2 * )((__global uchar*)mat_src1 + y * src1_step);
__global short2 *src2_y = (__global short2 * )((__global uchar*)mat_src2 + y * src0_step);
__global short2 *src3_y = (__global short2 * )((__global uchar*)mat_src3 + y * src1_step);
__global short8 *dst_y = (__global short8 *)((__global uchar*)mat_dst + y * dst_step);
short2 value0 = src0_y[x];
short2 value1 = src1_y[x];
short2 value2 = src2_y[x];
short2 value3 = src3_y[x];
dst_y[x] = (short8)(value0.x, value1.x, value2.x, value3.x,
value0.y, value1.y, value2.y, value3.y);
}
}
__kernel void merge_vector_C4_D4_1(int rows, int cols,
__global int *mat_dst, int dst_step,
__global int *mat_src0, int src0_step,
__global int *mat_src1, int src1_step,
__global int *mat_src2, int src2_step,
__global int *mat_src3, int src3_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global int *src0_y = (__global int * )((__global uchar*)mat_src0 + y * src0_step);
__global int *src1_y = (__global int * )((__global uchar*)mat_src1 + y * src1_step);
__global int *src2_y = (__global int * )((__global uchar*)mat_src2 + y * src0_step);
__global int *src3_y = (__global int * )((__global uchar*)mat_src3 + y * src1_step);
__global int4 *dst_y = (__global int4 *)((__global uchar*)mat_dst + y * dst_step);
int value0 = src0_y[x];
int value1 = src1_y[x];
int value2 = src2_y[x];
int value3 = src3_y[x];
dst_y[x] = (int4)(value0, value1, value2, value3);
}
}
__kernel void merge_vector_C4_D5_1(int rows, int cols,
__global float *mat_dst, int dst_step,
__global float *mat_src0, int src0_step,
__global float *mat_src1, int src1_step,
__global float *mat_src2, int src2_step,
__global float *mat_src3, int src3_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global float *src0_y = (__global float * )((__global uchar*)mat_src0 + y * src0_step);
__global float *src1_y = (__global float * )((__global uchar*)mat_src1 + y * src1_step);
__global float *src2_y = (__global float * )((__global uchar*)mat_src2 + y * src0_step);
__global float *src3_y = (__global float * )((__global uchar*)mat_src3 + y * src1_step);
__global float4 *dst_y = (__global float4 *)((__global uchar*)mat_dst + y * dst_step);
float value0 = src0_y[x];
float value1 = src1_y[x];
float value2 = src2_y[x];
float value3 = src3_y[x];
dst_y[x] = (float4)(value0, value1, value2, value3);
}
}
#if defined (DOUBLE_SUPPORT)
__kernel void merge_vector_C4_D6_1(int rows, int cols,
__global double *mat_dst, int dst_step,
__global double *mat_src0, int src0_step,
__global double *mat_src1, int src1_step,
__global double *mat_src2, int src2_step,
__global double *mat_src3, int src3_step)
{
int x = get_global_id(0);
int y = get_global_id(1);
if ((x < cols) && (y < rows))
{
__global double *src0_y = (__global double * )((__global uchar*)mat_src0 + y * src0_step);
__global double *src1_y = (__global double * )((__global uchar*)mat_src1 + y * src1_step);
__global double *src2_y = (__global double * )((__global uchar*)mat_src2 + y * src0_step);
__global double *src3_y = (__global double * )((__global uchar*)mat_src3 + y * src1_step);
__global double4 *dst_y = (__global double4 *)((__global uchar*)mat_dst + y * dst_step);
double value0 = src0_y[x];
double value1 = src1_y[x];
double value2 = src2_y[x];
double value3 = src3_y[x];
dst_y[x] = (double4)(value0, value1, value2, value3);
}
}
#endif