-
Notifications
You must be signed in to change notification settings - Fork 24
/
configure
executable file
·914 lines (816 loc) · 30.9 KB
/
configure
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
#!/bin/bash
#-----------------------------------------------------------------------------------------
# VCEEnc by rigaya
# -----------------------------------------------------------------------------------------
# ソースコードについて
# ・無保証です。
# ・本ソースコードを使用したことによるいかなる損害・トラブルについてrigayaは責任を負いません。
# 以上に了解して頂ける場合、本ソースコードの使用、複製、改変、再頒布を行って頂いて構いません。
# -----------------------------------------------------------------------------------------
CNF_LOG=config.log
cnf_write()
{
echo "$*"
echo "$*" >> ${CNF_LOG}
}
cnf_print()
{
printf "$*"
echo "$*" >> ${CNF_LOG}
}
write_config_mak()
{
echo $1
echo $1 >> config.mak
}
write_enc_config()
{
echo $1
echo $1 >> VCECore/rgy_config.h
}
write_app_rev()
{
echo $1
echo $1 >> VCECore/rgy_rev.h
}
cxx_check()
{
echo "" >> ${CNF_LOG}
if [ -n "$1" ]; then
printf "checking for $1..."
echo "### - checking for $1... --------------" >> ${CNF_LOG}
else
echo "### - test start --------------" >> ${CNF_LOG}
fi
echo "#include <iostream>" > cxx_check.c
if [ -n "$3" ]; then
echo "#include <$3>" >> cxx_check.c
fi
if [ -n "$4" ]; then
echo "extern \"C\" {" >> cxx_check.c
echo "#include <$4>" >> cxx_check.c
echo "}" >> cxx_check.c
fi
echo "int main(void){ $5; std::cout << \"Hello World!\" << std::endl; return 0;}" >> cxx_check.c
CXX_CMD="$CXX -w cxx_check.c $2 -o cxx_check"
echo "------ command ------------" >> ${CNF_LOG}
echo ${CXX_CMD} >> ${CNF_LOG}
echo "------ test ---------------" >> ${CNF_LOG}
cat cxx_check.c >> ${CNF_LOG}
echo "---------------------------" >> ${CNF_LOG}
$CXX_CMD 2>> ${CNF_LOG}
#$CXX cxx_check.c $1 -o cxx_check
ret=$?
rm -f cxx_check*
echo "### - test fin -> ${ret} ----------" >> ${CNF_LOG}
return $ret
}
regex_check()
{
echo "#include <iostream>" > cxx_check.c
echo "#include <string>" >> cxx_check.c
echo "#include <regex>" >> cxx_check.c
echo "int main(void){ try { std::regex re(R\"(\d+)\"); std::string test(\"1234\"); return std::regex_match(test, re) ? 0 : 1; } catch (...) { return 1; } }" >> cxx_check.c
$CXX cxx_check.c $1 -o cxx_check 2>/dev/null
ret=$?
if [ $ret -ne 0 ]; then
rm -f cxx_check*
return $ret
fi
./cxx_check 2>/dev/null
ret=$?
rm -f cxx_check*
return $ret
}
rm -f config.* .depend VCECore/rgy_config.h VCECore/rgy_rev.h
PKGCONFIG="pkg-config"
USE_PKGCONFIG=1
ENABLE_DEBUG=0
CC=${CC:-gcc}
CXX=${CXX:-g++}
LD=${LD:-g++}
PROGRAM=vceencc
PREFIX=${PREFIX:-/usr/local}
EXTRACXXFLAGS=""
EXTRALDFLAGS=""
SRCS=""
X86_64=1
NO_RDTSCP_INTRIN=0
CARGO=${CARGO:-cargo}
ENABLE_LTO=0
ENABLE_CPP_REGEX=1
LIBVA_SUPPORT=1
LIBVA_X11_SUPPORT=1
LIBVA_DRM_SUPPORT=1
OPENCL_HEADERS=""
VULKAN_HEADERS=""
CHECK_LIBAV_NAMES="libswresample libavutil libavcodec libavformat libavfilter libavdevice"
LIBAV_CFLAGS=""
LIBAV_LIBS=""
ENABLE_AVSW_READER=1
AV_CHANNEL_LAYOUT_STRUCT_AVAIL=1
AV_FRAME_DURATION_AVAIL=1
AVCODEC_PAR_CODED_SIDE_DATA_AVAIL=1
CHECK_VAPOURSYNTH_NAMES="vapoursynth vapoursynth-script"
ENABLE_VAPOURSYNTH=1
VAPOURSYNTH_LIBS=""
VAPOURSYNTH_CFLAGS=""
CHECK_AVISYNTH_NAMES="avisynth"
ENABLE_AVISYNTH=1
AVISYNTH_CFLAGS=""
CHECK_LIBASS_NAMES="libass"
LIBASS_CFLAGS=""
LIBASS_LIBS=""
ENABLE_LIBASS=1
CHECK_LIBPLACEBO_NAMES="libplacebo"
LIBPLACEBO_CFLAGS=""
LIBPLACEBO_LIBS=""
ENABLE_LIBPLACEBO=0
LIBPLACEBO_API_VER=338
CHECK_VULKAN_NAMES="vulkan"
VULKAN_CFLAGS=""
ENABLE_VULKAN=1
LIBDOVI_CFLAGS=""
LIBDOVI_LIBS=""
ENABLE_LIBDOVI=1
LIBHDR10PLUS_CFLAGS=""
LIBHDR10PLUS_LIBS=""
ENABLE_LIBHDR10PLUS=1
DTL_CFLAGS="-I./dtl"
ENABLE_DTL=1
CLRNG_CXXFLAGS="-I./clRNG/src/include"
CPPCODEC_CFLAGS="-I./cppcodec"
print_help()
{
cat << EOF
Usage: ./configure [options]
options:
-h, --help print this message
--prefix=PREFIX install vceencc into PREFIX/bin [${PREFIX}]
--cxx=CC set C compiler path [${CC}]
--cxx=CXX set C++ compiler path [${CXX}]
--pkg-config=PKGCONFIG set pkg-config path [${PKGCONFIG}]
--enable-debug compile in debug configuration [${ENABLE_DEBUG}]
--enable-lto compile with lto [${ENABLE_LTO}]
--opencl-headers set opencl headers path [${OPENCL_HEADERS}]
--vulkan-headers set vulkan headers path [${VULKAN_HEADERS}]
--extra-cxxflags=XCFLAGS add XCFLAGS to CXXFLAGS
--extra-ldflags=XLDFLAGS add XLDFLAGS to LDFLAGS
--disable-vapoursynth disable vapoursynth support [auto]
--disable-avisynth disable avisynth support [auto]
--disable-libass disable libass support [auto]
--disable-dtl disable dtl support [auto]
EOF
}
SRCDIR=$(dirname "$0")
if [ "${SRCDIR}" == "`pwd`" ]; then
SRCDIR=.
fi
for opt; do
optarg="${opt#*=}"
case "$opt" in
-h)
print_help
exit 0
;;
--help)
print_help
exit 0
;;
--prefix=*)
PREFIX="$optarg"
;;
--cc=*)
CC="$optarg"
;;
--cxx=*)
CXX="$optarg"
LD="$optarg"
;;
--extra-cxxflags=*)
EXTRACXXFLAGS="$optarg"
;;
--extra-ldflags=*)
EXTRALDFLAGS="$optarg"
;;
--enable-debug)
ENABLE_DEBUG=1
;;
--enable-lto)
ENABLE_LTO=1
;;
--opencl-headers=*)
OPENCL_HEADERS="$optarg"
;;
--disable-vapoursynth)
ENABLE_VAPOURSYNTH=0
;;
--disable-avisynth)
ENABLE_AVISYNTH=0
;;
--disable-libass)
ENABLE_LIBASS=0
;;
--disable-dtl)
ENABLE_DTL=0
;;
--pkg-config=*)
PKGCONFIG="$optarg"
;;
*)
echo "unknown option $opt"
exit 1
;;
esac
done
## log
echo "" > ${CNF_LOG}
echo "CNF_LOG=${CNF_LOG}" >> ${CNF_LOG}
echo "PKGCONFIG=${PKGCONFIG}" >> ${CNF_LOG}
echo "USE_PKGCONFIG=${USE_PKGCONFIG}" >> ${CNF_LOG}
echo "ENABLE_DEBUG=${ENABLE_DEBUG}" >> ${CNF_LOG}
echo "CC=${CC}" >> ${CNF_LOG}
echo "CXX=${CXX}" >> ${CNF_LOG}
echo "PROGRAM=${PROGRAM}" >> ${CNF_LOG}
echo "PREFIX=${PREFIX}" >> ${CNF_LOG}
echo "EXTRACXXFLAGS=${EXTRACXXFLAGS}" >> ${CNF_LOG}
echo "EXTRALDFLAGS=${EXTRALDFLAGS}" >> ${CNF_LOG}
echo "OPENCL_HEADERS=${OPENCL_HEADERS}" >> ${CNF_LOG}
echo "X86_64=${X86_64}" >> ${CNF_LOG}
echo "ENABLE_CPP_REGEX=${ENABLE_CPP_REGEX}" >> ${CNF_LOG}
echo "CHECK_LIBAV_NAMES=${CHECK_LIBAV_NAMES}" >> ${CNF_LOG}
echo "ENABLE_AVSW_READER=${ENABLE_AVSW_READER}" >> ${CNF_LOG}
echo "ENABLE_VAPOURSYNTH=${ENABLE_VAPOURSYNTH}" >> ${CNF_LOG}
echo "ENABLE_AVISYNTH=${ENABLE_AVISYNTH}" >> ${CNF_LOG}
echo "ENABLE_LIBASS=${ENABLE_LIBASS}" >> ${CNF_LOG}
echo "ENABLE_DTL=${ENABLE_DTL}" >> ${CNF_LOG}
for file in "${CXX}" "${LD}"; do
if [ ! `type -p $file 2> /dev/null` ]; then
cnf_write $file not found
exit 1
fi
done
cnf_print "checking for ${CXX}..."
if ! cxx_check "" ; then
cnf_write "${CXX} does not work"
exit 1
fi
cnf_write "OK"
if [ `echo | ${CXX} -E -dM - | egrep "WIN32|WIN64" | wc --lines` -ne 0 ]; then
cnf_write "This script does not support Windows platform."
cnf_write "For Windows, use Visual Studio."
exit 1
fi
if [ `echo | ${CXX} -E -dM - | grep "x86_64" | wc --lines` -eq 0 ]; then
X86_64=0
fi
CFLAGS="-Wall -Wno-missing-braces -Wno-unknown-pragmas -Wno-unused \
-DLINUX -DUNIX -D_FILE_OFFSET_BITS=64 -D__USE_LARGEFILE64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
CXXFLAGS="-Wall -Wno-missing-braces -Wno-unknown-pragmas -Wno-unused \
-DLINUX -DUNIX -D_FILE_OFFSET_BITS=64 -D__USE_LARGEFILE64 -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS \
-I${SRCDIR} -I${SRCDIR}/AMF/amf/public/include -I${SRCDIR}/AMF/amf/public/include/core -I${SRCDIR}/AMF/amf/public/include/components \
-I${SRCDIR}/VCECore -I${SRCDIR}/tinyxml2 -I${SRCDIR}/ttmath \
"
if cxx_check "-Wno-unknown-warning-option" "${CXXFLAGS} -Wno-unknown-warning-option ${LDFLAGS}" ; then
CFLAGS="${CFLAGS} -Wno-unknown-warning-option"
CXXFLAGS="${CXXFLAGS} -Wno-unknown-warning-option"
cnf_write "OK"
else
cnf_write "Skip"
fi
LDFLAGS="-L. -ldl -lm -lstdc++ -lstdc++fs"
if [ $X86_64 -ne 0 ]; then
CFLAGS="${CFLAGS} -DLINUX64 -m64"
CXXFLAGS="${CXXFLAGS} -DLINUX64 -m64"
LDFLAGS="${LDFLAGS} -m64"
else
CFLAGS="${CFLAGS} -DLINUX32 -m32"
CXXFLAGS="${CXXFLAGS} -DLINUX32 -m32"
LDFLAGS="${LDFLAGS} -m32"
fi
if cxx_check "pthread" "${CXXFLAGS} -pthread ${LDFLAGS} -lpthread" ; then
CXXFLAGS="$CXXFLAGS -pthread"
LDFLAGS="${LDFLAGS} -lpthread"
else
cnf_write "pthread not installed."
exit 1
fi
cnf_write "OK"
if cxx_check "c++17" "${CXXFLAGS} -std=c++17 ${LDFLAGS}" ; then
CXXFLAGS="$CXXFLAGS -std=c++17"
else
cnf_write "${CXX} does not work with -std=c++17"
exit 1
fi
cnf_write "OK"
if cxx_check "-msse4.1" "${CXXFLAGS} -msse4.1 ${LDFLAGS}" ; then
CXXFLAGS="$CXXFLAGS -msse4.1"
else
cnf_write "SSE4.1 not supported with this compiler."
exit 1
fi
cnf_write "OK"
if ! cxx_check "__rdtscp()" "${CXXFLAGS} ${LDFLAGS}" "" "x86intrin.h" "unsigned int a = 0; auto i = __rdtscp(&a);" ; then
CXXFLAGS="${CXXFLAGS} -DNO_RDTSCP_INTRIN=1"
cnf_write "no"
else
cnf_write "yes"
fi
if [ ! $ENABLE_DEBUG -eq 0 ]; then
cnf_write "configuring for debug..."
CXXFLAGS="${CXXFLAGS} -O0 -g -D_DEBUG"
CFLAGS="${CFLAGS} -O0 -g -D_DEBUG"
else
cnf_write "configuring for speed..."
CXXFLAGS="${CXXFLAGS} -O3 -DNDEBUG=1"
CFLAGS="${CFLAGS} -O3 -DNDEBUG=1"
if cxx_check "-mfpmath=sse" "${CXXFLAGS} -mfpmath=sse ${LDFLAGS}" ; then
CXXFLAGS="$CXXFLAGS -mfpmath=sse"
cnf_write "yes"
fi
if cxx_check "-fPIE" "${CXXFLAGS} -fPIE ${LDFLAGS}" ; then
CXXFLAGS="$CXXFLAGS -fPIE"
CFLAGS="$CFLAGS -fPIE"
cnf_write "yes"
fi
if ${CXX} -dM -E -x c /dev/null | grep "__clang__" > /dev/null; then
IS_CLANG=1
else
IS_CLANG=0
fi
if [ $IS_CLANG -eq 0 ]; then
if cxx_check "-ffast-math" "${CXXFLAGS} -ffast-math ${LDFLAGS}" ; then
CXXFLAGS="$CXXFLAGS -ffast-math"
cnf_write "yes"
fi
fi
if cxx_check "-fomit-frame-pointer" "${CXXFLAGS} -fomit-frame-pointer ${LDFLAGS}" ; then
CXXFLAGS="$CXXFLAGS -fomit-frame-pointer"
cnf_write "yes"
fi
LDFLAGS="$LDFLAGS -Wl,-s"
if [ $ENABLE_LTO -ne 0 ]; then
CXXFLAGS="$CXXFLAGS -flto"
LDFLAGS="$LDFLAGS -flto"
fi
fi
cnf_print "checking for pkg-config..."
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$PREFIX/lib/pkgconfig
type -p $PKGCONFIG 2>/dev/null 1>/dev/null
if [ $? -ne 0 ]; then
cnf_write "${PKGCONFIG} does not exist."
USE_PKGCONFIG=0
fi
cnf_write "OK"
if [ -n "$EXTRACXXFLAGS" ]; then
printf "checking --extra-cflags..."
if ! cxx_check "${CXXFLAGS} ${EXTRACXXFLAGS} ${LDFLAGS}" ; then
cnf_write "--extra-cflags=${EXTRACXXFLAGS} does not work"
exit 1
fi
cnf_write "OK"
fi
if [ -n "$EXTRALDFLAGS" ]; then
if ! cxx_check "--extra-ldflags" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LDFLAGS} ${EXTRALDFLAGS}" ; then
cnf_write "--extra-ldflags=${EXTRALDFLAGS} does not work"
exit 1
fi
cnf_write "OK"
fi
OPENCL_CXXFLAGS=
if [ "${OPENCL_HEADERS}" != "" ]; then
OPENCL_CXXFLAGS=-I${OPENCL_HEADERS}
fi
if cxx_check "opencl-headers" "${CXXFLAGS} ${OPENCL_CXXFLAGS}" "" "CL/opencl.h" "cl_int test = 0;" ; then
CXXFLAGS="${CXXFLAGS} ${OPENCL_CXXFLAGS}"
cnf_write "yes"
else
cnf_write "OpenCL headers not installed."
exit 1
fi
if cxx_check "clRNG-headers" "${CXXFLAGS} ${CLRNG_CXXFLAGS}" "" "clRNG/clRNG.h" "clrngStatus sts = (clrngStatus)0;" ; then
CXXFLAGS="${CXXFLAGS} ${CLRNG_CXXFLAGS}"
CFLAGS="${CFLAGS} ${CLRNG_CXXFLAGS}"
cnf_write "yes"
else
cnf_write "clRNG headers missing."
exit 1
fi
if [ $ENABLE_AVSW_READER -ne 0 ]; then
if [ $USE_PKGCONFIG -ne 0 ]; then
printf "checking libavcodec with pkg-config..."
if ! ${PKGCONFIG} --exists $CHECK_LIBAV_NAMES ; then
cnf_write "libs could not be detected by ${PKGCONFIG}. [ PKG_CONFIG_PATH=${PKG_CONFIG_PATH} ]"
else
cnf_write "OK"
LIBAV_LIBS=`${PKGCONFIG} --libs ${CHECK_LIBAV_NAMES}`
LIBAV_CFLAGS=`${PKGCONFIG} --cflags ${CHECK_LIBAV_NAMES}`
fi
fi
if [ -z "$LIBAV_LIBS" ]; then
LIBAV_LIBS=""
for lib in $CHECK_LIB_NAMES; do
LIBAV_LIBS="${LIBAV_LIBS} -l${lib#lib}"
done
cnf_write "lib settings might be inaqurate."
fi
if ! cxx_check "libavutil" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LIBAV_CFLAGS} ${LDFLAGS} ${EXTRALDFLAGS} ${LIBAV_LIBS}" "" "libavutil/avutil.h" "avutil_version();" ; then
cnf_write "no"
ENABLE_AVSW_READER=0
else
cnf_write "yes"
fi
if ! cxx_check "libavcodec" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LIBAV_CFLAGS} ${LDFLAGS} ${EXTRALDFLAGS} ${LIBAV_LIBS}" "" "libavcodec/avcodec.h" "avcodec_find_decoder((AVCodecID)0);" ; then
cnf_write "no"
ENABLE_AVSW_READER=0
else
cnf_write "yes"
fi
if ! cxx_check "libavformat" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LIBAV_CFLAGS} ${LDFLAGS} ${EXTRALDFLAGS} ${LIBAV_LIBS}" "" "libavformat/avformat.h" "avformat_find_stream_info(0,0);" ; then
cnf_write "no"
ENABLE_AVSW_READER=0
else
cnf_write "yes"
fi
if ! cxx_check "libavfilter" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LIBAV_CFLAGS} ${LDFLAGS} ${EXTRALDFLAGS} ${LIBAV_LIBS}" "" "libavfilter/avfilter.h" "avfilter_version();" ; then
cnf_write "no"
ENABLE_AVSW_READER=0
else
cnf_write "yes"
fi
if ! cxx_check "libswresample" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LIBAV_CFLAGS} ${LDFLAGS} ${EXTRALDFLAGS} ${LIBAV_LIBS}" "" "libswresample/swresample.h" "swr_alloc();" ; then
cnf_write "no"
ENABLE_AVSW_READER=0
else
cnf_write "yes"
fi
if ! cxx_check "AVChannelLayout" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LIBAV_CFLAGS} ${LDFLAGS} ${EXTRALDFLAGS} ${LIBAV_LIBS}" "" "libavutil/channel_layout.h" "AVChannelLayout ch_layout;" ; then
cnf_write "no"
AV_CHANNEL_LAYOUT_STRUCT_AVAIL=0
else
cnf_write "yes"
fi
if ! cxx_check "AVFrame::duration" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LIBAV_CFLAGS} ${LDFLAGS} ${EXTRALDFLAGS} ${LIBAV_LIBS}" "" "libavutil/frame.h" "AVFrame *frame; frame->duration = 0;" ; then
cnf_write "no"
AV_FRAME_DURATION_AVAIL=0
else
cnf_write "yes"
fi
if ! cxx_check "AVCodecParameters::coded_side_data" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LIBAV_CFLAGS} ${LDFLAGS} ${EXTRALDFLAGS} ${LIBAV_LIBS}" "" "libavcodec/codec_par.h" "AVCodecParameters *codecpar; codecpar->coded_side_data = 0;" ; then
cnf_write "no"
AVCODEC_PAR_CODED_SIDE_DATA_AVAIL=0
else
cnf_write "yes"
fi
if [ $ENABLE_AVSW_READER -eq 0 ]; then
cnf_write "libavutil, libavcodec, libavformat, libavfilter, libswresample are required to build vceencc."
exit 1
fi
fi
cnf_print "Checking for dovi..."
if ! ${PKGCONFIG} --exists dovi ; then
cnf_write "couldn't find system wide libdovi, trying included one."
cnf_print "checking for $CARGO..."
type -p $CARGO 2>/dev/null 1>/dev/null
if [ $? -ne 0 ]; then
cnf_write "${CARGO} does not exist."
ENABLE_LIBDOVI=0
else
cnf_write "OK"
fi
if [ $ENABLE_LIBDOVI -ne 0 ]; then
CARGO=${CARGO} ./build_libdovi.sh
LIBDOVI_PC=$(find `pwd`/build_libdovi -name 'dovi.pc')
cnf_print "checking libdovi with pkg-config..."
if ! ${PKGCONFIG} --exists ${LIBDOVI_PC} ; then
cnf_write "libs could not be detected by ${PKGCONFIG}. [ PKG_CONFIG_PATH=${PKG_CONFIG_PATH} ]"
else
cnf_write "OK"
LIBDOVI_LIBS=`${PKGCONFIG} --libs --static ${LIBDOVI_PC}`
LIBDOVI_CFLAGS=`${PKGCONFIG} --cflags ${LIBDOVI_PC}`
fi
if ! cxx_check "rpu_parser.h" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LIBDOVI_CFLAGS} ${LDFLAGS} ${EXTRALDFLAGS} ${LIBDOVI_LIBS}" "libdovi/rpu_parser.h" "" "dovi_parse_rpu(nullptr, 0);" ; then
cnf_write "no"
ENABLE_LIBDOVI=0
LIBDOVI_LIBS=""
LIBDOVI_CFLAGS=""
else
cnf_write "yes"
fi
fi
else
cnf_write "OK"
LIBDOVI_LIBS=`${PKGCONFIG} --libs --static dovi`
LIBDOVI_CFLAGS=`${PKGCONFIG} --cflags dovi`
fi
cnf_print "Checking for hdr10plus..."
if ! ${PKGCONFIG} --exists hdr10plus ; then
cnf_write "couldn't find system wide libhdr10plus, trying included one."
cnf_print "checking for $CARGO..."
type -p $CARGO 2>/dev/null 1>/dev/null
if [ $? -ne 0 ]; then
cnf_write "${CARGO} does not exist."
ENABLE_LIBHDR10PLUS=0
else
cnf_write "OK"
fi
if [ $ENABLE_LIBHDR10PLUS -ne 0 ]; then
CARGO=${CARGO} ./build_libhdr10plus.sh
LIBHDR10PLUS_PC=$(find `pwd`/build_libhdr10plus -name 'hdr10plus-rs.pc')
cnf_print "checking libhdr10plus with pkg-config..."
if ! ${PKGCONFIG} --exists ${LIBHDR10PLUS_PC} ; then
cnf_write "libs could not be detected by ${PKGCONFIG}. [ PKG_CONFIG_PATH=${PKG_CONFIG_PATH} ]"
ENABLE_LIBHDR10PLUS=0
else
cnf_write "OK"
LIBHDR10PLUS_LIBS=`${PKGCONFIG} --libs --static ${LIBHDR10PLUS_PC}`
LIBHDR10PLUS_CFLAGS=`${PKGCONFIG} --cflags ${LIBHDR10PLUS_PC}`
fi
fi
else
cnf_write "OK"
LIBHDR10PLUS_LIBS=`${PKGCONFIG} --libs --static hdr10plus-rs`
LIBHDR10PLUS_CFLAGS=`${PKGCONFIG} --cflags hdr10plus-rs`
fi
if [ $ENABLE_LIBHDR10PLUS -ne 0 ]; then
if ! cxx_check "hdr10plus.h" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LIBHDR10PLUS_CFLAGS} ${LDFLAGS} ${EXTRALDFLAGS} ${LIBHDR10PLUS_LIBS}" "libhdr10plus-rs/hdr10plus.h" "" "hdr10plus_rs_parse_json(nullptr);" ; then
cnf_write "no"
ENABLE_LIBHDR10PLUS=0
LIBHDR10PLUS_LIBS=""
LIBHDR10PLUS_CFLAGS=""
else
cnf_write "yes"
fi
fi
if [ $ENABLE_VULKAN -ne 0 ]; then
cnf_print "checking vulkan with pkg-config..."
if ! ${PKGCONFIG} --exists ${CHECK_VULKAN_NAMES} ; then
cnf_write "libs could not be detected by ${PKGCONFIG}. [ PKG_CONFIG_PATH=${PKG_CONFIG_PATH} ]"
else
cnf_write "OK"
VULKAN_CFLAGS=`${PKGCONFIG} --cflags ${CHECK_VULKAN_NAMES}`
fi
if ! cxx_check "vulkan/vulkan.h" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LIBAV_CFLAGS} ${VULKAN_CFLAGS} ${LDFLAGS} ${EXTRALDFLAGS} ${LIBAV_LIBS}" "" "vulkan/vulkan.h" "std::cout << VK_HEADER_VERSION << std::endl;" ; then
cnf_write "no"
cnf_write "vulkan headers not installed."
exit 1
else
cnf_write "yes"
fi
fi
if [ $ENABLE_VULKAN -eq 0 ]; then
ENABLE_LIBPLACEBO=0
fi
if [ $ENABLE_LIBPLACEBO -ne 0 ]; then
cnf_print "checking libplacebo with pkg-config..."
if ! ${PKGCONFIG} --exists ${CHECK_LIBPLACEBO_NAMES} ; then
cnf_write "libs could not be detected by ${PKGCONFIG}. [ PKG_CONFIG_PATH=${PKG_CONFIG_PATH} ]"
else
cnf_write "OK"
#LIBPLACEBO_LIBS=`${PKGCONFIG} --libs ${CHECK_LIBPLACEBO_NAMES}`
LIBPLACEBO_CFLAGS=`${PKGCONFIG} --cflags ${CHECK_LIBPLACEBO_NAMES}`
fi
if ! cxx_check "libplacebo/config.h" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LIBAV_CFLAGS} ${LIBPLACEBO_CFLAGS} ${LDFLAGS} ${EXTRALDFLAGS} ${LIBAV_LIBS} ${LIBPLACEBO_LIBS}" "" "libplacebo/config.h" "std::cout << PL_API_VER << std::endl;" ; then
cnf_write "no"
ENABLE_LIBPLACEBO=0
else
cnf_write "yes"
fi
cnf_print "checking for libplacebo API version..."
PL_API_VER=`echo "#include <iostream>" > cxx_check.c; echo "#include <libplacebo/config.h>" >> cxx_check.c; echo "int main(void){ std::cout << PL_API_VER << std::endl; return 0;}" >> cxx_check.c; $CXX cxx_check.c ${CXXFLAGS} ${EXTRACXXFLAGS} ${LIBAV_CFLAGS} ${LIBPLACEBO_CFLAGS} ${LDFLAGS} ${EXTRALDFLAGS} ${LIBAV_LIBS} ${LIBPLACEBO_LIBS} -o cxx_check 2>/dev/null; ./cxx_check 2>/dev/null; rm -f cxx_check*`
if [ -z "$PL_API_VER" ]; then
cnf_write "fail"
ENABLE_LIBPLACEBO=0
else
if [ $PL_API_VER -lt $LIBPLACEBO_API_VER ]; then
cnf_write "fail (${PL_API_VER})"
cnf_write "libplacebo API version >= ${LIBPLACEBO_API_VER} required."
ENABLE_LIBPLACEBO=0
else
cnf_write "OK (${PL_API_VER})"
fi
fi
if [ $ENABLE_LIBPLACEBO -eq 0 ]; then
LIBPLACEBO_CFLAGS=""
LIBPLACEBO_LIBS=""
fi
fi
if [ $ENABLE_VAPOURSYNTH -ne 0 ]; then
printf "checking vapoursynth with pkg-config..."
if ! ${PKGCONFIG} --exists ${CHECK_VAPOURSYNTH_NAMES} ; then
cnf_write "libs could not be detected by ${PKGCONFIG}. [ PKG_CONFIG_PATH=${PKG_CONFIG_PATH} ]"
else
cnf_write "OK"
VAPOURSYNTH_LIBS=`${PKGCONFIG} --libs ${CHECK_VAPOURSYNTH_NAMES}`
VAPOURSYNTH_CFLAGS=`${PKGCONFIG} --cflags ${CHECK_VAPOURSYNTH_NAMES}`
fi
if ! cxx_check "VapourSynth.h" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LIBAV_CFLAGS} ${VAPOURSYNTH_CFLAGS} ${LDFLAGS} ${EXTRALDFLAGS} ${LIBAV_LIBS} ${VAPOURSYNTH_LIBS}" "VapourSynth.h" "" "" ; then
cnf_write "no"
ENABLE_VAPOURSYNTH=0
else
cnf_write "yes"
fi
if ! cxx_check "VSScript.h" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LIBAV_CFLAGS} ${VAPOURSYNTH_CFLAGS} ${LDFLAGS} ${EXTRALDFLAGS} ${LIBAV_LIBS} ${VAPOURSYNTH_LIBS}" "VSScript.h" "" "" ; then
cnf_write "no"
ENABLE_VAPOURSYNTH=0
else
cnf_write "yes"
fi
if [ $ENABLE_VAPOURSYNTH -eq 0 ]; then
VAPOURSYNTH_CFLAGS=""
VAPOURSYNTH_LIBS=""
fi
fi
if [ $ENABLE_AVISYNTH -ne 0 ]; then
printf "checking avisynth with pkg-config..."
if ! ${PKGCONFIG} --exists ${CHECK_AVISYNTH_NAMES} ; then
cnf_write "libs could not be detected by ${PKGCONFIG}. [ PKG_CONFIG_PATH=${PKG_CONFIG_PATH} ]"
else
cnf_write "OK"
AVISYNTH_LIBS=`${PKGCONFIG} --libs ${CHECK_AVISYNTH_NAMES}`
AVISYNTH_CFLAGS=`${PKGCONFIG} --cflags ${CHECK_AVISYNTH_NAMES}`
fi
if ! cxx_check "avisynth_c.h" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LIBAV_CFLAGS} ${AVISYNTH_CFLAGS} ${LDFLAGS} ${EXTRALDFLAGS} ${AVISYNTH_LIBS}" "avisynth_c.h" "" "" ; then
cnf_write "no"
ENABLE_AVISYNTH=0
else
cnf_write "yes"
fi
if [ $ENABLE_AVISYNTH -eq 0 ]; then
AVISYNTH_CFLAGS=""
AVISYNTH_LIBS=""
fi
fi
if [ $ENABLE_LIBASS -ne 0 ]; then
printf "checking libass with pkg-config..."
if ! ${PKGCONFIG} --exists ${CHECK_LIBASS_NAMES} ; then
cnf_write "libs could not be detected by ${PKGCONFIG}. [ PKG_CONFIG_PATH=${PKG_CONFIG_PATH} ]"
else
cnf_write "OK"
LIBASS_LIBS=`${PKGCONFIG} --libs ${CHECK_LIBASS_NAMES}`
LIBASS_CFLAGS=`${PKGCONFIG} --cflags ${CHECK_LIBASS_NAMES}`
fi
if ! cxx_check "ass/ass.h" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LDFLAGS} ${EXTRALDFLAGS}" "" "ass/ass.h" "" ; then
cnf_write "no"
ENABLE_LIBASS=0
else
cnf_write "yes"
fi
if [ $ENABLE_LIBASS -eq 0 ]; then
LIBASS_CFLAGS=""
LIBASS_LIBS=""
fi
fi
if [ $ENABLE_DTL -ne 0 ]; then
if ! cxx_check "dtl/dtl.hpp" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LDFLAGS} ${EXTRALDFLAGS}" "dtl/dtl/dtl.hpp" "" "" ; then
if ! cxx_check "dtl/dtl.hpp" "${CXXFLAGS} ${EXTRACXXFLAGS} ${LDFLAGS} ${EXTRALDFLAGS}" "dtl/dtl.hpp" "" "" ; then
cnf_write "no"
ENABLE_DTL=0
else
cnf_write "yes"
fi
else
DTL_CFLAGS="-I./dtl"
cnf_write "yes"
fi
fi
SRC_VCECORE=" \
convert_csp.cpp convert_csp_avx.cpp \
convert_csp_avx2.cpp convert_csp_sse2.cpp convert_csp_sse41.cpp convert_csp_ssse3.cpp \
cpu_info.cpp gpu_info.cpp gpuz_info.cpp logo.cpp \
rgy_aspect_ratio.cpp rgy_avlog.cpp \
rgy_avutil.cpp rgy_bitstream.cpp rgy_bitstream_avx2.cpp rgy_bitstream_avx512bw.cpp \
rgy_chapter.cpp \
rgy_cmd.cpp rgy_codepage.cpp rgy_def.cpp \
rgy_device.cpp rgy_device_info_cache.cpp rgy_device_usage.cpp rgy_device_vulkan.cpp \
rgy_env.cpp rgy_err.cpp rgy_event.cpp \
rgy_faw.cpp rgy_faw_avx2.cpp rgy_faw_avx512bw.cpp \
rgy_filesystem.cpp \
rgy_filter.cpp rgy_filter_afs.cpp rgy_filter_afs_analyze.cpp rgy_filter_afs_filter.cpp \
rgy_filter_afs_merge.cpp rgy_filter_afs_synthesize.cpp rgy_filter_cl.cpp \
rgy_filter_colorspace.cpp rgy_filter_crop.cpp rgy_filter_convolution3d.cpp rgy_filter_curves.cpp \
rgy_filter_deband.cpp rgy_filter_decimate.cpp rgy_filter_decomb.cpp rgy_filter_delogo.cpp \
rgy_filter_denoise_dct.cpp rgy_filter_denoise_fft3d.cpp rgy_filter_denoise_knn.cpp rgy_filter_denoise_nlmeans.cpp \
rgy_filter_denoise_pmd.cpp rgy_filter_edgelevel.cpp rgy_filter_libplacebo.cpp rgy_filter_mpdecimate.cpp rgy_filter_nnedi.cpp \
rgy_filter_overlay.cpp rgy_filter_pad.cpp rgy_filter_resize.cpp rgy_filter_rff.cpp \
rgy_filter_smooth.cpp \
rgy_filter_ssim.cpp rgy_filter_subburn.cpp rgy_filter_transform.cpp rgy_filter_tweak.cpp \
rgy_filter_unsharp.cpp rgy_filter_warpsharp.cpp rgy_filter_yadif.cpp \
rgy_frame.cpp rgy_frame_info.cpp rgy_hdr10plus.cpp rgy_ini.cpp \
rgy_input.cpp rgy_input_avcodec.cpp rgy_input_avi.cpp rgy_input_avs.cpp \
rgy_input_raw.cpp rgy_input_sm.cpp rgy_input_vpy.cpp rgy_language.cpp \
rgy_libdovi.cpp rgy_libplacebo.cpp \
rgy_level_av1.cpp rgy_level_h264.cpp rgy_level_hevc.cpp \
rgy_memmem.cpp rgy_memmem_avx2.cpp rgy_memmem_avx512bw.cpp \
rgy_log.cpp rgy_opencl.cpp rgy_output.cpp rgy_output_avcodec.cpp \
rgy_perf_counter.cpp rgy_perf_monitor.cpp rgy_pipe.cpp rgy_pipe_linux.cpp \
rgy_prm.cpp rgy_resource.cpp rgy_simd.cpp rgy_status.cpp \
rgy_thread_affinity.cpp rgy_timecode.cpp rgy_util.cpp rgy_version.cpp \
rgy_vulkan.cpp rgy_wav_parser.cpp \
vce_amf.cpp vce_filter.cpp vce_cmd.cpp vce_core.cpp \
vce_device.cpp vce_param.cpp vce_util.cpp \
"
SRC_VCECORE_CL=" \
rgy_filter.cl rgy_filter_afs_analyze.cl rgy_filter_afs_filter.cl rgy_filter_afs_merge.cl \
rgy_filter_afs_synthesize.cl rgy_filter_convolution3d.cl rgy_filter_curves.cl \
rgy_filter_deband.cl rgy_filter_deband_gen_rand.cl rgy_filter_decimate.cl rgy_filter_decomb.cl \
rgy_filter_delogo.cl \
rgy_filter_denoise_dct.cl rgy_filter_denoise_fft3d.cl rgy_filter_denoise_knn.cl rgy_filter_denoise_nlmeans.cl \
rgy_filter_denoise_pmd.cl rgy_filter_edgelevel.cl \
rgy_filter_mpdecimate.cl rgy_filter_nnedi_common.cl rgy_filter_nnedi_k0.cl rgy_filter_nnedi_k1.cl \
rgy_filter_overlay.cl rgy_filter_pad.cl rgy_filter_resize.cl rgy_filter_smooth.cl \
rgy_filter_ssim.cl rgy_filter_subburn.cl rgy_filter_transform.cl rgy_filter_tweak.cl \
rgy_filter_unsharp.cl rgy_filter_warpsharp.cl rgy_filter_yadif.cl \
"
SRC_VCECORE_H=" \
rgy_filter_colorspace_func.h \
"
SRC_CLRNG=" \
clRNG.c private.c \
"
SRC_CLRNG_CLH=" \
clRNG/src/include/clRNG/clRNG.clh \
clRNG/src/include/clRNG/mrg31k3p.clh \
"
SRC_CLRNG_H=" \
clRNG/src/include/clRNG/private/mrg31k3p.c.h \
"
SRC_TINYXML2="tinyxml2.cpp"
PYW_PERF_MONITOR="perf_monitor.pyw"
RESOURCE_NNEDI_WEIGHT="nnedi3_weights.bin"
SRC_VCEENCC="VCEEncC.cpp"
# for src in $SRC_MFX_DISPATCH; do
# SRCS="$SRCS mfx_dispatch/src/$src"
# done
for src in $SRC_VCECORE; do
SRCS="$SRCS VCECore/$src"
done
for src in $SRC_CLRNG; do
SRCCS="$SRCCS clRNG/src/library/$src"
done
for cls in $SRC_VCECORE_CL; do
RCLS="$RCLS VCECore/$cls"
done
for hs in $SRC_VCECORE_H; do
RHS="$RHS VCECore/$hs"
done
for hs in $SRC_CLRNG_H; do
RHS="$RHS $hs"
done
for cls in $SRC_CLRNG_CLH; do
RCLHS="$RCLHS $cls"
done
for pyw in $PYW_PERF_MONITOR; do
PYWS="$PYWS PerfMonitor/$pyw"
done
for rcs in $RESOURCE_NNEDI_WEIGHT; do
RBINS="$RBINS resource/$rcs"
done
for src in $SRC_TINYXML2; do
SRCS="$SRCS tinyxml2/$src"
done
for src in $SRC_VCEENCC; do
SRCS="$SRCS VCEEncC/$src"
done
ENCODER_REV=`git rev-list HEAD | wc --lines`
cnf_write ""
cnf_write "Creating config.mak, rgy_config.h..."
echo "SRCS = $SRCS" >> config.mak
echo "SRCCS = $SRCCS" >> config.mak
echo "PYWS = $PYWS" >> config.mak
echo "RBINS = $RBINS" >> config.mak
echo "RHS = $RHS" >> config.mak
echo "RCLS = $RCLS" >> config.mak
echo "RCLHS = $RCLHS" >> config.mak
write_config_mak "SRCDIR = $SRCDIR"
write_config_mak "CC = $CC"
write_config_mak "CXX = $CXX"
write_config_mak "LD = $LD"
write_config_mak "PROGRAM = $PROGRAM"
write_config_mak "ENABLE_DEBUG = $ENABLE_DEBUG"
write_config_mak "CFLAGS = $CFLAGS"
write_config_mak "CXXFLAGS = $CXXFLAGS $EXTRACXXFLAGS $LIBAV_CFLAGS $VAPOURSYNTH_CFLAGS $AVISYNTH_CFLAGS $LIBASS_CFLAGS $DTL_CFLAGS $CPPCODEC_CFLAGS $VULKAN_CFLAGS $LIBPLACEBO_CFLAGS $LIBDOVI_CFLAGS $LIBHDR10PLUS_CFLAGS"
write_config_mak "LDFLAGS = $LDFLAGS $EXTRALDFLAGS $LIBAV_LIBS $LIBASS_LIBS $LIBDOVI_LIBS $LIBHDR10PLUS_LIBS"
write_config_mak "PREFIX = $PREFIX"
echo "X86_64 = ${X86_64}"
write_app_rev "#define ENCODER_REV \"$ENCODER_REV\""
write_enc_config "#define ENABLE_RAW_READER 1"
write_enc_config "#define ENABLE_AVI_READER 0"
write_enc_config "#define ENABLE_AVISYNTH_READER $ENABLE_AVISYNTH"
write_enc_config "#define ENABLE_VAPOURSYNTH_READER $ENABLE_VAPOURSYNTH"
write_enc_config "#define ENABLE_AVSW_READER $ENABLE_AVSW_READER"
write_enc_config "#define ENABLE_SM_READER 0"
write_enc_config "#define ENABLE_CUSTOM_VPP 1"
write_enc_config "#define ENABLE_LIBASS_SUBBURN $ENABLE_LIBASS"
write_enc_config "#define ENABLE_OPENCL 1"
write_enc_config "#define ENABLE_AVCODEC_OUT_THREAD 1"
write_enc_config "#define AV_CHANNEL_LAYOUT_STRUCT_AVAIL $AV_CHANNEL_LAYOUT_STRUCT_AVAIL"
write_enc_config "#define AV_FRAME_DURATION_AVAIL $AV_FRAME_DURATION_AVAIL"
write_enc_config "#define AVCODEC_PAR_CODED_SIDE_DATA_AVAIL $AVCODEC_PAR_CODED_SIDE_DATA_AVAIL"
write_enc_config "#define ENABLE_CPP_REGEX $ENABLE_CPP_REGEX"
write_enc_config "#define ENABLE_DTL $ENABLE_DTL"
write_enc_config "#define ENABLE_LIBDOVI $ENABLE_LIBDOVI"
write_enc_config "#define ENABLE_LIBHDR10PLUS $ENABLE_LIBHDR10PLUS"
write_enc_config "#define ENABLE_VULKAN $ENABLE_VULKAN"
write_enc_config "#define ENABLE_LIBPLACEBO $ENABLE_LIBPLACEBO"
cnf_write "successfully generated config.mak, rgy_config.h"