forked from b-fission/vn_winestuff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codec.sh
executable file
·366 lines (279 loc) · 10.9 KB
/
codec.sh
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
#!/bin/bash
echo
echo "Helper script to install codecs for VNs on wine (v2024-01-03)"
echo
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
Quit() { echo; exit; }
Heading() { echo; echo "[INSTALL] $@"; }
CheckEnv()
{
# check for wine. it can be defined in $WINE or found in $PATH
if [ "$WINE" = "" ]; then WINE="wine"; fi
if ! command -v "$WINE" >/dev/null; then
echo "There is no usable wine executable in your PATH."
echo "Either set it or the WINE variable and try again."
Quit
fi
# check if WINEPREFIX is defined
if [ "$WINEPREFIX" = "" ]; then
WINEPREFIX="~/.wine"
echo "WINEPREFIX is not set. Going to use $WINEPREFIX"
else
echo "WINEPREFIX is $WINEPREFIX"
fi
# determine arch if it's not defined yet
if [ "$WINEARCH" = "" ]; then
if [ ! -d "$WINEPREFIX/drive_c/windows/system32" ]; then
echo "A wine prefix does not appear to exist yet."
echo "Please run wineboot -i to initialize it."
Quit
elif [ -d "$WINEPREFIX/drive_c/windows/syswow64" ]; then
ARCH="win64"
else
ARCH="win32"
fi
echo "WINEARCH seems to be $ARCH"
else
ARCH=$WINEARCH
echo "WINEARCH specified as $ARCH"
fi
# check for valid WINEARCH (also end current wine session)
WINEDEBUG="-all" WINEARCH=$ARCH "$WINE" wineboot -e || Quit
}
RUN()
{
echo "[run] $WINE $@"
WINEDEBUG="-all" "$WINE" $@
if [ $? -ne 0 ]; then echo "some kind of error occurred."; Quit; fi
}
RUN64()
{
echo "[run64] ${WINE}64 $@"
WINEDEBUG="-all" "${WINE}64" $@
if [ $? -ne 0 ]; then echo "some kind of error occurred."; Quit; fi
}
GetWindowsVer()
{
OSVER=$(WINEDEBUG="-all" "$WINE" winecfg -v | tr -d '\r')
#echo "OS Ver is $OSVER"
}
SetWindowsVer()
{
REQVER=$1
# WinXP 64-bit has its own identifier
if [[ $REQVER = "winxp" && $ARCH = "win64" ]]; then REQVER="winxp64"; fi
RUN winecfg -v $REQVER
GetWindowsVer
}
GetSysDir()
{
if [ $ARCH = "win64" ]; then SYSDIR="syswow64"; else SYSDIR="system32"; fi
}
OverrideDll()
{
if [ "$2" != "" ]; then DATA="/d $2"; else DATA=""; fi
RUN reg add "HKCU\\Software\\Wine\\DllOverrides" /f /t REG_SZ /v $1 $DATA
}
SetClassDll32()
{
if [ $ARCH = "win64" ]; then WOWNODE="\\Wow6432Node"; else WOWNODE=""; fi
REGKEY="HKLM\\Software${WOWNODE}\\Classes\\CLSID\\{$1}\\InprocServer32"
RUN reg add $REGKEY /f /t REG_SZ /ve /d $2
}
Hash_SHA256()
{
if command -v sha256sum >/dev/null; then
HASH=$(sha256sum "$1" | sed -e "s/ .*//" | tr -d '\n')
elif command -v openssl >/dev/null; then
HASH=$(openssl sha256 "$1" | sed -e 's/SHA.* //')
else
echo "no usable sha256 utility available, cannot continue."; Quit
fi
if [ $HASH != $2 ]; then
echo "... hash mismatch on $1"
echo "download hash $HASH"
echo "expected hash $2"
Quit
fi
}
DownloadFile()
{ # args: $1=output_subdir $2=output_name $3=url $4=hash
DLFILE=$SCRIPT_DIR/$1/$2
DLFILEWIP=${DLFILE}.download
# download file if we don't have it yet
if [ ! -f "$DLFILE" ]; then
# download
mkdir -p "$SCRIPT_DIR/$1"
if command -v wget >/dev/null; then
wget --progress=bar -O "$DLFILEWIP" $3
elif command -v curl >/dev/null; then
curl -L -o "$DLFILEWIP" $3
else
echo "no downloader utility available, cannot continue."; Quit
fi
# delete download on failure
RET=$?
FSIZE=$(wc -c "$DLFILEWIP" | sed -e 's/ .*//')
if [[ $RET -ne 0 || $FSIZE -eq 0 ]]; then
echo "error occurred while downloading $2"
rm $DLFILEWIP 2> /dev/null
Quit
fi
mv "$DLFILEWIP" "$DLFILE"
fi
# file hash must match, otherwise quit
if [ -f "$DLFILE" ]; then
[ "$4" != "nohash" ] && Hash_SHA256 "$DLFILE" $4
else
echo "$1 is not found, cannot continue."; Quit
fi
}
DownloadFileInternal()
{
BASEURL="https://raw.githubusercontent.com/b-fission/vn_winestuff/master"
DownloadFile $1 $2 $BASEURL/$1/$2 $3
}
# ============================================================================
Disable_winegstreamer()
{
OverrideDll winegstreamer ""
OverrideDll ir50_32 ""
OverrideDll wmvcore ""
}
# ============================================================================
Install_mf()
{
Heading "mf"
WORKDIR=$SCRIPT_DIR/mf
if ! command -v unzip >/dev/null; then echo "unzip is not available, cannot continue."; Quit; fi
OVERRIDE_DLL="colorcnv dxva2 evr mf mferror mfplat mfplay mfreadwrite msmpeg2adec msmpeg2vdec sqmapi wmadmod wmvdecod"
REGISTER_DLL="colorcnv evr msmpeg2adec msmpeg2vdec wmadmod wmvdecod"
# install 32-bit components
DownloadFileInternal mf mf32.zip 2600aeae0f0a6aa2d4c08f847a148aed7a09218f1bfdc237b90b43990644cbbd
unzip -o -q -d "$WORKDIR/temp" "$WORKDIR/mf32.zip" || Quit;
cp -vf "$WORKDIR/temp/syswow64"/* "$WINEPREFIX/drive_c/windows/$SYSDIR"
Disable_winegstreamer
for DLL in $OVERRIDE_DLL; do OverrideDll $DLL native; done
RUN "c:/windows/$SYSDIR/reg.exe" import "$WORKDIR/temp/mf.reg"
RUN "c:/windows/$SYSDIR/reg.exe" import "$WORKDIR/temp/wmf.reg"
for DLL in $REGISTER_DLL; do RUN c:/windows/$SYSDIR/regsvr32.exe "c:/windows/$SYSDIR/$DLL.dll"; done
# install 64-bit components
if [ $ARCH = "win64" ]; then
DownloadFileInternal mf mf64.zip 8a316d8c2c32a7e56ed540026e79db76879cc61794b3331301390013339e8ad7
unzip -o -q -d "$WORKDIR/temp" "$WORKDIR/mf64.zip" || Quit;
cp -vf "$WORKDIR/temp/system32"/* "$WINEPREFIX/drive_c/windows/system32"
RUN64 "c:/windows/system32/reg.exe" import "$WORKDIR/temp/mf.reg"
RUN64 "c:/windows/system32/reg.exe" import "$WORKDIR/temp/wmf.reg"
for DLL in $REGISTER_DLL; do RUN64 "c:/windows/system32/regsvr32.exe" "c:/windows/system32/$DLL.dll"; done
fi
# cleanup
rm -fr "$WORKDIR/temp"
}
Install_quartz_dx()
{
Heading "quartz_dx"
DownloadFileInternal quartz_dx amstream.dll 0e87db588c7740c7c8e9d19af9b4843e497759300888445388ff915c5ccd145c
DownloadFileInternal quartz_dx devenum.dll ab49f2ebb9f99b640c14a4a1d830b35685aa758c7b1f5c62d77fdb6e09081387
DownloadFileInternal quartz_dx quartz.dll a378764866d8dd280e63dda4e62c5b10626cf46a230768fb24c3c3d5f7263b87
cp -fv "$SCRIPT_DIR/quartz_dx/"{quartz,devenum,amstream}.dll "$WINEPREFIX/drive_c/windows/$SYSDIR"
Disable_winegstreamer
OverrideDll amstream native,builtin
OverrideDll devenum native,builtin
OverrideDll quartz native,builtin
RUN c:/windows/$SYSDIR/regsvr32.exe c:/windows/$SYSDIR/amstream.dll
RUN c:/windows/$SYSDIR/regsvr32.exe c:/windows/$SYSDIR/devenum.dll
RUN c:/windows/$SYSDIR/regsvr32.exe c:/windows/$SYSDIR/quartz.dll
# also install dgVoodoo2 for compatibility
DownloadFileInternal dgvoodoo2 dgVoodoo2_8_1.zip 15f95a5c163f74105a03479fb2e868c04c432680e0892bf559198a93a7cd1c25
unzip -o -q -d "$SCRIPT_DIR/dgvoodoo2/temp" "$SCRIPT_DIR/dgvoodoo2/dgVoodoo2_8_1.zip" "MS/x86/DDraw.dll"
cp -fv "$SCRIPT_DIR/dgvoodoo2/temp/MS/x86/DDraw.dll" "$WINEPREFIX/drive_c/windows/$SYSDIR/ddraw.dll"
cp -fv "$SCRIPT_DIR/dgvoodoo2/dgVoodoo.conf" "$WINEPREFIX/drive_c/windows/$SYSDIR"
OverrideDll ddraw native
# cleanup
rm -fr "$SCRIPT_DIR/dgvoodoo2/temp"
}
Install_quartz2()
{
Heading "quartz2"
DownloadFileInternal quartz2 quartz2.dll fa52a0d0647413deeef57c5cb632f73a97a48588c16877fc1cc66404c3c21a2b
cp -fv "$SCRIPT_DIR/quartz2/quartz2.dll" "$WINEPREFIX/drive_c/windows/$SYSDIR/quartz2.dll"
RUN c:/windows/$SYSDIR/regsvr32.exe quartz2.dll
Disable_winegstreamer
# use wine's quartz for these DirectShow filters
DLL="c:\\windows\\$SYSDIR\\quartz.dll"
SetClassDll32 "79376820-07D0-11CF-A24D-0020AFD79767" $DLL #DirectSound
SetClassDll32 "6BC1CFFA-8FC1-4261-AC22-CFB4CC38DB50" $DLL #DefaultVideoRenderer
SetClassDll32 "70E102B0-5556-11CE-97C0-00AA0055595A" $DLL #VideoRenderer
SetClassDll32 "51B4ABF3-748F-4E3B-A276-C828330E926A" $DLL #VMR9
SetClassDll32 "B87BEB7B-8D29-423F-AE4D-6582C10175AC" $DLL #VMR7
}
Install_mciqtz32()
{
Heading "mciqtz32"
DownloadFileInternal mciqtz32 mciqtz32.dll 43d131bfd6884e2d8d0317aabaf0564e36937347ab43feccfc2b1c9d38c8527b
cp -fv "$SCRIPT_DIR/mciqtz32/mciqtz32.dll" "$WINEPREFIX/drive_c/windows/$SYSDIR/mciqtz32.dll"
OverrideDll mciqtz32 native
}
Install_wmp11()
{
Heading "wmp11"
PREV_OSVER=$OSVER
case $ARCH in
win32) wmf="wmfdist11.exe"; validhash=ddfea7b588200d8bb021dbf1716efb9f63029a0dd016d4c12db89734852e528d;;
win64) wmf="wmfdist11-64.exe"; validhash=eba63fa648016f3801e503fc91d9572b82aeb0409e73c27de0b4fbc51e81e505;;
*) Quit;;
esac
DownloadFileInternal wmp11 $wmf $validhash
SetWindowsVer winxp
Disable_winegstreamer
OverrideDll qasf native
OverrideDll wmvcore native
rm -vf "$WINEPREFIX/drive_c/windows/$SYSDIR"/{qasf,wmasf,wmvcore}.dll
RUN "$SCRIPT_DIR/wmp11/$wmf" /q
SetWindowsVer $PREV_OSVER
}
Install_xaudio29()
{
Heading "xaudio29"
DownloadFileInternal xaudio29 xaudio2_9.dll 667787326dd6cc94f16e332fd271d15aabe1aba2003964986c8ac56de07d5b57
cp -fv "$SCRIPT_DIR/xaudio29/xaudio2_9.dll" "$WINEPREFIX/drive_c/windows/$SYSDIR/xaudio2_9.dll"
cp -fv "$SCRIPT_DIR/xaudio29/xaudio2_9.dll" "$WINEPREFIX/drive_c/windows/$SYSDIR/xaudio2_8.dll"
OverrideDll xaudio2_9 native
OverrideDll xaudio2_8 native
}
Install_lavfilters()
{
Heading "LAVFilters"
VER="0.77.2"
FNAME="LAVFilters-$VER-Installer.exe"
DownloadFile lavfilters $FNAME "https://github.com/Nevcairiel/LAVFilters/releases/download/$VER/$FNAME" 3bf333bae56f9856fb7db96ce2410df1da3958ac6a9fd5ac965d33c7af6f27d7
RUN "$SCRIPT_DIR/lavfilters/$FNAME" /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-
RUN reg add "HKCU\\Software\\LAV\\Audio\\Formats" /f /t REG_DWORD /v wma /d 1
RUN reg add "HKCU\\Software\\LAV\\Audio\\Formats" /f /t REG_DWORD /v wmapro /d 1
RUN reg add "HKCU\\Software\\LAV\\Audio\\Formats" /f /t REG_DWORD /v wmalossless /d 1
RUN reg add "HKCU\\Software\\LAV\\Video\\Output" /f /t REG_DWORD /v yuy2 /d 0
}
# ============================================================================
# note: VERBS is sorted to our preferred call sequence
VERBS="quartz2 mciqtz32 wmp11 mf lavfilters quartz_dx xaudio29"
RunActions()
{
for item in $VERBS; do eval "do_$item=0"; done
for item in $@; do
VAL=$(eval "echo \$do_$item")
if [ "$VAL" = 0 ]; then eval "do_$item=1";
elif [ "$VAL" = 1 ]; then echo "duplicated verb: $item"; Quit;
else echo "invalid verb: $item"; Quit; fi
done
CheckEnv
GetWindowsVer
GetSysDir
for item in $VERBS; do [ $(eval "echo \$do_$item") = 1 ] && Install_${item}; done
}
if [ $# -gt 0 ]; then
RunActions $@
else
echo "Specify one or more of these verbs to install them:"
echo $(echo $VERBS | tr ' ' '\n' | sort)
echo
fi